├── screenshots ├── sdl.png ├── amdgpu.png ├── freebsd.png ├── ubuntu.png └── windows.png ├── nvidia-loader ├── nvidia-loader ├── README.md └── Makefile ├── doomgeneric ├── mus2mid.h ├── doomgeneric.c ├── statdump.h ├── net_dedicated.h ├── p_inter.h ├── w_main.h ├── net_sdl.h ├── doomdef.c ├── gusconf.h ├── r_segs.h ├── w_checksum.h ├── i_endoom.h ├── net_loop.h ├── p_tick.h ├── net_gui.h ├── p_setup.h ├── m_fixed.h ├── m_random.h ├── r_sky.h ├── doomgeneric.h ├── doomstat.c ├── d_textur.h ├── f_finale.h ├── dstrings.h ├── d_items.h ├── m_bbox.h ├── doomfeatures.h ├── i_timer.h ├── d_main.h ├── net_server.h ├── r_local.h ├── sha1.h ├── m_bbox.c ├── memio.h ├── wi_stuff.h ├── m_config.h ├── deh_str.h ├── net_io.h ├── w_merge.h ├── m_fixed.c ├── r_sky.c ├── m_argv.h ├── f_wipe.h ├── am_map.h ├── r_data.h ├── i_cdmus.h ├── m_cheat.h ├── hu_stuff.h ├── r_bsp.h ├── v_patch.h ├── deh_main.h ├── net_query.h ├── d_event.c ├── net_packet.h ├── m_menu.h ├── r_plane.h ├── d_think.h ├── d_ticcmd.h ├── i_scale.h ├── p_saveg.h ├── r_things.h ├── net_client.h ├── d_iwad.h ├── Makefile.freebsd ├── p_pspr.h ├── Makefile.sdl ├── Makefile ├── doom.h ├── Makefile.emscripten ├── w_wad.h ├── Makefile.soso ├── m_misc.h ├── i_timer.c ├── Makefile.sosox ├── Makefile.amdgpu ├── Makefile.djgpp ├── Makefile.nvptx ├── dummy.c ├── g_game.h ├── s_sound.h ├── w_file.c ├── doomgeneric_gpu.cc ├── i_swap.h ├── st_stuff.h ├── w_file.h ├── z_zone.h ├── i_system.h ├── m_cheat.c ├── w_file_stdc.c ├── d_items.c ├── w_checksum.c ├── dstrings.c ├── i_endoom.c ├── m_random.c ├── d_loop.h ├── r_draw.h ├── i_joystick.h ├── tables.h ├── doomtype.h ├── doomkeys.h ├── r_state.h ├── config.h ├── d_mode.h ├── deh_misc.h ├── v_video.h ├── p_telept.c ├── p_tick.c ├── r_main.h ├── d_event.h └── doomdef.h ├── .gitignore ├── amdgpu-loader ├── README.md └── Makefile ├── doomgeneric.sln ├── README.md └── README.TXT /screenshots/sdl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/screenshots/sdl.png -------------------------------------------------------------------------------- /screenshots/amdgpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/screenshots/amdgpu.png -------------------------------------------------------------------------------- /screenshots/freebsd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/screenshots/freebsd.png -------------------------------------------------------------------------------- /screenshots/ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/screenshots/ubuntu.png -------------------------------------------------------------------------------- /screenshots/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/screenshots/windows.png -------------------------------------------------------------------------------- /nvidia-loader/nvidia-loader: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhuber6/doomgeneric/HEAD/nvidia-loader/nvidia-loader -------------------------------------------------------------------------------- /doomgeneric/mus2mid.h: -------------------------------------------------------------------------------- 1 | #ifndef MUS2MID_H 2 | #define MUS2MID_H 3 | 4 | #include "doomtype.h" 5 | #include "memio.h" 6 | 7 | boolean mus2mid(MEMFILE *musinput, MEMFILE *midioutput); 8 | 9 | #endif /* #ifndef MUS2MID_H */ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.obj 3 | *.exe 4 | *.DS_Store 5 | *.log 6 | *.user 7 | *.json 8 | *.map 9 | *.wad 10 | *.savegame 11 | amdgpu-loader/amdgpu-loader 12 | nvidia-loader/nvidia-loader 13 | doomgeneric/doomgeneric 14 | *.cache/ 15 | build/ 16 | *~ 17 | .vs/ 18 | Debug/ 19 | Release/ 20 | -------------------------------------------------------------------------------- /doomgeneric/doomgeneric.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "m_argv.h" 4 | 5 | #include "doomgeneric.h" 6 | 7 | pixel_t* DG_ScreenBuffer = NULL; 8 | 9 | void M_FindResponseFile(void); 10 | void D_DoomMain (void); 11 | 12 | 13 | void doomgeneric_Create(int argc, char **argv) 14 | { 15 | // save arguments 16 | myargc = argc; 17 | myargv = argv; 18 | 19 | M_FindResponseFile(); 20 | 21 | DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4); 22 | 23 | DG_Init(); 24 | 25 | D_DoomMain (); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /doomgeneric/statdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(C) 2005-2014 Simon Howard 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | */ 16 | 17 | #ifndef DOOM_STATDUMP_H 18 | #define DOOM_STATDUMP_H 19 | 20 | void StatCopy(wbstartstruct_t *stats); 21 | void StatDump(void); 22 | 23 | #endif /* #ifndef DOOM_STATDUMP_H */ 24 | -------------------------------------------------------------------------------- /doomgeneric/net_dedicated.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dedicated server code. 16 | // 17 | 18 | #ifndef NET_DEDICATED_H 19 | #define NET_DEDICATED_H 20 | 21 | void NET_DedicatedServer(void); 22 | 23 | #endif /* #ifndef NET_DEDICATED_H */ 24 | 25 | 26 | -------------------------------------------------------------------------------- /doomgeneric/p_inter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __P_INTER__ 21 | #define __P_INTER__ 22 | 23 | 24 | 25 | 26 | boolean P_GivePower(player_t*, int); 27 | 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /doomgeneric/w_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Common code to parse command line, identifying WAD files to load. 16 | // 17 | 18 | #ifndef W_MAIN_H 19 | #define W_MAIN_H 20 | 21 | boolean W_ParseCommandLine(void); 22 | 23 | #endif /* #ifndef W_MAIN_H */ 24 | 25 | -------------------------------------------------------------------------------- /doomgeneric/net_sdl.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Networking module which uses SDL_net 16 | // 17 | 18 | #ifndef NET_SDL_H 19 | #define NET_SDL_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_module_t net_sdl_module; 24 | 25 | #endif /* #ifndef NET_SDL_H */ 26 | 27 | -------------------------------------------------------------------------------- /nvidia-loader/README.md: -------------------------------------------------------------------------------- 1 | # nvidia-loader 2 | 3 | A modified version of the loader utility used for testing in the LLVM C library. 4 | This uses the CUDA driver to interface with the GPU. We also depend on the RPC 5 | server implementation from the LLVM C library as well as the LLVM libraries 6 | themselves. The Makefile is unlikely to work unmodified on your system. 7 | 8 | It initializes the RPC interface, launches the `_start` kernel, and then listens 9 | on the RPC server to handle any requests the GPU makes. Because this runs DOOM, 10 | it also initializes an SDL2 window. The loader then exposes two function 11 | pointers to draw the screen and read input. The RPC implementation allows us to 12 | then call these functions. So, the portions that run on the CPU are to load the 13 | GPU program, handle file I/O, write the framebuffer to the screen, and read the 14 | input queue. Everything else is done on the GPU. 15 | -------------------------------------------------------------------------------- /doomgeneric/doomdef.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // DoomDef - basic defines for DOOM, e.g. Version, game mode 17 | // and skill level, and display parameters. 18 | // 19 | 20 | 21 | 22 | #include "doomdef.h" 23 | 24 | // Location for any defines turned variables. 25 | 26 | // None. 27 | 28 | 29 | -------------------------------------------------------------------------------- /doomgeneric/gusconf.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // GUS emulation code. 16 | // 17 | 18 | #ifndef __GUSCONF_H__ 19 | #define __GUSCONF_H__ 20 | 21 | #include "doomtype.h" 22 | 23 | extern char *gus_patch_path; 24 | extern unsigned int gus_ram_kb; 25 | 26 | boolean GUS_WriteConfig(char *path); 27 | 28 | #endif /* #ifndef __GUSCONF_H__ */ 29 | 30 | -------------------------------------------------------------------------------- /doomgeneric/r_segs.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh module, drawing LineSegs from BSP. 17 | // 18 | 19 | 20 | #ifndef __R_SEGS__ 21 | #define __R_SEGS__ 22 | 23 | 24 | 25 | 26 | void 27 | R_RenderMaskedSegRange 28 | ( drawseg_t* ds, 29 | int x1, 30 | int x2 ); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /doomgeneric/w_checksum.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Generate a checksum of the WAD directory. 17 | // 18 | 19 | #ifndef W_CHECKSUM_H 20 | #define W_CHECKSUM_H 21 | 22 | #include "doomtype.h" 23 | 24 | extern void W_Checksum(sha1_digest_t digest); 25 | 26 | #endif /* #ifndef W_CHECKSUM_H */ 27 | 28 | -------------------------------------------------------------------------------- /doomgeneric/i_endoom.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Exit text-mode ENDOOM screen. 17 | // 18 | 19 | 20 | #ifndef __I_ENDOOM__ 21 | #define __I_ENDOOM__ 22 | 23 | // Display the Endoom screen on shutdown. Pass a pointer to the 24 | // ENDOOM lump. 25 | 26 | void I_Endoom(byte *data); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /doomgeneric/net_loop.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Loopback network module for server compiled into the client 16 | // 17 | 18 | #ifndef NET_LOOP_H 19 | #define NET_LOOP_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_module_t net_loop_client_module; 24 | extern net_module_t net_loop_server_module; 25 | 26 | #endif /* #ifndef NET_LOOP_H */ 27 | 28 | -------------------------------------------------------------------------------- /doomgeneric/p_tick.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // ? 17 | // 18 | 19 | 20 | #ifndef __P_TICK__ 21 | #define __P_TICK__ 22 | 23 | 24 | 25 | 26 | // Called by C_Ticker, 27 | // can call G_PlayerExited. 28 | // Carries out all thinking of monsters and players. 29 | void P_Ticker (void); 30 | 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /amdgpu-loader/README.md: -------------------------------------------------------------------------------- 1 | # amdgpu-loader 2 | 3 | A modified version of the loader utility used for testing in the LLVM C library. 4 | This uses the [HSA implementation](https://github.com/ROCm/ROCR-Runtime) to 5 | interface with the GPU. We also depend on the RPC server implementation from the 6 | LLVM C library as well as the LLVM libraries themselves. The Makefile is 7 | unlikely to work unmodified on your system. 8 | 9 | It initializes the RPC interface, launches the `_start` kernel, and then listens 10 | on the RPC server to handle any requests the GPU makes. Because this runs DOOM, 11 | it also initializes an SDL2 window. The loader then exposes two function 12 | pointers to draw the screen and read input. The RPC implementation allows us to 13 | then call these functions. So, the portions that run on the CPU are to load the 14 | GPU program, handle file I/O, write the framebuffer to the screen, and read the 15 | input queue. Everything else is done on the GPU. 16 | -------------------------------------------------------------------------------- /doomgeneric/net_gui.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Graphical stuff related to the networking code: 15 | // 16 | // * The client waiting screen when we are waiting for the server to 17 | // start the game. 18 | // 19 | 20 | 21 | #ifndef NET_GUI_H 22 | #define NET_GUI_H 23 | 24 | #include "doomtype.h" 25 | 26 | extern void NET_WaitForLaunch(void); 27 | 28 | #endif /* #ifndef NET_GUI_H */ 29 | 30 | -------------------------------------------------------------------------------- /nvidia-loader/Makefile: -------------------------------------------------------------------------------- 1 | CC=clang++ 2 | CFLAGS+= -Os -I/opt/cuda/include -I$(shell dirname $(shell which $(CC)))/../include -fno-rtti -I../doomgeneric -D_REENTRANT -I${LLVM_SOURCE}/libc 3 | LDFLAGS+=-Wl,--gc-sections -L/opt/cuda/lib -L$(shell dirname $(shell which $(CC)))/../lib 4 | LIBS+=-lcuda -lLLVMSupport -lLLVMDemangle -lLLVMObject -lLLVMTargetParser -ltinfo -lSDL2 5 | 6 | # subdirectory for objects 7 | OBJDIR=build 8 | OUTPUT=nvidia-loader 9 | 10 | SRC_DOOM = nvidia-loader.o 11 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 12 | 13 | all: $(OUTPUT) 14 | 15 | clean: 16 | rm -rf $(OBJDIR) 17 | rm -f $(OUTPUT) 18 | 19 | $(OUTPUT): $(OBJS) 20 | @echo [Linking $@] 21 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 22 | -o $(OUTPUT) $(LIBS) 23 | @echo [Size] 24 | -$(CROSS_COMPILE)size $(OUTPUT) 25 | 26 | $(OBJS): | $(OBJDIR) 27 | 28 | $(OBJDIR): 29 | mkdir -p $(OBJDIR) 30 | 31 | $(OBJDIR)/%.o: %.cpp 32 | @echo [Compiling $<] 33 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 34 | 35 | print: 36 | @echo OBJS: $(OBJS) 37 | 38 | -------------------------------------------------------------------------------- /doomgeneric/p_setup.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Setup a game, startup stuff. 17 | // 18 | 19 | 20 | #ifndef __P_SETUP__ 21 | #define __P_SETUP__ 22 | 23 | 24 | 25 | 26 | // NOT called by W_Ticker. Fixme. 27 | void 28 | P_SetupLevel 29 | ( int episode, 30 | int map, 31 | int playermask, 32 | skill_t skill); 33 | 34 | // Called by startup code. 35 | void P_Init (void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /amdgpu-loader/Makefile: -------------------------------------------------------------------------------- 1 | CC=clang++ 2 | CFLAGS+= -Os -I/opt/rocm/include -I$(shell dirname $(shell which $(CC)))/../include -fno-rtti -I../doomgeneric -D_REENTRANT -I${LLVM_SOURCE}/libc 3 | LDFLAGS+=-Wl,--gc-sections -L/opt/rocm/lib -L$(shell dirname $(shell which $(CC)))/../lib 4 | LIBS+= -lhsa-runtime64 -lLLVMBinaryFormat -lLLVMObject -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMFrontendOffloading -lLLVMSupport -lLLVMDemangle -ltinfo -lSDL2 5 | 6 | # subdirectory for objects 7 | OBJDIR=build 8 | OUTPUT=amdgpu-loader 9 | 10 | SRC_DOOM = amdgpu-loader.o 11 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 12 | 13 | all: $(OUTPUT) 14 | 15 | clean: 16 | rm -rf $(OBJDIR) 17 | rm -f $(OUTPUT) 18 | 19 | $(OUTPUT): $(OBJS) 20 | @echo [Linking $@] 21 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 22 | -o $(OUTPUT) $(LIBS) 23 | @echo [Size] 24 | -$(CROSS_COMPILE)size $(OUTPUT) 25 | 26 | $(OBJS): | $(OBJDIR) 27 | 28 | $(OBJDIR): 29 | mkdir -p $(OBJDIR) 30 | 31 | $(OBJDIR)/%.o: %.cpp 32 | @echo [Compiling $<] 33 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 34 | 35 | print: 36 | @echo OBJS: $(OBJS) 37 | 38 | -------------------------------------------------------------------------------- /doomgeneric/m_fixed.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Fixed point arithemtics, implementation. 17 | // 18 | 19 | 20 | #ifndef __M_FIXED__ 21 | #define __M_FIXED__ 22 | 23 | 24 | 25 | 26 | // 27 | // Fixed point, 32bit as 16.16. 28 | // 29 | #define FRACBITS 16 30 | #define FRACUNIT (1< 5 | #include 6 | 7 | #ifndef DOOMGENERIC_RESX 8 | #define DOOMGENERIC_RESX 2 * 640 9 | #endif // DOOMGENERIC_RESX 10 | 11 | #ifndef DOOMGENERIC_RESY 12 | #define DOOMGENERIC_RESY 2 * 400 13 | #endif // DOOMGENERIC_RESY 14 | 15 | #define DOOM_DRAW_BUFFER ('d' << 24 | 0) 16 | #define DOOM_GET_INPUT ('d' << 24 | 1) 17 | 18 | #ifdef CMAP256 19 | 20 | typedef uint8_t pixel_t; 21 | 22 | #else // CMAP256 23 | 24 | typedef uint32_t pixel_t; 25 | 26 | #endif // CMAP256 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | extern pixel_t *DG_ScreenBuffer; 33 | 34 | void doomgeneric_Create(int argc, char **argv); 35 | void doomgeneric_Tick(); 36 | 37 | // Implement below functions for your platform 38 | void DG_Init(); 39 | void DG_DrawFrame(); 40 | void DG_SleepMs(uint32_t ms); 41 | uint32_t DG_GetTicksMs(); 42 | int DG_GetKey(int *pressed, unsigned char *key); 43 | void DG_SetWindowTitle(const char *title); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif // DOOM_GENERIC 50 | -------------------------------------------------------------------------------- /doomgeneric/doomstat.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Put all global tate variables here. 17 | // 18 | 19 | #include 20 | 21 | #include "doomstat.h" 22 | 23 | 24 | // Game Mode - identify IWAD as shareware, retail etc. 25 | GameMode_t gamemode = indetermined; 26 | GameMission_t gamemission = doom; 27 | GameVersion_t gameversion = exe_final2; 28 | char *gamedescription; 29 | 30 | // Set if homebrew PWAD stuff has been added. 31 | boolean modifiedgame; 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /doomgeneric/d_textur.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Typedefs related to to textures etc., 17 | // isolated here to make it easier separating modules. 18 | // 19 | 20 | 21 | #ifndef __D_TEXTUR__ 22 | #define __D_TEXTUR__ 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | 28 | 29 | // 30 | // Flats? 31 | // 32 | // a pic is an unmasked block of pixels 33 | typedef struct 34 | { 35 | byte width; 36 | byte height; 37 | byte data; 38 | } pic_t; 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /doomgeneric/f_finale.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __F_FINALE__ 21 | #define __F_FINALE__ 22 | 23 | 24 | #include "doomtype.h" 25 | #include "d_event.h" 26 | // 27 | // FINALE 28 | // 29 | 30 | // Called by main loop. 31 | boolean F_Responder (event_t* ev); 32 | 33 | // Called by main loop. 34 | void F_Ticker (void); 35 | 36 | // Called by main loop. 37 | void F_Drawer (void); 38 | 39 | 40 | void F_StartFinale (void); 41 | 42 | 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /doomgeneric/dstrings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // 16 | // DESCRIPTION: 17 | // DOOM strings, by language. 18 | // 19 | 20 | 21 | #ifndef __DSTRINGS__ 22 | #define __DSTRINGS__ 23 | 24 | 25 | // All important printed strings. 26 | 27 | #include "d_englsh.h" 28 | 29 | // Misc. other strings. 30 | #define SAVEGAMENAME "doomsav" 31 | 32 | 33 | // QuitDOOM messages 34 | // 8 per each game type 35 | #define NUM_QUITMESSAGES 8 36 | 37 | extern char *doom1_endmsg[]; 38 | extern char *doom2_endmsg[]; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /doomgeneric/d_items.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Items: key cards, artifacts, weapon, ammunition. 17 | // 18 | 19 | 20 | #ifndef __D_ITEMS__ 21 | #define __D_ITEMS__ 22 | 23 | #include "doomdef.h" 24 | 25 | 26 | 27 | // Weapon info: sprite frames, ammunition use. 28 | typedef struct 29 | { 30 | ammotype_t ammo; 31 | int upstate; 32 | int downstate; 33 | int readystate; 34 | int atkstate; 35 | int flashstate; 36 | 37 | } weaponinfo_t; 38 | 39 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /doomgeneric/m_bbox.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Nil. 17 | // 18 | 19 | 20 | #ifndef __M_BBOX__ 21 | #define __M_BBOX__ 22 | 23 | #include 24 | 25 | #include "m_fixed.h" 26 | 27 | 28 | // Bounding box coordinate storage. 29 | enum 30 | { 31 | BOXTOP, 32 | BOXBOTTOM, 33 | BOXLEFT, 34 | BOXRIGHT 35 | }; // bbox coordinates 36 | 37 | // Bounding box functions. 38 | void M_ClearBox (fixed_t* box); 39 | 40 | void 41 | M_AddToBox 42 | ( fixed_t* box, 43 | fixed_t x, 44 | fixed_t y ); 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /doomgeneric/doomfeatures.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // List of features which can be enabled/disabled to slim down the 16 | // program. 17 | // 18 | 19 | #ifndef DOOM_FEATURES_H 20 | #define DOOM_FEATURES_H 21 | 22 | // Enables wad merging (the '-merge' command line parameter) 23 | 24 | #undef FEATURE_WAD_MERGE 25 | 26 | // Enables dehacked support ('-deh') 27 | 28 | #undef FEATURE_DEHACKED 29 | 30 | // Enables multiplayer support (network games) 31 | 32 | #undef FEATURE_MULTIPLAYER 33 | 34 | // Enables sound output 35 | 36 | //#undef FEATURE_SOUND 37 | 38 | #endif /* #ifndef DOOM_FEATURES_H */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /doomgeneric/i_timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System-specific timer interface 17 | // 18 | 19 | 20 | #ifndef __I_TIMER__ 21 | #define __I_TIMER__ 22 | 23 | #define TICRATE 35 24 | 25 | // Called by D_DoomLoop, 26 | // returns current time in tics. 27 | int I_GetTime (void); 28 | 29 | // returns current time in ms 30 | int I_GetTimeMS (void); 31 | 32 | // Pause for a specified number of ms 33 | void I_Sleep(int ms); 34 | 35 | // Initialize timer 36 | void I_InitTimer(void); 37 | 38 | // Wait for vertical retrace or pause a bit. 39 | void I_WaitVBL(int count); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /doomgeneric/d_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System specific interface stuff. 17 | // 18 | 19 | 20 | #ifndef __D_MAIN__ 21 | #define __D_MAIN__ 22 | 23 | #include "doomdef.h" 24 | 25 | 26 | 27 | 28 | // Read events from all input devices 29 | 30 | void D_ProcessEvents (void); 31 | 32 | 33 | // 34 | // BASE LEVEL 35 | // 36 | void D_PageTicker (void); 37 | void D_PageDrawer (void); 38 | void D_AdvanceDemo (void); 39 | void D_DoAdvanceDemo (void); 40 | void D_StartTitle (void); 41 | 42 | // 43 | // GLOBAL VARIABLES 44 | // 45 | 46 | extern gameaction_t gameaction; 47 | 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /doomgeneric/net_server.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Network server code 15 | // 16 | 17 | #ifndef NET_SERVER_H 18 | #define NET_SERVER_H 19 | 20 | // initialize server and wait for connections 21 | 22 | void NET_SV_Init(void); 23 | 24 | // run server: check for new packets received etc. 25 | 26 | void NET_SV_Run(void); 27 | 28 | // Shut down the server 29 | // Blocks until all clients disconnect, or until a 5 second timeout 30 | 31 | void NET_SV_Shutdown(void); 32 | 33 | // Add a network module to the context used by the server 34 | 35 | void NET_SV_AddModule(net_module_t *module); 36 | 37 | // Register server with master server. 38 | 39 | void NET_SV_RegisterWithMaster(void); 40 | 41 | #endif /* #ifndef NET_SERVER_H */ 42 | 43 | -------------------------------------------------------------------------------- /doomgeneric/r_local.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh (R_*) module, global header. 17 | // All the rendering/drawing stuff is here. 18 | // 19 | 20 | #ifndef __R_LOCAL__ 21 | #define __R_LOCAL__ 22 | 23 | // Binary Angles, sine/cosine/atan lookups. 24 | #include "tables.h" 25 | 26 | // Screen size related parameters. 27 | #include "doomdef.h" 28 | 29 | // Include the refresh/render data structs. 30 | #include "r_data.h" 31 | 32 | 33 | 34 | // 35 | // Separate header file for each module. 36 | // 37 | #include "r_main.h" 38 | #include "r_bsp.h" 39 | #include "r_segs.h" 40 | #include "r_plane.h" 41 | #include "r_data.h" 42 | #include "r_things.h" 43 | #include "r_draw.h" 44 | 45 | #endif // __R_LOCAL__ 46 | -------------------------------------------------------------------------------- /doomgeneric/sha1.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // SHA-1 digest. 16 | // 17 | 18 | #ifndef __SHA1_H__ 19 | #define __SHA1_H__ 20 | 21 | #include "doomtype.h" 22 | 23 | typedef struct sha1_context_s sha1_context_t; 24 | typedef byte sha1_digest_t[20]; 25 | 26 | struct sha1_context_s { 27 | uint32_t h0,h1,h2,h3,h4; 28 | uint32_t nblocks; 29 | byte buf[64]; 30 | int count; 31 | }; 32 | 33 | void SHA1_Init(sha1_context_t *context); 34 | void SHA1_Update(sha1_context_t *context, byte *buf, size_t len); 35 | void SHA1_Final(sha1_digest_t digest, sha1_context_t *context); 36 | void SHA1_UpdateInt32(sha1_context_t *context, unsigned int val); 37 | void SHA1_UpdateString(sha1_context_t *context, char *str); 38 | 39 | #endif /* #ifndef __SHA1_H__ */ 40 | 41 | -------------------------------------------------------------------------------- /doomgeneric/m_bbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Main loop menu stuff. 17 | // Random number LUT. 18 | // Default Config File. 19 | // PCX Screenshots. 20 | // 21 | 22 | 23 | 24 | #include "m_bbox.h" 25 | 26 | 27 | 28 | 29 | void M_ClearBox (fixed_t *box) 30 | { 31 | box[BOXTOP] = box[BOXRIGHT] = INT_MIN; 32 | box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX; 33 | } 34 | 35 | void 36 | M_AddToBox 37 | ( fixed_t* box, 38 | fixed_t x, 39 | fixed_t y ) 40 | { 41 | if (xbox[BOXRIGHT]) 44 | box[BOXRIGHT] = x; 45 | if (ybox[BOXTOP]) 48 | box[BOXTOP] = y; 49 | } 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /doomgeneric/memio.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | 16 | #ifndef MEMIO_H 17 | #define MEMIO_H 18 | 19 | typedef struct _MEMFILE MEMFILE; 20 | 21 | typedef enum 22 | { 23 | MEM_SEEK_SET, 24 | MEM_SEEK_CUR, 25 | MEM_SEEK_END, 26 | } mem_rel_t; 27 | 28 | MEMFILE *mem_fopen_read(void *buf, size_t buflen); 29 | size_t mem_fread(void *buf, size_t size, size_t nmemb, MEMFILE *stream); 30 | MEMFILE *mem_fopen_write(void); 31 | size_t mem_fwrite(const void *ptr, size_t size, size_t nmemb, MEMFILE *stream); 32 | void mem_get_buf(MEMFILE *stream, void **buf, size_t *buflen); 33 | void mem_fclose(MEMFILE *stream); 34 | long mem_ftell(MEMFILE *stream); 35 | int mem_fseek(MEMFILE *stream, signed long offset, mem_rel_t whence); 36 | 37 | #endif /* #ifndef MEMIO_H */ 38 | 39 | -------------------------------------------------------------------------------- /doomgeneric/wi_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Intermission. 17 | // 18 | 19 | #ifndef __WI_STUFF__ 20 | #define __WI_STUFF__ 21 | 22 | //#include "v_video.h" 23 | 24 | #include "doomdef.h" 25 | 26 | // States for the intermission 27 | 28 | typedef enum 29 | { 30 | NoState = -1, 31 | StatCount, 32 | ShowNextLoc, 33 | } stateenum_t; 34 | 35 | // Called by main loop, animate the intermission. 36 | void WI_Ticker (void); 37 | 38 | // Called by main loop, 39 | // draws the intermission directly into the screen buffer. 40 | void WI_Drawer (void); 41 | 42 | // Setup for an intermission screen. 43 | void WI_Start(wbstartstruct_t* wbstartstruct); 44 | 45 | // Shut down the intermission screen 46 | void WI_End(void); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /doomgeneric/m_config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Configuration file interface. 17 | // 18 | 19 | 20 | #ifndef __M_CONFIG__ 21 | #define __M_CONFIG__ 22 | 23 | #include "doomtype.h" 24 | 25 | void M_LoadDefaults(void); 26 | void M_SaveDefaults(void); 27 | void M_SaveDefaultsAlternate(char *main, char *extra); 28 | void M_SetConfigDir(char *dir); 29 | void M_BindVariable(char *name, void *variable); 30 | boolean M_SetVariable(char *name, char *value); 31 | int M_GetIntVariable(char *name); 32 | const char *M_GetStrVariable(char *name); 33 | float M_GetFloatVariable(char *name); 34 | void M_SetConfigFilenames(char *main_config, char *extra_config); 35 | char *M_GetSaveGameDir(char *iwadname); 36 | 37 | extern char *configdir; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /doomgeneric/deh_str.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dehacked string replacements 16 | // 17 | 18 | #ifndef DEH_STR_H 19 | #define DEH_STR_H 20 | 21 | #include 22 | 23 | #include "doomfeatures.h" 24 | 25 | // Used to do dehacked text substitutions throughout the program 26 | 27 | #ifdef FEATURE_DEHACKED 28 | 29 | char *DEH_String(char *s); 30 | void DEH_printf(char *fmt, ...); 31 | void DEH_fprintf(FILE *fstream, char *fmt, ...); 32 | void DEH_snprintf(char *buffer, size_t len, char *fmt, ...); 33 | void DEH_AddStringReplacement(char *from_text, char *to_text); 34 | 35 | 36 | #else 37 | 38 | #define DEH_String(x) (x) 39 | #define DEH_printf printf 40 | #define DEH_fprintf fprintf 41 | #define DEH_snprintf snprintf 42 | #define DEH_AddStringReplacement(x, y) 43 | 44 | #endif 45 | 46 | #endif /* #ifndef DEH_STR_H */ 47 | 48 | -------------------------------------------------------------------------------- /doomgeneric/net_io.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Network packet manipulation (net_packet_t) 16 | // 17 | 18 | #ifndef NET_IO_H 19 | #define NET_IO_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_addr_t net_broadcast_addr; 24 | 25 | net_context_t *NET_NewContext(void); 26 | void NET_AddModule(net_context_t *context, net_module_t *module); 27 | void NET_SendPacket(net_addr_t *addr, net_packet_t *packet); 28 | void NET_SendBroadcast(net_context_t *context, net_packet_t *packet); 29 | boolean NET_RecvPacket(net_context_t *context, net_addr_t **addr, 30 | net_packet_t **packet); 31 | char *NET_AddrToString(net_addr_t *addr); 32 | void NET_FreeAddress(net_addr_t *addr); 33 | net_addr_t *NET_ResolveAddress(net_context_t *context, char *address); 34 | 35 | #endif /* #ifndef NET_IO_H */ 36 | 37 | -------------------------------------------------------------------------------- /doomgeneric/w_merge.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Handles merging of PWADs, similar to deutex's -merge option 16 | // 17 | // Ideally this should work exactly the same as in deutex, but trying to 18 | // read the deutex source code made my brain hurt. 19 | // 20 | 21 | #ifndef W_MERGE_H 22 | #define W_MERGE_H 23 | 24 | #define W_NWT_MERGE_SPRITES 0x1 25 | #define W_NWT_MERGE_FLATS 0x2 26 | 27 | // Add a new WAD and merge it into the main directory 28 | 29 | void W_MergeFile(char *filename); 30 | 31 | // NWT-style merging 32 | 33 | void W_NWTMergeFile(char *filename, int flags); 34 | 35 | // Acts the same as NWT's "-merge" option. 36 | 37 | void W_NWTDashMerge(char *filename); 38 | 39 | // Debug function that prints the WAD directory. 40 | 41 | void W_PrintDirectory(void); 42 | 43 | #endif /* #ifndef W_MERGE_H */ 44 | 45 | -------------------------------------------------------------------------------- /doomgeneric/m_fixed.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Fixed point implementation. 17 | // 18 | 19 | 20 | 21 | #include "stdlib.h" 22 | 23 | #include "doomtype.h" 24 | #include "i_system.h" 25 | 26 | #include "m_fixed.h" 27 | 28 | 29 | 30 | 31 | // Fixme. __USE_C_FIXED__ or something. 32 | 33 | fixed_t 34 | FixedMul 35 | ( fixed_t a, 36 | fixed_t b ) 37 | { 38 | return ((int64_t) a * (int64_t) b) >> FRACBITS; 39 | } 40 | 41 | 42 | 43 | // 44 | // FixedDiv, C version. 45 | // 46 | 47 | fixed_t FixedDiv(fixed_t a, fixed_t b) 48 | { 49 | if ((abs(a) >> 14) >= abs(b)) 50 | { 51 | return (a^b) < 0 ? INT_MIN : INT_MAX; 52 | } 53 | else 54 | { 55 | int64_t result; 56 | 57 | result = ((int64_t) a << 16) / b; 58 | 59 | return (fixed_t) result; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /doomgeneric/r_sky.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Sky rendering. The DOOM sky is a texture map like any 17 | // wall, wrapping around. A 1024 columns equal 360 degrees. 18 | // The default sky map is 256 columns and repeats 4 times 19 | // on a 320 screen? 20 | // 21 | // 22 | 23 | 24 | 25 | // Needed for FRACUNIT. 26 | #include "m_fixed.h" 27 | 28 | // Needed for Flat retrieval. 29 | #include "r_data.h" 30 | 31 | 32 | #include "r_sky.h" 33 | 34 | // 35 | // sky mapping 36 | // 37 | int skyflatnum; 38 | int skytexture; 39 | int skytexturemid; 40 | 41 | 42 | 43 | // 44 | // R_InitSkyMap 45 | // Called whenever the view size changes. 46 | // 47 | void R_InitSkyMap (void) 48 | { 49 | // skyflatnum = R_FlatNumForName ( SKYFLATNAME ); 50 | skytexturemid = 100*FRACUNIT; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /doomgeneric/m_argv.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Nil. 17 | // 18 | 19 | 20 | #ifndef __M_ARGV__ 21 | #define __M_ARGV__ 22 | 23 | #include "doomtype.h" 24 | 25 | // 26 | // MISC 27 | // 28 | extern int myargc; 29 | extern char** myargv; 30 | 31 | // Returns the position of the given parameter 32 | // in the arg list (0 if not found). 33 | int M_CheckParm (char* check); 34 | 35 | // Same as M_CheckParm, but checks that num_args arguments are available 36 | // following the specified argument. 37 | int M_CheckParmWithArgs(char *check, int num_args); 38 | 39 | void M_FindResponseFile(void); 40 | 41 | // Parameter has been specified? 42 | 43 | boolean M_ParmExists(char *check); 44 | 45 | // Get name of executable used to run this program: 46 | 47 | char *M_GetExecutableName(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /doomgeneric/f_wipe.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Mission start screen wipe/melt, special effects. 17 | // 18 | 19 | 20 | #ifndef __F_WIPE_H__ 21 | #define __F_WIPE_H__ 22 | 23 | // 24 | // SCREEN WIPE PACKAGE 25 | // 26 | 27 | enum 28 | { 29 | // simple gradual pixel change for 8-bit only 30 | wipe_ColorXForm, 31 | 32 | // weird screen melt 33 | wipe_Melt, 34 | 35 | wipe_NUMWIPES 36 | }; 37 | 38 | int 39 | wipe_StartScreen 40 | ( int x, 41 | int y, 42 | int width, 43 | int height ); 44 | 45 | 46 | int 47 | wipe_EndScreen 48 | ( int x, 49 | int y, 50 | int width, 51 | int height ); 52 | 53 | 54 | int 55 | wipe_ScreenWipe 56 | ( int wipeno, 57 | int x, 58 | int y, 59 | int width, 60 | int height, 61 | int ticks ); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /doomgeneric/am_map.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // AutoMap module. 17 | // 18 | 19 | #ifndef __AMMAP_H__ 20 | #define __AMMAP_H__ 21 | 22 | #include "d_event.h" 23 | #include "m_cheat.h" 24 | 25 | // Used by ST StatusBar stuff. 26 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 27 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 28 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 29 | 30 | 31 | // Called by main loop. 32 | boolean AM_Responder (event_t* ev); 33 | 34 | // Called by main loop. 35 | void AM_Ticker (void); 36 | 37 | // Called by main loop, 38 | // called instead of view drawer if automap active. 39 | void AM_Drawer (void); 40 | 41 | // Called to force the automap to quit 42 | // if the level is completed while it is up. 43 | void AM_Stop (void); 44 | 45 | 46 | extern cheatseq_t cheat_amap; 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /doomgeneric/r_data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh module, data I/O, caching, retrieval of graphics 17 | // by name. 18 | // 19 | 20 | 21 | #ifndef __R_DATA__ 22 | #define __R_DATA__ 23 | 24 | #include "r_defs.h" 25 | #include "r_state.h" 26 | 27 | 28 | // Retrieve column data for span blitting. 29 | byte* 30 | R_GetColumn 31 | ( int tex, 32 | int col ); 33 | 34 | 35 | // I/O, setting up the stuff. 36 | void R_InitData (void); 37 | void R_PrecacheLevel (void); 38 | 39 | 40 | // Retrieval. 41 | // Floor/ceiling opaque texture tiles, 42 | // lookup by name. For animation? 43 | int R_FlatNumForName (char* name); 44 | 45 | 46 | // Called by P_Ticker for switches and animations, 47 | // returns the texture number for the texture name. 48 | int R_TextureNumForName (char *name); 49 | int R_CheckTextureNumForName (char *name); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /doomgeneric/i_cdmus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | 16 | // i_cdmus.h 17 | 18 | #ifndef __ICDMUS__ 19 | #define __ICDMUS__ 20 | 21 | #define CDERR_NOTINSTALLED 10 // MSCDEX not installed 22 | #define CDERR_NOAUDIOSUPPORT 11 // CD-ROM Doesn't support audio 23 | #define CDERR_NOAUDIOTRACKS 12 // Current CD has no audio tracks 24 | #define CDERR_BADDRIVE 20 // Bad drive number 25 | #define CDERR_BADTRACK 21 // Bad track number 26 | #define CDERR_IOCTLBUFFMEM 22 // Not enough low memory for IOCTL 27 | #define CDERR_DEVREQBASE 100 // DevReq errors 28 | 29 | extern int cd_Error; 30 | 31 | int I_CDMusInit(void); 32 | void I_CDMusPrintStartup(void); 33 | int I_CDMusPlay(int track); 34 | int I_CDMusStop(void); 35 | int I_CDMusResume(void); 36 | int I_CDMusSetVolume(int volume); 37 | int I_CDMusFirstTrack(void); 38 | int I_CDMusLastTrack(void); 39 | int I_CDMusTrackLength(int track); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /doomgeneric.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2003 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doomgeneric", "doomgeneric\doomgeneric.vcxproj", "{95A126D2-CC94-4840-BF05-80305041B5FB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x64.ActiveCfg = Debug|x64 17 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x64.Build.0 = Debug|x64 18 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x86.ActiveCfg = Debug|Win32 19 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x86.Build.0 = Debug|Win32 20 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x64.ActiveCfg = Release|x64 21 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x64.Build.0 = Release|x64 22 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x86.ActiveCfg = Release|Win32 23 | {95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E444537A-F1DB-44A6-8720-C7DC7BB2C74A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /doomgeneric/m_cheat.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Cheat code checking. 17 | // 18 | 19 | 20 | #ifndef __M_CHEAT__ 21 | #define __M_CHEAT__ 22 | 23 | // 24 | // CHEAT SEQUENCE PACKAGE 25 | // 26 | 27 | // declaring a cheat 28 | 29 | #define CHEAT(value, parameters) \ 30 | { value, sizeof(value) - 1, parameters, 0, 0, "" } 31 | 32 | #define MAX_CHEAT_LEN 25 33 | #define MAX_CHEAT_PARAMS 5 34 | 35 | typedef struct 36 | { 37 | // settings for this cheat 38 | 39 | char sequence[MAX_CHEAT_LEN]; 40 | size_t sequence_len; 41 | int parameter_chars; 42 | 43 | // state used during the game 44 | 45 | size_t chars_read; 46 | int param_chars_read; 47 | char parameter_buf[MAX_CHEAT_PARAMS]; 48 | } cheatseq_t; 49 | 50 | int 51 | cht_CheckCheat 52 | ( cheatseq_t* cht, 53 | char key ); 54 | 55 | 56 | void 57 | cht_GetParam 58 | ( cheatseq_t* cht, 59 | char* buffer ); 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /doomgeneric/hu_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: Head up display 16 | // 17 | 18 | #ifndef __HU_STUFF_H__ 19 | #define __HU_STUFF_H__ 20 | 21 | #include "d_event.h" 22 | 23 | 24 | // 25 | // Globally visible constants. 26 | // 27 | #define HU_FONTSTART '!' // the first font characters 28 | #define HU_FONTEND '_' // the last font characters 29 | 30 | // Calculate # of glyphs in font. 31 | #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) 32 | 33 | #define HU_BROADCAST 5 34 | 35 | #define HU_MSGX 0 36 | #define HU_MSGY 0 37 | #define HU_MSGWIDTH 64 // in characters 38 | #define HU_MSGHEIGHT 1 // in lines 39 | 40 | #define HU_MSGTIMEOUT (4*TICRATE) 41 | 42 | // 43 | // HEADS UP TEXT 44 | // 45 | 46 | void HU_Init(void); 47 | void HU_Start(void); 48 | 49 | boolean HU_Responder(event_t* ev); 50 | 51 | void HU_Ticker(void); 52 | void HU_Drawer(void); 53 | char HU_dequeueChatChar(void); 54 | void HU_Erase(void); 55 | 56 | extern char *chat_macros[10]; 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /doomgeneric/r_bsp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh module, BSP traversal and handling. 17 | // 18 | 19 | 20 | #ifndef __R_BSP__ 21 | #define __R_BSP__ 22 | 23 | 24 | 25 | extern seg_t* curline; 26 | extern side_t* sidedef; 27 | extern line_t* linedef; 28 | extern sector_t* frontsector; 29 | extern sector_t* backsector; 30 | 31 | extern int rw_x; 32 | extern int rw_stopx; 33 | 34 | extern boolean segtextured; 35 | 36 | // false if the back side is the same plane 37 | extern boolean markfloor; 38 | extern boolean markceiling; 39 | 40 | extern boolean skymap; 41 | 42 | extern drawseg_t drawsegs[MAXDRAWSEGS]; 43 | extern drawseg_t* ds_p; 44 | 45 | extern lighttable_t** hscalelight; 46 | extern lighttable_t** vscalelight; 47 | extern lighttable_t** dscalelight; 48 | 49 | 50 | typedef void (*drawfunc_t) (int start, int stop); 51 | 52 | 53 | // BSP? 54 | void R_ClearClipSegs (void); 55 | void R_ClearDrawSegs (void); 56 | 57 | 58 | void R_RenderBSPNode (int bspnum); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /doomgeneric/v_patch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh/rendering module, shared data struct definitions. 17 | // 18 | 19 | 20 | #ifndef V_PATCH_H 21 | #define V_PATCH_H 22 | 23 | // Patches. 24 | // A patch holds one or more columns. 25 | // Patches are used for sprites and all masked pictures, 26 | // and we compose textures from the TEXTURE1/2 lists 27 | // of patches. 28 | 29 | typedef struct 30 | { 31 | short width; // bounding box size 32 | short height; 33 | short leftoffset; // pixels to the left of origin 34 | short topoffset; // pixels below the origin 35 | int columnofs[8]; // only [width] used 36 | // the [0] is &columnofs[width] 37 | } PACKEDATTR patch_t; 38 | 39 | // posts are runs of non masked source pixels 40 | typedef struct 41 | { 42 | byte topdelta; // -1 is the last post in a column 43 | byte length; // length data bytes follows 44 | } PACKEDATTR post_t; 45 | 46 | // column_t is a list of 0 or more post_t, (byte)-1 terminated 47 | typedef post_t column_t; 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /doomgeneric/deh_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dehacked entrypoint and common code 16 | // 17 | 18 | #ifndef DEH_MAIN_H 19 | #define DEH_MAIN_H 20 | 21 | #include "doomtype.h" 22 | #include "doomfeatures.h" 23 | #include "deh_str.h" 24 | #include "sha1.h" 25 | 26 | // These are the limits that dehacked uses (from dheinit.h in the dehacked 27 | // source). If these limits are exceeded, it does not generate an error, but 28 | // a warning is displayed. 29 | 30 | #define DEH_VANILLA_NUMSTATES 966 31 | #define DEH_VANILLA_NUMSFX 107 32 | 33 | void DEH_ParseCommandLine(void); 34 | int DEH_LoadFile(char *filename); 35 | int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error); 36 | int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error); 37 | 38 | boolean DEH_ParseAssignment(char *line, char **variable_name, char **value); 39 | 40 | void DEH_Checksum(sha1_digest_t digest); 41 | 42 | extern boolean deh_allow_extended_strings; 43 | extern boolean deh_allow_long_strings; 44 | extern boolean deh_allow_long_cheats; 45 | extern boolean deh_apply_cheats; 46 | 47 | #endif /* #ifndef DEH_MAIN_H */ 48 | 49 | -------------------------------------------------------------------------------- /doomgeneric/net_query.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Querying servers to find their current status. 16 | // 17 | 18 | #ifndef NET_QUERY_H 19 | #define NET_QUERY_H 20 | 21 | #include "net_defs.h" 22 | 23 | typedef void (*net_query_callback_t)(net_addr_t *addr, 24 | net_querydata_t *querydata, 25 | unsigned int ping_time, 26 | void *user_data); 27 | 28 | extern int NET_StartLANQuery(void); 29 | extern int NET_StartMasterQuery(void); 30 | 31 | extern void NET_LANQuery(void); 32 | extern void NET_MasterQuery(void); 33 | extern void NET_QueryAddress(char *addr); 34 | extern net_addr_t *NET_FindLANServer(void); 35 | 36 | extern int NET_Query_Poll(net_query_callback_t callback, void *user_data); 37 | 38 | extern net_addr_t *NET_Query_ResolveMaster(net_context_t *context); 39 | extern void NET_Query_AddToMaster(net_addr_t *master_addr); 40 | extern boolean NET_Query_CheckAddedToMaster(boolean *result); 41 | extern void NET_Query_MasterResponse(net_packet_t *packet); 42 | 43 | #endif /* #ifndef NET_QUERY_H */ 44 | 45 | -------------------------------------------------------------------------------- /doomgeneric/d_event.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // 16 | // DESCRIPTION: Event handling. 17 | // 18 | // Events are asynchronous inputs generally generated by the game user. 19 | // Events can be discarded if no responder claims them 20 | // 21 | 22 | #include 23 | #include "d_event.h" 24 | 25 | #define MAXEVENTS 64 26 | 27 | static event_t events[MAXEVENTS]; 28 | static int eventhead; 29 | static int eventtail; 30 | 31 | // 32 | // D_PostEvent 33 | // Called by the I/O functions when input is detected 34 | // 35 | void D_PostEvent (event_t* ev) 36 | { 37 | events[eventhead] = *ev; 38 | eventhead = (eventhead + 1) % MAXEVENTS; 39 | } 40 | 41 | // Read an event from the queue. 42 | 43 | event_t *D_PopEvent(void) 44 | { 45 | event_t *result; 46 | 47 | // No more events waiting. 48 | 49 | if (eventtail == eventhead) 50 | { 51 | return NULL; 52 | } 53 | 54 | result = &events[eventtail]; 55 | 56 | // Advance to the next event in the queue. 57 | 58 | eventtail = (eventtail + 1) % MAXEVENTS; 59 | 60 | return result; 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /doomgeneric/net_packet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Definitions for use in networking code. 16 | // 17 | 18 | #ifndef NET_PACKET_H 19 | #define NET_PACKET_H 20 | 21 | #include "net_defs.h" 22 | 23 | net_packet_t *NET_NewPacket(int initial_size); 24 | net_packet_t *NET_PacketDup(net_packet_t *packet); 25 | void NET_FreePacket(net_packet_t *packet); 26 | 27 | boolean NET_ReadInt8(net_packet_t *packet, unsigned int *data); 28 | boolean NET_ReadInt16(net_packet_t *packet, unsigned int *data); 29 | boolean NET_ReadInt32(net_packet_t *packet, unsigned int *data); 30 | 31 | boolean NET_ReadSInt8(net_packet_t *packet, signed int *data); 32 | boolean NET_ReadSInt16(net_packet_t *packet, signed int *data); 33 | boolean NET_ReadSInt32(net_packet_t *packet, signed int *data); 34 | 35 | char *NET_ReadString(net_packet_t *packet); 36 | 37 | void NET_WriteInt8(net_packet_t *packet, unsigned int i); 38 | void NET_WriteInt16(net_packet_t *packet, unsigned int i); 39 | void NET_WriteInt32(net_packet_t *packet, unsigned int i); 40 | 41 | void NET_WriteString(net_packet_t *packet, char *string); 42 | 43 | #endif /* #ifndef NET_PACKET_H */ 44 | 45 | -------------------------------------------------------------------------------- /doomgeneric/m_menu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Menu widget stuff, episode selection and such. 17 | // 18 | 19 | 20 | #ifndef __M_MENU__ 21 | #define __M_MENU__ 22 | 23 | 24 | 25 | #include "d_event.h" 26 | 27 | // 28 | // MENUS 29 | // 30 | // Called by main loop, 31 | // saves config file and calls I_Quit when user exits. 32 | // Even when the menu is not displayed, 33 | // this can resize the view and change game parameters. 34 | // Does all the real work of the menu interaction. 35 | boolean M_Responder (event_t *ev); 36 | 37 | 38 | // Called by main loop, 39 | // only used for menu (skull cursor) animation. 40 | void M_Ticker (void); 41 | 42 | // Called by main loop, 43 | // draws the menus directly into the screen buffer. 44 | void M_Drawer (void); 45 | 46 | // Called by D_DoomMain, 47 | // loads the config file. 48 | void M_Init (void); 49 | 50 | // Called by intro code to force menu up upon a keypress, 51 | // does nothing if menu is already up. 52 | void M_StartControlPanel (void); 53 | 54 | 55 | 56 | extern int detailLevel; 57 | extern int screenblocks; 58 | 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /doomgeneric/r_plane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh, visplane stuff (floor, ceilings). 17 | // 18 | 19 | 20 | #ifndef __R_PLANE__ 21 | #define __R_PLANE__ 22 | 23 | 24 | #include "r_data.h" 25 | 26 | 27 | 28 | // Visplane related. 29 | extern short* lastopening; 30 | 31 | 32 | typedef void (*planefunction_t) (int top, int bottom); 33 | 34 | extern planefunction_t floorfunc; 35 | extern planefunction_t ceilingfunc_t; 36 | 37 | extern short floorclip[SCREENWIDTH]; 38 | extern short ceilingclip[SCREENWIDTH]; 39 | 40 | extern fixed_t yslope[SCREENHEIGHT]; 41 | extern fixed_t distscale[SCREENWIDTH]; 42 | 43 | void R_InitPlanes (void); 44 | void R_ClearPlanes (void); 45 | 46 | void 47 | R_MapPlane 48 | ( int y, 49 | int x1, 50 | int x2 ); 51 | 52 | void 53 | R_MakeSpans 54 | ( int x, 55 | int t1, 56 | int b1, 57 | int t2, 58 | int b2 ); 59 | 60 | void R_DrawPlanes (void); 61 | 62 | visplane_t* 63 | R_FindPlane 64 | ( fixed_t height, 65 | int picnum, 66 | int lightlevel ); 67 | 68 | visplane_t* 69 | R_CheckPlane 70 | ( visplane_t* pl, 71 | int start, 72 | int stop ); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /doomgeneric/d_think.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // MapObj data. Map Objects or mobjs are actors, entities, 17 | // thinker, take-your-pick... anything that moves, acts, or 18 | // suffers state changes of more or less violent nature. 19 | // 20 | 21 | 22 | #ifndef __D_THINK__ 23 | #define __D_THINK__ 24 | 25 | 26 | 27 | 28 | 29 | // 30 | // Experimental stuff. 31 | // To compile this as "ANSI C with classes" 32 | // we will need to handle the various 33 | // action functions cleanly. 34 | // 35 | typedef void (*actionf_v)(); 36 | typedef void (*actionf_p1)( void* ); 37 | typedef void (*actionf_p2)( void*, void* ); 38 | 39 | typedef union 40 | { 41 | actionf_v acv; 42 | actionf_p1 acp1; 43 | actionf_p2 acp2; 44 | 45 | } actionf_t; 46 | 47 | 48 | 49 | 50 | 51 | // Historically, "think_t" is yet another 52 | // function pointer to a routine to handle 53 | // an actor. 54 | typedef actionf_t think_t; 55 | 56 | 57 | // Doubly linked list of actors. 58 | typedef struct thinker_s 59 | { 60 | struct thinker_s* prev; 61 | struct thinker_s* next; 62 | think_t function; 63 | 64 | } thinker_t; 65 | 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /doomgeneric/d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // Copyright(C) 2005-2014 Simon Howard 5 | // 6 | // This program is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation; either version 2 9 | // of the License, or (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // DESCRIPTION: 17 | // System specific interface stuff. 18 | // 19 | 20 | 21 | #ifndef __D_TICCMD__ 22 | #define __D_TICCMD__ 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | // The data sampled per tick (single player) 28 | // and transmitted to other peers (multiplayer). 29 | // Mainly movements/button commands per game tick, 30 | // plus a checksum for internal state consistency. 31 | 32 | typedef struct 33 | { 34 | signed char forwardmove; // *2048 for move 35 | signed char sidemove; // *2048 for move 36 | short angleturn; // <<16 for angle delta 37 | byte chatchar; 38 | byte buttons; 39 | // villsa [STRIFE] according to the asm, 40 | // consistancy is a short, not a byte 41 | byte consistancy; // checks for net game 42 | 43 | // villsa - Strife specific: 44 | 45 | byte buttons2; 46 | int inventory; 47 | 48 | // Heretic/Hexen specific: 49 | 50 | byte lookfly; // look/fly up/down/centering 51 | byte arti; // artitype_t to use 52 | } ticcmd_t; 53 | 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /doomgeneric/i_scale.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Pixel-doubling scale up functions. 17 | // 18 | 19 | 20 | #ifndef __I_SCALE__ 21 | #define __I_SCALE__ 22 | 23 | #include "doomtype.h" 24 | 25 | void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch); 26 | void I_ResetScaleTables(byte *palette); 27 | 28 | // Scaled modes (direct multiples of 320x200) 29 | 30 | extern screen_mode_t mode_scale_1x; 31 | extern screen_mode_t mode_scale_2x; 32 | extern screen_mode_t mode_scale_3x; 33 | extern screen_mode_t mode_scale_4x; 34 | extern screen_mode_t mode_scale_5x; 35 | 36 | // Vertically stretched modes (320x200 -> multiples of 320x240) 37 | 38 | extern screen_mode_t mode_stretch_1x; 39 | extern screen_mode_t mode_stretch_2x; 40 | extern screen_mode_t mode_stretch_3x; 41 | extern screen_mode_t mode_stretch_4x; 42 | extern screen_mode_t mode_stretch_5x; 43 | 44 | // Horizontally squashed modes (320x200 -> multiples of 256x200) 45 | 46 | extern screen_mode_t mode_squash_1x; 47 | extern screen_mode_t mode_squash_2x; 48 | extern screen_mode_t mode_squash_3x; 49 | extern screen_mode_t mode_squash_4x; 50 | extern screen_mode_t mode_squash_5x; 51 | 52 | #endif /* #ifndef __I_SCALE__ */ 53 | 54 | -------------------------------------------------------------------------------- /doomgeneric/p_saveg.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Savegame I/O, archiving, persistence. 17 | // 18 | 19 | 20 | #ifndef __P_SAVEG__ 21 | #define __P_SAVEG__ 22 | 23 | #include 24 | 25 | // maximum size of a savegame description 26 | 27 | #define SAVESTRINGSIZE 24 28 | 29 | // temporary filename to use while saving. 30 | 31 | char *P_TempSaveGameFile(void); 32 | 33 | // filename to use for a savegame slot 34 | 35 | char *P_SaveGameFile(int slot); 36 | 37 | // Savegame file header read/write functions 38 | 39 | boolean P_ReadSaveGameHeader(void); 40 | void P_WriteSaveGameHeader(char *description); 41 | 42 | // Savegame end-of-file read/write functions 43 | 44 | boolean P_ReadSaveGameEOF(void); 45 | void P_WriteSaveGameEOF(void); 46 | 47 | // Persistent storage/archiving. 48 | // These are the load / save game routines. 49 | void P_ArchivePlayers (void); 50 | void P_UnArchivePlayers (void); 51 | void P_ArchiveWorld (void); 52 | void P_UnArchiveWorld (void); 53 | void P_ArchiveThinkers (void); 54 | void P_UnArchiveThinkers (void); 55 | void P_ArchiveSpecials (void); 56 | void P_UnArchiveSpecials (void); 57 | 58 | extern FILE *save_stream; 59 | extern boolean savegame_error; 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /doomgeneric/r_things.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Rendering of moving objects, sprites. 17 | // 18 | 19 | 20 | #ifndef __R_THINGS__ 21 | #define __R_THINGS__ 22 | 23 | 24 | 25 | #define MAXVISSPRITES 128 26 | 27 | extern vissprite_t vissprites[MAXVISSPRITES]; 28 | extern vissprite_t* vissprite_p; 29 | extern vissprite_t vsprsortedhead; 30 | 31 | // Constant arrays used for psprite clipping 32 | // and initializing clipping. 33 | extern short negonearray[SCREENWIDTH]; 34 | extern short screenheightarray[SCREENWIDTH]; 35 | 36 | // vars for R_DrawMaskedColumn 37 | extern short* mfloorclip; 38 | extern short* mceilingclip; 39 | extern fixed_t spryscale; 40 | extern fixed_t sprtopscreen; 41 | 42 | extern fixed_t pspritescale; 43 | extern fixed_t pspriteiscale; 44 | 45 | 46 | void R_DrawMaskedColumn (column_t* column); 47 | 48 | 49 | void R_SortVisSprites (void); 50 | 51 | void R_AddSprites (sector_t* sec); 52 | void R_AddPSprites (void); 53 | void R_DrawSprites (void); 54 | void R_InitSprites (char** namelist); 55 | void R_ClearSprites (void); 56 | void R_DrawMasked (void); 57 | 58 | void 59 | R_ClipVisSprite 60 | ( vissprite_t* vis, 61 | int xl, 62 | int xh ); 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /doomgeneric/net_client.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Network client code 15 | // 16 | 17 | #ifndef NET_CLIENT_H 18 | #define NET_CLIENT_H 19 | 20 | #include "doomtype.h" 21 | #include "d_ticcmd.h" 22 | #include "sha1.h" 23 | #include "net_defs.h" 24 | 25 | boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data); 26 | void NET_CL_Disconnect(void); 27 | void NET_CL_Run(void); 28 | void NET_CL_Init(void); 29 | void NET_CL_LaunchGame(void); 30 | void NET_CL_StartGame(net_gamesettings_t *settings); 31 | void NET_CL_SendTiccmd(ticcmd_t *ticcmd, int maketic); 32 | boolean NET_CL_GetSettings(net_gamesettings_t *_settings); 33 | void NET_Init(void); 34 | 35 | void NET_BindVariables(void); 36 | 37 | extern boolean net_client_connected; 38 | extern boolean net_client_received_wait_data; 39 | extern net_waitdata_t net_client_wait_data; 40 | extern boolean net_waiting_for_launch; 41 | extern char *net_player_name; 42 | 43 | extern sha1_digest_t net_server_wad_sha1sum; 44 | extern sha1_digest_t net_server_deh_sha1sum; 45 | extern unsigned int net_server_is_freedoom; 46 | extern sha1_digest_t net_local_wad_sha1sum; 47 | extern sha1_digest_t net_local_deh_sha1sum; 48 | extern unsigned int net_local_is_freedoom; 49 | 50 | extern boolean drone; 51 | 52 | #endif /* #ifndef NET_CLIENT_H */ 53 | -------------------------------------------------------------------------------- /doomgeneric/d_iwad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Find IWAD and initialize according to IWAD type. 16 | // 17 | 18 | 19 | #ifndef __D_IWAD__ 20 | #define __D_IWAD__ 21 | 22 | #include "d_mode.h" 23 | 24 | #define IWAD_MASK_DOOM ((1 << doom) \ 25 | | (1 << doom2) \ 26 | | (1 << pack_tnt) \ 27 | | (1 << pack_plut) \ 28 | | (1 << pack_chex) \ 29 | | (1 << pack_hacx)) 30 | #define IWAD_MASK_HERETIC (1 << heretic) 31 | #define IWAD_MASK_HEXEN (1 << hexen) 32 | #define IWAD_MASK_STRIFE (1 << strife) 33 | 34 | typedef struct 35 | { 36 | char *name; 37 | GameMission_t mission; 38 | GameMode_t mode; 39 | char *description; 40 | } iwad_t; 41 | 42 | char *D_FindWADByName(char *filename); 43 | char *D_TryFindWADByName(char *filename); 44 | char *D_FindIWAD(int mask, GameMission_t *mission); 45 | const iwad_t **D_FindAllIWADs(int mask); 46 | char *D_SaveGameIWADName(GameMission_t gamemission); 47 | char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode); 48 | char *D_SuggestGameName(GameMission_t mission, GameMode_t mode); 49 | void D_CheckCorrectIWAD(GameMission_t mission); 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.freebsd: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | VB=@ 9 | 10 | 11 | CC=clang # gcc or g++ 12 | CFLAGS+=-ggdb3 -Os -I/usr/local/include 13 | LDFLAGS+=-Wl,--gc-sections -L/usr/local/lib 14 | CFLAGS+=-ggdb3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV # -DUSEASM 15 | LIBS+=-lm -lc -lX11 16 | 17 | # subdirectory for objects 18 | OBJDIR=build 19 | OUTPUT=doomgeneric 20 | 21 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_xlib.o 22 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 23 | 24 | all: $(OUTPUT) 25 | 26 | clean: 27 | rm -rf $(OBJDIR) 28 | rm -f $(OUTPUT) 29 | rm -f $(OUTPUT).gdb 30 | rm -f $(OUTPUT).map 31 | 32 | $(OUTPUT): $(OBJS) 33 | @echo [Linking $@] 34 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 35 | -o $(OUTPUT) $(LIBS) -Wl,-Map,$(OUTPUT).map 36 | @echo [Size] 37 | -$(CROSS_COMPILE)size $(OUTPUT) 38 | 39 | $(OBJS): | $(OBJDIR) 40 | 41 | $(OBJDIR): 42 | mkdir -p $(OBJDIR) 43 | 44 | $(OBJDIR)/%.o: %.c 45 | @echo [Compiling $<] 46 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 47 | 48 | print: 49 | @echo OBJS: $(OBJS) 50 | 51 | -------------------------------------------------------------------------------- /doomgeneric/p_pspr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Sprite animation. 17 | // 18 | 19 | 20 | #ifndef __P_PSPR__ 21 | #define __P_PSPR__ 22 | 23 | // Basic data types. 24 | // Needs fixed point, and BAM angles. 25 | #include "m_fixed.h" 26 | #include "tables.h" 27 | 28 | 29 | // 30 | // Needs to include the precompiled 31 | // sprite animation tables. 32 | // Header generated by multigen utility. 33 | // This includes all the data for thing animation, 34 | // i.e. the Thing Atrributes table 35 | // and the Frame Sequence table. 36 | #include "info.h" 37 | 38 | 39 | 40 | // 41 | // Frame flags: 42 | // handles maximum brightness (torches, muzzle flare, light sources) 43 | // 44 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 45 | #define FF_FRAMEMASK 0x7fff 46 | 47 | 48 | 49 | // 50 | // Overlay psprites are scaled shapes 51 | // drawn directly on the view screen, 52 | // coordinates are given for a 320*200 view screen. 53 | // 54 | typedef enum 55 | { 56 | ps_weapon, 57 | ps_flash, 58 | NUMPSPRITES 59 | 60 | } psprnum_t; 61 | 62 | typedef struct 63 | { 64 | state_t* state; // a NULL state means not active 65 | int tics; 66 | fixed_t sx; 67 | fixed_t sy; 68 | 69 | } pspdef_t; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.sdl: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | SDL_CFLAGS = `sdl2-config --cflags` 16 | SDL_LIBS = `sdl2-config --cflags --libs` -lSDL2_mixer 17 | 18 | 19 | CC=clang # gcc or g++ 20 | CFLAGS+=-DFEATURE_SOUND $(SDL_CFLAGS) 21 | LDFLAGS+= 22 | LIBS+=-lm -lc $(SDL_LIBS) 23 | 24 | # subdirectory for objects 25 | OBJDIR=build 26 | OUTPUT=doomgeneric 27 | 28 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_sdl.o mus2mid.o i_sdlmusic.o i_sdlsound.o 29 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 30 | 31 | all: $(OUTPUT) 32 | 33 | clean: 34 | rm -rf $(OBJDIR) 35 | rm -f $(OUTPUT) 36 | rm -f $(OUTPUT).gdb 37 | rm -f $(OUTPUT).map 38 | 39 | $(OUTPUT): $(OBJS) 40 | @echo [Linking $@] 41 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 42 | -o $(OUTPUT) $(LIBS) 43 | 44 | $(OBJS): | $(OBJDIR) 45 | 46 | $(OBJDIR): 47 | mkdir -p $(OBJDIR) 48 | 49 | $(OBJDIR)/%.o: %.c 50 | @echo [Compiling $<] 51 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 52 | 53 | print: 54 | @echo OBJS: $(OBJS) 55 | 56 | -------------------------------------------------------------------------------- /doomgeneric/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | CC=clang # gcc or g++ 16 | CFLAGS+=-ggdb3 -Os 17 | LDFLAGS+=-Wl,--gc-sections 18 | CFLAGS+=-ggdb3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM 19 | LIBS+=-lm -lc -lX11 20 | 21 | # subdirectory for objects 22 | OBJDIR=build 23 | OUTPUT=doomgeneric 24 | 25 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_xlib.o 26 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 27 | 28 | all: $(OUTPUT) 29 | 30 | clean: 31 | rm -rf $(OBJDIR) 32 | rm -f $(OUTPUT) 33 | rm -f $(OUTPUT).gdb 34 | rm -f $(OUTPUT).map 35 | 36 | $(OUTPUT): $(OBJS) 37 | @echo [Linking $@] 38 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 39 | -o $(OUTPUT) $(LIBS) -Wl,-Map,$(OUTPUT).map 40 | @echo [Size] 41 | -$(CROSS_COMPILE)size $(OUTPUT) 42 | 43 | $(OBJS): | $(OBJDIR) 44 | 45 | $(OBJDIR): 46 | mkdir -p $(OBJDIR) 47 | 48 | $(OBJDIR)/%.o: %.c 49 | @echo [Compiling $<] 50 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 51 | 52 | print: 53 | @echo OBJS: $(OBJS) 54 | 55 | -------------------------------------------------------------------------------- /doomgeneric/doom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * doom.h 3 | * 4 | * Created on: 18.02.2015 5 | * Author: Florian 6 | */ 7 | 8 | 9 | #ifndef SRC_CHOCDOOM_DOOM_H_ 10 | #define SRC_CHOCDOOM_DOOM_H_ 11 | 12 | /*---------------------------------------------------------------------* 13 | * additional includes * 14 | *---------------------------------------------------------------------*/ 15 | 16 | /*---------------------------------------------------------------------* 17 | * global definitions * 18 | *---------------------------------------------------------------------*/ 19 | 20 | /*---------------------------------------------------------------------* 21 | * type declarations * 22 | *---------------------------------------------------------------------*/ 23 | 24 | /*---------------------------------------------------------------------* 25 | * function prototypes * 26 | *---------------------------------------------------------------------*/ 27 | 28 | void D_DoomMain (void); 29 | 30 | /*---------------------------------------------------------------------* 31 | * global data * 32 | *---------------------------------------------------------------------*/ 33 | 34 | /*---------------------------------------------------------------------* 35 | * inline functions and function-like macros * 36 | *---------------------------------------------------------------------*/ 37 | 38 | /*---------------------------------------------------------------------* 39 | * eof * 40 | *---------------------------------------------------------------------*/ 41 | 42 | #endif /* SRC_CHOCDOOM_DOOM_H_ */ 43 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.emscripten: -------------------------------------------------------------------------------- 1 | 2 | ifeq ($(V),1) 3 | VB='' 4 | else 5 | VB=@ 6 | endif 7 | 8 | 9 | SDL_CFLAGS = `sdl2-config --cflags` 10 | SDL_LIBS = `sdl2-config --cflags --libs` -lSDL2_mixer 11 | 12 | 13 | CC=emcc 14 | CFLAGS+=-DFEATURE_SOUND -s SDL2_MIXER_FORMATS='["mid"]' $(SDL_CFLAGS) 15 | LDFLAGS+=--preload-file doom1.wad #--preload-file timidity.cfg --preload-file dgguspat 16 | LIBS+=-lm -lc $(SDL_LIBS) 17 | 18 | # subdirectory for objects 19 | OBJDIR=build 20 | OUTPUT=doomgeneric 21 | 22 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_emscripten.o mus2mid.o i_sdlmusic.o i_sdlsound.o 23 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 24 | 25 | all: $(OUTPUT) 26 | 27 | clean: 28 | rm -rf $(OBJDIR) 29 | rm -f $(OUTPUT).html 30 | rm -f $(OUTPUT).js 31 | rm -f $(OUTPUT).data 32 | rm -f $(OUTPUT).wasm 33 | 34 | $(OUTPUT): $(OBJS) 35 | @echo [Linking $@] 36 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 37 | -o $(OUTPUT).html $(LIBS) 38 | 39 | $(OBJS): | $(OBJDIR) 40 | 41 | $(OBJDIR): 42 | mkdir -p $(OBJDIR) 43 | 44 | $(OBJDIR)/%.o: %.c 45 | @echo [Compiling $<] 46 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 47 | 48 | print: 49 | @echo OBJS: $(OBJS) 50 | 51 | -------------------------------------------------------------------------------- /doomgeneric/w_wad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | 20 | #ifndef __W_WAD__ 21 | #define __W_WAD__ 22 | 23 | #include 24 | 25 | #include "doomtype.h" 26 | #include "d_mode.h" 27 | 28 | #include "w_file.h" 29 | 30 | 31 | // 32 | // TYPES 33 | // 34 | 35 | // 36 | // WADFILE I/O related stuff. 37 | // 38 | 39 | typedef struct lumpinfo_s lumpinfo_t; 40 | 41 | struct lumpinfo_s 42 | { 43 | char name[8]; 44 | wad_file_t *wad_file; 45 | int position; 46 | int size; 47 | void *cache; 48 | 49 | // Used for hash table lookups 50 | 51 | lumpinfo_t *next; 52 | }; 53 | 54 | 55 | extern lumpinfo_t *lumpinfo; 56 | extern unsigned int numlumps; 57 | 58 | wad_file_t *W_AddFile (char *filename); 59 | 60 | int W_CheckNumForName (char* name); 61 | int W_GetNumForName (char* name); 62 | 63 | int W_LumpLength (unsigned int lump); 64 | void W_ReadLump (unsigned int lump, void *dest); 65 | 66 | void* W_CacheLumpNum (int lump, int tag); 67 | void* W_CacheLumpName (char* name, int tag); 68 | 69 | void W_GenerateHashTable(void); 70 | 71 | extern unsigned int W_LumpNameHash(const char *s); 72 | 73 | void W_ReleaseLumpNum(int lump); 74 | void W_ReleaseLumpName(char *name); 75 | 76 | void W_CheckCorrectIWAD(GameMission_t mission); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.soso: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | CC=soso-clang # gcc or g++ 16 | CFLAGS+=-O3 17 | LDFLAGS+=$(SOSO_ROOT)/lib/crt1.o $(SOSO_ROOT)/lib/crti.o $(SOSO_ROOT)/lib/crtn.o 18 | CFLAGS+=-Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM 19 | LIBS+=-lm -lc /usr/lib/llvm-10/lib/clang/10.0.0/lib/linux/libclang_rt.builtins-i386.a 20 | 21 | # subdirectory for objects 22 | OBJDIR=build 23 | OUTPUT=fbdoom 24 | 25 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_soso.o 26 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 27 | 28 | all: $(OUTPUT) 29 | 30 | clean: 31 | rm -rf $(OBJDIR) 32 | rm -f $(OUTPUT) 33 | rm -f $(OUTPUT).gdb 34 | rm -f $(OUTPUT).map 35 | 36 | $(OUTPUT): $(OBJS) 37 | @echo [Linking $@] 38 | i386-soso-ld -v $(LDFLAGS) $(OBJS) -o $(OUTPUT) $(LIBS) 39 | @echo [Size] 40 | -$(CROSS_COMPILE)size $(OUTPUT) 41 | cp $(OUTPUT) ~/git/soso/userspace/bin/ 42 | 43 | $(OBJS): | $(OBJDIR) 44 | 45 | $(OBJDIR): 46 | mkdir -p $(OBJDIR) 47 | 48 | $(OBJDIR)/%.o: %.c 49 | @echo [Compiling $<] 50 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 51 | 52 | print: 53 | @echo OBJS: $(OBJS) 54 | 55 | -------------------------------------------------------------------------------- /doomgeneric/m_misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Miscellaneous. 17 | // 18 | 19 | 20 | #ifndef __M_MISC__ 21 | #define __M_MISC__ 22 | 23 | #include 24 | #include 25 | 26 | #include "doomtype.h" 27 | 28 | boolean M_WriteFile(char *name, void *source, int length); 29 | int M_ReadFile(char *name, byte **buffer); 30 | void M_MakeDirectory(char *dir); 31 | char *M_TempFile(char *s); 32 | boolean M_FileExists(char *file); 33 | long M_FileLength(FILE *handle); 34 | boolean M_StrToInt(const char *str, int *result); 35 | void M_ExtractFileBase(char *path, char *dest); 36 | void M_ForceUppercase(char *text); 37 | char *M_StrCaseStr(char *haystack, char *needle); 38 | char *M_StringDuplicate(const char *orig); 39 | boolean M_StringCopy(char *dest, const char *src, size_t dest_size); 40 | boolean M_StringConcat(char *dest, const char *src, size_t dest_size); 41 | char *M_StringReplace(const char *haystack, const char *needle, 42 | const char *replacement); 43 | char *M_StringJoin(const char *s, ...); 44 | boolean M_StringStartsWith(const char *s, const char *prefix); 45 | boolean M_StringEndsWith(const char *s, const char *suffix); 46 | int M_vsnprintf(char *buf, size_t buf_len, const char *s, va_list args); 47 | int M_snprintf(char *buf, size_t buf_len, const char *s, ...); 48 | char *M_OEMToUTF8(const char *ansi); 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /doomgeneric/i_timer.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Timer functions. 17 | // 18 | 19 | #include "i_timer.h" 20 | #include "doomtype.h" 21 | 22 | #include "doomgeneric.h" 23 | 24 | #include 25 | 26 | //#include 27 | //#include 28 | 29 | 30 | // 31 | // I_GetTime 32 | // returns time in 1/35th second tics 33 | // 34 | 35 | static uint32_t basetime = 0; 36 | 37 | 38 | int I_GetTicks(void) 39 | { 40 | return DG_GetTicksMs(); 41 | } 42 | 43 | int I_GetTime (void) 44 | { 45 | uint32_t ticks; 46 | 47 | ticks = I_GetTicks(); 48 | 49 | if (basetime == 0) 50 | basetime = ticks; 51 | 52 | ticks -= basetime; 53 | 54 | return (ticks * TICRATE) / 1000; 55 | } 56 | 57 | 58 | // 59 | // Same as I_GetTime, but returns time in milliseconds 60 | // 61 | 62 | int I_GetTimeMS(void) 63 | { 64 | uint32_t ticks; 65 | 66 | ticks = I_GetTicks(); 67 | 68 | if (basetime == 0) 69 | basetime = ticks; 70 | 71 | return ticks - basetime; 72 | } 73 | 74 | // Sleep for a specified number of ms 75 | 76 | void I_Sleep(int ms) 77 | { 78 | //SDL_Delay(ms); 79 | //usleep (ms * 1000); 80 | 81 | DG_SleepMs(ms); 82 | } 83 | 84 | void I_WaitVBL(int count) 85 | { 86 | //I_Sleep((count * 1000) / 70); 87 | } 88 | 89 | 90 | void I_InitTimer(void) 91 | { 92 | // initialize timer 93 | 94 | //SDL_Init(SDL_INIT_TIMER); 95 | } 96 | 97 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.sosox: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | CC=soso-clang # gcc or g++ 16 | CFLAGS+=-O3 17 | LDFLAGS+=$(SOSO_ROOT)/lib/crt1.o $(SOSO_ROOT)/lib/crti.o $(SOSO_ROOT)/lib/crtn.o 18 | CFLAGS+=-I$(SOSO_ROOT)/include/nano-x -Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM 19 | LIBS+=-lnano-X -lm -lc /usr/lib/llvm-10/lib/clang/10.0.0/lib/linux/libclang_rt.builtins-i386.a 20 | 21 | # subdirectory for objects 22 | OBJDIR=build 23 | OUTPUT=doom 24 | 25 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_sosox.o 26 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 27 | 28 | all: $(OUTPUT) 29 | 30 | clean: 31 | rm -rf $(OBJDIR) 32 | rm -f $(OUTPUT) 33 | rm -f $(OUTPUT).gdb 34 | rm -f $(OUTPUT).map 35 | 36 | $(OUTPUT): $(OBJS) 37 | @echo [Linking $@] 38 | i386-soso-ld -v $(LDFLAGS) $(OBJS) -o $(OUTPUT) $(LIBS) 39 | @echo [Size] 40 | -$(CROSS_COMPILE)size $(OUTPUT) 41 | cp $(OUTPUT) ~/git/soso/userspace/bin/ 42 | 43 | $(OBJS): | $(OBJDIR) 44 | 45 | $(OBJDIR): 46 | mkdir -p $(OBJDIR) 47 | 48 | $(OBJDIR)/%.o: %.c 49 | @echo [Compiling $<] 50 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 51 | 52 | print: 53 | @echo OBJS: $(OBJS) 54 | 55 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.amdgpu: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | TRIPLE=amdgcn-amd-amdhsa 16 | CC=clang 17 | CXX=clang++ 18 | CFLAGS+= -O1 -I$(shell dirname $(shell which $(CC)))/../include --target=$(TRIPLE) -mcpu=native -flto -nogpulib -fno-builtin-printf -I${LLVM_SOURCE}/libc 19 | LDFLAGS+= 20 | CFLAGS+=-Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM -DSHOWFPS 21 | LIBS+=-lm -lc $(shell dirname $(shell which $(CC)))/../lib/${TRIPLE}/crt1.o 22 | 23 | # subdirectory for objects 24 | OBJDIR=build 25 | OUTPUT=doomgeneric 26 | 27 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_gpu.o 28 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 29 | 30 | all: $(OUTPUT) 31 | 32 | clean: 33 | rm -rf $(OBJDIR) 34 | rm -f $(OUTPUT) 35 | rm -f $(OUTPUT).gdb 36 | rm -f $(OUTPUT).map 37 | 38 | $(OUTPUT): $(OBJS) 39 | @echo [Linking $@] 40 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 41 | -o $(OUTPUT) $(LIBS) -Wl,-Map,$(OUTPUT).map 42 | @echo [Size] 43 | -$(CROSS_COMPILE)size $(OUTPUT) 44 | 45 | $(OBJS): | $(OBJDIR) 46 | 47 | $(OBJDIR): 48 | mkdir -p $(OBJDIR) 49 | 50 | $(OBJDIR)/%.o: %.c 51 | @echo [Compiling $<] 52 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 53 | 54 | $(OBJDIR)/%.o: %.cc 55 | @echo [Compiling $<] 56 | $(VB)$(CXX) $(CFLAGS) -c $< -o $@ 57 | 58 | print: 59 | @echo OBJS: $(OBJS) 60 | 61 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.djgpp: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | .PHONY: all clean print 9 | 10 | .SUFFIXES: 11 | 12 | ifeq ($(V),1) 13 | VB='' 14 | else 15 | VB=@ 16 | endif 17 | 18 | 19 | 20 | CC:=i386-pc-msdosdjgpp-gcc 21 | OPTFLAGS:=-O3 22 | CFLAGS+=-std=gnu89 23 | CFLAGS+=$(OPTFLAGS) 24 | CFLAGS+=-Werror 25 | CFLAGS+=-DDOOMGENERIC_RESX=320 -DDOOMGENERIC_RESY=200 26 | CFLAGS+=-DFEATURE_SOUND=1 27 | CFLAGS+=-DCMAP256 28 | 29 | # link time optimization, no significant effect on performance 30 | # CFLAGS+=-flto 31 | # LDFLAGS+=-flto $(OPTFLAGS) 32 | 33 | # debug 34 | # CFLAGS+=-g 35 | # LDFLAGS+=-g 36 | 37 | LIBS+=-lalleg 38 | #LIBS+=-lalld # debug library 39 | 40 | # subdirectory for objects 41 | OBJDIR:=djgpp 42 | OUTPUT:=doomgen.exe 43 | 44 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_allegro.o mus2mid.o i_allegromusic.o i_allegrosound.o 45 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 46 | 47 | all: $(OUTPUT) 48 | 49 | clean: 50 | rm -rf $(OBJDIR) 51 | rm -f $(OUTPUT) 52 | rm -f $(OUTPUT).gdb 53 | rm -f $(OUTPUT).map 54 | 55 | $(OUTPUT): $(OBJS) 56 | @echo [Linking $@] 57 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 58 | -o $(OUTPUT) $(LIBS) 59 | 60 | $(OBJS): | $(OBJDIR) 61 | 62 | $(OBJDIR): 63 | mkdir -p $(OBJDIR) 64 | 65 | $(OBJDIR)/%.o: %.c 66 | @echo [Compiling $<] 67 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 68 | 69 | print: 70 | @echo OBJS: $(OBJS) 71 | 72 | -------------------------------------------------------------------------------- /doomgeneric/Makefile.nvptx: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # $Id:$ 4 | # 5 | # $Log:$ 6 | # 7 | 8 | ifeq ($(V),1) 9 | VB='' 10 | else 11 | VB=@ 12 | endif 13 | 14 | 15 | TRIPLE=nvptx64-nvidia-cuda 16 | CC=clang 17 | CXX=clang++ 18 | CFLAGS+= -O1 -I$(shell dirname $(shell which $(CC)))/../include --target=$(TRIPLE) -march=native -flto -nogpulib -fno-builtin-printf -I${LLVM_SOURCE}/libc 19 | LDFLAGS+=-Wl,--suppress-stack-size-warning 20 | CFLAGS+=-Wall -DNORMALUNIX -DLINUX -DSNDSERV -D_DEFAULT_SOURCE # -DUSEASM -DSHOWFPS 21 | LIBS+=-lm -lc $(shell dirname $(shell which $(CC)))/../lib/${TRIPLE}/crt1.o 22 | 23 | # subdirectory for objects 24 | OBJDIR=build 25 | OUTPUT=doomgeneric 26 | 27 | SRC_DOOM = 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_main.o w_wad.o z_zone.o w_file_stdc.o i_input.o i_video.o doomgeneric.o doomgeneric_gpu.o 28 | OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM)) 29 | 30 | all: $(OUTPUT) 31 | 32 | clean: 33 | rm -rf $(OBJDIR) 34 | rm -f $(OUTPUT) 35 | rm -f $(OUTPUT).gdb 36 | rm -f $(OUTPUT).map 37 | 38 | $(OUTPUT): $(OBJS) 39 | @echo [Linking $@] 40 | $(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \ 41 | -o $(OUTPUT) $(LIBS) 42 | @echo [Size] 43 | -$(CROSS_COMPILE)size $(OUTPUT) 44 | 45 | $(OBJS): | $(OBJDIR) 46 | 47 | $(OBJDIR): 48 | mkdir -p $(OBJDIR) 49 | 50 | $(OBJDIR)/%.o: %.c 51 | @echo [Compiling $<] 52 | $(VB)$(CC) $(CFLAGS) -c $< -o $@ 53 | 54 | $(OBJDIR)/%.o: %.cc 55 | @echo [Compiling $<] 56 | $(VB)$(CXX) $(CFLAGS) -c $< -o $@ 57 | 58 | print: 59 | @echo OBJS: $(OBJS) 60 | 61 | -------------------------------------------------------------------------------- /doomgeneric/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dummy.c 3 | * 4 | * Created on: 16.02.2015 5 | * Author: Florian 6 | */ 7 | 8 | 9 | /*---------------------------------------------------------------------* 10 | * include files * 11 | *---------------------------------------------------------------------*/ 12 | 13 | #include "doomtype.h" 14 | 15 | /*---------------------------------------------------------------------* 16 | * local definitions * 17 | *---------------------------------------------------------------------*/ 18 | 19 | /*---------------------------------------------------------------------* 20 | * external declarations * 21 | *---------------------------------------------------------------------*/ 22 | 23 | /*---------------------------------------------------------------------* 24 | * public data * 25 | *---------------------------------------------------------------------*/ 26 | 27 | boolean net_client_connected = false; 28 | 29 | boolean drone = false; 30 | 31 | /*---------------------------------------------------------------------* 32 | * private data * 33 | *---------------------------------------------------------------------*/ 34 | 35 | /*---------------------------------------------------------------------* 36 | * private functions * 37 | *---------------------------------------------------------------------*/ 38 | 39 | /*---------------------------------------------------------------------* 40 | * public functions * 41 | *---------------------------------------------------------------------*/ 42 | 43 | #ifndef FEATURE_SOUND 44 | 45 | void I_InitTimidityConfig(void) 46 | { 47 | } 48 | 49 | #endif 50 | 51 | /*---------------------------------------------------------------------* 52 | * eof * 53 | *---------------------------------------------------------------------*/ 54 | -------------------------------------------------------------------------------- /doomgeneric/g_game.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Duh. 17 | // 18 | 19 | 20 | #ifndef __G_GAME__ 21 | #define __G_GAME__ 22 | 23 | #include "doomdef.h" 24 | #include "d_event.h" 25 | #include "d_ticcmd.h" 26 | 27 | 28 | // 29 | // GAME 30 | // 31 | void G_DeathMatchSpawnPlayer (int playernum); 32 | 33 | void G_InitNew (skill_t skill, int episode, int map); 34 | 35 | // Can be called by the startup code or M_Responder. 36 | // A normal game starts at map 1, 37 | // but a warp test can start elsewhere 38 | void G_DeferedInitNew (skill_t skill, int episode, int map); 39 | 40 | void G_DeferedPlayDemo (char* demo); 41 | 42 | // Can be called by the startup code or M_Responder, 43 | // calls P_SetupLevel or W_EnterWorld. 44 | void G_LoadGame (char* name); 45 | 46 | void G_DoLoadGame (void); 47 | 48 | // Called by M_Responder. 49 | void G_SaveGame (int slot, char* description); 50 | 51 | // Only called by startup code. 52 | void G_RecordDemo (char* name); 53 | 54 | void G_BeginRecording (void); 55 | 56 | void G_PlayDemo (char* name); 57 | void G_TimeDemo (char* name); 58 | boolean G_CheckDemoStatus (void); 59 | 60 | void G_ExitLevel (void); 61 | void G_SecretExitLevel (void); 62 | 63 | void G_WorldDone (void); 64 | 65 | // Read current data from inputs and build a player movement command. 66 | 67 | void G_BuildTiccmd (ticcmd_t *cmd, int maketic); 68 | 69 | void G_Ticker (void); 70 | boolean G_Responder (event_t* ev); 71 | 72 | void G_ScreenShot (void); 73 | 74 | void G_DrawMouseSpeedBox(void); 75 | int G_VanillaVersionCode(void); 76 | 77 | extern int vanilla_savegame_limit; 78 | extern int vanilla_demo_limit; 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /doomgeneric/s_sound.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // The not so system specific sound interface. 17 | // 18 | 19 | 20 | #ifndef __S_SOUND__ 21 | #define __S_SOUND__ 22 | 23 | #include "p_mobj.h" 24 | #include "sounds.h" 25 | 26 | // 27 | // Initializes sound stuff, including volume 28 | // Sets channels, SFX and music volume, 29 | // allocates channel buffer, sets S_sfx lookup. 30 | // 31 | 32 | void S_Init(int sfxVolume, int musicVolume); 33 | 34 | 35 | // Shut down sound 36 | 37 | void S_Shutdown(void); 38 | 39 | 40 | 41 | // 42 | // Per level startup code. 43 | // Kills playing sounds at start of level, 44 | // determines music if any, changes music. 45 | // 46 | 47 | void S_Start(void); 48 | 49 | // 50 | // Start sound for thing at 51 | // using from sounds.h 52 | // 53 | 54 | void S_StartSound(void *origin, int sound_id); 55 | 56 | // Stop sound for thing at 57 | void S_StopSound(mobj_t *origin); 58 | 59 | 60 | // Start music using from sounds.h 61 | void S_StartMusic(int music_id); 62 | 63 | // Start music using from sounds.h, 64 | // and set whether looping 65 | void S_ChangeMusic(int music_id, int looping); 66 | 67 | // query if music is playing 68 | boolean S_MusicPlaying(void); 69 | 70 | // Stops the music fer sure. 71 | void S_StopMusic(void); 72 | 73 | // Stop and resume music, during game PAUSE. 74 | void S_PauseSound(void); 75 | void S_ResumeSound(void); 76 | 77 | 78 | // 79 | // Updates music & sounds 80 | // 81 | void S_UpdateSounds(mobj_t *listener); 82 | 83 | void S_SetMusicVolume(int volume); 84 | void S_SetSfxVolume(int volume); 85 | 86 | extern int snd_channels; 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /doomgeneric/w_file.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | #include 20 | 21 | #include "config.h" 22 | 23 | #include "doomtype.h" 24 | #include "m_argv.h" 25 | 26 | #include "w_file.h" 27 | 28 | extern wad_file_class_t stdc_wad_file; 29 | 30 | /* 31 | #ifdef _WIN32 32 | extern wad_file_class_t win32_wad_file; 33 | #endif 34 | */ 35 | 36 | #ifdef HAVE_MMAP 37 | extern wad_file_class_t posix_wad_file; 38 | #endif 39 | 40 | static wad_file_class_t *wad_file_classes[] = 41 | { 42 | /* 43 | #ifdef _WIN32 44 | &win32_wad_file, 45 | #endif 46 | */ 47 | #ifdef HAVE_MMAP 48 | &posix_wad_file, 49 | #endif 50 | &stdc_wad_file, 51 | }; 52 | 53 | wad_file_t *W_OpenFile(char *path) 54 | { 55 | wad_file_t *result; 56 | int i; 57 | 58 | //! 59 | // Use the OS's virtual memory subsystem to map WAD files 60 | // directly into memory. 61 | // 62 | 63 | if (!M_CheckParm("-mmap")) 64 | { 65 | return stdc_wad_file.OpenFile(path); 66 | } 67 | 68 | // Try all classes in order until we find one that works 69 | 70 | result = NULL; 71 | 72 | for (i = 0; i < arrlen(wad_file_classes); ++i) 73 | { 74 | result = wad_file_classes[i]->OpenFile(path); 75 | 76 | if (result != NULL) 77 | { 78 | break; 79 | } 80 | } 81 | 82 | return result; 83 | } 84 | 85 | void W_CloseFile(wad_file_t *wad) 86 | { 87 | wad->file_class->CloseFile(wad); 88 | } 89 | 90 | size_t W_Read(wad_file_t *wad, unsigned int offset, 91 | void *buffer, size_t buffer_len) 92 | { 93 | return wad->file_class->Read(wad, offset, buffer, buffer_len); 94 | } 95 | 96 | -------------------------------------------------------------------------------- /doomgeneric/doomgeneric_gpu.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "doomgeneric.h" 5 | #include "doomkeys.h" 6 | #include "m_argv.h" 7 | 8 | #include 9 | #include 10 | 11 | #define NS_IN_MS 1000000L 12 | 13 | [[gnu::visibility("protected")]] extern rpc::Client 14 | client asm("__llvm_rpc_client"); 15 | 16 | void DG_Init() {} 17 | 18 | void DG_DrawFrame() { 19 | auto port = client.open(); 20 | port.send([&](rpc::Buffer *buffer, uint32_t) { 21 | buffer->data[0] = reinterpret_cast(DG_ScreenBuffer); 22 | }); 23 | port.close(); 24 | } 25 | 26 | void DG_SleepMs(uint32_t ms) { 27 | struct timespec tim; 28 | tim.tv_sec = ms / 1000; 29 | tim.tv_nsec = (NS_IN_MS * ms) % (NS_IN_MS * 1000L); 30 | nanosleep(&tim, NULL); 31 | } 32 | 33 | uint32_t DG_GetTicksMs() { 34 | struct timespec tim; 35 | clock_gettime(CLOCK_MONOTONIC, &tim); 36 | return (uint32_t)(tim.tv_sec * 1000 + tim.tv_nsec / NS_IN_MS); 37 | } 38 | 39 | int DG_GetKey(int *pressed, unsigned char *doomKey) { 40 | auto port = client.open(); 41 | uint32_t key = 0; 42 | port.send_and_recv( 43 | [](rpc::Buffer *, uint32_t) {}, 44 | [&](rpc::Buffer *buffer, uint32_t) { key = buffer->data[0]; }); 45 | port.close(); 46 | if (key == 0) 47 | return 0; 48 | 49 | *pressed = key >> 8; 50 | *doomKey = key & 0xFF; 51 | 52 | return 1; 53 | } 54 | 55 | void DG_SetWindowTitle(const char *title) {} 56 | 57 | int main(int argc, char **argv, char **envp) { 58 | if (__gpu_thread_id(0) == 0) 59 | doomgeneric_Create(argc, argv); 60 | __gpu_sync_threads(); 61 | 62 | #ifdef SHOWFPS 63 | uint32_t time = DG_GetTicksMs(); 64 | uint32_t last_tick = 0; 65 | #endif 66 | for (int i = 0;; ++i) { 67 | doomgeneric_Tick(); 68 | 69 | #ifdef SHOWFPS 70 | if (__gpu_thread_id(0) == 0) { 71 | int interval = 10; 72 | if (i % interval == 0) { 73 | uint32_t new_time = DG_GetTicksMs(); 74 | uint32_t diff = (new_time - time); 75 | if (diff > 2000) { 76 | float fps = (float)(i - last_tick) / (diff / 1000.0f); 77 | last_tick = i; 78 | time = new_time; 79 | printf("fps %f\n", fps); 80 | } 81 | } 82 | } 83 | #endif 84 | } 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /doomgeneric/i_swap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Endianess handling, swapping 16bit and 32bit. 17 | // 18 | 19 | 20 | #ifndef __I_SWAP__ 21 | #define __I_SWAP__ 22 | 23 | #ifdef FEATURE_SOUND 24 | 25 | 26 | #ifdef __DJGPP__ 27 | 28 | 29 | #define SHORT(x) ((signed short) (x)) 30 | #define LONG(x) ((signed int) (x)) 31 | 32 | #define SYS_LITTLE_ENDIAN 33 | 34 | 35 | #else // __DJGPP__ 36 | 37 | 38 | #include 39 | 40 | // Endianess handling. 41 | // WAD files are stored little endian. 42 | 43 | // Just use SDL's endianness swapping functions. 44 | 45 | // These are deliberately cast to signed values; this is the behaviour 46 | // of the macros in the original source and some code relies on it. 47 | 48 | #define SHORT(x) ((signed short) SDL_SwapLE16(x)) 49 | #define LONG(x) ((signed int) SDL_SwapLE32(x)) 50 | 51 | // Defines for checking the endianness of the system. 52 | 53 | #if SDL_BYTEORDER == SYS_LIL_ENDIAN 54 | #define SYS_LITTLE_ENDIAN 55 | #elif SDL_BYTEORDER == SYS_BIG_ENDIAN 56 | #define SYS_BIG_ENDIAN 57 | #endif 58 | 59 | // cosmito from lsdldoom 60 | #define doom_swap_s(x) \ 61 | ((short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ 62 | (((unsigned short int)(x) & 0xff00) >> 8))) 63 | 64 | 65 | #if ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) 66 | #define doom_wtohs(x) doom_swap_s(x) 67 | #else 68 | #define doom_wtohs(x) (short int)(x) 69 | #endif 70 | 71 | 72 | #endif // __DJGPP__ 73 | 74 | 75 | #else // FEATURE_SOUND 76 | 77 | #define SHORT(x) ((signed short) (x)) 78 | #define LONG(x) ((signed int) (x)) 79 | 80 | #define SYS_LITTLE_ENDIAN 81 | 82 | #endif /* FEATURE_SOUND */ 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /doomgeneric/st_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Status bar code. 17 | // Does the face/direction indicator animatin. 18 | // Does palette indicators as well (red pain/berserk, bright pickup) 19 | // 20 | 21 | #ifndef __STSTUFF_H__ 22 | #define __STSTUFF_H__ 23 | 24 | #include "doomtype.h" 25 | #include "d_event.h" 26 | #include "m_cheat.h" 27 | 28 | // Size of statusbar. 29 | // Now sensitive for scaling. 30 | #define ST_HEIGHT 32 31 | #define ST_WIDTH SCREENWIDTH 32 | #define ST_Y (SCREENHEIGHT - ST_HEIGHT) 33 | 34 | 35 | // 36 | // STATUS BAR 37 | // 38 | 39 | // Called by main loop. 40 | boolean ST_Responder (event_t* ev); 41 | 42 | // Called by main loop. 43 | void ST_Ticker (void); 44 | 45 | // Called by main loop. 46 | void ST_Drawer (boolean fullscreen, boolean refresh); 47 | 48 | // Called when the console player is spawned on each level. 49 | void ST_Start (void); 50 | 51 | // Called by startup code. 52 | void ST_Init (void); 53 | 54 | 55 | 56 | // States for status bar code. 57 | typedef enum 58 | { 59 | AutomapState, 60 | FirstPersonState 61 | 62 | } st_stateenum_t; 63 | 64 | 65 | // States for the chat code. 66 | typedef enum 67 | { 68 | StartChatState, 69 | WaitDestState, 70 | GetChatState 71 | 72 | } st_chatstateenum_t; 73 | 74 | 75 | 76 | extern byte *st_backing_screen; 77 | extern cheatseq_t cheat_mus; 78 | extern cheatseq_t cheat_god; 79 | extern cheatseq_t cheat_ammo; 80 | extern cheatseq_t cheat_ammonokey; 81 | extern cheatseq_t cheat_noclip; 82 | extern cheatseq_t cheat_commercial_noclip; 83 | extern cheatseq_t cheat_powerup[7]; 84 | extern cheatseq_t cheat_choppers; 85 | extern cheatseq_t cheat_clev; 86 | extern cheatseq_t cheat_mypos; 87 | 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /doomgeneric/w_file.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | 20 | #ifndef __W_FILE__ 21 | #define __W_FILE__ 22 | 23 | #include 24 | #include "doomtype.h" 25 | 26 | typedef struct _wad_file_s wad_file_t; 27 | 28 | typedef struct 29 | { 30 | // Open a file for reading. 31 | 32 | wad_file_t *(*OpenFile)(char *path); 33 | 34 | // Close the specified file. 35 | 36 | void (*CloseFile)(wad_file_t *file); 37 | 38 | // Read data from the specified position in the file into the 39 | // provided buffer. Returns the number of bytes read. 40 | 41 | size_t (*Read)(wad_file_t *file, unsigned int offset, 42 | void *buffer, size_t buffer_len); 43 | 44 | } wad_file_class_t; 45 | 46 | struct _wad_file_s 47 | { 48 | // Class of this file. 49 | 50 | wad_file_class_t *file_class; 51 | 52 | // If this is NULL, the file cannot be mapped into memory. If this 53 | // is non-NULL, it is a pointer to the mapped file. 54 | 55 | byte *mapped; 56 | 57 | // Length of the file, in bytes. 58 | 59 | unsigned int length; 60 | }; 61 | 62 | // Open the specified file. Returns a pointer to a new wad_file_t 63 | // handle for the WAD file, or NULL if it could not be opened. 64 | 65 | wad_file_t *W_OpenFile(char *path); 66 | 67 | // Close the specified WAD file. 68 | 69 | void W_CloseFile(wad_file_t *wad); 70 | 71 | // Read data from the specified file into the provided buffer. The 72 | // data is read from the specified offset from the start of the file. 73 | // Returns the number of bytes read. 74 | 75 | size_t W_Read(wad_file_t *wad, unsigned int offset, 76 | void *buffer, size_t buffer_len); 77 | 78 | #endif /* #ifndef __W_FILE__ */ 79 | -------------------------------------------------------------------------------- /doomgeneric/z_zone.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Zone Memory Allocation, perhaps NeXT ObjectiveC inspired. 17 | // Remark: this was the only stuff that, according 18 | // to John Carmack, might have been useful for 19 | // Quake. 20 | // 21 | 22 | 23 | 24 | #ifndef __Z_ZONE__ 25 | #define __Z_ZONE__ 26 | 27 | #include 28 | 29 | // 30 | // ZONE MEMORY 31 | // PU - purge tags. 32 | 33 | enum 34 | { 35 | PU_STATIC = 1, // static entire execution time 36 | PU_SOUND, // static while playing 37 | PU_MUSIC, // static while playing 38 | PU_FREE, // a free block 39 | PU_LEVEL, // static until level exited 40 | PU_LEVSPEC, // a special thinker in a level 41 | 42 | // Tags >= PU_PURGELEVEL are purgable whenever needed. 43 | 44 | PU_PURGELEVEL, 45 | PU_CACHE, 46 | 47 | // Total number of different tag types 48 | 49 | PU_NUM_TAGS 50 | }; 51 | 52 | 53 | void Z_Init (void); 54 | void* Z_Malloc (int size, int tag, void *ptr); 55 | void Z_Free (void *ptr); 56 | void Z_FreeTags (int lowtag, int hightag); 57 | void Z_DumpHeap (int lowtag, int hightag); 58 | void Z_FileDumpHeap (FILE *f); 59 | void Z_CheckHeap (void); 60 | void Z_ChangeTag2 (void *ptr, int tag, char *file, int line); 61 | void Z_ChangeUser(void *ptr, void **user); 62 | int Z_FreeMemory (void); 63 | unsigned int Z_ZoneSize(void); 64 | 65 | // 66 | // This is used to get the local FILE:LINE info from CPP 67 | // prior to really call the function in question. 68 | // 69 | #define Z_ChangeTag(p,t) \ 70 | Z_ChangeTag2((p), (t), __FILE__, __LINE__) 71 | 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /doomgeneric/i_system.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System specific interface stuff. 17 | // 18 | 19 | 20 | #ifndef __I_SYSTEM__ 21 | #define __I_SYSTEM__ 22 | 23 | #include "d_ticcmd.h" 24 | #include "d_event.h" 25 | 26 | 27 | typedef void (*atexit_func_t)(void); 28 | 29 | // Called by DoomMain. 30 | void I_Init (void); 31 | 32 | // Called by startup code 33 | // to get the ammount of memory to malloc 34 | // for the zone management. 35 | byte* I_ZoneBase (int *size); 36 | 37 | boolean I_ConsoleStdout(void); 38 | 39 | 40 | // Asynchronous interrupt functions should maintain private queues 41 | // that are read by the synchronous functions 42 | // to be converted into events. 43 | 44 | // Either returns a null ticcmd, 45 | // or calls a loadable driver to build it. 46 | // This ticcmd will then be modified by the gameloop 47 | // for normal input. 48 | ticcmd_t* I_BaseTiccmd (void); 49 | 50 | 51 | // Called by M_Responder when quit is selected. 52 | // Clean exit, displays sell blurb. 53 | void I_Quit (void); 54 | 55 | void I_Error (char *error, ...); 56 | 57 | void I_Tactile (int on, int off, int total); 58 | 59 | boolean I_GetMemoryValue(unsigned int offset, void *value, int size); 60 | 61 | // Schedule a function to be called when the program exits. 62 | // If run_if_error is true, the function is called if the exit 63 | // is due to an error (I_Error) 64 | 65 | void I_AtExit(atexit_func_t func, boolean run_if_error); 66 | 67 | // Add all system-specific config file variable bindings. 68 | 69 | void I_BindVariables(void); 70 | 71 | // Print startup banner copyright message. 72 | 73 | void I_PrintStartupBanner(char *gamedescription); 74 | 75 | // Print a centered text banner displaying the given string. 76 | 77 | void I_PrintBanner(char *text); 78 | 79 | // Print a dividing line for startup banners. 80 | 81 | void I_PrintDivider(void); 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /doomgeneric/m_cheat.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Cheat sequence checking. 17 | // 18 | 19 | 20 | 21 | #include 22 | 23 | #include "doomtype.h" 24 | #include "m_cheat.h" 25 | 26 | // 27 | // CHEAT SEQUENCE PACKAGE 28 | // 29 | 30 | // 31 | // Called in st_stuff module, which handles the input. 32 | // Returns a 1 if the cheat was successful, 0 if failed. 33 | // 34 | int 35 | cht_CheckCheat 36 | ( cheatseq_t* cht, 37 | char key ) 38 | { 39 | // if we make a short sequence on a cheat with parameters, this 40 | // will not work in vanilla doom. behave the same. 41 | 42 | if (cht->parameter_chars > 0 && strlen(cht->sequence) < cht->sequence_len) 43 | return false; 44 | 45 | if (cht->chars_read < strlen(cht->sequence)) 46 | { 47 | // still reading characters from the cheat code 48 | // and verifying. reset back to the beginning 49 | // if a key is wrong 50 | 51 | if (key == cht->sequence[cht->chars_read]) 52 | ++cht->chars_read; 53 | else 54 | cht->chars_read = 0; 55 | 56 | cht->param_chars_read = 0; 57 | } 58 | else if (cht->param_chars_read < cht->parameter_chars) 59 | { 60 | // we have passed the end of the cheat sequence and are 61 | // entering parameters now 62 | 63 | cht->parameter_buf[cht->param_chars_read] = key; 64 | 65 | ++cht->param_chars_read; 66 | } 67 | 68 | if (cht->chars_read >= strlen(cht->sequence) 69 | && cht->param_chars_read >= cht->parameter_chars) 70 | { 71 | cht->chars_read = cht->param_chars_read = 0; 72 | 73 | return true; 74 | } 75 | 76 | // cheat not matched yet 77 | 78 | return false; 79 | } 80 | 81 | void 82 | cht_GetParam 83 | ( cheatseq_t* cht, 84 | char* buffer ) 85 | { 86 | memcpy(buffer, cht->parameter_buf, cht->parameter_chars); 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /doomgeneric/w_file_stdc.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | #include 20 | 21 | #include "m_misc.h" 22 | #include "w_file.h" 23 | #include "z_zone.h" 24 | 25 | typedef struct 26 | { 27 | wad_file_t wad; 28 | FILE *fstream; 29 | } stdc_wad_file_t; 30 | 31 | extern wad_file_class_t stdc_wad_file; 32 | 33 | static wad_file_t *W_StdC_OpenFile(char *path) 34 | { 35 | stdc_wad_file_t *result; 36 | FILE *fstream; 37 | 38 | fstream = fopen(path, "rb"); 39 | 40 | if (fstream == NULL) 41 | { 42 | return NULL; 43 | } 44 | 45 | // Create a new stdc_wad_file_t to hold the file handle. 46 | 47 | result = Z_Malloc(sizeof(stdc_wad_file_t), PU_STATIC, 0); 48 | result->wad.file_class = &stdc_wad_file; 49 | result->wad.mapped = NULL; 50 | result->wad.length = M_FileLength(fstream); 51 | result->fstream = fstream; 52 | 53 | return &result->wad; 54 | } 55 | 56 | static void W_StdC_CloseFile(wad_file_t *wad) 57 | { 58 | stdc_wad_file_t *stdc_wad; 59 | 60 | stdc_wad = (stdc_wad_file_t *) wad; 61 | 62 | fclose(stdc_wad->fstream); 63 | Z_Free(stdc_wad); 64 | } 65 | 66 | // Read data from the specified position in the file into the 67 | // provided buffer. Returns the number of bytes read. 68 | 69 | size_t W_StdC_Read(wad_file_t *wad, unsigned int offset, 70 | void *buffer, size_t buffer_len) 71 | { 72 | stdc_wad_file_t *stdc_wad; 73 | size_t result; 74 | 75 | stdc_wad = (stdc_wad_file_t *) wad; 76 | 77 | // Jump to the specified position in the file. 78 | 79 | fseek(stdc_wad->fstream, offset, SEEK_SET); 80 | 81 | // Read into the buffer. 82 | 83 | result = fread(buffer, 1, buffer_len, stdc_wad->fstream); 84 | 85 | return result; 86 | } 87 | 88 | 89 | wad_file_class_t stdc_wad_file = 90 | { 91 | W_StdC_OpenFile, 92 | W_StdC_CloseFile, 93 | W_StdC_Read, 94 | }; 95 | 96 | 97 | -------------------------------------------------------------------------------- /doomgeneric/d_items.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | 18 | 19 | // We are referring to sprite numbers. 20 | #include "info.h" 21 | 22 | #include "d_items.h" 23 | 24 | 25 | // 26 | // PSPRITE ACTIONS for waepons. 27 | // This struct controls the weapon animations. 28 | // 29 | // Each entry is: 30 | // ammo/amunition type 31 | // upstate 32 | // downstate 33 | // readystate 34 | // atkstate, i.e. attack/fire/hit frame 35 | // flashstate, muzzle flash 36 | // 37 | weaponinfo_t weaponinfo[NUMWEAPONS] = 38 | { 39 | { 40 | // fist 41 | am_noammo, 42 | S_PUNCHUP, 43 | S_PUNCHDOWN, 44 | S_PUNCH, 45 | S_PUNCH1, 46 | S_NULL 47 | }, 48 | { 49 | // pistol 50 | am_clip, 51 | S_PISTOLUP, 52 | S_PISTOLDOWN, 53 | S_PISTOL, 54 | S_PISTOL1, 55 | S_PISTOLFLASH 56 | }, 57 | { 58 | // shotgun 59 | am_shell, 60 | S_SGUNUP, 61 | S_SGUNDOWN, 62 | S_SGUN, 63 | S_SGUN1, 64 | S_SGUNFLASH1 65 | }, 66 | { 67 | // chaingun 68 | am_clip, 69 | S_CHAINUP, 70 | S_CHAINDOWN, 71 | S_CHAIN, 72 | S_CHAIN1, 73 | S_CHAINFLASH1 74 | }, 75 | { 76 | // missile launcher 77 | am_misl, 78 | S_MISSILEUP, 79 | S_MISSILEDOWN, 80 | S_MISSILE, 81 | S_MISSILE1, 82 | S_MISSILEFLASH1 83 | }, 84 | { 85 | // plasma rifle 86 | am_cell, 87 | S_PLASMAUP, 88 | S_PLASMADOWN, 89 | S_PLASMA, 90 | S_PLASMA1, 91 | S_PLASMAFLASH1 92 | }, 93 | { 94 | // bfg 9000 95 | am_cell, 96 | S_BFGUP, 97 | S_BFGDOWN, 98 | S_BFG, 99 | S_BFG1, 100 | S_BFGFLASH1 101 | }, 102 | { 103 | // chainsaw 104 | am_noammo, 105 | S_SAWUP, 106 | S_SAWDOWN, 107 | S_SAW, 108 | S_SAW1, 109 | S_NULL 110 | }, 111 | { 112 | // super shotgun 113 | am_shell, 114 | S_DSGUNUP, 115 | S_DSGUNDOWN, 116 | S_DSGUN, 117 | S_DSGUN1, 118 | S_DSGUNFLASH1 119 | }, 120 | }; 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /doomgeneric/w_checksum.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Generate a checksum of the WAD directory. 17 | // 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "m_misc.h" 24 | #include "sha1.h" 25 | #include "w_checksum.h" 26 | #include "w_wad.h" 27 | 28 | static wad_file_t **open_wadfiles = NULL; 29 | static int num_open_wadfiles = 0; 30 | 31 | static int GetFileNumber(wad_file_t *handle) 32 | { 33 | int i; 34 | int result; 35 | 36 | for (i=0; iname, sizeof(buf)); 62 | SHA1_UpdateString(sha1_context, buf); 63 | SHA1_UpdateInt32(sha1_context, GetFileNumber(lump->wad_file)); 64 | SHA1_UpdateInt32(sha1_context, lump->position); 65 | SHA1_UpdateInt32(sha1_context, lump->size); 66 | } 67 | 68 | void W_Checksum(sha1_digest_t digest) 69 | { 70 | sha1_context_t sha1_context; 71 | unsigned int i; 72 | 73 | SHA1_Init(&sha1_context); 74 | 75 | num_open_wadfiles = 0; 76 | 77 | // Go through each entry in the WAD directory, adding information 78 | // about each entry to the SHA1 hash. 79 | 80 | for (i=0; i 19 | #include 20 | 21 | #include "config.h" 22 | #include "doomtype.h" 23 | #include "i_video.h" 24 | 25 | #ifdef ORIGCODE 26 | #include "txt_main.h" 27 | #endif 28 | 29 | 30 | #ifdef __DJGPP__ 31 | #include 32 | #endif // __DJGPP__ 33 | 34 | 35 | #define ENDOOM_W 80 36 | #define ENDOOM_H 25 37 | 38 | // 39 | // Displays the text mode ending screen after the game quits 40 | // 41 | 42 | void I_Endoom(byte *endoom_data) 43 | { 44 | #ifdef ORIGCODE 45 | unsigned char *screendata; 46 | int y; 47 | int indent; 48 | 49 | // Set up text mode screen 50 | 51 | TXT_Init(); 52 | I_InitWindowTitle(); 53 | I_InitWindowIcon(); 54 | 55 | // Write the data to the screen memory 56 | 57 | screendata = TXT_GetScreenData(); 58 | 59 | indent = (ENDOOM_W - TXT_SCREEN_W) / 2; 60 | 61 | for (y=0; y 0) 75 | { 76 | break; 77 | } 78 | 79 | TXT_Sleep(0); 80 | } 81 | 82 | // Shut down text mode screen 83 | 84 | TXT_Shutdown(); 85 | 86 | #elif defined(__DJGPP__) 87 | 88 | int y; 89 | 90 | // move cursor to bottom 91 | // there's a direct call for moving cursor somewhere but this is simpler to write 92 | for (y = 0; y < ENDOOM_H; y++) { 93 | puts("\n"); 94 | } 95 | 96 | // allegro exit should have been run already and so we should be in text mode again 97 | movedata(_my_ds(), (unsigned) endoom_data, _dos_ds, 0xB8000UL, ENDOOM_W * ENDOOM_H * 2); 98 | 99 | #endif 100 | } 101 | 102 | -------------------------------------------------------------------------------- /doomgeneric/m_random.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Random number LUT. 17 | // 18 | 19 | // 20 | // M_Random 21 | // Returns a 0-255 number 22 | // 23 | 24 | static const unsigned char rndtable[256] = { 25 | 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 , 26 | 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 , 27 | 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 , 28 | 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 , 29 | 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 , 30 | 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 , 31 | 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 , 32 | 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 , 33 | 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 , 34 | 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 , 35 | 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 , 36 | 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 , 37 | 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 , 38 | 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 , 39 | 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 , 40 | 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 , 41 | 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 , 42 | 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 43 | 120, 163, 236, 249 44 | }; 45 | 46 | int rndindex = 0; 47 | int prndindex = 0; 48 | 49 | // Which one is deterministic? 50 | int P_Random (void) 51 | { 52 | prndindex = (prndindex+1)&0xff; 53 | return rndtable[prndindex]; 54 | } 55 | 56 | int M_Random (void) 57 | { 58 | rndindex = (rndindex+1)&0xff; 59 | return rndtable[rndindex]; 60 | } 61 | 62 | void M_ClearRandom (void) 63 | { 64 | rndindex = prndindex = 0; 65 | } 66 | -------------------------------------------------------------------------------- /doomgeneric/d_loop.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Main loop stuff. 17 | // 18 | 19 | #ifndef __D_LOOP__ 20 | #define __D_LOOP__ 21 | 22 | #include "net_defs.h" 23 | 24 | // Callback function invoked while waiting for the netgame to start. 25 | // The callback is invoked when new players are ready. The callback 26 | // should return true, or return false to abort startup. 27 | 28 | typedef boolean (*netgame_startup_callback_t)(int ready_players, 29 | int num_players); 30 | 31 | typedef struct 32 | { 33 | // Read events from the event queue, and process them. 34 | 35 | void (*ProcessEvents)(); 36 | 37 | // Given the current input state, fill in the fields of the specified 38 | // ticcmd_t structure with data for a new tic. 39 | 40 | void (*BuildTiccmd)(ticcmd_t *cmd, int maketic); 41 | 42 | // Advance the game forward one tic, using the specified player input. 43 | 44 | void (*RunTic)(ticcmd_t *cmds, boolean *ingame); 45 | 46 | // Run the menu (runs independently of the game). 47 | 48 | void (*RunMenu)(); 49 | } loop_interface_t; 50 | 51 | // Register callback functions for the main loop code to use. 52 | void D_RegisterLoopCallbacks(loop_interface_t *i); 53 | 54 | // Create any new ticcmds and broadcast to other players. 55 | void NetUpdate (void); 56 | 57 | // Broadcasts special packets to other players 58 | // to notify of game exit 59 | void D_QuitNetGame (void); 60 | 61 | //? how many ticks to run? 62 | void TryRunTics (void); 63 | 64 | // Called at start of game loop to initialize timers 65 | void D_StartGameLoop(void); 66 | 67 | // Initialize networking code and connect to server. 68 | 69 | boolean D_InitNetGame(net_connect_data_t *connect_data); 70 | 71 | // Start game with specified settings. The structure will be updated 72 | // with the actual settings for the game. 73 | 74 | void D_StartNetGame(net_gamesettings_t *settings, 75 | netgame_startup_callback_t callback); 76 | 77 | extern boolean singletics; 78 | extern int gametic, ticdup; 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /doomgeneric/r_draw.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System specific interface stuff. 17 | // 18 | 19 | 20 | #ifndef __R_DRAW__ 21 | #define __R_DRAW__ 22 | 23 | 24 | 25 | 26 | extern lighttable_t* dc_colormap; 27 | extern int dc_x; 28 | extern int dc_yl; 29 | extern int dc_yh; 30 | extern fixed_t dc_iscale; 31 | extern fixed_t dc_texturemid; 32 | 33 | // first pixel in a column 34 | extern byte* dc_source; 35 | 36 | 37 | // The span blitting interface. 38 | // Hook in assembler or system specific BLT 39 | // here. 40 | void R_DrawColumn (void); 41 | void R_DrawColumnLow (void); 42 | 43 | // The Spectre/Invisibility effect. 44 | void R_DrawFuzzColumn (void); 45 | void R_DrawFuzzColumnLow (void); 46 | 47 | // Draw with color translation tables, 48 | // for player sprite rendering, 49 | // Green/Red/Blue/Indigo shirts. 50 | void R_DrawTranslatedColumn (void); 51 | void R_DrawTranslatedColumnLow (void); 52 | 53 | void 54 | R_VideoErase 55 | ( unsigned ofs, 56 | int count ); 57 | 58 | extern int ds_y; 59 | extern int ds_x1; 60 | extern int ds_x2; 61 | 62 | extern lighttable_t* ds_colormap; 63 | 64 | extern fixed_t ds_xfrac; 65 | extern fixed_t ds_yfrac; 66 | extern fixed_t ds_xstep; 67 | extern fixed_t ds_ystep; 68 | 69 | // start of a 64*64 tile image 70 | extern byte* ds_source; 71 | 72 | extern byte* translationtables; 73 | extern byte* dc_translation; 74 | 75 | 76 | // Span blitting for rows, floor/ceiling. 77 | // No Sepctre effect needed. 78 | void R_DrawSpan (void); 79 | 80 | // Low resolution mode, 160x200? 81 | void R_DrawSpanLow (void); 82 | 83 | 84 | void 85 | R_InitBuffer 86 | ( int width, 87 | int height ); 88 | 89 | 90 | // Initialize color translation tables, 91 | // for player rendering etc. 92 | void R_InitTranslationTables (void); 93 | 94 | 95 | 96 | // Rendering function. 97 | void R_FillBackScreen (void); 98 | 99 | // If the view size is not full screen, draws a border around it. 100 | void R_DrawViewBorder (void); 101 | 102 | 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /doomgeneric/i_joystick.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // System-specific joystick interface. 16 | // 17 | 18 | 19 | #ifndef __I_JOYSTICK__ 20 | #define __I_JOYSTICK__ 21 | 22 | // Number of "virtual" joystick buttons defined in configuration files. 23 | // This needs to be at least as large as the number of different key 24 | // bindings supported by the higher-level game code (joyb* variables). 25 | #define NUM_VIRTUAL_BUTTONS 10 26 | 27 | // If this bit is set in a configuration file axis value, the axis is 28 | // not actually a joystick axis, but instead is a "button axis". This 29 | // means that instead of reading an SDL joystick axis, we read the 30 | // state of two buttons to get the axis value. This is needed for eg. 31 | // the PS3 SIXAXIS controller, where the D-pad buttons register as 32 | // buttons, not as two axes. 33 | #define BUTTON_AXIS 0x10000 34 | 35 | // Query whether a given axis value describes a button axis. 36 | #define IS_BUTTON_AXIS(axis) ((axis) >= 0 && ((axis) & BUTTON_AXIS) != 0) 37 | 38 | // Get the individual buttons from a button axis value. 39 | #define BUTTON_AXIS_NEG(axis) ((axis) & 0xff) 40 | #define BUTTON_AXIS_POS(axis) (((axis) >> 8) & 0xff) 41 | 42 | // Create a button axis value from two button values. 43 | #define CREATE_BUTTON_AXIS(neg, pos) (BUTTON_AXIS | (neg) | ((pos) << 8)) 44 | 45 | // If this bit is set in an axis value, the axis is not actually a 46 | // joystick axis, but is a "hat" axis. This means that we read (one of) 47 | // the hats on the joystick. 48 | #define HAT_AXIS 0x20000 49 | 50 | #define IS_HAT_AXIS(axis) ((axis) >= 0 && ((axis) & HAT_AXIS) != 0) 51 | 52 | // Get the hat number from a hat axis value. 53 | #define HAT_AXIS_HAT(axis) ((axis) & 0xff) 54 | // Which axis of the hat? (horizonal or vertical) 55 | #define HAT_AXIS_DIRECTION(axis) (((axis) >> 8) & 0xff) 56 | 57 | #define CREATE_HAT_AXIS(hat, direction) \ 58 | (HAT_AXIS | (hat) | ((direction) << 8)) 59 | 60 | #define HAT_AXIS_HORIZONTAL 1 61 | #define HAT_AXIS_VERTICAL 2 62 | 63 | void I_InitJoystick(void); 64 | void I_ShutdownJoystick(void); 65 | void I_UpdateJoystick(void); 66 | 67 | void I_BindJoystickVariables(void); 68 | 69 | #endif /* #ifndef __I_JOYSTICK__ */ 70 | 71 | -------------------------------------------------------------------------------- /doomgeneric/tables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // Copyright(C) 2005-2014 Simon Howard 5 | // 6 | // This program is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation; either version 2 9 | // of the License, or (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // DESCRIPTION: 17 | // Lookup tables. 18 | // Do not try to look them up :-). 19 | // In the order of appearance: 20 | // 21 | // int finetangent[4096] - Tangens LUT. 22 | // Should work with BAM fairly well (12 of 16bit, 23 | // effectively, by shifting). 24 | // 25 | // int finesine[10240] - Sine lookup. 26 | // Guess what, serves as cosine, too. 27 | // Remarkable thing is, how to use BAMs with this? 28 | // 29 | // int tantoangle[2049] - ArcTan LUT, 30 | // maps tan(angle) to angle fast. Gotta search. 31 | // 32 | 33 | 34 | #ifndef __TABLES__ 35 | #define __TABLES__ 36 | 37 | #include "doomtype.h" 38 | 39 | #include "m_fixed.h" 40 | 41 | #define FINEANGLES 8192 42 | #define FINEMASK (FINEANGLES-1) 43 | 44 | 45 | // 0x100000000 to 0x2000 46 | #define ANGLETOFINESHIFT 19 47 | 48 | // Effective size is 10240. 49 | extern const fixed_t finesine[5*FINEANGLES/4]; 50 | 51 | // Re-use data, is just PI/2 pahse shift. 52 | extern const fixed_t *finecosine; 53 | 54 | 55 | // Effective size is 4096. 56 | extern const fixed_t finetangent[FINEANGLES/2]; 57 | 58 | // Gamma correction tables. 59 | extern const byte gammatable[5][256]; 60 | 61 | // Binary Angle Measument, BAM. 62 | 63 | #define ANG45 0x20000000 64 | #define ANG90 0x40000000 65 | #define ANG180 0x80000000 66 | #define ANG270 0xc0000000 67 | #define ANG_MAX 0xffffffff 68 | 69 | #define ANG1 (ANG45 / 45) 70 | #define ANG60 (ANG180 / 3) 71 | 72 | // Heretic code uses this definition as though it represents one 73 | // degree, but it is not! This is actually ~1.40 degrees. 74 | 75 | #define ANG1_X 0x01000000 76 | 77 | #define SLOPERANGE 2048 78 | #define SLOPEBITS 11 79 | #define DBITS (FRACBITS-SLOPEBITS) 80 | 81 | typedef unsigned angle_t; 82 | 83 | 84 | // Effective size is 2049; 85 | // The +1 size is to handle the case when x==y 86 | // without additional checking. 87 | extern const angle_t tantoangle[SLOPERANGE+1]; 88 | 89 | 90 | // Utility function, 91 | // called by R_PointToAngle. 92 | int SlopeDiv(unsigned int num, unsigned int den); 93 | 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /doomgeneric/doomtype.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Simple basic typedefs, isolated here to make it easier 17 | // separating modules. 18 | // 19 | 20 | 21 | #ifndef __DOOMTYPE__ 22 | #define __DOOMTYPE__ 23 | 24 | #include 25 | 26 | // #define macros to provide functions missing in Windows. 27 | // Outside Windows, we use strings.h for str[n]casecmp. 28 | 29 | 30 | #ifdef _WIN32 31 | 32 | #define strcasecmp _stricmp 33 | #define strncasecmp _strnicmp 34 | 35 | #else 36 | 37 | #include 38 | 39 | #endif 40 | 41 | 42 | // 43 | // The packed attribute forces structures to be packed into the minimum 44 | // space necessary. If this is not done, the compiler may align structure 45 | // fields differently to optimize memory access, inflating the overall 46 | // structure size. It is important to use the packed attribute on certain 47 | // structures where alignment is important, particularly data read/written 48 | // to disk. 49 | // 50 | 51 | #ifdef __GNUC__ 52 | #define PACKEDATTR __attribute__((packed)) 53 | #else 54 | #define PACKEDATTR 55 | #endif 56 | 57 | // C99 integer types; with gcc we just use this. Other compilers 58 | // should add conditional statements that define the C99 types. 59 | 60 | // What is really wanted here is stdint.h; however, some old versions 61 | // of Solaris don't have stdint.h and only have inttypes.h (the 62 | // pre-standardisation version). inttypes.h is also in the C99 63 | // standard and defined to include stdint.h, so include this. 64 | 65 | #include 66 | 67 | #ifdef __cplusplus 68 | 69 | // Use builtin bool type with C++. 70 | 71 | typedef bool boolean; 72 | 73 | #else 74 | 75 | typedef enum 76 | { 77 | false = 0, 78 | true = 1, 79 | undef = 0xFFFFFFFF 80 | } boolean; 81 | 82 | #endif 83 | 84 | typedef uint8_t byte; 85 | 86 | #include 87 | 88 | #if defined(_WIN32) || defined(__DJGPP__) 89 | 90 | #define DIR_SEPARATOR '\\' 91 | #define DIR_SEPARATOR_S "\\" 92 | #define PATH_SEPARATOR ';' 93 | 94 | #else 95 | 96 | #define DIR_SEPARATOR '/' 97 | #define DIR_SEPARATOR_S "/" 98 | #define PATH_SEPARATOR ':' 99 | 100 | #endif 101 | 102 | #define arrlen(array) (sizeof(array) / sizeof(*array)) 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /doomgeneric/doomkeys.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Key definitions 17 | // 18 | 19 | #ifndef __DOOMKEYS__ 20 | #define __DOOMKEYS__ 21 | 22 | // 23 | // DOOM keyboard definition. 24 | // This is the stuff configured by Setup.Exe. 25 | // Most key data are simple ascii (uppercased). 26 | // 27 | #define KEY_RIGHTARROW 0xae 28 | #define KEY_LEFTARROW 0xac 29 | #define KEY_UPARROW 0xad 30 | #define KEY_DOWNARROW 0xaf 31 | #define KEY_STRAFE_L 0xa0 32 | #define KEY_STRAFE_R 0xa1 33 | #define KEY_USE 0xa2 34 | #define KEY_FIRE 0xa3 35 | #define KEY_ESCAPE 27 36 | #define KEY_ENTER 13 37 | #define KEY_TAB 9 38 | #define KEY_F1 (0x80+0x3b) 39 | #define KEY_F2 (0x80+0x3c) 40 | #define KEY_F3 (0x80+0x3d) 41 | #define KEY_F4 (0x80+0x3e) 42 | #define KEY_F5 (0x80+0x3f) 43 | #define KEY_F6 (0x80+0x40) 44 | #define KEY_F7 (0x80+0x41) 45 | #define KEY_F8 (0x80+0x42) 46 | #define KEY_F9 (0x80+0x43) 47 | #define KEY_F10 (0x80+0x44) 48 | #define KEY_F11 (0x80+0x57) 49 | #define KEY_F12 (0x80+0x58) 50 | 51 | #define KEY_BACKSPACE 0x7f 52 | #define KEY_PAUSE 0xff 53 | 54 | #define KEY_EQUALS 0x3d 55 | #define KEY_MINUS 0x2d 56 | 57 | #define KEY_RSHIFT (0x80+0x36) 58 | #define KEY_RCTRL (0x80+0x1d) 59 | #define KEY_RALT (0x80+0x38) 60 | 61 | #define KEY_LALT KEY_RALT 62 | 63 | // new keys: 64 | 65 | #define KEY_CAPSLOCK (0x80+0x3a) 66 | #define KEY_NUMLOCK (0x80+0x45) 67 | #define KEY_SCRLCK (0x80+0x46) 68 | #define KEY_PRTSCR (0x80+0x59) 69 | 70 | #define KEY_HOME (0x80+0x47) 71 | #define KEY_END (0x80+0x4f) 72 | #define KEY_PGUP (0x80+0x49) 73 | #define KEY_PGDN (0x80+0x51) 74 | #define KEY_INS (0x80+0x52) 75 | #define KEY_DEL (0x80+0x53) 76 | 77 | #define KEYP_0 0 78 | #define KEYP_1 KEY_END 79 | #define KEYP_2 KEY_DOWNARROW 80 | #define KEYP_3 KEY_PGDN 81 | #define KEYP_4 KEY_LEFTARROW 82 | #define KEYP_5 '5' 83 | #define KEYP_6 KEY_RIGHTARROW 84 | #define KEYP_7 KEY_HOME 85 | #define KEYP_8 KEY_UPARROW 86 | #define KEYP_9 KEY_PGUP 87 | 88 | #define KEYP_DIVIDE '/' 89 | #define KEYP_PLUS '+' 90 | #define KEYP_MINUS '-' 91 | #define KEYP_MULTIPLY '*' 92 | #define KEYP_PERIOD 0 93 | #define KEYP_EQUALS KEY_EQUALS 94 | #define KEYP_ENTER KEY_ENTER 95 | 96 | #endif // __DOOMKEYS__ 97 | 98 | -------------------------------------------------------------------------------- /doomgeneric/r_state.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh/render internal state variables (global). 17 | // 18 | 19 | 20 | #ifndef __R_STATE__ 21 | #define __R_STATE__ 22 | 23 | // Need data structure definitions. 24 | #include "d_player.h" 25 | #include "r_data.h" 26 | 27 | 28 | 29 | 30 | 31 | 32 | // 33 | // Refresh internal data structures, 34 | // for rendering. 35 | // 36 | 37 | // needed for texture pegging 38 | extern fixed_t* textureheight; 39 | 40 | // needed for pre rendering (fracs) 41 | extern fixed_t* spritewidth; 42 | 43 | extern fixed_t* spriteoffset; 44 | extern fixed_t* spritetopoffset; 45 | 46 | extern lighttable_t* colormaps; 47 | 48 | extern int viewwidth; 49 | extern int scaledviewwidth; 50 | extern int viewheight; 51 | 52 | extern int firstflat; 53 | 54 | // for global animation 55 | extern int* flattranslation; 56 | extern int* texturetranslation; 57 | 58 | 59 | // Sprite.... 60 | extern int firstspritelump; 61 | extern int lastspritelump; 62 | extern int numspritelumps; 63 | 64 | 65 | 66 | // 67 | // Lookup tables for map data. 68 | // 69 | extern int numsprites; 70 | extern spritedef_t* sprites; 71 | 72 | extern int numvertexes; 73 | extern vertex_t* vertexes; 74 | 75 | extern int numsegs; 76 | extern seg_t* segs; 77 | 78 | extern int numsectors; 79 | extern sector_t* sectors; 80 | 81 | extern int numsubsectors; 82 | extern subsector_t* subsectors; 83 | 84 | extern int numnodes; 85 | extern node_t* nodes; 86 | 87 | extern int numlines; 88 | extern line_t* lines; 89 | 90 | extern int numsides; 91 | extern side_t* sides; 92 | 93 | 94 | // 95 | // POV data. 96 | // 97 | extern fixed_t viewx; 98 | extern fixed_t viewy; 99 | extern fixed_t viewz; 100 | 101 | extern angle_t viewangle; 102 | extern player_t* viewplayer; 103 | 104 | 105 | // ? 106 | extern angle_t clipangle; 107 | 108 | extern int viewangletox[FINEANGLES/2]; 109 | extern angle_t xtoviewangle[SCREENWIDTH+1]; 110 | //extern fixed_t finetangent[FINEANGLES/2]; 111 | 112 | extern fixed_t rw_distance; 113 | extern angle_t rw_normalangle; 114 | 115 | 116 | 117 | // angle to line origin 118 | extern int rw_angle1; 119 | 120 | // Segs count? 121 | extern int sscount; 122 | 123 | extern visplane_t* floorplane; 124 | extern visplane_t* ceilingplane; 125 | 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /doomgeneric/config.h: -------------------------------------------------------------------------------- 1 | /* config.hin. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DEV_ISA_SPKRIO_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_DEV_SPEAKER_SPEAKER_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #define HAVE_INTTYPES_H 1 11 | 12 | /* Define to 1 if you have the `ioperm' function. */ 13 | #undef HAVE_IOPERM 14 | 15 | /* Define to 1 if you have the `amd64' library (-lamd64). */ 16 | #undef HAVE_LIBAMD64 17 | 18 | /* Define to 1 if you have the `i386' library (-li386). */ 19 | #undef HAVE_LIBI386 20 | 21 | /* Define to 1 if you have the `m' library (-lm). */ 22 | #undef HAVE_LIBM 23 | 24 | /* Define to 1 if you have the `png' library (-lpng). */ 25 | #undef HAVE_LIBPNG 26 | 27 | /* Define to 1 if you have the `samplerate' library (-lsamplerate). */ 28 | #undef HAVE_LIBSAMPLERATE 29 | 30 | /* Define to 1 if you have the `z' library (-lz). */ 31 | #undef HAVE_LIBZ 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_LINUX_KD_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_MEMORY_H 38 | 39 | /* Define to 1 if you have the `mmap' function. */ 40 | #undef HAVE_MMAP 41 | 42 | /* Define to 1 if you have the `sched_setaffinity' function. */ 43 | #undef HAVE_SCHED_SETAFFINITY 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #define HAVE_STDINT_H 1 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #define HAVE_STDLIB_H 1 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #define HAVE_STRINGS_H 1 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #define HAVE_STRING_H 1 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_SYS_STAT_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #define HAVE_SYS_TYPES_H 1 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_UNISTD_H 65 | 66 | /* Name of package */ 67 | #define PACKAGE "Doom" 68 | 69 | /* Define to the address where bug reports for this package should be sent. */ 70 | #undef PACKAGE_BUGREPORT 71 | 72 | /* Define to the full name of this package. */ 73 | #define PACKAGE_NAME "Doom Generic" 74 | 75 | /* Define to the full name and version of this package. */ 76 | #define PACKAGE_STRING "Doom Generic 0.1" 77 | 78 | /* Define to the one symbol short name of this package. */ 79 | #define PACKAGE_TARNAME "doomgeneric.tar" 80 | 81 | /* Define to the home page for this package. */ 82 | #define PACKAGE_URL "" 83 | 84 | /* Define to the version of this package. */ 85 | #define PACKAGE_VERSION 0.1 86 | 87 | /* Change this when you create your awesome forked version */ 88 | #define PROGRAM_PREFIX "doomgeneric" 89 | 90 | /* Define to 1 if you have the ANSI C header files. */ 91 | #define STDC_HEADERS 1 92 | 93 | /* Version number of package */ 94 | #define VERSION 0.1 95 | 96 | /* Define to 1 if you want to compile the unmodified code */ 97 | #undef ORIGCODE 98 | 99 | /* Define to the directory where all game files are located */ 100 | #define FILES_DIR "." 101 | -------------------------------------------------------------------------------- /doomgeneric/d_mode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Functions and definitions relating to the game type and operational 17 | // mode. 18 | // 19 | 20 | #ifndef __D_MODE__ 21 | #define __D_MODE__ 22 | 23 | #include "doomtype.h" 24 | 25 | // The "mission" controls what game we are playing. 26 | 27 | typedef enum 28 | { 29 | doom, // Doom 1 30 | doom2, // Doom 2 31 | pack_tnt, // Final Doom: TNT: Evilution 32 | pack_plut, // Final Doom: The Plutonia Experiment 33 | pack_chex, // Chex Quest (modded doom) 34 | pack_hacx, // Hacx (modded doom2) 35 | heretic, // Heretic 36 | hexen, // Hexen 37 | strife, // Strife 38 | 39 | none 40 | } GameMission_t; 41 | 42 | // The "mode" allows more accurate specification of the game mode we are 43 | // in: eg. shareware vs. registered. So doom1.wad and doom.wad are the 44 | // same mission, but a different mode. 45 | 46 | typedef enum 47 | { 48 | shareware, // Doom/Heretic shareware 49 | registered, // Doom/Heretic registered 50 | commercial, // Doom II/Hexen 51 | retail, // Ultimate Doom 52 | indetermined // Unknown. 53 | } GameMode_t; 54 | 55 | // What version are we emulating? 56 | 57 | typedef enum 58 | { 59 | exe_doom_1_2, // Doom 1.2: shareware and registered 60 | exe_doom_1_666, // Doom 1.666: for shareware, registered and commercial 61 | exe_doom_1_7, // Doom 1.7/1.7a: " 62 | exe_doom_1_8, // Doom 1.8: " 63 | exe_doom_1_9, // Doom 1.9: " 64 | exe_hacx, // Hacx 65 | exe_ultimate, // Ultimate Doom (retail) 66 | exe_final, // Final Doom 67 | exe_final2, // Final Doom (alternate exe) 68 | exe_chex, // Chex Quest executable (based on Final Doom) 69 | 70 | exe_heretic_1_3, // Heretic 1.3 71 | 72 | exe_hexen_1_1, // Hexen 1.1 73 | exe_strife_1_2, // Strife v1.2 74 | exe_strife_1_31 // Strife v1.31 75 | } GameVersion_t; 76 | 77 | // Skill level. 78 | 79 | typedef enum 80 | { 81 | sk_noitems = -1, // the "-skill 0" hack 82 | sk_baby = 0, 83 | sk_easy, 84 | sk_medium, 85 | sk_hard, 86 | sk_nightmare 87 | } skill_t; 88 | 89 | boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode); 90 | boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version); 91 | boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode, 92 | int episode, int map); 93 | int D_GetNumEpisodes(GameMission_t mission, GameMode_t mode); 94 | boolean D_IsEpisodeMap(GameMission_t mission); 95 | char *D_GameMissionString(GameMission_t mission); 96 | 97 | #endif /* #ifndef __D_MODE__ */ 98 | 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # doomgpu 2 | 3 | This is a port of DOOM that runs (almost) entirely on the GPU using the [LLVM C 4 | library for GPUs](https://libc.llvm.org/gpu/) based on the 5 | [doomgeneric](https://github.com/ozkl/doomgeneric) interface. 6 | 7 | To try it you will need a WAD file (game data). If you don't own the game, 8 | shareware version is freely available (doom1.wad). 9 | 10 | This implementation works on NVIDIA as well as AMDGPU. To use the NVIDIA 11 | implementation perform the same steps but with the `nvptx` loader and make 12 | target. 13 | 14 | # requirements 15 | 16 | * A Linux operating system 17 | * An AMDGPU with ROCm support 18 | * SDL2 libraries 19 | * A ROCm or ROCR-Runtime installation 20 | * An LLVM build off of the main branch (LLVM22 as of writing) 21 | 22 | # why 23 | 24 | Because I can. 25 | 26 | # how 27 | 28 | The `clang` compiler can target GPUs directly. We emit a single kernel that 29 | calls the 'main' function. Functions that require the operating system are 30 | handled through the RPC interface. See [my LLVM 31 | talk](https://www.youtube.com/watch?v=_LLGc48GYHc) for more information. 32 | 33 | This implementation defines the `amdgpu-loader` utility, which handles launching 34 | the `main` kernel, setting up the SDL2 window interface, and provides functions 35 | to get the input keys and write the output framebuffer. Okay, it's not 36 | *entirely* on the GPU, but all the logic and rendering runs on the GPU. 37 | 38 | # building and running 39 | 40 | You will need an LLVM installation with the LLVM C library for GPUs enabled. 41 | Don't do a shared library build of LLVM it will probably break. See [the 42 | documentation](https://libc.llvm.org/gpu/building.html#standard-runtimes-build) 43 | for how to build it. You will need to do a build of LLVM from source as none of 44 | the package managers will include these libraries and we need headers that exist 45 | in-tree. 46 | 47 | Once installed, use the newly built `clang` compiler to build the libraries. 48 | Make sure that you have `include/hsa.h` and `libhsa-runtime64.so` available from 49 | your ROCm installation. Point the makefiles to your LLVM source tree for the RPC 50 | implementation. 51 | 52 | This currently only works with a single block / workgroup on the GPU. Logic is 53 | all done singe-threaded but software rendering is distributed amongst the 54 | threads. 55 | 56 | 57 | ```console 58 | $ make -C amdgpu-loader/ -j LLVM_SOURCE=/path/to/your/llvm 59 | $ make -C doomgeneric/ -f Makefile.amdgpu -j LLVM_SOURCE=/path/to/your/llvm 60 | $ ./amdgpu-loader/amdgpu-loader --threads 512 ./doomgeneric/doomgeneric -iwad doom1.wad 61 | ``` 62 | 63 | If you try this on NVIDIA it might now work depending on how much memory the 64 | CUDA system allocator can provide. If you want to fix that please ask me about 65 | making a PR in LLVM to support NVIDIA in the LLVM libc GPU allocator! 66 | 67 | ![AMDGPU](screenshots/amdgpu.png) 68 | Video 69 | [![Hastily recorded video demo](https://img.youtube.com/vi/E7X1yvyVml4/maxresdefault.jpg)](https://www.youtube.com/watch?v=E7X1yvyVml4) 70 | 71 | Thanks to [@hardcode84](https://github.com/hardcode84) for porting help. 72 | 73 | # hardware 74 | 75 | The system I tested this on has: 76 | * Arch Linux with kernel 6.10.5 77 | * AMD ATI Radeon RX 6950 XT GPU 78 | * NVIDIA RTX 4000 SFF Ada Generation 79 | * NVIDIA CUDA version 12.1 80 | * ROCm version 6.0 81 | -------------------------------------------------------------------------------- /doomgeneric/deh_misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Parses "Misc" sections in dehacked files 16 | // 17 | 18 | #ifndef DEH_MISC_H 19 | #define DEH_MISC_H 20 | 21 | #include "doomfeatures.h" 22 | 23 | #define DEH_DEFAULT_INITIAL_HEALTH 100 24 | #define DEH_DEFAULT_INITIAL_BULLETS 50 25 | #define DEH_DEFAULT_MAX_HEALTH 200 26 | #define DEH_DEFAULT_MAX_ARMOR 200 27 | #define DEH_DEFAULT_GREEN_ARMOR_CLASS 1 28 | #define DEH_DEFAULT_BLUE_ARMOR_CLASS 2 29 | #define DEH_DEFAULT_MAX_SOULSPHERE 200 30 | #define DEH_DEFAULT_SOULSPHERE_HEALTH 100 31 | #define DEH_DEFAULT_MEGASPHERE_HEALTH 200 32 | #define DEH_DEFAULT_GOD_MODE_HEALTH 100 33 | #define DEH_DEFAULT_IDFA_ARMOR 200 34 | #define DEH_DEFAULT_IDFA_ARMOR_CLASS 2 35 | #define DEH_DEFAULT_IDKFA_ARMOR 200 36 | #define DEH_DEFAULT_IDKFA_ARMOR_CLASS 2 37 | #define DEH_DEFAULT_BFG_CELLS_PER_SHOT 40 38 | #define DEH_DEFAULT_SPECIES_INFIGHTING 0 39 | 40 | #ifdef FEATURE_DEHACKED 41 | 42 | extern int deh_initial_health; 43 | extern int deh_initial_bullets; 44 | extern int deh_max_health; 45 | extern int deh_max_armor; 46 | extern int deh_green_armor_class; 47 | extern int deh_blue_armor_class; 48 | extern int deh_max_soulsphere; 49 | extern int deh_soulsphere_health; 50 | extern int deh_megasphere_health; 51 | extern int deh_god_mode_health; 52 | extern int deh_idfa_armor; 53 | extern int deh_idfa_armor_class; 54 | extern int deh_idkfa_armor; 55 | extern int deh_idkfa_armor_class; 56 | extern int deh_bfg_cells_per_shot; 57 | extern int deh_species_infighting; 58 | 59 | #else 60 | 61 | // If dehacked is disabled, hard coded values 62 | 63 | #define deh_initial_health DEH_DEFAULT_INITIAL_HEALTH 64 | #define deh_initial_bullets DEH_DEFAULT_INITIAL_BULLETS 65 | #define deh_max_health DEH_DEFAULT_MAX_HEALTH 66 | #define deh_max_armor DEH_DEFAULT_MAX_ARMOR 67 | #define deh_green_armor_class DEH_DEFAULT_GREEN_ARMOR_CLASS 68 | #define deh_blue_armor_class DEH_DEFAULT_BLUE_ARMOR_CLASS 69 | #define deh_max_soulsphere DEH_DEFAULT_MAX_SOULSPHERE 70 | #define deh_soulsphere_health DEH_DEFAULT_SOULSPHERE_HEALTH 71 | #define deh_megasphere_health DEH_DEFAULT_MEGASPHERE_HEALTH 72 | #define deh_god_mode_health DEH_DEFAULT_GOD_MODE_HEALTH 73 | #define deh_idfa_armor DEH_DEFAULT_IDFA_ARMOR 74 | #define deh_idfa_armor_class DEH_DEFAULT_IDFA_ARMOR_CLASS 75 | #define deh_idkfa_armor DEH_DEFAULT_IDKFA_ARMOR 76 | #define deh_idkfa_armor_class DEH_DEFAULT_IDKFA_ARMOR_CLASS 77 | #define deh_bfg_cells_per_shot DEH_DEFAULT_BFG_CELLS_PER_SHOT 78 | #define deh_species_infighting DEH_DEFAULT_SPECIES_INFIGHTING 79 | 80 | #endif 81 | 82 | #endif /* #ifndef DEH_MISC_H */ 83 | 84 | -------------------------------------------------------------------------------- /doomgeneric/v_video.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Gamma correction LUT. 17 | // Functions to draw patches (by post) directly to screen. 18 | // Functions to blit a block to the screen. 19 | // 20 | 21 | 22 | #ifndef __V_VIDEO__ 23 | #define __V_VIDEO__ 24 | 25 | #include "doomtype.h" 26 | 27 | // Needed because we are refering to patches. 28 | #include "v_patch.h" 29 | 30 | // 31 | // VIDEO 32 | // 33 | 34 | #define CENTERY (SCREENHEIGHT/2) 35 | 36 | 37 | extern int dirtybox[4]; 38 | 39 | extern byte *tinttable; 40 | 41 | // haleyjd 08/28/10: implemented for Strife support 42 | // haleyjd 08/28/10: Patch clipping callback, implemented to support Choco 43 | // Strife. 44 | typedef boolean (*vpatchclipfunc_t)(patch_t *, int, int); 45 | void V_SetPatchClipCallback(vpatchclipfunc_t func); 46 | 47 | 48 | // Allocates buffer screens, call before R_Init. 49 | void V_Init (void); 50 | 51 | // Draw a block from the specified source screen to the screen. 52 | 53 | void V_CopyRect(int srcx, int srcy, byte *source, 54 | int width, int height, 55 | int destx, int desty); 56 | 57 | void V_DrawPatch(int x, int y, patch_t *patch); 58 | void V_DrawPatchFlipped(int x, int y, patch_t *patch); 59 | void V_DrawTLPatch(int x, int y, patch_t *patch); 60 | void V_DrawAltTLPatch(int x, int y, patch_t * patch); 61 | void V_DrawShadowedPatch(int x, int y, patch_t *patch); 62 | void V_DrawXlaPatch(int x, int y, patch_t * patch); // villsa [STRIFE] 63 | void V_DrawPatchDirect(int x, int y, patch_t *patch); 64 | 65 | // Draw a linear block of pixels into the view buffer. 66 | 67 | void V_DrawBlock(int x, int y, int width, int height, byte *src); 68 | 69 | void V_MarkRect(int x, int y, int width, int height); 70 | 71 | void V_DrawFilledBox(int x, int y, int w, int h, int c); 72 | void V_DrawHorizLine(int x, int y, int w, int c); 73 | void V_DrawVertLine(int x, int y, int h, int c); 74 | void V_DrawBox(int x, int y, int w, int h, int c); 75 | 76 | // Draw a raw screen lump 77 | 78 | void V_DrawRawScreen(byte *raw); 79 | 80 | // Temporarily switch to using a different buffer to draw graphics, etc. 81 | 82 | void V_UseBuffer(byte *buffer); 83 | 84 | // Return to using the normal screen buffer to draw graphics. 85 | 86 | void V_RestoreBuffer(void); 87 | 88 | // Save a screenshot of the current screen to a file, named in the 89 | // format described in the string passed to the function, eg. 90 | // "DOOM%02i.pcx" 91 | 92 | void V_ScreenShot(char *format); 93 | 94 | // Load the lookup table for translucency calculations from the TINTTAB 95 | // lump. 96 | 97 | void V_LoadTintTable(void); 98 | 99 | // villsa [STRIFE] 100 | // Load the lookup table for translucency calculations from the XLATAB 101 | // lump. 102 | 103 | void V_LoadXlaTable(void); 104 | 105 | void V_DrawMouseSpeedBox(int speed); 106 | 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /doomgeneric/p_telept.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Teleportation. 17 | // 18 | 19 | 20 | 21 | 22 | #include "doomdef.h" 23 | #include "doomstat.h" 24 | 25 | #include "s_sound.h" 26 | 27 | #include "p_local.h" 28 | 29 | 30 | // Data. 31 | #include "sounds.h" 32 | 33 | // State. 34 | #include "r_state.h" 35 | 36 | 37 | 38 | // 39 | // TELEPORTATION 40 | // 41 | int 42 | EV_Teleport 43 | ( line_t* line, 44 | int side, 45 | mobj_t* thing ) 46 | { 47 | int i; 48 | int tag; 49 | mobj_t* m; 50 | mobj_t* fog; 51 | unsigned an; 52 | thinker_t* thinker; 53 | sector_t* sector; 54 | fixed_t oldx; 55 | fixed_t oldy; 56 | fixed_t oldz; 57 | 58 | // don't teleport missiles 59 | if (thing->flags & MF_MISSILE) 60 | return 0; 61 | 62 | // Don't teleport if hit back of line, 63 | // so you can get out of teleporter. 64 | if (side == 1) 65 | return 0; 66 | 67 | 68 | tag = line->tag; 69 | for (i = 0; i < numsectors; i++) 70 | { 71 | if (sectors[ i ].tag == tag ) 72 | { 73 | thinker = thinkercap.next; 74 | for (thinker = thinkercap.next; 75 | thinker != &thinkercap; 76 | thinker = thinker->next) 77 | { 78 | // not a mobj 79 | if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) 80 | continue; 81 | 82 | m = (mobj_t *)thinker; 83 | 84 | // not a teleportman 85 | if (m->type != MT_TELEPORTMAN ) 86 | continue; 87 | 88 | sector = m->subsector->sector; 89 | // wrong sector 90 | if (sector-sectors != i ) 91 | continue; 92 | 93 | oldx = thing->x; 94 | oldy = thing->y; 95 | oldz = thing->z; 96 | 97 | if (!P_TeleportMove (thing, m->x, m->y)) 98 | return 0; 99 | 100 | // The first Final Doom executable does not set thing->z 101 | // when teleporting. This quirk is unique to this 102 | // particular version; the later version included in 103 | // some versions of the Id Anthology fixed this. 104 | 105 | if (gameversion != exe_final) 106 | thing->z = thing->floorz; 107 | 108 | if (thing->player) 109 | thing->player->viewz = thing->z+thing->player->viewheight; 110 | 111 | // spawn teleport fog at source and destination 112 | fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 113 | S_StartSound (fog, sfx_telept); 114 | an = m->angle >> ANGLETOFINESHIFT; 115 | fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] 116 | , thing->z, MT_TFOG); 117 | 118 | // emit sound, where? 119 | S_StartSound (fog, sfx_telept); 120 | 121 | // don't move for a bit 122 | if (thing->player) 123 | thing->reactiontime = 18; 124 | 125 | thing->angle = m->angle; 126 | thing->momx = thing->momy = thing->momz = 0; 127 | return 1; 128 | } 129 | } 130 | } 131 | return 0; 132 | } 133 | 134 | -------------------------------------------------------------------------------- /doomgeneric/p_tick.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Archiving: SaveGame I/O. 17 | // Thinker, Ticker. 18 | // 19 | 20 | 21 | #include "z_zone.h" 22 | #include "p_local.h" 23 | 24 | #include "doomstat.h" 25 | 26 | 27 | int leveltime; 28 | 29 | // 30 | // THINKERS 31 | // All thinkers should be allocated by Z_Malloc 32 | // so they can be operated on uniformly. 33 | // The actual structures will vary in size, 34 | // but the first element must be thinker_t. 35 | // 36 | 37 | 38 | 39 | // Both the head and tail of the thinker list. 40 | thinker_t thinkercap; 41 | 42 | 43 | // 44 | // P_InitThinkers 45 | // 46 | void P_InitThinkers (void) 47 | { 48 | thinkercap.prev = thinkercap.next = &thinkercap; 49 | } 50 | 51 | 52 | 53 | 54 | // 55 | // P_AddThinker 56 | // Adds a new thinker at the end of the list. 57 | // 58 | void P_AddThinker (thinker_t* thinker) 59 | { 60 | thinkercap.prev->next = thinker; 61 | thinker->next = &thinkercap; 62 | thinker->prev = thinkercap.prev; 63 | thinkercap.prev = thinker; 64 | } 65 | 66 | 67 | 68 | // 69 | // P_RemoveThinker 70 | // Deallocation is lazy -- it will not actually be freed 71 | // until its thinking turn comes up. 72 | // 73 | void P_RemoveThinker (thinker_t* thinker) 74 | { 75 | // FIXME: NOP. 76 | thinker->function.acv = (actionf_v)(-1); 77 | } 78 | 79 | 80 | 81 | // 82 | // P_AllocateThinker 83 | // Allocates memory and adds a new thinker at the end of the list. 84 | // 85 | void P_AllocateThinker (thinker_t* thinker) 86 | { 87 | } 88 | 89 | 90 | 91 | // 92 | // P_RunThinkers 93 | // 94 | void P_RunThinkers (void) 95 | { 96 | thinker_t* currentthinker; 97 | 98 | currentthinker = thinkercap.next; 99 | while (currentthinker != &thinkercap) 100 | { 101 | if ( currentthinker->function.acv == (actionf_v)(-1) ) 102 | { 103 | // time to remove it 104 | currentthinker->next->prev = currentthinker->prev; 105 | currentthinker->prev->next = currentthinker->next; 106 | Z_Free (currentthinker); 107 | } 108 | else 109 | { 110 | if (currentthinker->function.acp1) 111 | currentthinker->function.acp1 (currentthinker); 112 | } 113 | currentthinker = currentthinker->next; 114 | } 115 | } 116 | 117 | 118 | 119 | // 120 | // P_Ticker 121 | // 122 | 123 | void P_Ticker (void) 124 | { 125 | int i; 126 | 127 | // run the tic 128 | if (paused) 129 | return; 130 | 131 | // pause if in menu and at least one tic has been run 132 | if ( !netgame 133 | && menuactive 134 | && !demoplayback 135 | && players[consoleplayer].viewz != 1) 136 | { 137 | return; 138 | } 139 | 140 | 141 | for (i=0 ; i 24 | #include 25 | 26 | #include "doomtype.h" 27 | #include "i_timer.h" 28 | #include "d_mode.h" 29 | 30 | // 31 | // Global parameters/defines. 32 | // 33 | // DOOM version 34 | #define DOOM_VERSION 109 35 | 36 | // Version code for cph's longtics hack ("v1.91") 37 | #define DOOM_191_VERSION 111 38 | 39 | 40 | // If rangecheck is undefined, 41 | // most parameter validation debugging code will not be compiled 42 | #define RANGECHECK 43 | 44 | // The maximum number of players, multiplayer/networking. 45 | #define MAXPLAYERS 4 46 | 47 | // The current state of the game: whether we are 48 | // playing, gazing at the intermission screen, 49 | // the game final animation, or a demo. 50 | typedef enum 51 | { 52 | GS_LEVEL, 53 | GS_INTERMISSION, 54 | GS_FINALE, 55 | GS_DEMOSCREEN, 56 | } gamestate_t; 57 | 58 | typedef enum 59 | { 60 | ga_nothing, 61 | ga_loadlevel, 62 | ga_newgame, 63 | ga_loadgame, 64 | ga_savegame, 65 | ga_playdemo, 66 | ga_completed, 67 | ga_victory, 68 | ga_worlddone, 69 | ga_screenshot 70 | } gameaction_t; 71 | 72 | // 73 | // Difficulty/skill settings/filters. 74 | // 75 | 76 | // Skill flags. 77 | #define MTF_EASY 1 78 | #define MTF_NORMAL 2 79 | #define MTF_HARD 4 80 | 81 | // Deaf monsters/do not react to sound. 82 | #define MTF_AMBUSH 8 83 | 84 | 85 | // 86 | // Key cards. 87 | // 88 | typedef enum 89 | { 90 | it_bluecard, 91 | it_yellowcard, 92 | it_redcard, 93 | it_blueskull, 94 | it_yellowskull, 95 | it_redskull, 96 | 97 | NUMCARDS 98 | 99 | } card_t; 100 | 101 | 102 | 103 | // The defined weapons, 104 | // including a marker indicating 105 | // user has not changed weapon. 106 | typedef enum 107 | { 108 | wp_fist, 109 | wp_pistol, 110 | wp_shotgun, 111 | wp_chaingun, 112 | wp_missile, 113 | wp_plasma, 114 | wp_bfg, 115 | wp_chainsaw, 116 | wp_supershotgun, 117 | 118 | NUMWEAPONS, 119 | 120 | // No pending weapon change. 121 | wp_nochange 122 | 123 | } weapontype_t; 124 | 125 | 126 | // Ammunition types defined. 127 | typedef enum 128 | { 129 | am_clip, // Pistol / chaingun ammo. 130 | am_shell, // Shotgun / double barreled shotgun. 131 | am_cell, // Plasma rifle, BFG. 132 | am_misl, // Missile launcher. 133 | NUMAMMO, 134 | am_noammo // Unlimited for chainsaw / fist. 135 | 136 | } ammotype_t; 137 | 138 | 139 | // Power up artifacts. 140 | typedef enum 141 | { 142 | pw_invulnerability, 143 | pw_strength, 144 | pw_invisibility, 145 | pw_ironfeet, 146 | pw_allmap, 147 | pw_infrared, 148 | NUMPOWERS 149 | 150 | } powertype_t; 151 | 152 | 153 | 154 | // 155 | // Power up durations, 156 | // how many seconds till expiration, 157 | // assuming TICRATE is 35 ticks/second. 158 | // 159 | typedef enum 160 | { 161 | INVULNTICS = (30*TICRATE), 162 | INVISTICS = (60*TICRATE), 163 | INFRATICS = (120*TICRATE), 164 | IRONTICS = (60*TICRATE) 165 | 166 | } powerduration_t; 167 | 168 | #endif // __DOOMDEF__ 169 | -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- 1 | ================ 2 | = doomgeneric = 3 | ================ 4 | 5 | To port DOOM easly, I made some changes to source code. 6 | Now, all you need to do is implement the functions in doomgeneric.h to port DOOM to a new system. 7 | doomgeneric_win.c is a Windows GDI port. It is also a good example for how to port doomgeneric. 8 | 9 | Original readme 10 | =============== 11 | 12 | Here it is, at long last. The DOOM source code is released for your 13 | non-profit use. You still need real DOOM data to work with this code. 14 | If you don't actually own a real copy of one of the DOOMs, you should 15 | still be able to find them at software stores. 16 | 17 | Many thanks to Bernd Kreimeier for taking the time to clean up the 18 | project and make sure that it actually works. Projects tends to rot if 19 | you leave it alone for a few years, and it takes effort for someone to 20 | deal with it again. 21 | 22 | The bad news: this code only compiles and runs on linux. We couldn't 23 | release the dos code because of a copyrighted sound library we used 24 | (wow, was that a mistake -- I write my own sound code now), and I 25 | honestly don't even know what happened to the port that microsoft did 26 | to windows. 27 | 28 | Still, the code is quite portable, and it should be straightforward to 29 | bring it up on just about any platform. 30 | 31 | I wrote this code a long, long time ago, and there are plenty of things 32 | that seem downright silly in retrospect (using polar coordinates for 33 | clipping comes to mind), but overall it should still be a usefull base 34 | to experiment and build on. 35 | 36 | The basic rendering concept -- horizontal and vertical lines of constant 37 | Z with fixed light shading per band was dead-on, but the implementation 38 | could be improved dramatically from the original code if it were 39 | revisited. The way the rendering proceded from walls to floors to 40 | sprites could be collapsed into a single front-to-back walk of the bsp 41 | tree to collect information, then draw all the contents of a subsector 42 | on the way back up the tree. It requires treating floors and ceilings 43 | as polygons, rather than just the gaps between walls, and it requires 44 | clipping sprite billboards into subsector fragments, but it would be 45 | The Right Thing. 46 | 47 | The movement and line of sight checking against the lines is one of the 48 | bigger misses that I look back on. It is messy code that had some 49 | failure cases, and there was a vastly simpler (and faster) solution 50 | sitting in front of my face. I used the BSP tree for rendering things, 51 | but I didn't realize at the time that it could also be used for 52 | environment testing. Replacing the line of sight test with a bsp line 53 | clip would be pretty easy. Sweeping volumes for movement gets a bit 54 | tougher, and touches on many of the challenges faced in quake / quake2 55 | with edge bevels on polyhedrons. 56 | 57 | Some project ideas: 58 | 59 | Port it to your favorite operating system. 60 | 61 | Add some rendering features -- transparency, look up / down, slopes, 62 | etc. 63 | 64 | Add some game features -- weapons, jumping, ducking, flying, etc. 65 | 66 | Create a packet server based internet game. 67 | 68 | Create a client / server based internet game. 69 | 70 | Do a 3D accelerated version. On modern hardware (fast pentium + 3DFX) 71 | you probably wouldn't even need to be clever -- you could just draw the 72 | entire level and get reasonable speed. With a touch of effort, it should 73 | easily lock at 60 fps (well, there are some issues with DOOM's 35 hz 74 | timebase...). The biggest issues would probably be the non-power of two 75 | texture sizes and the walls composed of multiple textures. 76 | 77 | 78 | I don't have a real good guess at how many people are going to be 79 | playing with this, but if significant projects are undertaken, it would 80 | be cool to see a level of community cooperation. I know that most early 81 | projects are going to be rough hacks done in isolation, but I would be 82 | very pleased to see a coordinated 'net release of an improved, backwards 83 | compatable version of DOOM on multiple platforms next year. 84 | 85 | Have fun. 86 | 87 | John Carmack 88 | 12-23-97 89 | --------------------------------------------------------------------------------