├── make.bat ├── PCFX.OBJ ├── AUDIO_WF.LIB ├── AudioLib.zip ├── README.md ├── p_inter.h ├── r_segs.h ├── p_tick.h ├── mus2mid.h ├── p_setup.h ├── i_main.c ├── r_sky.h ├── f_finale.h ├── p_saveg.h ├── wi_stuff.h ├── d_ticcmd.h ├── i_sound.h ├── r_local.h ├── am_map.h ├── r_sky.c ├── f_wipe.h ├── r_data.h ├── dstrings.h ├── d_main.h ├── doomtype.h ├── newdoom.lnk ├── hu_stuff.h ├── SNDCARDS.H ├── r_bsp.h ├── defs.inc ├── m_menu.h ├── d_think.h ├── r_plane.h ├── dutils.h ├── w_wad.h ├── r_things.h ├── g_game.h ├── st_stuff.h ├── USRHOOKS.H ├── m_misc.h ├── p_pspr.h ├── TASK_MAN.H ├── PCFX.H ├── s_sound.h ├── DMX.H ├── tables.h ├── v_video.h ├── USRHOOKS.C ├── z_zone.h ├── makefile ├── r_draw.h ├── d_event.h ├── r_state.h ├── MUSIC.H ├── i_ibm_a.asm ├── p_telept.c ├── p_tick.c ├── DPMIAPI.H ├── d_net.h ├── r_main.h ├── st_lib.h ├── dutils.c ├── hu_lib.h ├── FX_MAN.H ├── d_player.h ├── i_system.h ├── doomdata.h ├── st_lib.c ├── sounds.h ├── f_wipe.c ├── p_local.h ├── doomdef.h ├── sounds.c ├── p_ceilng.c ├── doomstat.h ├── i_cyber.c ├── p_plats.c └── hu_lib.c /make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | wmake %1 %2 %3 %4 %5 %6 %7 %8 %9 3 | -------------------------------------------------------------------------------- /PCFX.OBJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nukeykt/PCDoom-v2/HEAD/PCFX.OBJ -------------------------------------------------------------------------------- /AUDIO_WF.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nukeykt/PCDoom-v2/HEAD/AUDIO_WF.LIB -------------------------------------------------------------------------------- /AudioLib.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nukeykt/PCDoom-v2/HEAD/AudioLib.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # As of 02-05-2022 PCDoom-v2 is succeeded by the gamesrc-ver-recreation project 2 | https://bitbucket.org/gamesrc-ver-recreation/doom 3 | 4 | https://bitbucket.org/gamesrc-ver-recreation/strife 5 | 6 | # PCDoom-v2 7 | Doom port for DOS 8 | 9 | Build instructions: 10 | 1) Install Open Watcom C version 1.9. 11 | 2) Install Turbo Assembler 2.51, which is distributed with Borland C++ 2.0 (not compatible with x64, use DOSBox). 12 | 3) Add Watcom's bin folder (binnt on Windows, binw on DOS) to the PATH. 13 | 4) Run make.bat. 14 | -------------------------------------------------------------------------------- /p_inter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | boolean P_GivePower(player_t*, int); 24 | 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /r_segs.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | void 25 | R_RenderMaskedSegRange 26 | ( drawseg_t* ds, 27 | int x1, 28 | int x2 ); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /p_tick.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Called by C_Ticker, 25 | // can call G_PlayerExited. 26 | // Carries out all thinking of monsters and players. 27 | void P_Ticker (void); 28 | 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /mus2mid.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // Copyright(C) 2006 Ben Ryves 2006 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 | // 17 | // mus2mid.h - Ben Ryves 2006 - http://benryves.com - benryves@benryves.com 18 | // Use to convert a MUS file into a single track, type 0 MIDI file. 19 | 20 | #ifndef MUS2MID_H 21 | #define MUS2MID_H 22 | 23 | int mus2mid(FILE *musinput, FILE *midioutput); 24 | 25 | #endif /* #ifndef MUS2MID_H */ 26 | 27 | -------------------------------------------------------------------------------- /p_setup.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __P_SETUP__ 20 | #define __P_SETUP__ 21 | 22 | 23 | // NOT called by W_Ticker. Fixme. 24 | void 25 | P_SetupLevel 26 | ( int episode, 27 | int map, 28 | int playermask, 29 | skill_t skill); 30 | 31 | // Called by startup code. 32 | void P_Init (void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /i_main.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Main program, simply calls D_DoomMain high level loop. 18 | // 19 | 20 | #include "doomdef.h" 21 | 22 | #include "m_misc.h" 23 | #include "d_main.h" 24 | 25 | int 26 | main 27 | ( int argc, 28 | char** argv ) 29 | { 30 | myargc = argc; 31 | myargv = argv; 32 | 33 | D_DoomMain (); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /r_sky.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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. 17 | // 18 | 19 | 20 | #ifndef __R_SKY__ 21 | #define __R_SKY__ 22 | 23 | // SKY, store the number for name. 24 | #define SKYFLATNAME "F_SKY1" 25 | 26 | // The sky map is 256*128*4 maps. 27 | #define ANGLETOSKYSHIFT 22 28 | 29 | extern int skytexture; 30 | extern int skytexturemid; 31 | 32 | // Called whenever the view size changes. 33 | void R_InitSkyMap (void); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /f_finale.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | -------------------------------------------------------------------------------- /p_saveg.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | 24 | // Persistent storage/archiving. 25 | // These are the load / save game routines. 26 | void P_ArchivePlayers (void); 27 | void P_UnArchivePlayers (void); 28 | void P_ArchiveWorld (void); 29 | void P_UnArchiveWorld (void); 30 | void P_ArchiveThinkers (void); 31 | void P_UnArchiveThinkers (void); 32 | void P_ArchiveSpecials (void); 33 | void P_UnArchiveSpecials (void); 34 | 35 | extern byte* save_p; 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /wi_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | 34 | } stateenum_t; 35 | 36 | // Called by main loop, animate the intermission. 37 | void WI_Ticker (void); 38 | 39 | // Called by main loop, 40 | // draws the intermission directly into the screen buffer. 41 | void WI_Drawer (void); 42 | 43 | // Setup for an intermission screen. 44 | void WI_Start(wbstartstruct_t* wbstartstruct); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __D_TICCMD__ 20 | #define __D_TICCMD__ 21 | 22 | #include "doomtype.h" 23 | 24 | // The data sampled per tick (single player) 25 | // and transmitted to other peers (multiplayer). 26 | // Mainly movements/button commands per game tick, 27 | // plus a checksum for internal state consistency. 28 | typedef struct 29 | { 30 | char forwardmove; // *2048 for move 31 | char sidemove; // *2048 for move 32 | short angleturn; // <<16 for angle delta 33 | short consistancy; // checks for net game 34 | byte chatchar; 35 | byte buttons; 36 | } ticcmd_t; 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /i_sound.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 id Software, Inc. 3 | // Copyright (C) 1993-2008 Raven Software 4 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 interface for sound. 18 | // 19 | 20 | #ifndef __I_SOUND__ 21 | #define __I_SOUND__ 22 | 23 | #define SND_TICRATE 140 // tic rate for updating sound 24 | #define SND_MAXSONGS 40 // max number of songs in game 25 | #define SND_SAMPLERATE 11025 // sample rate of sound effects 26 | 27 | typedef enum 28 | { 29 | snd_none, 30 | snd_PC, 31 | snd_Adlib, 32 | snd_SB, 33 | snd_PAS, 34 | snd_GUS, 35 | snd_MPU, 36 | snd_MPU2, 37 | snd_MPU3, 38 | snd_AWE, 39 | snd_ENSONIQ, 40 | snd_CODEC, 41 | NUM_SCARDS 42 | } cardenum_t; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /r_local.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | -------------------------------------------------------------------------------- /am_map.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Used by ST StatusBar stuff. 23 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 24 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 25 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 26 | 27 | 28 | // Called by main loop. 29 | boolean AM_Responder (event_t* ev); 30 | 31 | // Called by main loop. 32 | void AM_Ticker (void); 33 | 34 | // Called by main loop, 35 | // called instead of view drawer if automap active. 36 | void AM_Drawer (void); 37 | 38 | // Called to force the automap to quit 39 | // if the level is completed while it is up. 40 | void AM_Stop (void); 41 | 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /r_sky.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Needed for FRACUNIT. 25 | #include "doomdef.h" 26 | 27 | // Needed for Flat retrieval. 28 | #include "r_data.h" 29 | #include "r_sky.h" 30 | 31 | // 32 | // sky mapping 33 | // 34 | int skyflatnum; 35 | int skytexture; 36 | int skytexturemid; 37 | 38 | 39 | 40 | // 41 | // R_InitSkyMap 42 | // Called whenever the view size changes. 43 | // 44 | void R_InitSkyMap (void) 45 | { 46 | skyflatnum = R_FlatNumForName ( SKYFLATNAME ); 47 | skytexturemid = 100*FRACUNIT; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /f_wipe.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | -------------------------------------------------------------------------------- /r_data.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __R_DATA__ 21 | #define __R_DATA__ 22 | 23 | #include "r_defs.h" 24 | #include "r_state.h" 25 | 26 | // Retrieve column data for span blitting. 27 | byte* 28 | R_GetColumn 29 | ( int tex, 30 | int col ); 31 | 32 | 33 | // I/O, setting up the stuff. 34 | void R_InitData (void); 35 | void R_PrecacheLevel (void); 36 | 37 | 38 | // Retrieval. 39 | // Floor/ceiling opaque texture tiles, 40 | // lookup by name. For animation? 41 | int R_FlatNumForName (char* name); 42 | 43 | 44 | // Called by P_Ticker for switches and animations, 45 | // returns the texture number for the texture name. 46 | int R_TextureNumForName (char *name); 47 | int R_CheckTextureNumForName (char *name); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /dstrings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // DOOM strings, by language. 17 | // 18 | 19 | #ifndef __DSTRINGS__ 20 | #define __DSTRINGS__ 21 | 22 | 23 | // All important printed strings. 24 | // Language selection (message strings). 25 | // Use -DFRENCH etc. 26 | 27 | #ifdef FRENCH 28 | #include "d_french.h" 29 | #else 30 | #include "d_englsh.h" 31 | #endif 32 | 33 | // Misc. other strings. 34 | #define SAVEGAMENAME "doomsav" 35 | 36 | 37 | // 38 | // File locations, 39 | // relative to current position. 40 | // Path names are OS-sensitive. 41 | // 42 | #define DEVMAPS "f:/doom/data_se/" 43 | #define DEVDATA "c:/localid/" 44 | 45 | 46 | // Not done in french? 47 | 48 | // QuitDOOM messages 49 | #define NUM_QUITMESSAGES 8 50 | 51 | extern char endmsg1[NUM_QUITMESSAGES][80]; 52 | extern char endmsg2[NUM_QUITMESSAGES][80]; 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /d_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __D_MAIN__ 20 | #define __D_MAIN__ 21 | 22 | #include "d_event.h" 23 | 24 | #define MAXWADFILES 20 25 | extern char* wadfiles[MAXWADFILES]; 26 | 27 | void D_AddFile (char *file); 28 | 29 | 30 | 31 | // 32 | // D_DoomMain() 33 | // Not a globally visible function, just included for source reference, 34 | // calls all startup code, parses command line options. 35 | // If not overrided by user input, calls N_AdvanceDemo. 36 | // 37 | void D_DoomMain (void); 38 | 39 | // Called by IO functions when input is detected. 40 | void D_PostEvent (event_t* ev); 41 | 42 | 43 | 44 | // 45 | // BASE LEVEL 46 | // 47 | void D_PageTicker (void); 48 | void D_PageDrawer (void); 49 | void D_AdvanceDemo (void); 50 | void D_StartTitle (void); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /doomtype.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __DOOMTYPE__ 21 | #define __DOOMTYPE__ 22 | 23 | 24 | #ifndef __BYTEBOOL__ 25 | #define __BYTEBOOL__ 26 | // Fixed to use builtin bool type with C++. 27 | #ifdef __cplusplus 28 | typedef bool boolean; 29 | #else 30 | typedef enum {false, true} boolean; 31 | #endif 32 | typedef unsigned char byte; 33 | #endif 34 | 35 | #define MAXCHAR ((char)0x7f) 36 | #define MAXSHORT ((short)0x7fff) 37 | 38 | // Max pos 32-bit int. 39 | #define MAXINT ((int)0x7fffffff) 40 | #define MAXLONG ((long)0x7fffffff) 41 | #define MINCHAR ((char)0x80) 42 | #define MINSHORT ((short)0x8000) 43 | 44 | // Max negative 32-bit integer. 45 | #define MININT ((int)0x80000000) 46 | #define MINLONG ((long)0x80000000) 47 | 48 | 49 | 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /newdoom.lnk: -------------------------------------------------------------------------------- 1 | 2 | # newdoom.EXE Linker directive file 3 | 4 | option quiet 5 | option map 6 | option stack=65536 7 | option stub=wstub 8 | debug all 9 | libpath %WATCOM%\lib386 10 | libpath %WATCOM%\lib386\dos 11 | lib noemu387.lib 12 | #lib dmx 13 | lib audio_wf.lib 14 | format os2 le 15 | name newdoom 16 | 17 | file i_main.obj 18 | file i_ibm.obj 19 | file i_sound.obj 20 | file i_cyber.obj 21 | file i_ibm_a.obj 22 | file planar.obj 23 | file tables.obj 24 | file f_finale.obj 25 | file d_main.obj 26 | file d_net.obj 27 | file g_game.obj 28 | file m_menu.obj 29 | file m_misc.obj 30 | file am_map.obj 31 | file p_ceilng.obj 32 | file p_doors.obj 33 | file p_enemy.obj 34 | file p_floor.obj 35 | file p_inter.obj 36 | file p_lights.obj 37 | file p_map.obj 38 | file p_maputl.obj 39 | file p_plats.obj 40 | file p_pspr.obj 41 | file p_setup.obj 42 | file p_sight.obj 43 | file p_spec.obj 44 | file p_switch.obj 45 | file p_mobj.obj 46 | file p_telept.obj 47 | file p_saveg.obj 48 | file p_tick.obj 49 | file p_user.obj 50 | file r_bsp.obj 51 | file r_data.obj 52 | file r_draw.obj 53 | file r_main.obj 54 | file r_sky.obj 55 | file r_plane.obj 56 | file r_segs.obj 57 | file r_things.obj 58 | file w_wad.obj 59 | file v_video.obj 60 | file z_zone.obj 61 | file st_stuff.obj 62 | file st_lib.obj 63 | file hu_stuff.obj 64 | file hu_lib.obj 65 | file wi_stuff.obj 66 | file s_sound.obj 67 | file sounds.obj 68 | file dutils.obj 69 | file f_wipe.obj 70 | file info.obj 71 | 72 | file dmx.obj 73 | file usrhooks.obj 74 | file mus2mid.obj 75 | file pcfx.obj 76 | -------------------------------------------------------------------------------- /hu_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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_MSGREFRESH KEY_ENTER 36 | #define HU_MSGX 0 37 | #define HU_MSGY 0 38 | #define HU_MSGWIDTH 64 // in characters 39 | #define HU_MSGHEIGHT 1 // in lines 40 | 41 | #define HU_MSGTIMEOUT (4*TICRATE) 42 | 43 | // 44 | // HEADS UP TEXT 45 | // 46 | 47 | void HU_Init(void); 48 | void HU_Start(void); 49 | 50 | boolean HU_Responder(event_t* ev); 51 | 52 | void HU_Ticker(void); 53 | void HU_Drawer(void); 54 | char HU_dequeueChatChar(void); 55 | void HU_Erase(void); 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /SNDCARDS.H: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------- 2 | /* 3 | Copyright (C) 1996, 2003 - 3D Realms Entertainment 4 | 5 | This file is part of Duke Nukem 3D version 1.5 - Atomic Edition 6 | 7 | Duke Nukem 3D is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation; either version 2 10 | of the License, or (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | 16 | See the GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | 22 | Original Source: 1994 - Jim Dose 23 | Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms 24 | */ 25 | //------------------------------------------------------------------------- 26 | 27 | #ifndef __SNDCARDS_H 28 | #define __SNDCARDS_H 29 | 30 | #define ASS_VERSION_STRING "1.1" 31 | 32 | typedef enum 33 | { 34 | // ASS_NoSound, 35 | SoundBlaster, 36 | ProAudioSpectrum, 37 | SoundMan16, 38 | Adlib, 39 | GenMidi, 40 | SoundCanvas, 41 | Awe32, 42 | WaveBlaster, 43 | SoundScape, 44 | UltraSound, 45 | SoundSource, 46 | TandySoundSource, 47 | PC, 48 | NumSoundCards 49 | } soundcardnames; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /r_bsp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | extern seg_t* curline; 25 | extern side_t* sidedef; 26 | extern line_t* linedef; 27 | extern sector_t* frontsector; 28 | extern sector_t* backsector; 29 | 30 | extern int rw_x; 31 | extern int rw_stopx; 32 | 33 | extern boolean segtextured; 34 | 35 | // false if the back side is the same plane 36 | extern boolean markfloor; 37 | extern boolean markceiling; 38 | 39 | extern boolean skymap; 40 | 41 | extern drawseg_t drawsegs[MAXDRAWSEGS]; 42 | extern drawseg_t* ds_p; 43 | 44 | extern lighttable_t** hscalelight; 45 | extern lighttable_t** vscalelight; 46 | extern lighttable_t** dscalelight; 47 | 48 | 49 | typedef void (*drawfunc_t) (int start, int stop); 50 | 51 | 52 | // BSP? 53 | void R_ClearClipSegs (void); 54 | void R_ClearDrawSegs (void); 55 | 56 | 57 | void R_RenderBSPNode (int bspnum); 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /defs.inc: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 1993-1996 Id Software, Inc. 3 | ; Copyright (C) 1993-2008 Raven Software 4 | ; Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | SKIPPRIMITIVES = 0 ; set to 1 to skip unwound drawing 17 | 18 | 19 | SCREEN = 0a0000h 20 | SCREENWIDTH = 320 21 | SCREENHEIGHT = 200 22 | PLANEWIDTH = 80 23 | PLANESIZE = 80*200 24 | 25 | PEL_WRITE_ADR = 03c8h 26 | PEL_DATA = 03c9h 27 | 28 | SC_INDEX = 03C4h 29 | SC_MAPMASK = 2 30 | 31 | OP_RET = 0c3h 32 | OP_MOVAL = 08ah 33 | OP_MOVDEST = 088h 34 | 35 | 36 | .DATA 37 | 38 | EXTRN _dc_colormap:DWORD 39 | EXTRN _dc_x:DWORD 40 | EXTRN _dc_yl:DWORD 41 | EXTRN _dc_yh:DWORD 42 | EXTRN _dc_iscale:DWORD 43 | EXTRN _dc_texturemid:DWORD 44 | EXTRN _dc_source:DWORD 45 | 46 | EXTRN _ylookup:DWORD 47 | EXTRN _columnofs:DWORD 48 | 49 | 50 | EXTRN _ds_y:DWORD 51 | EXTRN _ds_x1:DWORD 52 | EXTRN _ds_x2:DWORD 53 | EXTRN _ds_colormap:DWORD 54 | EXTRN _ds_xfrac:DWORD 55 | EXTRN _ds_yfrac:DWORD 56 | EXTRN _ds_xstep:DWORD 57 | EXTRN _ds_ystep:DWORD 58 | EXTRN _ds_source:DWORD 59 | 60 | PUSHR MACRO 61 | pushad 62 | ENDM 63 | 64 | POPR MACRO 65 | popad 66 | ENDM 67 | -------------------------------------------------------------------------------- /m_menu.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __M_MENU__ 20 | #define __M_MENU__ 21 | 22 | 23 | 24 | #include "d_event.h" 25 | 26 | // 27 | // MENUS 28 | // 29 | // Called by main loop, 30 | // saves config file and calls I_Quit when user exits. 31 | // Even when the menu is not displayed, 32 | // this can resize the view and change game parameters. 33 | // Does all the real work of the menu interaction. 34 | boolean M_Responder (event_t *ev); 35 | 36 | 37 | // Called by main loop, 38 | // only used for menu (skull cursor) animation. 39 | void M_Ticker (void); 40 | 41 | // Called by main loop, 42 | // draws the menus directly into the screen buffer. 43 | void M_Drawer (void); 44 | 45 | // Called by D_DoomMain, 46 | // loads the config file. 47 | void M_Init (void); 48 | 49 | // Called by intro code to force menu up upon a keypress, 50 | // does nothing if menu is already up. 51 | void M_StartControlPanel (void); 52 | 53 | 54 | 55 | 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /d_think.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __D_THINK__ 22 | #define __D_THINK__ 23 | 24 | 25 | 26 | // 27 | // Experimental stuff. 28 | // To compile this as "ANSI C with classes" 29 | // we will need to handle the various 30 | // action functions cleanly. 31 | // 32 | typedef void (*actionf_v)(); 33 | typedef void (*actionf_p1)( void* ); 34 | typedef void (*actionf_p2)( void*, void* ); 35 | 36 | typedef union 37 | { 38 | actionf_p1 acp1; 39 | actionf_v acv; 40 | actionf_p2 acp2; 41 | 42 | } actionf_t; 43 | 44 | 45 | 46 | 47 | 48 | // Historically, "think_t" is yet another 49 | // function pointer to a routine to handle 50 | // an actor. 51 | typedef actionf_t think_t; 52 | 53 | 54 | // Doubly linked list of actors. 55 | typedef struct thinker_s 56 | { 57 | struct thinker_s* prev; 58 | struct thinker_s* next; 59 | think_t function; 60 | 61 | } thinker_t; 62 | 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /r_plane.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Visplane related. 28 | extern short* lastopening; 29 | 30 | 31 | typedef void (*planefunction_t) (int top, int bottom); 32 | 33 | extern planefunction_t floorfunc; 34 | extern planefunction_t ceilingfunc_t; 35 | 36 | extern short floorclip[SCREENWIDTH]; 37 | extern short ceilingclip[SCREENWIDTH]; 38 | 39 | extern fixed_t yslope[SCREENHEIGHT]; 40 | extern fixed_t distscale[SCREENWIDTH]; 41 | 42 | void R_InitPlanes (void); 43 | void R_ClearPlanes (void); 44 | 45 | void 46 | R_MapPlane 47 | ( int y, 48 | int x1, 49 | int x2 ); 50 | 51 | void 52 | R_MakeSpans 53 | ( int x, 54 | int t1, 55 | int b1, 56 | int t2, 57 | int b2 ); 58 | 59 | void R_DrawPlanes (void); 60 | 61 | visplane_t* 62 | R_FindPlane 63 | ( fixed_t height, 64 | int picnum, 65 | int lightlevel ); 66 | 67 | visplane_t* 68 | R_CheckPlane 69 | ( visplane_t* pl, 70 | int start, 71 | int stop ); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /dutils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __DUTILS__ 20 | #define __DUTILS__ 21 | 22 | typedef struct lnode_s { 23 | void* value; 24 | struct lnode_s* prev; 25 | struct lnode_s* next; 26 | } lnode_t; 27 | 28 | typedef struct { 29 | lnode_t* start; 30 | lnode_t* end; 31 | } list_t; 32 | 33 | list_t* dll_NewList(void); 34 | lnode_t* dll_AddEndNode(list_t* list, void* value); 35 | lnode_t* dll_AddStartNode(list_t* list, void* value); 36 | void* dll_DelNode(list_t* list, lnode_t* node); 37 | void* dll_DelEndNode(list_t* list); 38 | void* dll_DelStartNode(list_t* list); 39 | 40 | // 41 | // CHEAT SEQUENCE PACKAGE 42 | // 43 | 44 | #define SCRAMBLE(a) \ 45 | ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ 46 | + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) 47 | 48 | typedef struct 49 | { 50 | unsigned char* sequence; 51 | unsigned char* p; 52 | 53 | } cheatseq_t; 54 | 55 | int 56 | cht_CheckCheat 57 | ( cheatseq_t* cht, 58 | char key ); 59 | 60 | 61 | void 62 | cht_GetParam 63 | ( cheatseq_t* cht, 64 | char* buffer ); 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /w_wad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | 24 | // 25 | // TYPES 26 | // 27 | typedef struct 28 | { 29 | // Should be "IWAD" or "PWAD". 30 | char identification[4]; 31 | int numlumps; 32 | int infotableofs; 33 | 34 | } wadinfo_t; 35 | 36 | 37 | typedef struct 38 | { 39 | int filepos; 40 | int size; 41 | char name[8]; 42 | 43 | } filelump_t; 44 | 45 | // 46 | // WADFILE I/O related stuff. 47 | // 48 | typedef struct 49 | { 50 | char name[8]; 51 | int handle; 52 | int position; 53 | int size; 54 | } lumpinfo_t; 55 | 56 | 57 | extern void** lumpcache; 58 | extern lumpinfo_t* lumpinfo; 59 | extern int numlumps; 60 | 61 | void W_InitMultipleFiles (char** filenames); 62 | void W_Reload (void); 63 | 64 | int W_CheckNumForName (char* name); 65 | int W_GetNumForName (char* name); 66 | 67 | int W_LumpLength (int lump); 68 | void W_ReadLump (int lump, void *dest); 69 | 70 | void* W_CacheLumpNum (int lump, int tag); 71 | void* W_CacheLumpName (char* name, int tag); 72 | 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /r_things.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #define MAXVISSPRITES 128 24 | 25 | extern vissprite_t vissprites[MAXVISSPRITES]; 26 | extern vissprite_t* vissprite_p; 27 | extern vissprite_t vsprsortedhead; 28 | 29 | // Constant arrays used for psprite clipping 30 | // and initializing clipping. 31 | extern short negonearray[SCREENWIDTH]; 32 | extern short screenheightarray[SCREENWIDTH]; 33 | 34 | // vars for R_DrawMaskedColumn 35 | extern short* mfloorclip; 36 | extern short* mceilingclip; 37 | extern fixed_t spryscale; 38 | extern fixed_t sprtopscreen; 39 | 40 | extern fixed_t pspritescale; 41 | extern fixed_t pspriteiscale; 42 | 43 | 44 | void R_DrawMaskedColumn (column_t* column); 45 | 46 | 47 | void R_SortVisSprites (void); 48 | 49 | void R_AddSprites (sector_t* sec); 50 | void R_AddPSprites (void); 51 | void R_DrawSprites (void); 52 | void R_InitSprites (char** namelist); 53 | void R_ClearSprites (void); 54 | void R_DrawMasked (void); 55 | 56 | void 57 | R_ClipVisSprite 58 | ( vissprite_t* vis, 59 | int xl, 60 | int xh ); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /g_game.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __G_GAME__ 20 | #define __G_GAME__ 21 | 22 | #include "doomdef.h" 23 | #include "d_event.h" 24 | 25 | 26 | 27 | // 28 | // GAME 29 | // 30 | void G_DeathMatchSpawnPlayer (int playernum); 31 | 32 | void G_InitNew (skill_t skill, int episode, int map); 33 | 34 | // Can be called by the startup code or M_Responder. 35 | // A normal game starts at map 1, 36 | // but a warp test can start elsewhere 37 | void G_DeferedInitNew (skill_t skill, int episode, int map); 38 | 39 | void G_DeferedPlayDemo (char* demo); 40 | 41 | // Can be called by the startup code or M_Responder, 42 | // calls P_SetupLevel or W_EnterWorld. 43 | void G_LoadGame (char* name); 44 | 45 | void G_DoLoadGame (void); 46 | 47 | // Called by M_Responder. 48 | void G_SaveGame (int slot, char* description); 49 | 50 | // Only called by startup code. 51 | void G_RecordDemo (char* name); 52 | 53 | void G_BeginRecording (void); 54 | 55 | void G_PlayDemo (char* name); 56 | void G_TimeDemo (char* name); 57 | boolean G_CheckDemoStatus (void); 58 | 59 | void G_ExitLevel (void); 60 | void G_SecretExitLevel (void); 61 | 62 | void G_WorldDone (void); 63 | 64 | void G_Ticker (void); 65 | boolean G_Responder (event_t* ev); 66 | 67 | void G_ScreenShot (void); 68 | 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /st_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | 27 | // Size of statusbar. 28 | // Now sensitive for scaling. 29 | #define ST_HEIGHT 32*SCREEN_MUL 30 | #define ST_WIDTH SCREENWIDTH 31 | #define ST_Y (SCREENHEIGHT - ST_HEIGHT) 32 | 33 | 34 | // 35 | // STATUS BAR 36 | // 37 | 38 | // Called by main loop. 39 | boolean ST_Responder (event_t* ev); 40 | 41 | // Called by main loop. 42 | void ST_Ticker (void); 43 | 44 | // Called by main loop. 45 | void ST_Drawer (boolean fullscreen, boolean refresh); 46 | 47 | // Called when the console player is spawned on each level. 48 | void ST_Start (void); 49 | 50 | // Called by startup code. 51 | void ST_Init (void); 52 | 53 | 54 | 55 | // States for status bar code. 56 | typedef enum 57 | { 58 | AutomapState, 59 | FirstPersonState 60 | 61 | } st_stateenum_t; 62 | 63 | 64 | // States for the chat code. 65 | typedef enum 66 | { 67 | StartChatState, 68 | WaitDestState, 69 | GetChatState 70 | 71 | } st_chatstateenum_t; 72 | 73 | 74 | boolean ST_Responder(event_t* ev); 75 | 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /USRHOOKS.H: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /********************************************************************** 21 | module: USRHOOKS.H 22 | 23 | author: James R. Dose 24 | date: July 26, 1994 25 | 26 | Public header file for USRHOOKS.C. 27 | 28 | This module contains cover functions for operations the library 29 | needs that may be restricted by the calling program. The function 30 | prototypes in this header should not be modified. 31 | **********************************************************************/ 32 | 33 | #ifndef __USRHOOKS_H 34 | #define __USRHOOKS_H 35 | 36 | /*--------------------------------------------------------------------- 37 | Error definitions 38 | ---------------------------------------------------------------------*/ 39 | 40 | enum USRHOOKS_Errors 41 | { 42 | USRHOOKS_Warning = -2, 43 | USRHOOKS_Error = -1, 44 | USRHOOKS_Ok = 0 45 | }; 46 | 47 | 48 | /*--------------------------------------------------------------------- 49 | Function Prototypes 50 | ---------------------------------------------------------------------*/ 51 | 52 | int USRHOOKS_GetMem( void **ptr, unsigned long size ); 53 | int USRHOOKS_FreeMem( void *ptr ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /m_misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __M_MISC__ 19 | #define __M_MISC__ 20 | 21 | 22 | #include "doomdef.h" 23 | #include "doomtype.h" 24 | // 25 | // MISC 26 | // 27 | extern int myargc; 28 | extern char** myargv; 29 | 30 | // Returns the position of the given parameter 31 | // in the arg list (0 if not found). 32 | int M_CheckParm (char* check); 33 | 34 | boolean 35 | M_WriteFile 36 | ( char const* name, 37 | void* source, 38 | int length ); 39 | 40 | int 41 | M_ReadFile 42 | ( char const* name, 43 | byte** buffer ); 44 | 45 | // Returns a number from 0 to 255, 46 | // from a lookup table. 47 | int M_Random(void); 48 | 49 | // As M_Random, but used only by the play simulation. 50 | int P_Random(void); 51 | 52 | // Fix randoms for demos. 53 | void M_ClearRandom(void); 54 | 55 | // Bounding box coordinate storage. 56 | enum 57 | { 58 | BOXTOP, 59 | BOXBOTTOM, 60 | BOXLEFT, 61 | BOXRIGHT 62 | }; // bbox coordinates 63 | 64 | // Bounding box functions. 65 | void M_ClearBox (fixed_t* box); 66 | 67 | void 68 | M_AddToBox 69 | ( fixed_t* box, 70 | fixed_t x, 71 | fixed_t y ); 72 | 73 | void M_ScreenShot (void); 74 | 75 | void M_LoadDefaults (void); 76 | 77 | void M_SaveDefaults (void); 78 | 79 | 80 | int 81 | M_DrawText 82 | ( int x, 83 | int y, 84 | boolean direct, 85 | char* string ); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /p_pspr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __P_PSPR__ 20 | #define __P_PSPR__ 21 | 22 | // Basic data types. 23 | // Needs fixed point, and BAM angles. 24 | #include "doomdef.h" 25 | #include "tables.h" 26 | 27 | 28 | // 29 | // Needs to include the precompiled 30 | // sprite animation tables. 31 | // Header generated by multigen utility. 32 | // This includes all the data for thing animation, 33 | // i.e. the Thing Atrributes table 34 | // and the Frame Sequence table. 35 | #include "info.h" 36 | 37 | 38 | // 39 | // Frame flags: 40 | // handles maximum brightness (torches, muzzle flare, light sources) 41 | // 42 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 43 | #define FF_FRAMEMASK 0x7fff 44 | 45 | 46 | 47 | // 48 | // Overlay psprites are scaled shapes 49 | // drawn directly on the view screen, 50 | // coordinates are given for a 320*200 view screen. 51 | // 52 | typedef enum 53 | { 54 | ps_weapon, 55 | ps_flash, 56 | NUMPSPRITES 57 | 58 | } psprnum_t; 59 | 60 | typedef struct 61 | { 62 | state_t* state; // a NULL state means not active 63 | int tics; 64 | fixed_t sx; 65 | fixed_t sy; 66 | 67 | } pspdef_t; 68 | 69 | // Weapon info: sprite frames, ammunition use. 70 | typedef struct 71 | { 72 | ammotype_t ammo; 73 | int upstate; 74 | int downstate; 75 | int readystate; 76 | int atkstate; 77 | int flashstate; 78 | 79 | } weaponinfo_t; 80 | 81 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /TASK_MAN.H: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /********************************************************************** 21 | module: TASK_MAN.C 22 | 23 | author: James R. Dose 24 | date: July 25, 1994 25 | 26 | Public header for TASK_MAN.C, a low level timer task scheduler. 27 | 28 | (c) Copyright 1994 James R. Dose. All Rights Reserved. 29 | **********************************************************************/ 30 | 31 | #ifndef __TASK_MAN_H 32 | #define __TASK_MAN_H 33 | 34 | enum TASK_ERRORS 35 | { 36 | TASK_Warning = -2, 37 | TASK_Error = -1, 38 | TASK_Ok = 0 39 | }; 40 | 41 | typedef struct task 42 | { 43 | struct task *next; 44 | struct task *prev; 45 | void ( *TaskService )( struct task * ); 46 | void *data; 47 | long rate; 48 | volatile long count; 49 | int priority; 50 | int active; 51 | } task; 52 | 53 | // TS_InInterrupt is TRUE during a taskman interrupt. 54 | // Use this if you have code that may be used both outside 55 | // and within interrupts. 56 | 57 | extern volatile int TS_InInterrupt; 58 | 59 | void TS_Shutdown( void ); 60 | task *TS_ScheduleTask( void ( *Function )( task * ), int rate, 61 | int priority, void *data ); 62 | int TS_Terminate( task *ptr ); 63 | void TS_Dispatch( void ); 64 | void TS_SetTaskRate( task *Task, int rate ); 65 | void TS_UnlockMemory( void ); 66 | int TS_LockMemory( void ); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /PCFX.H: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /********************************************************************** 21 | module: PCFX.H 22 | 23 | author: James R. Dose 24 | date: April 1, 1994 25 | 26 | Public header for ADLIBFX.C 27 | 28 | (c) Copyright 1994 James R. Dose. All Rights Reserved. 29 | **********************************************************************/ 30 | 31 | #ifndef __PCFX_H 32 | #define __PCFX_H 33 | 34 | enum PCFX_Errors 35 | { 36 | PCFX_Warning = -2, 37 | PCFX_Error = -1, 38 | PCFX_Ok = 0, 39 | PCFX_NoVoices, 40 | PCFX_VoiceNotFound, 41 | PCFX_DPMI_Error 42 | }; 43 | 44 | #define PCFX_MaxVolume 255 45 | #define PCFX_MinVoiceHandle 1 46 | 47 | typedef struct 48 | { 49 | unsigned long length; 50 | short int priority; 51 | char data[]; 52 | } PCSound; 53 | 54 | char *PCFX_ErrorString( int ErrorNumber ); 55 | int PCFX_Stop( int handle ); 56 | void PCFX_UseLookup( int use, unsigned value ); 57 | int PCFX_VoiceAvailable( int priority ); 58 | int PCFX_Play( PCSound *sound, int priority, unsigned long callbackval ); 59 | int PCFX_SoundPlaying( int handle ); 60 | int PCFX_SetTotalVolume( int volume ); 61 | int PCFX_GetTotalVolume( void ); 62 | void PCFX_SetCallBack( void ( *function )( unsigned long ) ); 63 | int PCFX_Init( void ); 64 | int PCFX_Shutdown( void ); 65 | #pragma aux PCFX_Shutdown frame; 66 | void PCFX_UnlockMemory( void ); 67 | int PCFX_LockMemory( void ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /s_sound.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | 24 | 25 | // 26 | // Initializes sound stuff, including volume 27 | // Sets channels, SFX and music volume, 28 | // allocates channel buffer, sets S_sfx lookup. 29 | // 30 | void 31 | S_Init 32 | ( int sfxVolume, 33 | int musicVolume ); 34 | 35 | 36 | 37 | 38 | // 39 | // Per level startup code. 40 | // Kills playing sounds at start of level, 41 | // determines music if any, changes music. 42 | // 43 | void S_Start(void); 44 | 45 | 46 | // 47 | // Start sound for thing at 48 | // using from sounds.h 49 | // 50 | void 51 | S_StartSound 52 | ( void* origin, 53 | int sound_id ); 54 | 55 | 56 | 57 | // Will start a sound at a given volume. 58 | void 59 | S_StartSoundAtVolume 60 | ( void* origin, 61 | int sound_id, 62 | int volume ); 63 | 64 | 65 | // Stop sound for thing at 66 | void S_StopSound(void* origin); 67 | 68 | 69 | // Start music using from sounds.h 70 | void S_StartMusic(int music_id); 71 | 72 | // Start music using from sounds.h, 73 | // and set whether looping 74 | void 75 | S_ChangeMusic 76 | ( int music_id, 77 | int looping ); 78 | 79 | // Stops the music fer sure. 80 | void S_StopMusic(void); 81 | 82 | // Stop and resume music, during game PAUSE. 83 | void S_PauseSound(void); 84 | void S_ResumeSound(void); 85 | 86 | 87 | // 88 | // Updates music & sounds 89 | // 90 | void S_UpdateSounds(void* listener); 91 | 92 | void S_SetMusicVolume(int volume); 93 | void S_SetSfxVolume(int volume); 94 | 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /DMX.H: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2015 Alexey Khokholov (Nuke.YKT) 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 | #ifndef _DMX_H_ 16 | #define _DMX_H_ 17 | 18 | 19 | int AL_DetectFM(void); 20 | int MPU_Init(int addr); 21 | int GUS_Init(void); 22 | void GUS_Shutdown(void); 23 | 24 | void TSM_Install(int rate); 25 | int TSM_NewService(int(*function)(void), int rate, int unk1, int unk2); 26 | void TSM_DelService(int unk1); 27 | void TSM_Remove(void); 28 | void MUS_PauseSong(int handle); 29 | void MUS_ResumeSong(int handle); 30 | void MUS_SetMasterVolume(int volume); 31 | int MUS_RegisterSong(void *data); 32 | int MUS_UnregisterSong(int handle); 33 | int MUS_QrySongPlaying(int handle); 34 | int MUS_StopSong(int handle); 35 | int MUS_ChainSong(int handle, int next); 36 | int MUS_PlaySong(int handle, int volume); 37 | int SFX_PlayPatch(void *vdata, int pitch, int sep, int vol, int unk1, int unk2); 38 | void SFX_StopPatch(int handle); 39 | int SFX_Playing(int handle); 40 | void SFX_SetOrigin(int handle, int pitch, int sep, int vol); 41 | int GF1_Detect(void); 42 | void GF1_SetMap(void *data, int len); 43 | int SB_Detect(int *port, int *irq, int *dma, int *unk); 44 | void SB_SetCard(int port, int irq, int dma); 45 | int AL_Detect(int *port, int *unk); 46 | void AL_SetCard(int port, void *data); 47 | int MPU_Detect(int *port, int *unk); 48 | void MPU_SetCard(int port); 49 | int DMX_Init(int rate, int maxsng, int mdev, int sdev); 50 | void DMX_DeInit(void); 51 | void WAV_PlayMode(int channels, int samplerate); 52 | int CODEC_Detect(int *a, int *b); 53 | int ENS_Detect(void); 54 | 55 | 56 | #define AHW_PC_SPEAKER 1 57 | #define AHW_ADLIB 2 58 | #define AHW_AWE32 4 59 | #define AHW_SOUND_BLASTER 8 60 | #define AHW_MPU_401 16 61 | #define AHW_ULTRA_SOUND 32 62 | #define AHW_MEDIA_VISION 64 63 | #define AHW_ENSONIQ 256 64 | #define AHW_CODEC 512 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /tables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Lookup tables. 17 | // Do not try to look them up :-). 18 | // In the order of appearance: 19 | // 20 | // int finetangent[4096] - Tangens LUT. 21 | // Should work with BAM fairly well (12 of 16bit, 22 | // effectively, by shifting). 23 | // 24 | // int finesine[10240] - Sine lookup. 25 | // Guess what, serves as cosine, too. 26 | // Remarkable thing is, how to use BAMs with this? 27 | // 28 | // int tantoangle[2049] - ArcTan LUT, 29 | // maps tan(angle) to angle fast. Gotta search. 30 | // 31 | //----------------------------------------------------------------------------- 32 | 33 | 34 | #ifndef __TABLES__ 35 | #define __TABLES__ 36 | 37 | 38 | #define PI 3.141592657 39 | 40 | 41 | #include "doomdef.h" 42 | 43 | #define FINEANGLES 8192 44 | #define FINEMASK (FINEANGLES-1) 45 | 46 | 47 | // 0x100000000 to 0x2000 48 | #define ANGLETOFINESHIFT 19 49 | 50 | // Effective size is 10240. 51 | extern fixed_t finesine[5*FINEANGLES/4]; 52 | 53 | // Re-use data, is just PI/2 pahse shift. 54 | extern fixed_t* finecosine; 55 | 56 | 57 | // Effective size is 4096. 58 | extern fixed_t finetangent[FINEANGLES/2]; 59 | 60 | // Binary Angle Measument, BAM. 61 | #define ANG45 0x20000000 62 | #define ANG90 0x40000000 63 | #define ANG180 0x80000000 64 | #define ANG270 0xc0000000 65 | 66 | 67 | #define SLOPERANGE 2048 68 | #define SLOPEBITS 11 69 | #define DBITS (FRACBITS-SLOPEBITS) 70 | 71 | typedef unsigned angle_t; 72 | 73 | 74 | // Effective size is 2049; 75 | // The +1 size is to handle the case when x==y 76 | // without additional checking. 77 | extern angle_t tantoangle[SLOPERANGE+1]; 78 | 79 | 80 | // Utility function, 81 | // called by R_PointToAngle. 82 | int 83 | SlopeDiv 84 | ( unsigned num, 85 | unsigned den); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /v_video.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #include "doomdef.h" 28 | 29 | // Needed because we are refering to patches. 30 | #include "r_data.h" 31 | 32 | // 33 | // VIDEO 34 | // 35 | 36 | #define CENTERY (SCREENHEIGHT/2) 37 | 38 | 39 | // Screen 0 is the screen updated by I_Update screen. 40 | // Screen 1 is an extra buffer. 41 | 42 | 43 | 44 | extern byte* screens[5]; 45 | 46 | extern int dirtybox[4]; 47 | 48 | extern byte gammatable[5][256]; 49 | extern int usegamma; 50 | 51 | 52 | 53 | // Allocates buffer screens, call before R_Init. 54 | void V_Init (void); 55 | 56 | 57 | void 58 | V_CopyRect 59 | ( int srcx, 60 | int srcy, 61 | int srcscrn, 62 | int width, 63 | int height, 64 | int destx, 65 | int desty, 66 | int destscrn ); 67 | 68 | void 69 | V_DrawPatch 70 | ( int x, 71 | int y, 72 | int scrn, 73 | patch_t* patch); 74 | 75 | void 76 | V_DrawPatchDirect 77 | ( int x, 78 | int y, 79 | int scrn, 80 | patch_t* patch ); 81 | 82 | 83 | // Draw a linear block of pixels into the view buffer. 84 | void 85 | V_DrawBlock 86 | ( int x, 87 | int y, 88 | int scrn, 89 | int width, 90 | int height, 91 | byte* src ); 92 | 93 | // Reads a linear block of pixels into the view buffer. 94 | void 95 | V_GetBlock 96 | ( int x, 97 | int y, 98 | int scrn, 99 | int width, 100 | int height, 101 | byte* dest ); 102 | 103 | 104 | void 105 | V_MarkRect 106 | ( int x, 107 | int y, 108 | int width, 109 | int height ); 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /USRHOOKS.C: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /********************************************************************** 21 | module: USRHOOKS.C 22 | 23 | author: James R. Dose 24 | date: July 26, 1994 25 | 26 | This module contains cover functions for operations the library 27 | needs that may be restricted by the calling program. This code 28 | is left public for you to modify. 29 | **********************************************************************/ 30 | 31 | #include 32 | #include "usrhooks.h" 33 | 34 | 35 | /*--------------------------------------------------------------------- 36 | Function: USRHOOKS_GetMem 37 | 38 | Allocates the requested amount of memory and returns a pointer to 39 | its location, or NULL if an error occurs. NOTE: pointer is assumed 40 | to be dword aligned. 41 | ---------------------------------------------------------------------*/ 42 | 43 | int USRHOOKS_GetMem 44 | ( 45 | void **ptr, 46 | unsigned long size 47 | ) 48 | 49 | { 50 | void *memory; 51 | 52 | memory = malloc( size ); 53 | if ( memory == NULL ) 54 | { 55 | return( USRHOOKS_Error ); 56 | } 57 | 58 | *ptr = memory; 59 | 60 | return( USRHOOKS_Ok ); 61 | } 62 | 63 | 64 | /*--------------------------------------------------------------------- 65 | Function: USRHOOKS_FreeMem 66 | 67 | Deallocates the memory associated with the specified pointer. 68 | ---------------------------------------------------------------------*/ 69 | 70 | int USRHOOKS_FreeMem 71 | ( 72 | void *ptr 73 | ) 74 | 75 | { 76 | if ( ptr == NULL ) 77 | { 78 | return( USRHOOKS_Error ); 79 | } 80 | 81 | free( ptr ); 82 | 83 | return( USRHOOKS_Ok ); 84 | } 85 | -------------------------------------------------------------------------------- /z_zone.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __Z_ZONE__ 24 | #define __Z_ZONE__ 25 | 26 | #include 27 | 28 | // 29 | // ZONE MEMORY 30 | // PU - purge tags. 31 | // Tags < 100 are not overwritten until freed. 32 | #define PU_STATIC 1 // static entire execution time 33 | #define PU_SOUND 2 // static while playing 34 | #define PU_MUSIC 3 // static while playing 35 | #define PU_DAVE 4 // anything else Dave wants static 36 | #define PU_LEVEL 50 // static until level exited 37 | #define PU_LEVSPEC 51 // a special thinker in a level 38 | // Tags >= 100 are purgable whenever needed. 39 | #define PU_PURGELEVEL 100 40 | #define PU_CACHE 101 41 | 42 | 43 | void Z_Init (void); 44 | void* Z_Malloc (int size, int tag, void *ptr); 45 | void Z_Free (void *ptr); 46 | void Z_FreeTags (int lowtag, int hightag); 47 | void Z_DumpHeap (int lowtag, int hightag); 48 | void Z_FileDumpHeap (FILE *f); 49 | void Z_CheckHeap (void); 50 | void Z_ChangeTag2 (void *ptr, int tag); 51 | int Z_FreeMemory (void); 52 | 53 | 54 | typedef struct memblock_s 55 | { 56 | int size; // including the header and possibly tiny fragments 57 | void** user; // NULL if a free block 58 | int tag; // purgelevel 59 | int id; // should be ZONEID 60 | struct memblock_s* next; 61 | struct memblock_s* prev; 62 | } memblock_t; 63 | 64 | // 65 | // This is used to get the local FILE:LINE info from CPP 66 | // prior to really call the function in question. 67 | // 68 | #define Z_ChangeTag(p,t) \ 69 | { \ 70 | if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \ 71 | I_Error("Z_CT at "__FILE__":%i",__LINE__); \ 72 | Z_ChangeTag2(p,t); \ 73 | }; 74 | 75 | 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | 2 | # NEWDOOM.EXE and DOOM.EXE makefile 3 | 4 | # -------------------------------------------------------------------------- 5 | # 6 | # 4r use 80486 timings and register argument passing 7 | # c compile only 8 | # d1 include line number debugging information 9 | # d2 include full sybolic debugging information 10 | # ei force enums to be of type int 11 | # j change char default from unsigned to signed 12 | # oa relax aliasing checking 13 | # od do not optimize 14 | # oe[=#] expand functions inline, # = quads (default 20) 15 | # oi use the inline library functions 16 | # om generate inline 80x87 code for math functions 17 | # ot optimize for time 18 | # ox maximum optimization 19 | # s remove stack overflow checks 20 | # zp1 align structures on bytes 21 | # zq use quiet mode 22 | # /i=dir add include directories 23 | # 24 | # -------------------------------------------------------------------------- 25 | 26 | CCOPTS = /d2 /omaxet /zp1 /4r /ei /j /zq /i=dmx 27 | 28 | GLOBOBJS = & 29 | i_main.obj & 30 | i_ibm.obj & 31 | i_sound.obj & 32 | i_cyber.obj & 33 | i_ibm_a.obj & 34 | planar.obj & 35 | tables.obj & 36 | f_finale.obj & 37 | d_main.obj & 38 | d_net.obj & 39 | g_game.obj & 40 | m_menu.obj & 41 | m_misc.obj & 42 | am_map.obj & 43 | p_ceilng.obj & 44 | p_doors.obj & 45 | p_enemy.obj & 46 | p_floor.obj & 47 | p_inter.obj & 48 | p_lights.obj & 49 | p_map.obj & 50 | p_maputl.obj & 51 | p_plats.obj & 52 | p_pspr.obj & 53 | p_setup.obj & 54 | p_sight.obj & 55 | p_spec.obj & 56 | p_switch.obj & 57 | p_mobj.obj & 58 | p_telept.obj & 59 | p_saveg.obj & 60 | p_tick.obj & 61 | p_user.obj & 62 | r_bsp.obj & 63 | r_data.obj & 64 | r_draw.obj & 65 | r_main.obj & 66 | r_sky.obj & 67 | r_plane.obj & 68 | r_segs.obj & 69 | r_things.obj & 70 | w_wad.obj & 71 | v_video.obj & 72 | z_zone.obj & 73 | st_stuff.obj & 74 | st_lib.obj & 75 | hu_stuff.obj & 76 | hu_lib.obj & 77 | wi_stuff.obj & 78 | s_sound.obj & 79 | sounds.obj & 80 | dutils.obj & 81 | f_wipe.obj & 82 | # info.obj 83 | info.obj & 84 | dmx.obj & 85 | usrhooks.obj & 86 | mus2mid.obj 87 | 88 | newdoom.exe : $(GLOBOBJS) i_ibm.obj 89 | wlink @newdoom.lnk 90 | copy newdoom.exe doom.exe 91 | wstrip doom.exe 92 | # 4gwbind 4gwpro.exe striptic.exe heretic.exe -V 93 | # prsucc 94 | 95 | .c.obj : 96 | wcc386 $(CCOPTS) $[* 97 | 98 | .asm.obj : 99 | tasm /mx $[* 100 | 101 | clean : .SYMBOLIC 102 | del *.obj 103 | del newdoom.exe 104 | -------------------------------------------------------------------------------- /r_draw.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | extern lighttable_t* dc_colormap; 25 | extern int dc_x; 26 | extern int dc_yl; 27 | extern int dc_yh; 28 | extern fixed_t dc_iscale; 29 | extern fixed_t dc_texturemid; 30 | 31 | // first pixel in a column 32 | extern byte* dc_source; 33 | 34 | 35 | // The span blitting interface. 36 | // Hook in assembler or system specific BLT 37 | // here. 38 | void R_DrawColumn (void); 39 | void R_DrawColumnLow (void); 40 | 41 | // The Spectre/Invisibility effect. 42 | void R_DrawFuzzColumn (void); 43 | void R_DrawFuzzColumnLow (void); 44 | 45 | // Draw with color translation tables, 46 | // for player sprite rendering, 47 | // Green/Red/Blue/Indigo shirts. 48 | void R_DrawTranslatedColumn (void); 49 | void R_DrawTranslatedColumnLow (void); 50 | 51 | void 52 | R_VideoErase 53 | ( unsigned ofs, 54 | int count ); 55 | 56 | extern int ds_y; 57 | extern int ds_x1; 58 | extern int ds_x2; 59 | 60 | extern lighttable_t* ds_colormap; 61 | 62 | extern fixed_t ds_xfrac; 63 | extern fixed_t ds_yfrac; 64 | extern fixed_t ds_xstep; 65 | extern fixed_t ds_ystep; 66 | 67 | // start of a 64*64 tile image 68 | extern byte* ds_source; 69 | 70 | extern byte* translationtables; 71 | extern byte* dc_translation; 72 | 73 | 74 | // Span blitting for rows, floor/ceiling. 75 | // No Sepctre effect needed. 76 | void R_DrawSpan (void); 77 | 78 | // Low resolution mode, 160x200? 79 | void R_DrawSpanLow (void); 80 | 81 | 82 | void 83 | R_InitBuffer 84 | ( int width, 85 | int height ); 86 | 87 | 88 | // Initialize color translation tables, 89 | // for player rendering etc. 90 | void R_InitTranslationTables (void); 91 | 92 | 93 | 94 | // Rendering function. 95 | void R_FillBackScreen (void); 96 | 97 | // If the view size is not full screen, draws a border around it. 98 | void R_DrawViewBorder (void); 99 | 100 | 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /d_event.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __D_EVENT__ 19 | #define __D_EVENT__ 20 | 21 | 22 | #include "doomtype.h" 23 | 24 | 25 | // 26 | // Event handling. 27 | // 28 | 29 | // Input event types. 30 | typedef enum 31 | { 32 | ev_keydown, 33 | ev_keyup, 34 | ev_mouse, 35 | ev_joystick 36 | } evtype_t; 37 | 38 | // Event structure. 39 | typedef struct 40 | { 41 | evtype_t type; 42 | int data1; // keys / mouse/joystick buttons 43 | int data2; // mouse/joystick x move 44 | int data3; // mouse/joystick y move 45 | } event_t; 46 | 47 | 48 | typedef enum 49 | { 50 | ga_nothing, 51 | ga_loadlevel, 52 | ga_newgame, 53 | ga_loadgame, 54 | ga_savegame, 55 | ga_playdemo, 56 | ga_completed, 57 | ga_victory, 58 | ga_worlddone, 59 | ga_screenshot 60 | } gameaction_t; 61 | 62 | 63 | 64 | // 65 | // Button/action code definitions. 66 | // 67 | typedef enum 68 | { 69 | // Press "Fire". 70 | BT_ATTACK = 1, 71 | // Use button, to open doors, activate switches. 72 | BT_USE = 2, 73 | 74 | // Flag: game events, not really buttons. 75 | BT_SPECIAL = 128, 76 | BT_SPECIALMASK = 3, 77 | 78 | // Flag, weapon change pending. 79 | // If true, the next 3 bits hold weapon num. 80 | BT_CHANGE = 4, 81 | // The 3bit weapon mask and shift, convenience. 82 | BT_WEAPONMASK = (8+16+32), 83 | BT_WEAPONSHIFT = 3, 84 | 85 | // Pause the game. 86 | BTS_PAUSE = 1, 87 | // Save the game at each console. 88 | BTS_SAVEGAME = 2, 89 | 90 | // Savegame slot numbers 91 | // occupy the second byte of buttons. 92 | BTS_SAVEMASK = (4+8+16), 93 | BTS_SAVESHIFT = 2, 94 | 95 | } buttoncode_t; 96 | 97 | 98 | 99 | 100 | // 101 | // GLOBAL VARIABLES 102 | // 103 | #define MAXEVENTS 64 104 | 105 | extern event_t events[MAXEVENTS]; 106 | extern int eventhead; 107 | extern int eventtail; 108 | 109 | extern gameaction_t gameaction; 110 | 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /r_state.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Refresh internal data structures, 31 | // for rendering. 32 | // 33 | 34 | // needed for texture pegging 35 | extern fixed_t* textureheight; 36 | 37 | // needed for pre rendering (fracs) 38 | extern fixed_t* spritewidth; 39 | 40 | extern fixed_t* spriteoffset; 41 | extern fixed_t* spritetopoffset; 42 | 43 | extern lighttable_t* colormaps; 44 | 45 | extern int viewwidth; 46 | extern int scaledviewwidth; 47 | extern int viewheight; 48 | 49 | extern int firstflat; 50 | 51 | // for global animation 52 | extern int* flattranslation; 53 | extern int* texturetranslation; 54 | 55 | 56 | // Sprite.... 57 | extern int firstspritelump; 58 | extern int lastspritelump; 59 | extern int numspritelumps; 60 | 61 | 62 | 63 | // 64 | // Lookup tables for map data. 65 | // 66 | extern int numsprites; 67 | extern spritedef_t* sprites; 68 | 69 | extern int numvertexes; 70 | extern vertex_t* vertexes; 71 | 72 | extern int numsegs; 73 | extern seg_t* segs; 74 | 75 | extern int numsectors; 76 | extern sector_t* sectors; 77 | 78 | extern int numsubsectors; 79 | extern subsector_t* subsectors; 80 | 81 | extern int numnodes; 82 | extern node_t* nodes; 83 | 84 | extern int numlines; 85 | extern line_t* lines; 86 | 87 | extern int numsides; 88 | extern side_t* sides; 89 | 90 | 91 | // 92 | // POV data. 93 | // 94 | extern fixed_t viewx; 95 | extern fixed_t viewy; 96 | extern fixed_t viewz; 97 | 98 | extern angle_t viewangle; 99 | extern player_t* viewplayer; 100 | 101 | 102 | // ? 103 | extern angle_t clipangle; 104 | 105 | extern int viewangletox[FINEANGLES/2]; 106 | extern angle_t xtoviewangle[SCREENWIDTH+1]; 107 | //extern fixed_t finetangent[FINEANGLES/2]; 108 | 109 | extern fixed_t rw_distance; 110 | extern angle_t rw_normalangle; 111 | 112 | 113 | 114 | // angle to line origin 115 | extern int rw_angle1; 116 | 117 | // Segs count? 118 | extern int sscount; 119 | 120 | extern visplane_t* floorplane; 121 | extern visplane_t* ceilingplane; 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /MUSIC.H: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------- 2 | /* 3 | Copyright (C) 1996, 2003 - 3D Realms Entertainment 4 | 5 | This file is part of Duke Nukem 3D version 1.5 - Atomic Edition 6 | 7 | Duke Nukem 3D is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation; either version 2 10 | of the License, or (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | 16 | See the GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | 22 | Original Source: 1994 - Jim Dose 23 | Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms 24 | */ 25 | //------------------------------------------------------------------------- 26 | 27 | #ifndef __MUSIC_H 28 | #define __MUSIC_H 29 | 30 | #include "sndcards.h" 31 | 32 | extern int MUSIC_ErrorCode; 33 | 34 | enum MUSIC_ERRORS 35 | { 36 | MUSIC_Warning = -2, 37 | MUSIC_Error = -1, 38 | MUSIC_Ok = 0, 39 | MUSIC_ASSVersion, 40 | MUSIC_SoundCardError, 41 | MUSIC_MPU401Error, 42 | MUSIC_InvalidCard, 43 | MUSIC_MidiError, 44 | MUSIC_TaskManError, 45 | MUSIC_FMNotDetected, 46 | MUSIC_DPMI_Error 47 | }; 48 | 49 | typedef struct 50 | { 51 | unsigned long tickposition; 52 | unsigned long milliseconds; 53 | unsigned int measure; 54 | unsigned int beat; 55 | unsigned int tick; 56 | } songposition; 57 | 58 | #define MUSIC_LoopSong ( 1 == 1 ) 59 | #define MUSIC_PlayOnce ( !MUSIC_LoopSong ) 60 | 61 | char *MUSIC_ErrorString( int ErrorNumber ); 62 | int MUSIC_Init( int SoundCard, int Address ); 63 | int MUSIC_Shutdown( void ); 64 | void MUSIC_SetMaxFMMidiChannel( int channel ); 65 | void MUSIC_SetVolume( int volume ); 66 | void MUSIC_SetMidiChannelVolume( int channel, int volume ); 67 | void MUSIC_ResetMidiChannelVolumes( void ); 68 | int MUSIC_GetVolume( void ); 69 | void MUSIC_SetLoopFlag( int loopflag ); 70 | int MUSIC_SongPlaying( void ); 71 | void MUSIC_Continue( void ); 72 | void MUSIC_Pause( void ); 73 | int MUSIC_StopSong( void ); 74 | int MUSIC_PlaySong( unsigned char *song, int loopflag ); 75 | void MUSIC_SetContext( int context ); 76 | int MUSIC_GetContext( void ); 77 | void MUSIC_SetSongTick( unsigned long PositionInTicks ); 78 | void MUSIC_SetSongTime( unsigned long milliseconds ); 79 | void MUSIC_SetSongPosition( int measure, int beat, int tick ); 80 | void MUSIC_GetSongPosition( songposition *pos ); 81 | void MUSIC_GetSongLength( songposition *pos ); 82 | int MUSIC_FadeVolume( int tovolume, int milliseconds ); 83 | int MUSIC_FadeActive( void ); 84 | void MUSIC_StopFade( void ); 85 | void MUSIC_RerouteMidiChannel( int channel, int cdecl ( *function )( int event, int c1, int c2 ) ); 86 | void MUSIC_RegisterTimbreBank( unsigned char *timbres ); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /i_ibm_a.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 1993-1996 Id Software, Inc. 3 | ; Copyright (C) 1993-2008 Raven Software 4 | ; Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | ; IBM DOS VGA graphics and key/mouse/joystick. 18 | ; 19 | .386 20 | .MODEL small 21 | 22 | .DATA 23 | 24 | 25 | 26 | .CODE 27 | 28 | IF 0 29 | #define PEL_WRITE_ADR 0x3c8 30 | #define PEL_READ_ADR 0x3c7 31 | #define PEL_DATA 0x3c9 32 | ENDIF 33 | 34 | ; 35 | ; I_DivException 36 | ; 37 | 38 | PROC I_DivException_ 39 | PUBLIC I_DivException_ 40 | mov edx,03c9h 41 | mov al,63 42 | out dx,al 43 | 44 | mov ebx,0ffffffh 45 | mov eax,[ebx] 46 | retf 47 | ENDP 48 | 49 | ; 50 | ; I_SetDivException 51 | ; 52 | 53 | PROC I_SetDivException_ 54 | PUBLIC I_SetDivException_ 55 | pusha 56 | 57 | mov eax,0212h 58 | mov ebx,0 59 | mov ecx,cs 60 | mov edx,OFFSET I_DivException_ 61 | int 31h 62 | jnc good 63 | 64 | popa 65 | mov eax,0 66 | ret 67 | 68 | good: 69 | popa 70 | mov eax,1 71 | ret 72 | 73 | ENDP 74 | 75 | 76 | ; 77 | ; I_ReadJoystick 78 | ; 79 | ; Read the absolute joystick values 80 | ; returns false if not connected 81 | ; 82 | 83 | .data 84 | 85 | _joystickx dd 0 86 | _joysticky dd 0 87 | PUBLIC _joystickx, _joysticky 88 | 89 | .code 90 | 91 | PROC I_ReadJoystick_ 92 | PUBLIC I_ReadJoystick_ 93 | pusha 94 | pushf ; state of interrupt flag 95 | cli 96 | 97 | mov dx,0201h 98 | in al,dx 99 | out dx,al ; Clear the resistors 100 | 101 | mov ah,1 ; Get masks into registers 102 | mov ch,2 103 | 104 | xor esi,esi ; Clear count registers 105 | xor edi,edi 106 | xor ebx,ebx ; Clear high byte of bx for later 107 | 108 | mov ebp,10000 ; joystick is disconnected if value is this big 109 | 110 | jloop: 111 | in al,dx ; Get bits indicating whether all are finished 112 | 113 | dec ebp ; Check bounding register 114 | jz bad ; We have a silly value - abort 115 | 116 | mov bl,al ; Duplicate the bits 117 | and bl,ah ; Mask off useless bits (in [xb]) 118 | add esi,ebx ; Possibly increment count register 119 | mov cl,bl ; Save for testing later 120 | 121 | mov bl,al 122 | and bl,ch ; [yb] 123 | add edi,ebx 124 | 125 | add cl,bl 126 | jnz jloop ; If both bits were 0, drop out 127 | 128 | done: 129 | mov [_joystickx],esi 130 | shr edi,1 ; because 2s were added 131 | mov [_joysticky],edi 132 | 133 | popf ; restore interrupt flag 134 | popa 135 | mov eax,1 ; read was ok 136 | ret 137 | 138 | bad: 139 | popf ; restore interrupt flag 140 | popa 141 | xor eax, eax ; read was bad 142 | ret 143 | 144 | ENDP 145 | 146 | 147 | END 148 | 149 | -------------------------------------------------------------------------------- /p_telept.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #include "doomdef.h" 22 | 23 | #include "s_sound.h" 24 | 25 | #include "p_local.h" 26 | 27 | 28 | // Data. 29 | #include "sounds.h" 30 | 31 | // State. 32 | #include "r_state.h" 33 | 34 | 35 | 36 | // 37 | // TELEPORTATION 38 | // 39 | int 40 | EV_Teleport 41 | ( line_t* line, 42 | int side, 43 | mobj_t* thing ) 44 | { 45 | int i; 46 | int tag; 47 | mobj_t* m; 48 | mobj_t* fog; 49 | unsigned an; 50 | thinker_t* thinker; 51 | sector_t* sector; 52 | fixed_t oldx; 53 | fixed_t oldy; 54 | fixed_t oldz; 55 | 56 | // don't teleport missiles 57 | if (thing->flags & MF_MISSILE) 58 | return 0; 59 | 60 | // Don't teleport if hit back of line, 61 | // so you can get out of teleporter. 62 | if (side == 1) 63 | return 0; 64 | 65 | 66 | tag = line->tag; 67 | for (i = 0; i < numsectors; i++) 68 | { 69 | if (sectors[ i ].tag == tag ) 70 | { 71 | thinker = thinkercap.next; 72 | for (thinker = thinkercap.next; 73 | thinker != &thinkercap; 74 | thinker = thinker->next) 75 | { 76 | // not a mobj 77 | if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) 78 | continue; 79 | 80 | m = (mobj_t *)thinker; 81 | 82 | // not a teleportman 83 | if (m->type != MT_TELEPORTMAN ) 84 | continue; 85 | 86 | sector = m->subsector->sector; 87 | // wrong sector 88 | if (sector-sectors != i ) 89 | continue; 90 | 91 | oldx = thing->x; 92 | oldy = thing->y; 93 | oldz = thing->z; 94 | 95 | if (!P_TeleportMove (thing, m->x, m->y)) 96 | return 0; 97 | #if (EXE_VERSION != EXE_VERSION_FINAL) 98 | thing->z = thing->floorz; //fixme: not needed? 99 | #endif 100 | if (thing->player) 101 | thing->player->viewz = thing->z+thing->player->viewheight; 102 | 103 | // spawn teleport fog at source and destination 104 | fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 105 | S_StartSound (fog, sfx_telept); 106 | an = m->angle >> ANGLETOFINESHIFT; 107 | fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] 108 | , thing->z, MT_TFOG); 109 | 110 | // emit sound, where? 111 | S_StartSound (fog, sfx_telept); 112 | 113 | // don't move for a bit 114 | if (thing->player) 115 | thing->reactiontime = 18; 116 | 117 | thing->angle = m->angle; 118 | thing->momx = thing->momy = thing->momz = 0; 119 | return 1; 120 | } 121 | } 122 | } 123 | return 0; 124 | } 125 | 126 | -------------------------------------------------------------------------------- /p_tick.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #include "z_zone.h" 21 | #include "p_local.h" 22 | 23 | #include "doomstat.h" 24 | 25 | 26 | int leveltime; 27 | 28 | // 29 | // THINKERS 30 | // All thinkers should be allocated by Z_Malloc 31 | // so they can be operated on uniformly. 32 | // The actual structures will vary in size, 33 | // but the first element must be thinker_t. 34 | // 35 | 36 | 37 | 38 | // Both the head and tail of the thinker list. 39 | thinker_t thinkercap; 40 | 41 | 42 | // 43 | // P_InitThinkers 44 | // 45 | void P_InitThinkers (void) 46 | { 47 | thinkercap.prev = thinkercap.next = &thinkercap; 48 | } 49 | 50 | 51 | 52 | 53 | // 54 | // P_AddThinker 55 | // Adds a new thinker at the end of the list. 56 | // 57 | void P_AddThinker (thinker_t* thinker) 58 | { 59 | thinkercap.prev->next = thinker; 60 | thinker->next = &thinkercap; 61 | thinker->prev = thinkercap.prev; 62 | thinkercap.prev = thinker; 63 | } 64 | 65 | 66 | 67 | // 68 | // P_RemoveThinker 69 | // Deallocation is lazy -- it will not actually be freed 70 | // until its thinking turn comes up. 71 | // 72 | void P_RemoveThinker (thinker_t* thinker) 73 | { 74 | // FIXME: NOP. 75 | thinker->function.acv = (actionf_v)(-1); 76 | } 77 | 78 | 79 | 80 | // 81 | // P_AllocateThinker 82 | // Allocates memory and adds a new thinker at the end of the list. 83 | // 84 | void P_AllocateThinker (thinker_t* thinker) 85 | { 86 | } 87 | 88 | 89 | 90 | // 91 | // P_RunThinkers 92 | // 93 | void P_RunThinkers (void) 94 | { 95 | thinker_t* currentthinker; 96 | 97 | currentthinker = thinkercap.next; 98 | while (currentthinker != &thinkercap) 99 | { 100 | if ( currentthinker->function.acv == (actionf_v)(-1) ) 101 | { 102 | // time to remove it 103 | currentthinker->next->prev = currentthinker->prev; 104 | currentthinker->prev->next = currentthinker->next; 105 | Z_Free (currentthinker); 106 | } 107 | else 108 | { 109 | if (currentthinker->function.acp1) 110 | currentthinker->function.acp1 (currentthinker); 111 | } 112 | currentthinker = currentthinker->next; 113 | } 114 | } 115 | 116 | 117 | 118 | // 119 | // P_Ticker 120 | // 121 | 122 | void P_Ticker (void) 123 | { 124 | int i; 125 | 126 | // run the tic 127 | if (paused) 128 | return; 129 | 130 | // pause if in menu and at least one tic has been run 131 | if ( !netgame 132 | && menuactive 133 | && !demoplayback 134 | && players[consoleplayer].viewz != 1) 135 | { 136 | return; 137 | } 138 | 139 | 140 | for (i=0 ; istart = list->end = NULL; 28 | return list; 29 | } 30 | 31 | lnode_t* dll_AddEndNode(list_t* list, void* value) 32 | { 33 | lnode_t* node; 34 | 35 | if (!list) 36 | { 37 | I_Error("Bad list in dll_AddEndNode"); 38 | } 39 | 40 | node = (lnode_t*)Z_Malloc(sizeof(lnode_t), PU_STATIC, 0); 41 | 42 | node->value = value; 43 | node->next = NULL; 44 | node->prev = list->end; 45 | 46 | if (list->end) 47 | { 48 | list->end->next = node; 49 | } 50 | else 51 | { 52 | list->start = node; 53 | } 54 | 55 | list->end = node; 56 | 57 | return node; 58 | } 59 | 60 | lnode_t* dll_AddStartNode(list_t* list, void* value) 61 | { 62 | lnode_t* node; 63 | 64 | if (!list) 65 | { 66 | I_Error("Bad list in dll_AddStartNode"); 67 | } 68 | 69 | node = (lnode_t*)Z_Malloc(sizeof(lnode_t), PU_STATIC, 0); 70 | 71 | node->value = value; 72 | node->prev = NULL; 73 | node->next = list->start; 74 | 75 | if (list->start) 76 | { 77 | list->start->next = node; 78 | } 79 | else 80 | { 81 | list->end = node; 82 | } 83 | 84 | list->start = node; 85 | 86 | return node; 87 | } 88 | 89 | void* dll_DelNode(list_t* list, lnode_t* node) 90 | { 91 | void* value; 92 | if (!list) 93 | { 94 | I_Error("Bad list in dll_DelNode"); 95 | } 96 | if (!list->start) 97 | { 98 | I_Error("Empty list in dll_DelNode"); 99 | } 100 | value = node->value; 101 | if (node->prev) 102 | { 103 | node->prev->next = node->next; 104 | } 105 | if (node->next) 106 | { 107 | node->next->prev = node->prev; 108 | } 109 | if (node == list->start) 110 | { 111 | list->start = node->next; 112 | } 113 | if (node == list->end) 114 | { 115 | list->end = node->prev; 116 | } 117 | Z_Free(node); 118 | return value; 119 | } 120 | 121 | void* dll_DelEndNode(list_t* list) 122 | { 123 | return dll_DelNode(list, list->end); 124 | } 125 | 126 | void* dll_DelStartNode(list_t* list) 127 | { 128 | return dll_DelNode(list, list->start); 129 | } 130 | 131 | // 132 | // CHEAT SEQUENCE PACKAGE 133 | // 134 | 135 | static int firsttime = 1; 136 | static unsigned char cheat_xlate_table[256]; 137 | 138 | 139 | // 140 | // Called in st_stuff module, which handles the input. 141 | // Returns a 1 if the cheat was successful, 0 if failed. 142 | // 143 | int 144 | cht_CheckCheat 145 | ( cheatseq_t* cht, 146 | char key ) 147 | { 148 | int i; 149 | int rc = 0; 150 | 151 | if (firsttime) 152 | { 153 | firsttime = 0; 154 | for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i); 155 | } 156 | 157 | if (!cht->p) 158 | cht->p = cht->sequence; // initialize if first time 159 | 160 | if (*cht->p == 0) 161 | *(cht->p++) = key; 162 | else if 163 | (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; 164 | else 165 | cht->p = cht->sequence; 166 | 167 | if (*cht->p == 1) 168 | cht->p++; 169 | else if (*cht->p == 0xff) // end of sequence character 170 | { 171 | cht->p = cht->sequence; 172 | rc = 1; 173 | } 174 | 175 | return rc; 176 | } 177 | 178 | void 179 | cht_GetParam 180 | ( cheatseq_t* cht, 181 | char* buffer ) 182 | { 183 | 184 | unsigned char *p, c; 185 | 186 | p = cht->sequence; 187 | while (*(p++) != 1); 188 | 189 | do 190 | { 191 | c = *p; 192 | *(buffer++) = c; 193 | *(p++) = 0; 194 | } 195 | while (c && *p!=0xff ); 196 | 197 | if (*p==0xff) 198 | *buffer = 0; 199 | 200 | } 201 | 202 | 203 | -------------------------------------------------------------------------------- /hu_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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: none 16 | // 17 | 18 | #ifndef __HULIB__ 19 | #define __HULIB__ 20 | 21 | // We are referring to patches. 22 | #include "r_defs.h" 23 | 24 | 25 | // background and foreground screen numbers 26 | // different from other modules. 27 | #define BG 1 28 | #define FG 0 29 | 30 | // font stuff 31 | #define HU_CHARERASE KEY_BACKSPACE 32 | 33 | #define HU_MAXLINES 4 34 | #define HU_MAXLINELENGTH 80 35 | 36 | // 37 | // Typedefs of widgets 38 | // 39 | 40 | // Text Line widget 41 | // (parent of Scrolling Text and Input Text widgets) 42 | typedef struct 43 | { 44 | // left-justified position of scrolling text window 45 | int x; 46 | int y; 47 | 48 | patch_t** f; // font 49 | int sc; // start character 50 | char l[HU_MAXLINELENGTH+1]; // line of text 51 | int len; // current line length 52 | 53 | // whether this line needs to be udpated 54 | int needsupdate; 55 | 56 | } hu_textline_t; 57 | 58 | 59 | 60 | // Scrolling Text window widget 61 | // (child of Text Line widget) 62 | typedef struct 63 | { 64 | hu_textline_t l[HU_MAXLINES]; // text lines to draw 65 | int h; // height in lines 66 | int cl; // current line number 67 | 68 | // pointer to boolean stating whether to update window 69 | boolean* on; 70 | boolean laston; // last value of *->on. 71 | 72 | } hu_stext_t; 73 | 74 | 75 | 76 | // Input Text Line widget 77 | // (child of Text Line widget) 78 | typedef struct 79 | { 80 | hu_textline_t l; // text line to input on 81 | 82 | // left margin past which I am not to delete characters 83 | int lm; 84 | 85 | // pointer to boolean stating whether to update window 86 | boolean* on; 87 | boolean laston; // last value of *->on; 88 | 89 | } hu_itext_t; 90 | 91 | 92 | // 93 | // Widget creation, access, and update routines 94 | // 95 | 96 | // initializes heads-up widget library 97 | void HUlib_init(void); 98 | 99 | // 100 | // textline code 101 | // 102 | 103 | // clear a line of text 104 | void HUlib_clearTextLine(hu_textline_t *t); 105 | 106 | void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); 107 | 108 | // returns success 109 | boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); 110 | 111 | // returns success 112 | boolean HUlib_delCharFromTextLine(hu_textline_t *t); 113 | 114 | // draws tline 115 | void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); 116 | 117 | // erases text line 118 | void HUlib_eraseTextLine(hu_textline_t *l); 119 | 120 | 121 | // 122 | // Scrolling Text window widget routines 123 | // 124 | 125 | // ? 126 | void 127 | HUlib_initSText 128 | ( hu_stext_t* s, 129 | int x, 130 | int y, 131 | int h, 132 | patch_t** font, 133 | int startchar, 134 | boolean* on ); 135 | 136 | // add a new line 137 | void HUlib_addLineToSText(hu_stext_t* s); 138 | 139 | // ? 140 | void 141 | HUlib_addMessageToSText 142 | ( hu_stext_t* s, 143 | char* prefix, 144 | char* msg ); 145 | 146 | // draws stext 147 | void HUlib_drawSText(hu_stext_t* s); 148 | 149 | // erases all stext lines 150 | void HUlib_eraseSText(hu_stext_t* s); 151 | 152 | // Input Text Line widget routines 153 | void 154 | HUlib_initIText 155 | ( hu_itext_t* it, 156 | int x, 157 | int y, 158 | patch_t** font, 159 | int startchar, 160 | boolean* on ); 161 | 162 | // enforces left margin 163 | void HUlib_delCharFromIText(hu_itext_t* it); 164 | 165 | // enforces left margin 166 | void HUlib_eraseLineFromIText(hu_itext_t* it); 167 | 168 | // resets line and left margin 169 | void HUlib_resetIText(hu_itext_t* it); 170 | 171 | // left of left-margin 172 | void 173 | HUlib_addPrefixToIText 174 | ( hu_itext_t* it, 175 | char* str ); 176 | 177 | // whether eaten 178 | boolean 179 | HUlib_keyInIText 180 | ( hu_itext_t* it, 181 | unsigned char ch ); 182 | 183 | void HUlib_drawIText(hu_itext_t* it); 184 | 185 | // erases all itext lines 186 | void HUlib_eraseIText(hu_itext_t* it); 187 | 188 | #endif 189 | -------------------------------------------------------------------------------- /FX_MAN.H: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 | 13 | See the GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | 19 | */ 20 | /********************************************************************** 21 | module: FX_MAN.H 22 | 23 | author: James R. Dose 24 | date: March 17, 1994 25 | 26 | Public header for FX_MAN.C 27 | 28 | (c) Copyright 1994 James R. Dose. All Rights Reserved. 29 | **********************************************************************/ 30 | 31 | #ifndef __FX_MAN_H 32 | #define __FX_MAN_H 33 | 34 | #include "sndcards.h" 35 | 36 | typedef struct 37 | { 38 | int MaxVoices; 39 | int MaxSampleBits; 40 | int MaxChannels; 41 | } fx_device; 42 | 43 | #define MonoFx 1 44 | #define StereoFx 2 45 | 46 | typedef struct 47 | { 48 | unsigned long Address; 49 | unsigned long Type; 50 | unsigned long Interrupt; 51 | unsigned long Dma8; 52 | unsigned long Dma16; 53 | unsigned long Midi; 54 | unsigned long Emu; 55 | } fx_blaster_config; 56 | 57 | enum FX_ERRORS 58 | { 59 | FX_Warning = -2, 60 | FX_Error = -1, 61 | FX_Ok = 0, 62 | FX_ASSVersion, 63 | FX_BlasterError, 64 | FX_SoundCardError, 65 | FX_InvalidCard, 66 | FX_MultiVocError, 67 | FX_DPMI_Error 68 | }; 69 | 70 | enum fx_BLASTER_Types 71 | { 72 | fx_SB = 1, 73 | fx_SBPro = 2, 74 | fx_SB20 = 3, 75 | fx_SBPro2 = 4, 76 | fx_SB16 = 6 77 | }; 78 | 79 | 80 | char *FX_ErrorString( int ErrorNumber ); 81 | int FX_SetupCard( int SoundCard, fx_device *device ); 82 | int FX_GetBlasterSettings( fx_blaster_config *blaster ); 83 | int FX_SetupSoundBlaster( fx_blaster_config blaster, int *MaxVoices, int *MaxSampleBits, int *MaxChannels ); 84 | int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate ); 85 | int FX_Shutdown( void ); 86 | int FX_SetCallBack( void ( *function )( unsigned long ) ); 87 | void FX_SetVolume( int volume ); 88 | int FX_GetVolume( void ); 89 | 90 | void FX_SetReverseStereo( int setting ); 91 | int FX_GetReverseStereo( void ); 92 | void FX_SetReverb( int reverb ); 93 | void FX_SetFastReverb( int reverb ); 94 | int FX_GetMaxReverbDelay( void ); 95 | int FX_GetReverbDelay( void ); 96 | void FX_SetReverbDelay( int delay ); 97 | 98 | int FX_VoiceAvailable( int priority ); 99 | int FX_EndLooping( int handle ); 100 | int FX_SetPan( int handle, int vol, int left, int right ); 101 | int FX_SetPitch( int handle, int pitchoffset ); 102 | int FX_SetFrequency( int handle, int frequency ); 103 | 104 | int FX_PlayVOC( char *ptr, int pitchoffset, int vol, int left, int right, 105 | int priority, unsigned long callbackval ); 106 | int FX_PlayLoopedVOC( char *ptr, long loopstart, long loopend, 107 | int pitchoffset, int vol, int left, int right, int priority, 108 | unsigned long callbackval ); 109 | int FX_PlayWAV( char *ptr, int pitchoffset, int vol, int left, int right, 110 | int priority, unsigned long callbackval ); 111 | int FX_PlayLoopedWAV( char *ptr, long loopstart, long loopend, 112 | int pitchoffset, int vol, int left, int right, int priority, 113 | unsigned long callbackval ); 114 | int FX_PlayVOC3D( char *ptr, int pitchoffset, int angle, int distance, 115 | int priority, unsigned long callbackval ); 116 | int FX_PlayWAV3D( char *ptr, int pitchoffset, int angle, int distance, 117 | int priority, unsigned long callbackval ); 118 | int FX_PlayRaw( char *ptr, unsigned long length, unsigned rate, 119 | int pitchoffset, int vol, int left, int right, int priority, 120 | unsigned long callbackval ); 121 | int FX_PlayLoopedRaw( char *ptr, unsigned long length, char *loopstart, 122 | char *loopend, unsigned rate, int pitchoffset, int vol, int left, 123 | int right, int priority, unsigned long callbackval ); 124 | int FX_Pan3D( int handle, int angle, int distance ); 125 | int FX_SoundActive( int handle ); 126 | int FX_SoundsPlaying( void ); 127 | int FX_StopSound( int handle ); 128 | int FX_StopAllSounds( void ); 129 | int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), 130 | int rate, int pitchoffset, int vol, int left, int right, 131 | int priority, unsigned long callbackval ); 132 | int FX_StartRecording( int MixRate, void ( *function )( char *ptr, int length ) ); 133 | void FX_StopRecord( void ); 134 | 135 | #endif 136 | -------------------------------------------------------------------------------- /d_player.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | #ifndef __D_PLAYER__ 19 | #define __D_PLAYER__ 20 | 21 | 22 | // The player data structure depends on a number 23 | // of other structs: items (internal inventory), 24 | // animation states (closely tied to the sprites 25 | // used to represent them, unfortunately). 26 | #include "p_pspr.h" 27 | 28 | // In addition, the player is just a special 29 | // case of the generic moving object/actor. 30 | #include "p_mobj.h" 31 | 32 | // Finally, for odd reasons, the player input 33 | // is buffered within the player data struct, 34 | // as commands per game tick. 35 | #include "d_ticcmd.h" 36 | 37 | 38 | 39 | 40 | // 41 | // Player states. 42 | // 43 | typedef enum 44 | { 45 | // Playing or camping. 46 | PST_LIVE, 47 | // Dead on the ground, view follows killer. 48 | PST_DEAD, 49 | // Ready to restart/respawn??? 50 | PST_REBORN 51 | 52 | } playerstate_t; 53 | 54 | 55 | // 56 | // Player internal flags, for cheats and debug. 57 | // 58 | typedef enum 59 | { 60 | // No clipping, walk through barriers. 61 | CF_NOCLIP = 1, 62 | // No damage, no health loss. 63 | CF_GODMODE = 2, 64 | // Not really a cheat, just a debug aid. 65 | CF_NOMOMENTUM = 4 66 | 67 | } cheat_t; 68 | 69 | 70 | // 71 | // Extended player object info: player_t 72 | // 73 | typedef struct player_s 74 | { 75 | mobj_t* mo; 76 | playerstate_t playerstate; 77 | ticcmd_t cmd; 78 | 79 | // Determine POV, 80 | // including viewpoint bobbing during movement. 81 | // Focal origin above r.z 82 | fixed_t viewz; 83 | // Base height above floor for viewz. 84 | fixed_t viewheight; 85 | // Bob/squat speed. 86 | fixed_t deltaviewheight; 87 | // bounded/scaled total momentum. 88 | fixed_t bob; 89 | 90 | // This is only used between levels, 91 | // mo->health is used during levels. 92 | int health; 93 | int armorpoints; 94 | // Armor type is 0-2. 95 | int armortype; 96 | 97 | // Power ups. invinc and invis are tic counters. 98 | int powers[NUMPOWERS]; 99 | boolean cards[NUMCARDS]; 100 | boolean backpack; 101 | 102 | // Frags, kills of other players. 103 | int frags[MAXPLAYERS]; 104 | weapontype_t readyweapon; 105 | 106 | // Is wp_nochange if not changing. 107 | weapontype_t pendingweapon; 108 | 109 | boolean weaponowned[NUMWEAPONS]; 110 | int ammo[NUMAMMO]; 111 | int maxammo[NUMAMMO]; 112 | 113 | // True if button down last tic. 114 | int attackdown; 115 | int usedown; 116 | 117 | // Bit flags, for cheats and debug. 118 | // See cheat_t, above. 119 | int cheats; 120 | 121 | // Refired shots are less accurate. 122 | int refire; 123 | 124 | // For intermission stats. 125 | int killcount; 126 | int itemcount; 127 | int secretcount; 128 | 129 | // Hint messages. 130 | char* message; 131 | 132 | // For screen flashing (red or bright). 133 | int damagecount; 134 | int bonuscount; 135 | 136 | // Who did damage (NULL for floors/ceilings). 137 | mobj_t* attacker; 138 | 139 | // So gun flashes light up areas. 140 | int extralight; 141 | 142 | // Current PLAYPAL, ??? 143 | // can be set to REDCOLORMAP for pain, etc. 144 | int fixedcolormap; 145 | 146 | // Player skin colorshift, 147 | // 0-3 for which color to draw player. 148 | int colormap; 149 | 150 | // Overlay view sprites (gun, etc). 151 | pspdef_t psprites[NUMPSPRITES]; 152 | 153 | // True if secret level has been done. 154 | boolean didsecret; 155 | 156 | } player_t; 157 | 158 | 159 | // 160 | // INTERMISSION 161 | // Structure passed e.g. to WI_Start(wb) 162 | // 163 | typedef struct 164 | { 165 | boolean in; // whether the player is in game 166 | 167 | // Player stats, kills, collected items etc. 168 | int skills; 169 | int sitems; 170 | int ssecret; 171 | int stime; 172 | int frags[4]; 173 | int score; // current score on entry, modified on return 174 | 175 | } wbplayerstruct_t; 176 | 177 | typedef struct 178 | { 179 | int epsd; // episode # (0-2) 180 | 181 | // if true, splash the secret level 182 | boolean didsecret; 183 | 184 | // previous and next levels, origin 0 185 | int last; 186 | int next; 187 | 188 | int maxkills; 189 | int maxitems; 190 | int maxsecret; 191 | int maxfrags; 192 | 193 | // the par time 194 | int partime; 195 | 196 | // index of this player in game 197 | int pnum; 198 | 199 | wbplayerstruct_t plyr[MAXPLAYERS]; 200 | 201 | } wbstartstruct_t; 202 | 203 | 204 | #endif 205 | -------------------------------------------------------------------------------- /i_system.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 1993-2008 Raven Software 4 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 __I_SYSTEM__ 22 | #define __I_SYSTEM__ 23 | 24 | #include "d_ticcmd.h" 25 | #include "d_event.h" 26 | #include "sounds.h" 27 | 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 | 38 | // Called by D_DoomLoop, 39 | // returns current time in tics. 40 | int I_GetTime (void); 41 | 42 | 43 | // 44 | // Called by D_DoomLoop, 45 | // called before processing any tics in a frame 46 | // (just after displaying a frame). 47 | // Time consuming syncronous operations 48 | // are performed here (joystick reading). 49 | // Can call D_PostEvent. 50 | // 51 | void I_StartFrame (void); 52 | 53 | 54 | // 55 | // Called by D_DoomLoop, 56 | // called before processing each tic in a frame. 57 | // Quick syncronous operations are performed here. 58 | // Can call D_PostEvent. 59 | void I_StartTic (void); 60 | 61 | // Asynchronous interrupt functions should maintain private queues 62 | // that are read by the synchronous functions 63 | // to be converted into events. 64 | 65 | // Either returns a null ticcmd, 66 | // or calls a loadable driver to build it. 67 | // This ticcmd will then be modified by the gameloop 68 | // for normal input. 69 | ticcmd_t* I_BaseTiccmd (void); 70 | 71 | 72 | // Called by M_Responder when quit is selected. 73 | // Clean exit, displays sell blurb. 74 | void I_Quit (void); 75 | 76 | 77 | // Allocates from low memory under dos, 78 | // just mallocs under unix 79 | byte* I_AllocLow (int length); 80 | 81 | void I_Tactile (int on, int off, int total); 82 | 83 | 84 | void I_Error (char *error, ...); 85 | 86 | void I_BeginRead(void); 87 | void I_EndRead(void); 88 | 89 | // 90 | // MUSIC I/O 91 | // 92 | 93 | int I_RegisterSong(void *data); 94 | // called by anything that wants to register a song lump with the sound lib 95 | // calls Paul's function of the similar name to register music only. 96 | // note that the song data is the same for any sound card and is paul's 97 | // MUS format. Returns a handle which will be passed to all other music 98 | // functions. 99 | 100 | void I_UnRegisterSong(int handle); 101 | // called by anything which is finished with a song and no longer needs 102 | // the sound library to be aware of it. All songs should be stopped 103 | // before calling this, but it will double check and stop it if necessary. 104 | 105 | void I_LoopSong(int handle); 106 | // called by anything that wishes to start music. 107 | // plays a song, and when the song is done, starts playing it again in 108 | // an endless loop. the start is faded in over three seconds. 109 | 110 | void I_StopSong(int handle); 111 | // called by anything that wishes to stop music. 112 | // stops a song abruptly. 113 | void I_SetMusicVolume(int volume); 114 | void I_ResumeSong(int handle); 115 | void I_PlaySong(int handle, boolean looping); 116 | void I_PauseSong(int handle); 117 | void I_ResumeSong(int handle); 118 | 119 | // SFX I/O 120 | // 121 | 122 | int I_GetSfxLumpNum(sfxinfo_t* sfx); 123 | // called by routines which wish to play a sound effect at some later 124 | // time. Pass it the lump name of a sound effect WITHOUT the sfx 125 | // prefix. This means the maximum name length is 7 letters/digits. 126 | // The prefixes for different sound cards are 'S','M','A', and 'P'. 127 | // They refer to the card type. The routine will cache in the 128 | // appropriate sound effect when it is played. 129 | 130 | int I_StartSound (int id, void *data, int vol, int sep, int pitch, int priority); 131 | // Starts a sound in a particular sound channel 132 | 133 | void I_UpdateSoundParams(int handle, int vol, int sep, int pitch); 134 | // Updates the volume, separation, and pitch of a sound channel 135 | 136 | void I_StopSound(int handle); 137 | // Stops a sound channel 138 | 139 | int I_SoundIsPlaying(int handle); 140 | // called by S_*()'s to see if a channel is still playing. Returns 0 141 | // if no longer playing, 1 if playing. 142 | void I_SetChannels(int channels); 143 | 144 | // Called by D_DoomMain, 145 | // determines the hardware configuration 146 | // and sets up the video mode 147 | void I_InitGraphics(void); 148 | 149 | 150 | void I_ShutdownGraphics(void); 151 | 152 | // Takes full 8 bit values. 153 | void I_SetPalette(byte* palette); 154 | 155 | void I_UpdateNoBlit(void); 156 | void I_FinishUpdate(void); 157 | 158 | // Wait for vertical retrace or pause a bit. 159 | void I_WaitVBL(int count); 160 | 161 | void I_ReadScreen(byte* scr); 162 | 163 | void I_BeginRead(void); 164 | void I_EndRead(void); 165 | 166 | 167 | // Called by D_DoomMain. 168 | void I_InitNetwork(void); 169 | void I_NetCmd(void); 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /doomdata.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // all external data is defined here 17 | // most of the data is loaded into different structures at run time 18 | // some internal structures shared by many modules are here 19 | // 20 | 21 | #ifndef __DOOMDATA__ 22 | #define __DOOMDATA__ 23 | 24 | // The most basic types we use, portability. 25 | #include "doomtype.h" 26 | 27 | // Some global defines, that configure the game. 28 | #include "doomdef.h" 29 | 30 | 31 | 32 | // 33 | // Map level types. 34 | // The following data structures define the persistent format 35 | // used in the lumps of the WAD files. 36 | // 37 | 38 | // Lump order in a map WAD: each map needs a couple of lumps 39 | // to provide a complete scene geometry description. 40 | enum 41 | { 42 | ML_LABEL, // A separator, name, ExMx or MAPxx 43 | ML_THINGS, // Monsters, items.. 44 | ML_LINEDEFS, // LineDefs, from editing 45 | ML_SIDEDEFS, // SideDefs, from editing 46 | ML_VERTEXES, // Vertices, edited and BSP splits generated 47 | ML_SEGS, // LineSegs, from LineDefs split by BSP 48 | ML_SSECTORS, // SubSectors, list of LineSegs 49 | ML_NODES, // BSP nodes 50 | ML_SECTORS, // Sectors, from editing 51 | ML_REJECT, // LUT, sector-sector visibility 52 | ML_BLOCKMAP // LUT, motion clipping, walls/grid element 53 | }; 54 | 55 | 56 | // A single Vertex. 57 | typedef struct 58 | { 59 | short x; 60 | short y; 61 | } mapvertex_t; 62 | 63 | 64 | // A SideDef, defining the visual appearance of a wall, 65 | // by setting textures and offsets. 66 | typedef struct 67 | { 68 | short textureoffset; 69 | short rowoffset; 70 | char toptexture[8]; 71 | char bottomtexture[8]; 72 | char midtexture[8]; 73 | // Front sector, towards viewer. 74 | short sector; 75 | } mapsidedef_t; 76 | 77 | 78 | 79 | // A LineDef, as used for editing, and as input 80 | // to the BSP builder. 81 | typedef struct 82 | { 83 | short v1; 84 | short v2; 85 | short flags; 86 | short special; 87 | short tag; 88 | // sidenum[1] will be -1 if one sided 89 | short sidenum[2]; 90 | } maplinedef_t; 91 | 92 | 93 | // 94 | // LineDef attributes. 95 | // 96 | 97 | // Solid, is an obstacle. 98 | #define ML_BLOCKING 1 99 | 100 | // Blocks monsters only. 101 | #define ML_BLOCKMONSTERS 2 102 | 103 | // Backside will not be present at all 104 | // if not two sided. 105 | #define ML_TWOSIDED 4 106 | 107 | // If a texture is pegged, the texture will have 108 | // the end exposed to air held constant at the 109 | // top or bottom of the texture (stairs or pulled 110 | // down things) and will move with a height change 111 | // of one of the neighbor sectors. 112 | // Unpegged textures allways have the first row of 113 | // the texture at the top pixel of the line for both 114 | // top and bottom textures (use next to windows). 115 | 116 | // upper texture unpegged 117 | #define ML_DONTPEGTOP 8 118 | 119 | // lower texture unpegged 120 | #define ML_DONTPEGBOTTOM 16 121 | 122 | // In AutoMap: don't map as two sided: IT'S A SECRET! 123 | #define ML_SECRET 32 124 | 125 | // Sound rendering: don't let sound cross two of these. 126 | #define ML_SOUNDBLOCK 64 127 | 128 | // Don't draw on the automap at all. 129 | #define ML_DONTDRAW 128 130 | 131 | // Set if already seen, thus drawn in automap. 132 | #define ML_MAPPED 256 133 | 134 | 135 | 136 | 137 | // Sector definition, from editing. 138 | typedef struct 139 | { 140 | short floorheight; 141 | short ceilingheight; 142 | char floorpic[8]; 143 | char ceilingpic[8]; 144 | short lightlevel; 145 | short special; 146 | short tag; 147 | } mapsector_t; 148 | 149 | // SubSector, as generated by BSP. 150 | typedef struct 151 | { 152 | short numsegs; 153 | // Index of first one, segs are stored sequentially. 154 | short firstseg; 155 | } mapsubsector_t; 156 | 157 | 158 | // LineSeg, generated by splitting LineDefs 159 | // using partition lines selected by BSP builder. 160 | typedef struct 161 | { 162 | short v1; 163 | short v2; 164 | short angle; 165 | short linedef; 166 | short side; 167 | short offset; 168 | } mapseg_t; 169 | 170 | 171 | 172 | // BSP node structure. 173 | 174 | // Indicate a leaf. 175 | #define NF_SUBSECTOR 0x8000 176 | 177 | typedef struct 178 | { 179 | // Partition line from (x,y) to x+dx,y+dy) 180 | short x; 181 | short y; 182 | short dx; 183 | short dy; 184 | 185 | // Bounding box for each child, 186 | // clip against view frustum. 187 | short bbox[2][4]; 188 | 189 | // If NF_SUBSECTOR its a subsector, 190 | // else it's a node of another subtree. 191 | unsigned short children[2]; 192 | 193 | } mapnode_t; 194 | 195 | 196 | 197 | 198 | // Thing definition, position, orientation and type, 199 | // plus skill/visibility flags and attributes. 200 | typedef struct 201 | { 202 | short x; 203 | short y; 204 | short angle; 205 | short type; 206 | short options; 207 | } mapthing_t; 208 | 209 | 210 | 211 | 212 | 213 | #endif // __DOOMDATA__ 214 | -------------------------------------------------------------------------------- /st_lib.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 status bar widget code. 17 | // 18 | #include 19 | 20 | #include "doomdef.h" 21 | 22 | #include "z_zone.h" 23 | #include "v_video.h" 24 | 25 | #include "i_system.h" 26 | 27 | #include "w_wad.h" 28 | 29 | #include "st_stuff.h" 30 | #include "st_lib.h" 31 | #include "r_local.h" 32 | 33 | 34 | // in AM_map.c 35 | extern boolean automapactive; 36 | 37 | 38 | 39 | 40 | // 41 | // Hack display negative frags. 42 | // Loads and store the stminus lump. 43 | // 44 | patch_t* sttminus; 45 | 46 | void STlib_init(void) 47 | { 48 | sttminus = (patch_t *) W_CacheLumpName("STTMINUS", PU_STATIC); 49 | } 50 | 51 | 52 | // ? 53 | void 54 | STlib_initNum 55 | ( st_number_t* n, 56 | int x, 57 | int y, 58 | patch_t** pl, 59 | int* num, 60 | boolean* on, 61 | int width ) 62 | { 63 | n->x = x; 64 | n->y = y; 65 | n->oldnum = 0; 66 | n->width = width; 67 | n->num = num; 68 | n->on = on; 69 | n->p = pl; 70 | } 71 | 72 | 73 | // 74 | // A fairly efficient way to draw a number 75 | // based on differences from the old number. 76 | // Note: worth the trouble? 77 | // 78 | void 79 | STlib_drawNum 80 | ( st_number_t* n, 81 | boolean refresh ) 82 | { 83 | 84 | int numdigits = n->width; 85 | int num = *n->num; 86 | 87 | int w = SHORT(n->p[0]->width); 88 | int h = SHORT(n->p[0]->height); 89 | int x = n->x; 90 | 91 | int neg; 92 | 93 | n->oldnum = *n->num; 94 | 95 | neg = num < 0; 96 | 97 | if (neg) 98 | { 99 | if (numdigits == 2 && num < -9) 100 | num = -9; 101 | else if (numdigits == 3 && num < -99) 102 | num = -99; 103 | 104 | num = -num; 105 | } 106 | 107 | // clear the area 108 | x = n->x - numdigits*w; 109 | 110 | if (n->y - ST_Y < 0) 111 | I_Error("drawNum: n->y - ST_Y < 0"); 112 | 113 | V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG); 114 | 115 | // if non-number, do not draw it 116 | if (num == 1994) 117 | return; 118 | 119 | x = n->x; 120 | 121 | // in the special case of 0, you draw 0 122 | if (!num) 123 | V_DrawPatch(x - w, n->y, FG, n->p[ 0 ]); 124 | 125 | // draw the new number 126 | while (num && numdigits--) 127 | { 128 | x -= w; 129 | V_DrawPatch(x, n->y, FG, n->p[ num % 10 ]); 130 | num /= 10; 131 | } 132 | 133 | // draw a minus sign if necessary 134 | if (neg) 135 | V_DrawPatch(x - 8, n->y, FG, sttminus); 136 | } 137 | 138 | 139 | // 140 | void 141 | STlib_updateNum 142 | ( st_number_t* n, 143 | boolean refresh ) 144 | { 145 | if (*n->on) STlib_drawNum(n, refresh); 146 | } 147 | 148 | 149 | // 150 | void 151 | STlib_initPercent 152 | ( st_percent_t* p, 153 | int x, 154 | int y, 155 | patch_t** pl, 156 | int* num, 157 | boolean* on, 158 | patch_t* percent ) 159 | { 160 | STlib_initNum(&p->n, x, y, pl, num, on, 3); 161 | p->p = percent; 162 | } 163 | 164 | 165 | 166 | 167 | void 168 | STlib_updatePercent 169 | ( st_percent_t* per, 170 | int refresh ) 171 | { 172 | if (refresh && *per->n.on) 173 | V_DrawPatch(per->n.x, per->n.y, FG, per->p); 174 | 175 | STlib_updateNum(&per->n, refresh); 176 | } 177 | 178 | 179 | 180 | void 181 | STlib_initMultIcon 182 | ( st_multicon_t* i, 183 | int x, 184 | int y, 185 | patch_t** il, 186 | int* inum, 187 | boolean* on ) 188 | { 189 | i->x = x; 190 | i->y = y; 191 | i->oldinum = -1; 192 | i->inum = inum; 193 | i->on = on; 194 | i->p = il; 195 | } 196 | 197 | 198 | 199 | void 200 | STlib_updateMultIcon 201 | ( st_multicon_t* mi, 202 | boolean refresh ) 203 | { 204 | int w; 205 | int h; 206 | int x; 207 | int y; 208 | 209 | if (*mi->on 210 | && (mi->oldinum != *mi->inum || refresh) 211 | && (*mi->inum!=-1)) 212 | { 213 | if (mi->oldinum != -1) 214 | { 215 | x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset); 216 | y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset); 217 | w = SHORT(mi->p[mi->oldinum]->width); 218 | h = SHORT(mi->p[mi->oldinum]->height); 219 | 220 | if (y - ST_Y < 0) 221 | I_Error("updateMultIcon: y - ST_Y < 0"); 222 | 223 | V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); 224 | } 225 | V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]); 226 | mi->oldinum = *mi->inum; 227 | } 228 | } 229 | 230 | 231 | 232 | void 233 | STlib_initBinIcon 234 | ( st_binicon_t* b, 235 | int x, 236 | int y, 237 | patch_t* i, 238 | boolean* val, 239 | boolean* on ) 240 | { 241 | b->x = x; 242 | b->y = y; 243 | b->oldval = 0; 244 | b->val = val; 245 | b->on = on; 246 | b->p = i; 247 | } 248 | 249 | 250 | 251 | void 252 | STlib_updateBinIcon 253 | ( st_binicon_t* bi, 254 | boolean refresh ) 255 | { 256 | int x; 257 | int y; 258 | int w; 259 | int h; 260 | 261 | if (*bi->on 262 | && (bi->oldval != *bi->val || refresh)) 263 | { 264 | x = bi->x - SHORT(bi->p->leftoffset); 265 | y = bi->y - SHORT(bi->p->topoffset); 266 | w = SHORT(bi->p->width); 267 | h = SHORT(bi->p->height); 268 | 269 | if (y - ST_Y < 0) 270 | I_Error("updateBinIcon: y - ST_Y < 0"); 271 | 272 | if (*bi->val) 273 | V_DrawPatch(bi->x, bi->y, FG, bi->p); 274 | else 275 | V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); 276 | 277 | bi->oldval = *bi->val; 278 | } 279 | 280 | } 281 | 282 | -------------------------------------------------------------------------------- /sounds.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Created by the sound utility written by Dave Taylor. 17 | // Kept as a sample, DOOM2 sounds. Frozen. 18 | // 19 | 20 | #ifndef __SOUNDS__ 21 | #define __SOUNDS__ 22 | 23 | 24 | // 25 | // SoundFX struct. 26 | // 27 | typedef struct sfxinfo_struct sfxinfo_t; 28 | 29 | struct sfxinfo_struct 30 | { 31 | // up to 6-character name 32 | char* name; 33 | 34 | // Sfx singularity (only one at a time) 35 | int singularity; 36 | 37 | // Sfx priority 38 | int priority; 39 | 40 | // referenced sound if a link 41 | sfxinfo_t* link; 42 | 43 | // pitch if a link 44 | int pitch; 45 | 46 | // volume if a link 47 | int volume; 48 | 49 | // sound data 50 | void* data; 51 | 52 | // this is checked every second to see if sound 53 | // can be thrown out (if 0, then decrement, if -1, 54 | // then throw out, if > 0, then it is in use) 55 | int usefulness; 56 | 57 | // lump number of sfx 58 | int lumpnum; 59 | }; 60 | 61 | 62 | 63 | 64 | // 65 | // MusicInfo struct. 66 | // 67 | typedef struct 68 | { 69 | // up to 6-character name 70 | char* name; 71 | 72 | // lump number of music 73 | int lumpnum; 74 | 75 | // music data 76 | void* data; 77 | 78 | // music handle once registered 79 | int handle; 80 | 81 | } musicinfo_t; 82 | 83 | 84 | 85 | 86 | // the complete set of sound effects 87 | extern sfxinfo_t S_sfx[]; 88 | 89 | // the complete set of music 90 | extern musicinfo_t S_music[]; 91 | 92 | // 93 | // Identifiers for all music in game. 94 | // 95 | 96 | typedef enum 97 | { 98 | mus_None, 99 | mus_e1m1, 100 | mus_e1m2, 101 | mus_e1m3, 102 | mus_e1m4, 103 | mus_e1m5, 104 | mus_e1m6, 105 | mus_e1m7, 106 | mus_e1m8, 107 | mus_e1m9, 108 | mus_e2m1, 109 | mus_e2m2, 110 | mus_e2m3, 111 | mus_e2m4, 112 | mus_e2m5, 113 | mus_e2m6, 114 | mus_e2m7, 115 | mus_e2m8, 116 | mus_e2m9, 117 | mus_e3m1, 118 | mus_e3m2, 119 | mus_e3m3, 120 | mus_e3m4, 121 | mus_e3m5, 122 | mus_e3m6, 123 | mus_e3m7, 124 | mus_e3m8, 125 | mus_e3m9, 126 | mus_inter, 127 | mus_intro, 128 | mus_bunny, 129 | mus_victor, 130 | mus_introa, 131 | mus_runnin, 132 | mus_stalks, 133 | mus_countd, 134 | mus_betwee, 135 | mus_doom, 136 | mus_the_da, 137 | mus_shawn, 138 | mus_ddtblu, 139 | mus_in_cit, 140 | mus_dead, 141 | mus_stlks2, 142 | mus_theda2, 143 | mus_doom2, 144 | mus_ddtbl2, 145 | mus_runni2, 146 | mus_dead2, 147 | mus_stlks3, 148 | mus_romero, 149 | mus_shawn2, 150 | mus_messag, 151 | mus_count2, 152 | mus_ddtbl3, 153 | mus_ampie, 154 | mus_theda3, 155 | mus_adrian, 156 | mus_messg2, 157 | mus_romer2, 158 | mus_tense, 159 | mus_shawn3, 160 | mus_openin, 161 | mus_evil, 162 | mus_ultima, 163 | mus_read_m, 164 | mus_dm2ttl, 165 | mus_dm2int, 166 | NUMMUSIC 167 | } musicenum_t; 168 | 169 | 170 | // 171 | // Identifiers for all sfx in game. 172 | // 173 | 174 | typedef enum 175 | { 176 | sfx_None, 177 | sfx_pistol, 178 | sfx_shotgn, 179 | sfx_sgcock, 180 | sfx_dshtgn, 181 | sfx_dbopn, 182 | sfx_dbcls, 183 | sfx_dbload, 184 | sfx_plasma, 185 | sfx_bfg, 186 | sfx_sawup, 187 | sfx_sawidl, 188 | sfx_sawful, 189 | sfx_sawhit, 190 | sfx_rlaunc, 191 | sfx_rxplod, 192 | sfx_firsht, 193 | sfx_firxpl, 194 | sfx_pstart, 195 | sfx_pstop, 196 | sfx_doropn, 197 | sfx_dorcls, 198 | sfx_stnmov, 199 | sfx_swtchn, 200 | sfx_swtchx, 201 | sfx_plpain, 202 | sfx_dmpain, 203 | sfx_popain, 204 | sfx_vipain, 205 | sfx_mnpain, 206 | sfx_pepain, 207 | sfx_slop, 208 | sfx_itemup, 209 | sfx_wpnup, 210 | sfx_oof, 211 | sfx_telept, 212 | sfx_posit1, 213 | sfx_posit2, 214 | sfx_posit3, 215 | sfx_bgsit1, 216 | sfx_bgsit2, 217 | sfx_sgtsit, 218 | sfx_cacsit, 219 | sfx_brssit, 220 | sfx_cybsit, 221 | sfx_spisit, 222 | sfx_bspsit, 223 | sfx_kntsit, 224 | sfx_vilsit, 225 | sfx_mansit, 226 | sfx_pesit, 227 | sfx_sklatk, 228 | sfx_sgtatk, 229 | sfx_skepch, 230 | sfx_vilatk, 231 | sfx_claw, 232 | sfx_skeswg, 233 | sfx_pldeth, 234 | sfx_pdiehi, 235 | sfx_podth1, 236 | sfx_podth2, 237 | sfx_podth3, 238 | sfx_bgdth1, 239 | sfx_bgdth2, 240 | sfx_sgtdth, 241 | sfx_cacdth, 242 | sfx_skldth, 243 | sfx_brsdth, 244 | sfx_cybdth, 245 | sfx_spidth, 246 | sfx_bspdth, 247 | sfx_vildth, 248 | sfx_kntdth, 249 | sfx_pedth, 250 | sfx_skedth, 251 | sfx_posact, 252 | sfx_bgact, 253 | sfx_dmact, 254 | sfx_bspact, 255 | sfx_bspwlk, 256 | sfx_vilact, 257 | sfx_noway, 258 | sfx_barexp, 259 | sfx_punch, 260 | sfx_hoof, 261 | sfx_metal, 262 | sfx_chgun, 263 | sfx_tink, 264 | sfx_bdopn, 265 | sfx_bdcls, 266 | sfx_itmbk, 267 | sfx_flame, 268 | sfx_flamst, 269 | sfx_getpow, 270 | sfx_bospit, 271 | sfx_boscub, 272 | sfx_bossit, 273 | sfx_bospn, 274 | sfx_bosdth, 275 | sfx_manatk, 276 | sfx_mandth, 277 | sfx_sssit, 278 | sfx_ssdth, 279 | sfx_keenpn, 280 | sfx_keendt, 281 | sfx_skeact, 282 | sfx_skesit, 283 | sfx_skeatk, 284 | sfx_radio, 285 | NUMSFX 286 | } sfxenum_t; 287 | 288 | #endif 289 | -------------------------------------------------------------------------------- /f_wipe.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 begin melt/wipe screen special effect. 17 | // 18 | 19 | 20 | 21 | #include "z_zone.h" 22 | #include "i_system.h" 23 | #include "v_video.h" 24 | #include "m_misc.h" 25 | 26 | #include "doomdef.h" 27 | 28 | #include "f_wipe.h" 29 | 30 | // 31 | // SCREEN WIPE PACKAGE 32 | // 33 | 34 | // when zero, stop the wipe 35 | static boolean go = 0; 36 | 37 | static byte* wipe_scr_start; 38 | static byte* wipe_scr_end; 39 | static byte* wipe_scr; 40 | 41 | 42 | void 43 | wipe_shittyColMajorXform 44 | ( short* array, 45 | int width, 46 | int height ) 47 | { 48 | int x; 49 | int y; 50 | short* dest; 51 | 52 | dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); 53 | 54 | for(y=0;y *e) 94 | { 95 | newval = *w - ticks; 96 | if (newval < *e) 97 | *w = *e; 98 | else 99 | *w = newval; 100 | changed = true; 101 | } 102 | else if (*w < *e) 103 | { 104 | newval = *w + ticks; 105 | if (newval > *e) 106 | *w = *e; 107 | else 108 | *w = newval; 109 | changed = true; 110 | } 111 | } 112 | w++; 113 | e++; 114 | } 115 | 116 | return !changed; 117 | 118 | } 119 | 120 | int 121 | wipe_exitColorXForm 122 | ( int width, 123 | int height, 124 | int ticks ) 125 | { 126 | return 0; 127 | } 128 | 129 | 130 | static int* y; 131 | 132 | int 133 | wipe_initMelt 134 | ( int width, 135 | int height, 136 | int ticks ) 137 | { 138 | int i, r; 139 | 140 | // copy start screen to main screen 141 | memcpy(wipe_scr, wipe_scr_start, width*height); 142 | 143 | // makes this wipe faster (in theory) 144 | // to have stuff in column-major format 145 | wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); 146 | wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); 147 | 148 | // setup initial column positions 149 | // (y<0 => not ready to scroll yet) 150 | y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0); 151 | y[0] = -(M_Random()%16); 152 | for (i=1;i 0) y[i] = 0; 157 | else if (y[i] == -16) y[i] = -15; 158 | } 159 | 160 | return 0; 161 | } 162 | 163 | int 164 | wipe_doMelt 165 | ( int width, 166 | int height, 167 | int ticks ) 168 | { 169 | int i; 170 | int j; 171 | int dy; 172 | int idx; 173 | 174 | short* s; 175 | short* d; 176 | boolean done = true; 177 | 178 | width/=2; 179 | 180 | while (ticks--) 181 | { 182 | for (i=0;i= height) dy = height - y[i]; 192 | s = &((short *)wipe_scr_end)[i*height+y[i]]; 193 | d = &((short *)wipe_scr)[y[i]*width+i]; 194 | idx = 0; 195 | for (j=dy;j;j--) 196 | { 197 | d[idx] = *(s++); 198 | idx += width; 199 | } 200 | y[i] += dy; 201 | s = &((short *)wipe_scr_start)[i*height]; 202 | d = &((short *)wipe_scr)[y[i]*width+i]; 203 | idx = 0; 204 | for (j=height-y[i];j;j--) 205 | { 206 | d[idx] = *(s++); 207 | idx += width; 208 | } 209 | done = false; 210 | } 211 | } 212 | } 213 | 214 | return done; 215 | 216 | } 217 | 218 | int 219 | wipe_exitMelt 220 | ( int width, 221 | int height, 222 | int ticks ) 223 | { 224 | Z_Free(y); 225 | return 0; 226 | } 227 | 228 | int 229 | wipe_StartScreen 230 | ( int x, 231 | int y, 232 | int width, 233 | int height ) 234 | { 235 | wipe_scr_start = screens[2]; 236 | I_ReadScreen(wipe_scr_start); 237 | return 0; 238 | } 239 | 240 | int 241 | wipe_EndScreen 242 | ( int x, 243 | int y, 244 | int width, 245 | int height ) 246 | { 247 | wipe_scr_end = screens[3]; 248 | I_ReadScreen(wipe_scr_end); 249 | V_DrawBlock(x, y, 0, width, height, wipe_scr_start); // restore start scr. 250 | return 0; 251 | } 252 | 253 | int 254 | wipe_ScreenWipe 255 | ( int wipeno, 256 | int x, 257 | int y, 258 | int width, 259 | int height, 260 | int ticks ) 261 | { 262 | int rc; 263 | static int (*wipes[])(int, int, int) = 264 | { 265 | wipe_initColorXForm, wipe_doColorXForm, wipe_exitColorXForm, 266 | wipe_initMelt, wipe_doMelt, wipe_exitMelt 267 | }; 268 | 269 | void V_MarkRect(int, int, int, int); 270 | 271 | // initial stuff 272 | if (!go) 273 | { 274 | go = 1; 275 | // wipe_scr = (byte *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG 276 | wipe_scr = screens[0]; 277 | (*wipes[wipeno*3])(width, height, ticks); 278 | } 279 | 280 | // do a piece of wipe-in 281 | V_MarkRect(0, 0, width, height); 282 | rc = (*wipes[wipeno*3+1])(width, height, ticks); 283 | // V_DrawBlock(x, y, 0, width, height, wipe_scr); // DEBUG 284 | 285 | // final stuff 286 | if (rc) 287 | { 288 | go = 0; 289 | (*wipes[wipeno*3+2])(width, height, ticks); 290 | } 291 | 292 | return !go; 293 | 294 | } 295 | -------------------------------------------------------------------------------- /p_local.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Play functions, animation, global header. 17 | // 18 | 19 | 20 | #ifndef __P_LOCAL__ 21 | #define __P_LOCAL__ 22 | 23 | #ifndef __R_LOCAL__ 24 | #include "r_local.h" 25 | #endif 26 | 27 | #define FLOATSPEED (FRACUNIT*4) 28 | 29 | 30 | #define MAXHEALTH 100 31 | #define VIEWHEIGHT (41*FRACUNIT) 32 | 33 | // mapblocks are used to check movement 34 | // against lines and things 35 | #define MAPBLOCKUNITS 128 36 | #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) 37 | #define MAPBLOCKSHIFT (FRACBITS+7) 38 | #define MAPBMASK (MAPBLOCKSIZE-1) 39 | #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) 40 | 41 | 42 | // player radius for movement checking 43 | #define PLAYERRADIUS 16*FRACUNIT 44 | 45 | // MAXRADIUS is for precalculated sector block boxes 46 | // the spider demon is larger, 47 | // but we do not have any moving sectors nearby 48 | #define MAXRADIUS 32*FRACUNIT 49 | 50 | #define GRAVITY FRACUNIT 51 | #define MAXMOVE (30*FRACUNIT) 52 | 53 | #define USERANGE (64*FRACUNIT) 54 | #define MELEERANGE (64*FRACUNIT) 55 | #define MISSILERANGE (32*64*FRACUNIT) 56 | 57 | // follow a player exlusively for 3 seconds 58 | #define BASETHRESHOLD 100 59 | 60 | 61 | 62 | // 63 | // P_TICK 64 | // 65 | 66 | // both the head and tail of the thinker list 67 | extern thinker_t thinkercap; 68 | 69 | 70 | void P_InitThinkers (void); 71 | void P_AddThinker (thinker_t* thinker); 72 | void P_RemoveThinker (thinker_t* thinker); 73 | 74 | 75 | // 76 | // P_PSPR 77 | // 78 | void P_SetupPsprites (player_t* curplayer); 79 | void P_MovePsprites (player_t* curplayer); 80 | void P_DropWeapon (player_t* player); 81 | 82 | 83 | // 84 | // P_USER 85 | // 86 | void P_PlayerThink (player_t* player); 87 | 88 | 89 | // 90 | // P_MOBJ 91 | // 92 | #define ONFLOORZ MININT 93 | #define ONCEILINGZ MAXINT 94 | 95 | // Time interval for item respawning. 96 | #define ITEMQUESIZE 128 97 | 98 | extern mapthing_t itemrespawnque[ITEMQUESIZE]; 99 | extern int itemrespawntime[ITEMQUESIZE]; 100 | extern int iquehead; 101 | extern int iquetail; 102 | 103 | 104 | void P_RespawnSpecials (void); 105 | 106 | mobj_t* 107 | P_SpawnMobj 108 | ( fixed_t x, 109 | fixed_t y, 110 | fixed_t z, 111 | mobjtype_t type ); 112 | 113 | void P_RemoveMobj (mobj_t* th); 114 | boolean P_SetMobjState (mobj_t* mobj, statenum_t state); 115 | void P_MobjThinker (mobj_t* mobj); 116 | 117 | void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); 118 | void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); 119 | mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type); 120 | void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type); 121 | 122 | 123 | // 124 | // P_ENEMY 125 | // 126 | void P_NoiseAlert (mobj_t* target, mobj_t* emmiter); 127 | 128 | 129 | // 130 | // P_MAPUTL 131 | // 132 | typedef struct 133 | { 134 | fixed_t x; 135 | fixed_t y; 136 | fixed_t dx; 137 | fixed_t dy; 138 | 139 | } divline_t; 140 | 141 | typedef struct 142 | { 143 | fixed_t frac; // along trace line 144 | boolean isaline; 145 | union { 146 | mobj_t* thing; 147 | line_t* line; 148 | } d; 149 | } intercept_t; 150 | 151 | #define MAXINTERCEPTS 128 152 | 153 | extern intercept_t intercepts[MAXINTERCEPTS]; 154 | extern intercept_t* intercept_p; 155 | 156 | typedef boolean (*traverser_t) (intercept_t *in); 157 | 158 | fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); 159 | int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line); 160 | int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line); 161 | void P_MakeDivline (line_t* li, divline_t* dl); 162 | fixed_t P_InterceptVector (divline_t* v2, divline_t* v1); 163 | int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld); 164 | 165 | extern fixed_t opentop; 166 | extern fixed_t openbottom; 167 | extern fixed_t openrange; 168 | extern fixed_t lowfloor; 169 | 170 | void P_LineOpening (line_t* linedef); 171 | 172 | boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ); 173 | boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) ); 174 | 175 | #define PT_ADDLINES 1 176 | #define PT_ADDTHINGS 2 177 | #define PT_EARLYOUT 4 178 | 179 | extern divline_t trace; 180 | 181 | boolean 182 | P_PathTraverse 183 | ( fixed_t x1, 184 | fixed_t y1, 185 | fixed_t x2, 186 | fixed_t y2, 187 | int flags, 188 | boolean (*trav) (intercept_t *)); 189 | 190 | void P_UnsetThingPosition (mobj_t* thing); 191 | void P_SetThingPosition (mobj_t* thing); 192 | 193 | 194 | // 195 | // P_MAP 196 | // 197 | 198 | // If "floatok" true, move would be ok 199 | // if within "tmfloorz - tmceilingz". 200 | extern boolean floatok; 201 | extern fixed_t tmfloorz; 202 | extern fixed_t tmceilingz; 203 | 204 | 205 | extern line_t* ceilingline; 206 | 207 | boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); 208 | boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y); 209 | boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y); 210 | void P_SlideMove (mobj_t* mo); 211 | boolean P_CheckSight (mobj_t* t1, mobj_t* t2); 212 | void P_UseLines (player_t* player); 213 | 214 | boolean P_ChangeSector (sector_t* sector, boolean crunch); 215 | 216 | extern mobj_t* linetarget; // who got hit (or NULL) 217 | 218 | fixed_t 219 | P_AimLineAttack 220 | ( mobj_t* t1, 221 | angle_t angle, 222 | fixed_t distance ); 223 | 224 | void 225 | P_LineAttack 226 | ( mobj_t* t1, 227 | angle_t angle, 228 | fixed_t distance, 229 | fixed_t slope, 230 | int damage ); 231 | 232 | void 233 | P_RadiusAttack 234 | ( mobj_t* spot, 235 | mobj_t* source, 236 | int damage ); 237 | 238 | 239 | 240 | // 241 | // P_SETUP 242 | // 243 | extern byte* rejectmatrix; // for fast sight rejection 244 | extern short* blockmaplump; // offsets in blockmap are from here 245 | extern short* blockmap; 246 | extern int bmapwidth; 247 | extern int bmapheight; // in mapblocks 248 | extern fixed_t bmaporgx; 249 | extern fixed_t bmaporgy; // origin of block map 250 | extern mobj_t** blocklinks; // for thing chains 251 | 252 | 253 | 254 | // 255 | // P_INTER 256 | // 257 | extern int maxammo[NUMAMMO]; 258 | extern int clipammo[NUMAMMO]; 259 | 260 | void 261 | P_TouchSpecialThing 262 | ( mobj_t* special, 263 | mobj_t* toucher ); 264 | 265 | void 266 | P_DamageMobj 267 | ( mobj_t* target, 268 | mobj_t* inflictor, 269 | mobj_t* source, 270 | int damage ); 271 | 272 | 273 | // 274 | // P_SPEC 275 | // 276 | #include "p_spec.h" 277 | 278 | 279 | #endif // __P_LOCAL__ 280 | -------------------------------------------------------------------------------- /doomdef.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 1993-2008 Raven Software 4 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Internally used data structures for virtually everything, 18 | // key definitions, lots of other stuff. 19 | // 20 | 21 | #ifndef __DOOMDEF__ 22 | #define __DOOMDEF__ 23 | 24 | #include 25 | #include 26 | 27 | // 28 | // Global parameters/defines. 29 | // 30 | // DOOM version 31 | enum { VERSION = 109 }; 32 | 33 | #define EXE_VERSION_1_9 0 34 | #define EXE_VERSION_ULTIMATE 1 35 | #define EXE_VERSION_FINAL 2 36 | #define EXE_VERSION_FINAL2 3 37 | 38 | #define EXE_VERSION EXE_VERSION_1_9 39 | 40 | // If rangecheck is undefined, 41 | // most parameter validation debugging code will not be compiled 42 | #define RANGECHECK 43 | 44 | 45 | // 46 | // For resize of screen, at start of game. 47 | // It will not work dynamically, see visplanes. 48 | // 49 | #define BASE_WIDTH 320 50 | 51 | // It is educational but futile to change this 52 | // scaling e.g. to 2. Drawing of status bar, 53 | // menues etc. is tied to the scale implied 54 | // by the graphics. 55 | #define SCREEN_MUL 1 56 | #define INV_ASPECT_RATIO 0.625 // 0.75, ideally 57 | 58 | // Defines suck. C sucks. 59 | // C++ might sucks for OOP, but it sure is a better C. 60 | // So there. 61 | #define SCREENWIDTH 320 62 | //SCREEN_MUL*BASE_WIDTH //320 63 | #define SCREENHEIGHT 200 64 | //(int)(SCREEN_MUL*BASE_WIDTH*INV_ASPECT_RATIO) //200 65 | 66 | #define FRACBITS 16 67 | #define FRACUNIT (1<direction) 49 | { 50 | case 0: 51 | // IN STASIS 52 | break; 53 | case 1: 54 | // UP 55 | res = T_MovePlane(ceiling->sector, 56 | ceiling->speed, 57 | ceiling->topheight, 58 | false,1,ceiling->direction); 59 | 60 | if (!(leveltime&7)) 61 | { 62 | switch(ceiling->type) 63 | { 64 | case silentCrushAndRaise: 65 | break; 66 | default: 67 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, 68 | sfx_stnmov); 69 | // ? 70 | break; 71 | } 72 | } 73 | 74 | if (res == pastdest) 75 | { 76 | switch(ceiling->type) 77 | { 78 | case raiseToHighest: 79 | P_RemoveActiveCeiling(ceiling); 80 | break; 81 | 82 | case silentCrushAndRaise: 83 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, 84 | sfx_pstop); 85 | case fastCrushAndRaise: 86 | case crushAndRaise: 87 | ceiling->direction = -1; 88 | break; 89 | 90 | default: 91 | break; 92 | } 93 | 94 | } 95 | break; 96 | 97 | case -1: 98 | // DOWN 99 | res = T_MovePlane(ceiling->sector, 100 | ceiling->speed, 101 | ceiling->bottomheight, 102 | ceiling->crush,1,ceiling->direction); 103 | 104 | if (!(leveltime&7)) 105 | { 106 | switch(ceiling->type) 107 | { 108 | case silentCrushAndRaise: break; 109 | default: 110 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, 111 | sfx_stnmov); 112 | } 113 | } 114 | 115 | if (res == pastdest) 116 | { 117 | switch(ceiling->type) 118 | { 119 | case silentCrushAndRaise: 120 | S_StartSound((mobj_t *)&ceiling->sector->soundorg, 121 | sfx_pstop); 122 | case crushAndRaise: 123 | ceiling->speed = CEILSPEED; 124 | case fastCrushAndRaise: 125 | ceiling->direction = 1; 126 | break; 127 | 128 | case lowerAndCrush: 129 | case lowerToFloor: 130 | P_RemoveActiveCeiling(ceiling); 131 | break; 132 | 133 | default: 134 | break; 135 | } 136 | } 137 | else // ( res != pastdest ) 138 | { 139 | if (res == crushed) 140 | { 141 | switch(ceiling->type) 142 | { 143 | case silentCrushAndRaise: 144 | case crushAndRaise: 145 | case lowerAndCrush: 146 | ceiling->speed = CEILSPEED / 8; 147 | break; 148 | 149 | default: 150 | break; 151 | } 152 | } 153 | } 154 | break; 155 | } 156 | } 157 | 158 | 159 | // 160 | // EV_DoCeiling 161 | // Move a ceiling up/down and all around! 162 | // 163 | int 164 | EV_DoCeiling 165 | ( line_t* line, 166 | ceiling_e type ) 167 | { 168 | int secnum; 169 | int rtn; 170 | sector_t* sec; 171 | ceiling_t* ceiling; 172 | 173 | secnum = -1; 174 | rtn = 0; 175 | 176 | // Reactivate in-stasis ceilings...for certain types. 177 | switch(type) 178 | { 179 | case fastCrushAndRaise: 180 | case silentCrushAndRaise: 181 | case crushAndRaise: 182 | P_ActivateInStasisCeiling(line); 183 | default: 184 | break; 185 | } 186 | 187 | while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) 188 | { 189 | sec = §ors[secnum]; 190 | if (sec->specialdata) 191 | continue; 192 | 193 | // new door thinker 194 | rtn = 1; 195 | ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); 196 | P_AddThinker (&ceiling->thinker); 197 | sec->specialdata = ceiling; 198 | ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; 199 | ceiling->sector = sec; 200 | ceiling->crush = false; 201 | 202 | switch(type) 203 | { 204 | case fastCrushAndRaise: 205 | ceiling->crush = true; 206 | ceiling->topheight = sec->ceilingheight; 207 | ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); 208 | ceiling->direction = -1; 209 | ceiling->speed = CEILSPEED * 2; 210 | break; 211 | 212 | case silentCrushAndRaise: 213 | case crushAndRaise: 214 | ceiling->crush = true; 215 | ceiling->topheight = sec->ceilingheight; 216 | case lowerAndCrush: 217 | case lowerToFloor: 218 | ceiling->bottomheight = sec->floorheight; 219 | if (type != lowerToFloor) 220 | ceiling->bottomheight += 8*FRACUNIT; 221 | ceiling->direction = -1; 222 | ceiling->speed = CEILSPEED; 223 | break; 224 | 225 | case raiseToHighest: 226 | ceiling->topheight = P_FindHighestCeilingSurrounding(sec); 227 | ceiling->direction = 1; 228 | ceiling->speed = CEILSPEED; 229 | break; 230 | } 231 | 232 | ceiling->tag = sec->tag; 233 | ceiling->type = type; 234 | P_AddActiveCeiling(ceiling); 235 | } 236 | return rtn; 237 | } 238 | 239 | 240 | // 241 | // Add an active ceiling 242 | // 243 | void P_AddActiveCeiling(ceiling_t* c) 244 | { 245 | int i; 246 | 247 | for (i = 0; i < MAXCEILINGS;i++) 248 | { 249 | if (activeceilings[i] == NULL) 250 | { 251 | activeceilings[i] = c; 252 | return; 253 | } 254 | } 255 | } 256 | 257 | 258 | 259 | // 260 | // Remove a ceiling's thinker 261 | // 262 | void P_RemoveActiveCeiling(ceiling_t* c) 263 | { 264 | int i; 265 | 266 | for (i = 0;i < MAXCEILINGS;i++) 267 | { 268 | if (activeceilings[i] == c) 269 | { 270 | activeceilings[i]->sector->specialdata = NULL; 271 | P_RemoveThinker (&activeceilings[i]->thinker); 272 | activeceilings[i] = NULL; 273 | break; 274 | } 275 | } 276 | } 277 | 278 | 279 | 280 | // 281 | // Restart a ceiling that's in-stasis 282 | // 283 | void P_ActivateInStasisCeiling(line_t* line) 284 | { 285 | int i; 286 | 287 | for (i = 0;i < MAXCEILINGS;i++) 288 | { 289 | if (activeceilings[i] 290 | && (activeceilings[i]->tag == line->tag) 291 | && (activeceilings[i]->direction == 0)) 292 | { 293 | activeceilings[i]->direction = activeceilings[i]->olddirection; 294 | activeceilings[i]->thinker.function.acp1 295 | = (actionf_p1)T_MoveCeiling; 296 | } 297 | } 298 | } 299 | 300 | 301 | 302 | // 303 | // EV_CeilingCrushStop 304 | // Stop a ceiling from crushing! 305 | // 306 | int EV_CeilingCrushStop(line_t *line) 307 | { 308 | int i; 309 | int rtn; 310 | 311 | rtn = 0; 312 | for (i = 0;i < MAXCEILINGS;i++) 313 | { 314 | if (activeceilings[i] 315 | && (activeceilings[i]->tag == line->tag) 316 | && (activeceilings[i]->direction != 0)) 317 | { 318 | activeceilings[i]->olddirection = activeceilings[i]->direction; 319 | activeceilings[i]->thinker.function.acv = (actionf_v)NULL; 320 | activeceilings[i]->direction = 0; // in-stasis 321 | rtn = 1; 322 | } 323 | } 324 | 325 | 326 | return rtn; 327 | } 328 | -------------------------------------------------------------------------------- /doomstat.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // All the global variables that store the internal state. 17 | // Theoretically speaking, the internal state of the engine 18 | // should be found by looking at the variables collected 19 | // here, and every relevant module will have to include 20 | // this header file. 21 | // In practice, things are a bit messy. 22 | // 23 | 24 | 25 | #ifndef __D_STATE__ 26 | #define __D_STATE__ 27 | 28 | // We need globally shared data structures, 29 | // for defining the global state variables. 30 | #include "doomdata.h" 31 | #include "d_net.h" 32 | 33 | // We need the playr data structure as well. 34 | #include "d_player.h" 35 | 36 | 37 | 38 | // ------------------------ 39 | // Command line parameters. 40 | // 41 | extern boolean nomonsters; // checkparm of -nomonsters 42 | extern boolean respawnparm; // checkparm of -respawn 43 | extern boolean fastparm; // checkparm of -fast 44 | 45 | extern boolean devparm; // DEBUG: launched with -devparm 46 | 47 | 48 | // Set if homebrew PWAD stuff has been added. 49 | extern boolean modifiedgame; 50 | 51 | // ------------------------------------------- 52 | // Selected skill type, map etc. 53 | // 54 | 55 | // Defaults for menu, methinks. 56 | extern skill_t startskill; 57 | extern int startepisode; 58 | extern int startmap; 59 | 60 | extern boolean autostart; 61 | 62 | // Selected by user. 63 | extern skill_t gameskill; 64 | extern int gameepisode; 65 | extern int gamemap; 66 | 67 | extern boolean shareware; 68 | extern boolean registered; 69 | extern boolean commercial; 70 | extern boolean plutonia; 71 | extern boolean tnt; 72 | extern boolean french; 73 | 74 | 75 | // Nightmare mode flag, single player. 76 | extern boolean respawnmonsters; 77 | 78 | // Netgame? Only true if >1 player. 79 | extern boolean netgame; 80 | 81 | // Flag: true only if started as net deathmatch. 82 | // An enum might handle altdeath/cooperative better. 83 | extern boolean deathmatch; 84 | 85 | // ------------------------- 86 | // Internal parameters for sound rendering. 87 | // These have been taken from the DOS version, 88 | // but are not (yet) supported with Linux 89 | // (e.g. no sound volume adjustment with menu. 90 | 91 | // These are not used, but should be (menu). 92 | // From m_menu.c: 93 | // Sound FX volume has default, 0 - 15 94 | // Music volume has default, 0 - 15 95 | // These are multiplied by 8. 96 | //extern int snd_SfxVolume; // maximum volume for sound 97 | //extern int snd_MusicVolume; // maximum volume for music 98 | 99 | // Current music/sfx card - index useless 100 | // w/o a reference LUT in a sound module. 101 | // Ideally, this would use indices found 102 | // in: /usr/include/linux/soundcard.h 103 | extern int snd_MusicDevice; 104 | extern int snd_SfxDevice; 105 | // Config file? Same disclaimer as above. 106 | extern int snd_DesiredMusicDevice; 107 | extern int snd_DesiredSfxDevice; 108 | 109 | 110 | // ------------------------- 111 | // Status flags for refresh. 112 | // 113 | 114 | // Depending on view size - no status bar? 115 | // Note that there is no way to disable the 116 | // status bar explicitely. 117 | extern boolean statusbaractive; 118 | 119 | extern boolean automapactive; // In AutoMap mode? 120 | extern boolean menuactive; // Menu overlayed? 121 | extern boolean paused; // Game Pause? 122 | 123 | 124 | extern boolean viewactive; 125 | 126 | extern boolean nodrawers; 127 | extern boolean noblit; 128 | 129 | extern int viewwindowx; 130 | extern int viewwindowy; 131 | extern int viewheight; 132 | extern int viewwidth; 133 | extern int scaledviewwidth; 134 | 135 | 136 | 137 | 138 | 139 | 140 | // This one is related to the 3-screen display mode. 141 | // ANG90 = left side, ANG270 = right 142 | extern int viewangleoffset; 143 | 144 | // Player taking events, and displaying. 145 | extern int consoleplayer; 146 | extern int displayplayer; 147 | 148 | 149 | // ------------------------------------- 150 | // Scores, rating. 151 | // Statistics on a given map, for intermission. 152 | // 153 | extern int totalkills; 154 | extern int totalitems; 155 | extern int totalsecret; 156 | 157 | // Timer, for scores. 158 | extern int levelstarttic; // gametic at level start 159 | extern int leveltime; // tics in game play for par 160 | 161 | 162 | 163 | // -------------------------------------- 164 | // DEMO playback/recording related stuff. 165 | // No demo, there is a human player in charge? 166 | // Disable save/end game? 167 | extern boolean usergame; 168 | 169 | //? 170 | extern boolean demoplayback; 171 | extern boolean demorecording; 172 | 173 | // Quit after playing a demo from cmdline. 174 | extern boolean singledemo; 175 | 176 | 177 | 178 | 179 | //? 180 | extern gamestate_t gamestate; 181 | 182 | 183 | 184 | 185 | 186 | 187 | //----------------------------- 188 | // Internal parameters, fixed. 189 | // These are set by the engine, and not changed 190 | // according to user inputs. Partly load from 191 | // WAD, partly set at startup time. 192 | 193 | 194 | 195 | extern int gametic; 196 | 197 | 198 | // Bookkeeping on players - state. 199 | extern player_t players[MAXPLAYERS]; 200 | 201 | // Alive? Disconnected? 202 | extern boolean playeringame[MAXPLAYERS]; 203 | 204 | 205 | // Player spawn spots for deathmatch. 206 | #define MAX_DM_STARTS 10 207 | extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; 208 | extern mapthing_t* deathmatch_p; 209 | 210 | // Player spawn spots. 211 | extern mapthing_t playerstarts[MAXPLAYERS]; 212 | 213 | // Intermission stats. 214 | // Parameters for world map / intermission. 215 | extern wbstartstruct_t wminfo; 216 | 217 | 218 | // LUT of ammunition limits for each kind. 219 | // This doubles with BackPack powerup item. 220 | extern int maxammo[NUMAMMO]; 221 | 222 | 223 | 224 | 225 | 226 | //----------------------------------------- 227 | // Internal parameters, used for engine. 228 | // 229 | 230 | // File handling stuff. 231 | extern char basedefault[1024]; 232 | extern FILE* debugfile; 233 | 234 | // if true, load all graphics at level load 235 | extern boolean precache; 236 | 237 | 238 | // wipegamestate can be set to -1 239 | // to force a wipe on the next draw 240 | extern gamestate_t wipegamestate; 241 | 242 | extern int mouseSensitivity; 243 | //? 244 | // debug flag to cancel adaptiveness 245 | extern boolean singletics; 246 | 247 | extern int bodyqueslot; 248 | 249 | 250 | 251 | // Needed to store the number of the dummy sky flat. 252 | // Used for rendering, 253 | // as well as tracking projectiles etc. 254 | extern int skyflatnum; 255 | 256 | 257 | 258 | // Netgame stuff (buffers and pointers, i.e. indices). 259 | 260 | // This is ??? 261 | extern doomcom_t* doomcom; 262 | 263 | // This points inside doomcom. 264 | extern doomdata_t* netbuffer; 265 | 266 | 267 | extern ticcmd_t localcmds[BACKUPTICS]; 268 | extern int rndindex; 269 | 270 | extern int maketic; 271 | extern int nettics[MAXNETNODES]; 272 | 273 | extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; 274 | extern int ticdup; 275 | 276 | 277 | 278 | #endif 279 | -------------------------------------------------------------------------------- /i_cyber.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 1993-2008 Raven Software 4 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // CyberMan 18 | // 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "i_system.h" 25 | 26 | // 27 | // Doom control structure 28 | // 29 | // The keybaord and joystick will add to the values set by the cyberman, 30 | // to a maximum of 0x19000 for forwardmove and sidemove. Angleturn is 31 | // not bounded at all. 32 | // 33 | // parm normal fast 34 | // ----- ------ ---- 35 | // forwardmove 0xc800 0x19000 36 | // sidemove 0xc000 0x14000 37 | // angleturn 0x2800000 0x5000000 38 | // 39 | // The keyboard and joystick have a 1/3 second slow turn of 0x1400000 under 40 | // normal speed to help aiming. 41 | // 42 | 43 | #define BT_ATTACK 1 44 | #define BT_USE 2 45 | #define BT_CHANGE 4 // if true, the next 3 bits hold weapon num 46 | #define BT_WEAPONMASK (8+16+32) 47 | #define BT_WEAPONSHIFT 3 48 | 49 | 50 | 51 | // 52 | // CyberMan detection and usage info 53 | // 54 | #define DPMI_INT 0x31 55 | #define MOUSE_INT 0x33 56 | 57 | #define DOSMEMSIZE 64 // enough for any SWIFT structure 58 | 59 | typedef struct { 60 | short x; 61 | short y; 62 | short z; 63 | short pitch; 64 | short roll; 65 | short yaw; 66 | short buttons; 67 | } SWIFT_3DStatus; 68 | 69 | // DPMI real mode interrupt structure 70 | static struct rminfo { 71 | long EDI; 72 | long ESI; 73 | long EBP; 74 | long reserved_by_system; 75 | long EBX; 76 | long EDX; 77 | long ECX; 78 | long EAX; 79 | short flags; 80 | short ES,DS,FS,GS,IP,CS,SP,SS; 81 | } RMI; 82 | 83 | typedef struct { 84 | unsigned char deviceType; 85 | unsigned char majorVersion; 86 | unsigned char minorVersion; 87 | unsigned char absRelFlags; 88 | unsigned char centeringFlags; 89 | unsigned char reserved[5]; 90 | } StaticDeviceData; 91 | 92 | // values for deviceType: 93 | #define DEVTYPE_CYBERMAN 1 94 | 95 | short selector; 96 | unsigned short segment; // segment of DOS memory block 97 | SWIFT_3DStatus *cyberstat; 98 | int isCyberPresent; // is CyberMan present? 99 | 100 | 101 | static union REGS regs; 102 | static struct SREGS sregs; 103 | 104 | 105 | extern int mousepresent; 106 | 107 | // 108 | // I_StartupCyberMan 109 | // If a cyberman is present, init it and set isCyberPresent to 1 110 | // 111 | void I_StartupCyberMan(void) 112 | { 113 | StaticDeviceData *pbuf; 114 | int success = 0; 115 | 116 | isCyberPresent = 0; 117 | 118 | cyberstat = (SWIFT_3DStatus *)I_AllocLow(DOSMEMSIZE); 119 | segment = (int)cyberstat >> 4; 120 | 121 | pbuf = (StaticDeviceData *)cyberstat; 122 | memset(pbuf, 0, sizeof(StaticDeviceData)); 123 | 124 | // Use DPMI call 300h to issue mouse interrupt 125 | memset(&RMI, 0, sizeof(RMI)); 126 | RMI.EAX = 0x53C1; // SWIFT: Get Static Device Data 127 | RMI.ES = segment; 128 | RMI.EDX = 0; 129 | memset(&sregs, 0, sizeof(sregs)); 130 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 131 | regs.w.bx = MOUSE_INT; 132 | regs.w.cx = 0; 133 | regs.x.edi = FP_OFF(&RMI); 134 | sregs.es = FP_SEG(&RMI); 135 | int386x(DPMI_INT, ®s, ®s, &sregs); 136 | 137 | if ((short)RMI.EAX != 1) 138 | { 139 | // SWIFT functions not present 140 | printf("CyberMan: Wrong mouse driver - no SWIFT support (AX=%04x).\n", 141 | (unsigned)(short)RMI.EAX); 142 | } 143 | else 144 | { 145 | if (pbuf->deviceType != DEVTYPE_CYBERMAN) 146 | { 147 | // no SWIFT device, or not CyberMan 148 | if (pbuf->deviceType == 0) 149 | { 150 | printf("CyberMan: no SWIFT device connected.\n"); 151 | } 152 | else 153 | { 154 | printf("CyberMan: SWIFT device is not a CyberMan! (type=%d)\n", 155 | pbuf->deviceType); 156 | } 157 | } 158 | else 159 | { 160 | printf("CyberMan: CyberMan %d.%02d connected.\n", 161 | pbuf->majorVersion, pbuf->minorVersion); 162 | isCyberPresent = 1; 163 | mousepresent = 0; 164 | } 165 | } 166 | } 167 | 168 | 169 | 170 | // 171 | // I_ReadCyberCmds 172 | // 173 | 174 | int oldpos; 175 | 176 | void I_ReadCyberCmd(ticcmd_t *cmd) 177 | { 178 | int delta; 179 | 180 | // Use DPMI call 300h to issue mouse interrupt 181 | memset(&RMI, 0, sizeof(RMI)); 182 | RMI.EAX = 0x5301; // SWIFT: Get Position and Buttons 183 | RMI.ES = segment; 184 | RMI.EDX = 0; 185 | memset(&sregs, 0, sizeof(sregs)); 186 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 187 | regs.w.bx = MOUSE_INT; 188 | regs.w.cx = 0; 189 | regs.x.edi = FP_OFF(&RMI); 190 | sregs.es = FP_SEG(&RMI); 191 | int386x(DPMI_INT, ®s, ®s, &sregs); 192 | 193 | if (cyberstat->y < -7900) 194 | { 195 | cmd->forwardmove = 0xc800 / 2048; 196 | } 197 | else if (cyberstat->y > 7900) 198 | { 199 | cmd->forwardmove = -0xc800 / 2048; 200 | } 201 | 202 | if (cyberstat->buttons & 4) 203 | { 204 | cmd->buttons |= BT_ATTACK; 205 | } 206 | if (cyberstat->buttons & 2) 207 | { 208 | cmd->buttons |= BT_USE; 209 | } 210 | 211 | delta = cyberstat->x - oldpos; 212 | oldpos = cyberstat->x; 213 | 214 | if (cyberstat->buttons & 1) // strafe 215 | { 216 | if (cyberstat->x < -7900) 217 | { 218 | cmd->sidemove = -0xc800 / 2048; 219 | } 220 | else if (cyberstat->x > 7900) 221 | { 222 | cmd->sidemove = 0xc800 / 2048; 223 | } 224 | else 225 | { 226 | cmd->sidemove = delta * 40 / 2048; 227 | } 228 | } 229 | else 230 | { 231 | if (cyberstat->x < -7900) 232 | { 233 | cmd->angleturn = 0x280; 234 | } 235 | else if (cyberstat->x > 7900) 236 | { 237 | cmd->angleturn = -0x280; 238 | } 239 | else 240 | { 241 | cmd->angleturn = -delta * 0xa / 16; 242 | } 243 | } 244 | } 245 | 246 | 247 | void I_Tactile(int on, int off, int total) 248 | { 249 | if (!isCyberPresent) 250 | { 251 | return; 252 | } 253 | 254 | on /= 5; 255 | off /= 5; 256 | total /= 40; 257 | if (on > 255) 258 | { 259 | on = 255; 260 | } 261 | if (off > 255) 262 | { 263 | off = 255; 264 | } 265 | if (total > 255) 266 | { 267 | total = 255; 268 | } 269 | 270 | memset(&RMI, 0, sizeof(RMI)); 271 | RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons 272 | RMI.EBX = on * 256 + off; 273 | RMI.ECX = total; 274 | memset(&sregs, 0, sizeof(sregs)); 275 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 276 | regs.w.bx = MOUSE_INT; 277 | regs.w.cx = 0; 278 | regs.x.edi = FP_OFF(&RMI); 279 | sregs.es = FP_SEG(&RMI); 280 | int386x(DPMI_INT, ®s, ®s, &sregs); 281 | } 282 | -------------------------------------------------------------------------------- /p_plats.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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 | // Plats (i.e. elevator platforms) code, raising/lowering. 17 | // 18 | 19 | 20 | #include "i_system.h" 21 | #include "z_zone.h" 22 | #include "m_misc.h" 23 | 24 | #include "doomdef.h" 25 | #include "p_local.h" 26 | 27 | #include "s_sound.h" 28 | 29 | // State. 30 | #include "doomstat.h" 31 | #include "r_state.h" 32 | 33 | // Data. 34 | #include "sounds.h" 35 | 36 | 37 | plat_t* activeplats[MAXPLATS]; 38 | 39 | 40 | 41 | // 42 | // Move a plat up and down 43 | // 44 | void T_PlatRaise(plat_t* plat) 45 | { 46 | result_e res; 47 | 48 | switch(plat->status) 49 | { 50 | case up: 51 | res = T_MovePlane(plat->sector, 52 | plat->speed, 53 | plat->high, 54 | plat->crush,0,1); 55 | 56 | if (plat->type == raiseAndChange 57 | || plat->type == raiseToNearestAndChange) 58 | { 59 | if (!(leveltime&7)) 60 | S_StartSound((mobj_t *)&plat->sector->soundorg, 61 | sfx_stnmov); 62 | } 63 | 64 | 65 | if (res == crushed && (!plat->crush)) 66 | { 67 | plat->count = plat->wait; 68 | plat->status = down; 69 | S_StartSound((mobj_t *)&plat->sector->soundorg, 70 | sfx_pstart); 71 | } 72 | else 73 | { 74 | if (res == pastdest) 75 | { 76 | plat->count = plat->wait; 77 | plat->status = waiting; 78 | S_StartSound((mobj_t *)&plat->sector->soundorg, 79 | sfx_pstop); 80 | 81 | switch(plat->type) 82 | { 83 | case blazeDWUS: 84 | case downWaitUpStay: 85 | P_RemoveActivePlat(plat); 86 | break; 87 | 88 | case raiseAndChange: 89 | case raiseToNearestAndChange: 90 | P_RemoveActivePlat(plat); 91 | break; 92 | 93 | default: 94 | break; 95 | } 96 | } 97 | } 98 | break; 99 | 100 | case down: 101 | res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); 102 | 103 | if (res == pastdest) 104 | { 105 | plat->count = plat->wait; 106 | plat->status = waiting; 107 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstop); 108 | } 109 | break; 110 | 111 | case waiting: 112 | if (!--plat->count) 113 | { 114 | if (plat->sector->floorheight == plat->low) 115 | plat->status = up; 116 | else 117 | plat->status = down; 118 | S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstart); 119 | } 120 | case in_stasis: 121 | break; 122 | } 123 | } 124 | 125 | 126 | // 127 | // Do Platforms 128 | // "amount" is only used for SOME platforms. 129 | // 130 | int 131 | EV_DoPlat 132 | ( line_t* line, 133 | plattype_e type, 134 | int amount ) 135 | { 136 | plat_t* plat; 137 | int secnum; 138 | int rtn; 139 | sector_t* sec; 140 | 141 | secnum = -1; 142 | rtn = 0; 143 | 144 | 145 | // Activate all plats that are in_stasis 146 | switch(type) 147 | { 148 | case perpetualRaise: 149 | P_ActivateInStasis(line->tag); 150 | break; 151 | 152 | default: 153 | break; 154 | } 155 | 156 | while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) 157 | { 158 | sec = §ors[secnum]; 159 | 160 | if (sec->specialdata) 161 | continue; 162 | 163 | // Find lowest & highest floors around sector 164 | rtn = 1; 165 | plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); 166 | P_AddThinker(&plat->thinker); 167 | 168 | plat->type = type; 169 | plat->sector = sec; 170 | plat->sector->specialdata = plat; 171 | plat->thinker.function.acp1 = (actionf_p1) T_PlatRaise; 172 | plat->crush = false; 173 | plat->tag = line->tag; 174 | 175 | switch(type) 176 | { 177 | case raiseToNearestAndChange: 178 | plat->speed = PLATSPEED/2; 179 | sec->floorpic = sides[line->sidenum[0]].sector->floorpic; 180 | plat->high = P_FindNextHighestFloor(sec,sec->floorheight); 181 | plat->wait = 0; 182 | plat->status = up; 183 | // NO MORE DAMAGE, IF APPLICABLE 184 | sec->special = 0; 185 | 186 | S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); 187 | break; 188 | 189 | case raiseAndChange: 190 | plat->speed = PLATSPEED/2; 191 | sec->floorpic = sides[line->sidenum[0]].sector->floorpic; 192 | plat->high = sec->floorheight + amount*FRACUNIT; 193 | plat->wait = 0; 194 | plat->status = up; 195 | 196 | S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); 197 | break; 198 | 199 | case downWaitUpStay: 200 | plat->speed = PLATSPEED * 4; 201 | plat->low = P_FindLowestFloorSurrounding(sec); 202 | 203 | if (plat->low > sec->floorheight) 204 | plat->low = sec->floorheight; 205 | 206 | plat->high = sec->floorheight; 207 | plat->wait = 35*PLATWAIT; 208 | plat->status = down; 209 | S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); 210 | break; 211 | 212 | case blazeDWUS: 213 | plat->speed = PLATSPEED * 8; 214 | plat->low = P_FindLowestFloorSurrounding(sec); 215 | 216 | if (plat->low > sec->floorheight) 217 | plat->low = sec->floorheight; 218 | 219 | plat->high = sec->floorheight; 220 | plat->wait = 35*PLATWAIT; 221 | plat->status = down; 222 | S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); 223 | break; 224 | 225 | case perpetualRaise: 226 | plat->speed = PLATSPEED; 227 | plat->low = P_FindLowestFloorSurrounding(sec); 228 | 229 | if (plat->low > sec->floorheight) 230 | plat->low = sec->floorheight; 231 | 232 | plat->high = P_FindHighestFloorSurrounding(sec); 233 | 234 | if (plat->high < sec->floorheight) 235 | plat->high = sec->floorheight; 236 | 237 | plat->wait = 35*PLATWAIT; 238 | plat->status = P_Random()&1; 239 | 240 | S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); 241 | break; 242 | } 243 | P_AddActivePlat(plat); 244 | } 245 | return rtn; 246 | } 247 | 248 | 249 | 250 | void P_ActivateInStasis(int tag) 251 | { 252 | int i; 253 | 254 | for (i = 0;i < MAXPLATS;i++) 255 | if (activeplats[i] 256 | && (activeplats[i])->tag == tag 257 | && (activeplats[i])->status == in_stasis) 258 | { 259 | (activeplats[i])->status = (activeplats[i])->oldstatus; 260 | (activeplats[i])->thinker.function.acp1 261 | = (actionf_p1) T_PlatRaise; 262 | } 263 | } 264 | 265 | void EV_StopPlat(line_t* line) 266 | { 267 | int j; 268 | 269 | for (j = 0;j < MAXPLATS;j++) 270 | if (activeplats[j] 271 | && ((activeplats[j])->status != in_stasis) 272 | && ((activeplats[j])->tag == line->tag)) 273 | { 274 | (activeplats[j])->oldstatus = (activeplats[j])->status; 275 | (activeplats[j])->status = in_stasis; 276 | (activeplats[j])->thinker.function.acv = (actionf_v)NULL; 277 | } 278 | } 279 | 280 | void P_AddActivePlat(plat_t* plat) 281 | { 282 | int i; 283 | 284 | for (i = 0;i < MAXPLATS;i++) 285 | if (activeplats[i] == NULL) 286 | { 287 | activeplats[i] = plat; 288 | return; 289 | } 290 | I_Error ("P_AddActivePlat: no more plats!"); 291 | } 292 | 293 | void P_RemoveActivePlat(plat_t* plat) 294 | { 295 | int i; 296 | for (i = 0;i < MAXPLATS;i++) 297 | if (plat == activeplats[i]) 298 | { 299 | (activeplats[i])->sector->specialdata = NULL; 300 | P_RemoveThinker(&(activeplats[i])->thinker); 301 | activeplats[i] = NULL; 302 | 303 | return; 304 | } 305 | I_Error ("P_RemoveActivePlat: can't find plat!"); 306 | } 307 | -------------------------------------------------------------------------------- /hu_lib.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 1993-1996 Id Software, Inc. 3 | // Copyright (C) 2016-2017 Alexey Khokholov (Nuke.YKT) 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: heads-up text and input code 16 | // 17 | 18 | #include 19 | 20 | #include "doomdef.h" 21 | 22 | #include "v_video.h" 23 | 24 | #include "hu_lib.h" 25 | #include "r_local.h" 26 | #include "r_draw.h" 27 | 28 | // boolean : whether the screen is always erased 29 | #define noterased viewwindowx 30 | 31 | extern boolean automapactive; // in AM_map.c 32 | 33 | void HUlib_init(void) 34 | { 35 | } 36 | 37 | void HUlib_clearTextLine(hu_textline_t* t) 38 | { 39 | t->len = 0; 40 | t->l[0] = 0; 41 | t->needsupdate = true; 42 | } 43 | 44 | void 45 | HUlib_initTextLine 46 | ( hu_textline_t* t, 47 | int x, 48 | int y, 49 | patch_t** f, 50 | int sc ) 51 | { 52 | t->x = x; 53 | t->y = y; 54 | t->f = f; 55 | t->sc = sc; 56 | HUlib_clearTextLine(t); 57 | } 58 | 59 | boolean 60 | HUlib_addCharToTextLine 61 | ( hu_textline_t* t, 62 | char ch ) 63 | { 64 | 65 | if (t->len == HU_MAXLINELENGTH) 66 | return false; 67 | else 68 | { 69 | t->l[t->len++] = ch; 70 | t->l[t->len] = 0; 71 | t->needsupdate = 4; 72 | return true; 73 | } 74 | 75 | } 76 | 77 | boolean HUlib_delCharFromTextLine(hu_textline_t* t) 78 | { 79 | 80 | if (!t->len) return false; 81 | else 82 | { 83 | t->l[--t->len] = 0; 84 | t->needsupdate = 4; 85 | return true; 86 | } 87 | 88 | } 89 | 90 | void 91 | HUlib_drawTextLine 92 | ( hu_textline_t* l, 93 | boolean drawcursor ) 94 | { 95 | 96 | int i; 97 | int w; 98 | int x; 99 | unsigned char c; 100 | 101 | // draw the new stuff 102 | x = l->x; 103 | for (i=0;ilen;i++) 104 | { 105 | c = toupper(l->l[i]); 106 | if (c != ' ' 107 | && c >= l->sc 108 | && c <= '_') 109 | { 110 | w = SHORT(l->f[c - l->sc]->width); 111 | if (x+w > SCREENWIDTH) 112 | break; 113 | V_DrawPatchDirect(x, l->y, FG, l->f[c - l->sc]); 114 | x += w; 115 | } 116 | else 117 | { 118 | x += 4; 119 | if (x >= SCREENWIDTH) 120 | break; 121 | } 122 | } 123 | 124 | // draw the cursor if requested 125 | if (drawcursor 126 | && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) 127 | { 128 | V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]); 129 | } 130 | } 131 | 132 | 133 | // sorta called by HU_Erase and just better darn get things straight 134 | void HUlib_eraseTextLine(hu_textline_t* l) 135 | { 136 | int lh; 137 | int y; 138 | int yoffset; 139 | static boolean lastautomapactive = true; 140 | 141 | // Only erases when NOT in automap and the screen is reduced, 142 | // and the text must either need updating or refreshing 143 | // (because of a recent change back from the automap) 144 | 145 | if (!automapactive && 146 | viewwindowx && l->needsupdate) 147 | { 148 | lh = SHORT(l->f[0]->height) + 1; 149 | for (y=l->y,yoffset=y*SCREENWIDTH ; yy+lh ; y++,yoffset+=SCREENWIDTH) 150 | { 151 | if (y < viewwindowy || y >= viewwindowy + viewheight) 152 | R_VideoErase(yoffset, SCREENWIDTH); // erase entire line 153 | else 154 | { 155 | R_VideoErase(yoffset, viewwindowx); // erase left border 156 | R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); 157 | // erase right border 158 | } 159 | } 160 | } 161 | 162 | lastautomapactive = automapactive; 163 | if (l->needsupdate) l->needsupdate--; 164 | 165 | } 166 | 167 | void 168 | HUlib_initSText 169 | ( hu_stext_t* s, 170 | int x, 171 | int y, 172 | int h, 173 | patch_t** font, 174 | int startchar, 175 | boolean* on ) 176 | { 177 | 178 | int i; 179 | 180 | s->h = h; 181 | s->on = on; 182 | s->laston = true; 183 | s->cl = 0; 184 | for (i=0;il[i], 186 | x, y - i*(SHORT(font[0]->height)+1), 187 | font, startchar); 188 | 189 | } 190 | 191 | void HUlib_addLineToSText(hu_stext_t* s) 192 | { 193 | 194 | int i; 195 | 196 | // add a clear line 197 | if (++s->cl == s->h) 198 | s->cl = 0; 199 | HUlib_clearTextLine(&s->l[s->cl]); 200 | 201 | // everything needs updating 202 | for (i=0 ; ih ; i++) 203 | s->l[i].needsupdate = 4; 204 | 205 | } 206 | 207 | void 208 | HUlib_addMessageToSText 209 | ( hu_stext_t* s, 210 | char* prefix, 211 | char* msg ) 212 | { 213 | HUlib_addLineToSText(s); 214 | if (prefix) 215 | while (*prefix) 216 | HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++)); 217 | 218 | while (*msg) 219 | HUlib_addCharToTextLine(&s->l[s->cl], *(msg++)); 220 | } 221 | 222 | void HUlib_drawSText(hu_stext_t* s) 223 | { 224 | int i, idx; 225 | hu_textline_t *l; 226 | 227 | if (!*s->on) 228 | return; // if not on, don't draw 229 | 230 | // draw everything 231 | for (i=0 ; ih ; i++) 232 | { 233 | idx = s->cl - i; 234 | if (idx < 0) 235 | idx += s->h; // handle queue of lines 236 | 237 | l = &s->l[idx]; 238 | 239 | // need a decision made here on whether to skip the draw 240 | HUlib_drawTextLine(l, false); // no cursor, please 241 | } 242 | 243 | } 244 | 245 | void HUlib_eraseSText(hu_stext_t* s) 246 | { 247 | 248 | int i; 249 | 250 | for (i=0 ; ih ; i++) 251 | { 252 | if (s->laston && !*s->on) 253 | s->l[i].needsupdate = 4; 254 | HUlib_eraseTextLine(&s->l[i]); 255 | } 256 | s->laston = *s->on; 257 | 258 | } 259 | 260 | void 261 | HUlib_initIText 262 | ( hu_itext_t* it, 263 | int x, 264 | int y, 265 | patch_t** font, 266 | int startchar, 267 | boolean* on ) 268 | { 269 | it->lm = 0; // default left margin is start of text 270 | it->on = on; 271 | it->laston = true; 272 | HUlib_initTextLine(&it->l, x, y, font, startchar); 273 | } 274 | 275 | 276 | // The following deletion routines adhere to the left margin restriction 277 | void HUlib_delCharFromIText(hu_itext_t* it) 278 | { 279 | if (it->l.len != it->lm) 280 | HUlib_delCharFromTextLine(&it->l); 281 | } 282 | 283 | void HUlib_eraseLineFromIText(hu_itext_t* it) 284 | { 285 | while (it->lm != it->l.len) 286 | HUlib_delCharFromTextLine(&it->l); 287 | } 288 | 289 | // Resets left margin as well 290 | void HUlib_resetIText(hu_itext_t* it) 291 | { 292 | it->lm = 0; 293 | HUlib_clearTextLine(&it->l); 294 | } 295 | 296 | void 297 | HUlib_addPrefixToIText 298 | ( hu_itext_t* it, 299 | char* str ) 300 | { 301 | while (*str) 302 | HUlib_addCharToTextLine(&it->l, *(str++)); 303 | it->lm = it->l.len; 304 | } 305 | 306 | // wrapper function for handling general keyed input. 307 | // returns true if it ate the key 308 | boolean 309 | HUlib_keyInIText 310 | ( hu_itext_t* it, 311 | unsigned char ch ) 312 | { 313 | 314 | if (ch >= ' ' && ch <= '_') 315 | HUlib_addCharToTextLine(&it->l, (char) ch); 316 | else 317 | if (ch == KEY_BACKSPACE) 318 | HUlib_delCharFromIText(it); 319 | else 320 | if (ch != KEY_ENTER) 321 | return false; // did not eat key 322 | 323 | return true; // ate the key 324 | 325 | } 326 | 327 | void HUlib_drawIText(hu_itext_t* it) 328 | { 329 | 330 | hu_textline_t *l = &it->l; 331 | 332 | if (!*it->on) 333 | return; 334 | HUlib_drawTextLine(l, true); // draw the line w/ cursor 335 | 336 | } 337 | 338 | void HUlib_eraseIText(hu_itext_t* it) 339 | { 340 | if (it->laston && !*it->on) 341 | it->l.needsupdate = 4; 342 | HUlib_eraseTextLine(&it->l); 343 | it->laston = *it->on; 344 | } 345 | 346 | --------------------------------------------------------------------------------