├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.TXT ├── README.md ├── fips ├── fips-files ├── configs │ ├── wasm-make-debug.yml │ ├── wasm-make-release.yml │ ├── wasm-ninja-debug.yml │ ├── wasm-ninja-release.yml │ ├── wasm-vscode-debug.yml │ └── wasm-vscode-release.yml └── verbs │ └── webpage.py ├── fips.cmd ├── fips.yml └── src ├── CMakeLists.txt ├── am_map.c ├── am_map.h ├── aweromgm.sf2.wasm ├── config.h ├── d_englsh.h ├── d_event.c ├── d_event.h ├── d_items.c ├── d_items.h ├── d_iwad.c ├── d_iwad.h ├── d_loop.c ├── d_loop.h ├── d_main.c ├── d_main.h ├── d_mode.c ├── d_mode.h ├── d_net.c ├── d_player.h ├── d_textur.h ├── d_think.h ├── d_ticcmd.h ├── deh_main.h ├── deh_misc.h ├── deh_str.h ├── doom-assets.yml ├── doom.h ├── doom1.wad.wasm ├── doomdata.h ├── doomdef.c ├── doomdef.h ├── doomfeatures.h ├── doomgeneric.c ├── doomgeneric.h ├── doomgeneric_sokol.c ├── doomkeys.h ├── doomstat.c ├── doomstat.h ├── doomtype.h ├── dstrings.c ├── dstrings.h ├── dummy.c ├── f_finale.c ├── f_finale.h ├── f_wipe.c ├── f_wipe.h ├── g_game.c ├── g_game.h ├── gusconf.c ├── gusconf.h ├── hu_lib.c ├── hu_lib.h ├── hu_stuff.c ├── hu_stuff.h ├── i_cdmus.c ├── i_cdmus.h ├── i_endoom.c ├── i_endoom.h ├── i_input.c ├── i_joystick.c ├── i_joystick.h ├── i_main.c ├── i_scale.c ├── i_scale.h ├── i_sound.c ├── i_sound.h ├── i_swap.h ├── i_system.c ├── i_system.h ├── i_timer.c ├── i_timer.h ├── i_video.c ├── i_video.h ├── icon.c ├── info.c ├── info.h ├── m_argv.c ├── m_argv.h ├── m_bbox.c ├── m_bbox.h ├── m_cheat.c ├── m_cheat.h ├── m_config.c ├── m_config.h ├── m_controls.c ├── m_controls.h ├── m_fixed.c ├── m_fixed.h ├── m_menu.c ├── m_menu.h ├── m_misc.c ├── m_misc.h ├── m_random.c ├── m_random.h ├── memio.c ├── memio.h ├── mus.h ├── net_client.h ├── net_dedicated.h ├── net_defs.h ├── net_gui.h ├── net_io.h ├── net_loop.h ├── net_packet.h ├── net_query.h ├── net_sdl.h ├── net_server.h ├── p_ceilng.c ├── p_doors.c ├── p_enemy.c ├── p_floor.c ├── p_inter.c ├── p_inter.h ├── p_lights.c ├── p_local.h ├── p_map.c ├── p_maputl.c ├── p_mobj.c ├── p_mobj.h ├── p_plats.c ├── p_pspr.c ├── p_pspr.h ├── p_saveg.c ├── p_saveg.h ├── p_setup.c ├── p_setup.h ├── p_sight.c ├── p_spec.c ├── p_spec.h ├── p_switch.c ├── p_telept.c ├── p_tick.c ├── p_tick.h ├── p_user.c ├── r_bsp.c ├── r_bsp.h ├── r_data.c ├── r_data.h ├── r_defs.h ├── r_draw.c ├── r_draw.h ├── r_local.h ├── r_main.c ├── r_main.h ├── r_plane.c ├── r_plane.h ├── r_segs.c ├── r_segs.h ├── r_sky.c ├── r_sky.h ├── r_state.h ├── r_things.c ├── r_things.h ├── s_sound.c ├── s_sound.h ├── sha1.c ├── sha1.h ├── shell.html ├── sokol.c ├── sokol_shaders.glsl ├── sounds.c ├── sounds.h ├── st_lib.c ├── st_lib.h ├── st_stuff.c ├── st_stuff.h ├── statdump.c ├── statdump.h ├── tables.c ├── tables.h ├── tsf.h ├── v_patch.h ├── v_video.c ├── v_video.h ├── w_checksum.c ├── w_checksum.h ├── w_file.c ├── w_file.h ├── w_file_stdc.c ├── w_main.c ├── w_main.h ├── w_merge.h ├── w_wad.c ├── w_wad.h ├── wi_stuff.c ├── wi_stuff.h ├── z_zone.c └── z_zone.h /.gitignore: -------------------------------------------------------------------------------- 1 | #>fips 2 | # this area is managed by fips, do not edit 3 | .fips-* 4 | *.pyc 5 | .vscode/ 6 | .idea/ 7 | CMakeUserPresets.json 8 | # 0 : 57 | if args[0] == 'build' : 58 | build_deploy_webpage(fips_dir, proj_dir) 59 | elif args[0] == 'serve' : 60 | serve_webpage(fips_dir, proj_dir) 61 | else : 62 | log.error("Invalid param '{}', expected 'build' or 'serve'".format(args[0])) 63 | else : 64 | log.error("Param 'build' or 'serve' expected") 65 | 66 | #------------------------------------------------------------------------------- 67 | def help() : 68 | log.info(log.YELLOW + 69 | 'fips webpage build\n' + 70 | 'fips webpage serve\n' + 71 | log.DEF + 72 | ' build the doom-sokol webpage') 73 | -------------------------------------------------------------------------------- /fips.cmd: -------------------------------------------------------------------------------- 1 | @python fips %* 2 | 3 | -------------------------------------------------------------------------------- /fips.yml: -------------------------------------------------------------------------------- 1 | # 2 | # doomgeneric 3 | # 4 | --- 5 | imports: 6 | sokol: 7 | git: https://github.com/floooh/sokol 8 | sokol-tools-bin: 9 | git: https://github.com/floooh/sokol-tools-bin 10 | fips-utils: 11 | git: https://github.com/fips-libs/fips-utils 12 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_lib(sokol) 2 | fips_files(sokol.c) 3 | if (FIPS_OSX) 4 | fips_frameworks_osx(Cocoa QuartzCore Metal MetalKit AudioToolbox) 5 | elseif (FIPS_LINUX) 6 | fips_libs(X11 Xi Xcursor GL m dl asound) 7 | endif() 8 | if(FIPS_EMSCRIPTEN) 9 | target_compile_definitions(sokol PRIVATE SOKOL_GLES3) 10 | set(slang "glsl300es") 11 | elseif(FIPS_WINDOWS) 12 | target_compile_definitions(sokol PRIVATE SOKOL_D3D11) 13 | set(slang "hlsl4") 14 | elseif(FIPS_OSX) 15 | target_compile_options(sokol PRIVATE -x objective-c) 16 | target_compile_definitions(sokol PRIVATE SOKOL_METAL) 17 | set(slang "metal_macos") 18 | else() 19 | target_compile_definitions(sokol PRIVATE SOKOL_GLCORE) 20 | set(slang "glsl430") 21 | endif() 22 | fips_end_lib() 23 | 24 | fips_begin_app(doom windowed) 25 | fips_files( 26 | doomgeneric_sokol.c 27 | dummy.c 28 | am_map.c 29 | doomdef.c 30 | doomstat.c 31 | dstrings.c 32 | d_event.c 33 | d_items.c 34 | d_iwad.c 35 | d_loop.c 36 | d_main.c 37 | d_mode.c 38 | d_net.c 39 | f_finale.c 40 | f_wipe.c 41 | g_game.c 42 | hu_lib.c 43 | hu_stuff.c 44 | info.c 45 | i_cdmus.c 46 | i_endoom.c 47 | i_joystick.c 48 | i_scale.c 49 | i_sound.c 50 | i_system.c 51 | i_timer.c 52 | memio.c 53 | m_argv.c 54 | m_bbox.c 55 | m_cheat.c 56 | m_config.c 57 | m_controls.c 58 | m_fixed.c 59 | m_menu.c 60 | m_misc.c 61 | m_random.c 62 | p_ceilng.c 63 | p_doors.c 64 | p_enemy.c 65 | p_floor.c 66 | p_inter.c 67 | p_lights.c 68 | p_map.c 69 | p_maputl.c 70 | p_mobj.c 71 | p_plats.c 72 | p_pspr.c 73 | p_saveg.c 74 | p_setup.c 75 | p_sight.c 76 | p_spec.c 77 | p_switch.c 78 | p_telept.c 79 | p_tick.c 80 | p_user.c 81 | r_bsp.c 82 | r_data.c 83 | r_draw.c 84 | r_main.c 85 | r_plane.c 86 | r_segs.c 87 | r_sky.c 88 | r_things.c 89 | sha1.c 90 | sounds.c 91 | statdump.c 92 | st_lib.c 93 | st_stuff.c 94 | s_sound.c 95 | tables.c 96 | v_video.c 97 | wi_stuff.c 98 | w_checksum.c 99 | w_file.c 100 | w_main.c 101 | w_wad.c 102 | z_zone.c 103 | i_input.c 104 | i_video.c 105 | doomgeneric.c 106 | ) 107 | fips_deps(sokol) 108 | sokol_shader(sokol_shaders.glsl ${slang}) 109 | fipsutil_copy(doom-assets.yml) 110 | if (FIPS_CLANG OR FIPS_GCC) 111 | target_compile_options(doom PRIVATE 112 | -Wno-unknown-warning-option 113 | -Wno-sign-compare 114 | -Wno-unused-parameter 115 | -Wno-unused-const-variable 116 | -Wno-unused-but-set-parameter 117 | -Wno-unused-but-set-variable 118 | -Wno-absolute-value 119 | -Wno-null-pointer-subtraction 120 | -Wno-pointer-to-int-cast 121 | ) 122 | endif() 123 | if (FIPS_GCC) 124 | target_compile_options(doom PRIVATE 125 | -Wno-implicit-fallthrough 126 | -Wno-enum-conversion 127 | -Wno-format-truncation 128 | -Wno-type-limits 129 | ) 130 | endif() 131 | if (FIPS_MSVC) 132 | target_compile_options(doom PRIVATE 133 | /wd4244 /wd4267 # conversion from 'xxx' to 'yyy' possible loss of data 134 | /wd4146 # unary minus perator applied to unsigned type, result still unsigned 135 | /wd4018 # signed/unsigned mismatch 136 | /wd4996 # ...deprecated... 137 | /wd4311 # pointer trunction from 'xxx' to 'yyy' 138 | ) 139 | endif() 140 | fips_end_app() 141 | -------------------------------------------------------------------------------- /src/am_map.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // AutoMap module. 17 | // 18 | 19 | #ifndef __AMMAP_H__ 20 | #define __AMMAP_H__ 21 | 22 | #include "d_event.h" 23 | #include "m_cheat.h" 24 | 25 | // Used by ST StatusBar stuff. 26 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 27 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 28 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 29 | 30 | 31 | // Called by main loop. 32 | boolean AM_Responder (event_t* ev); 33 | 34 | // Called by main loop. 35 | void AM_Ticker (void); 36 | 37 | // Called by main loop, 38 | // called instead of view drawer if automap active. 39 | void AM_Drawer (void); 40 | 41 | // Called to force the automap to quit 42 | // if the level is completed while it is up. 43 | void AM_Stop (void); 44 | 45 | 46 | extern cheatseq_t cheat_amap; 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/aweromgm.sf2.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/doom-sokol/138639a66b6e40a8202e03f67957d0fd314fb565/src/aweromgm.sf2.wasm -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /* config.hin. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DEV_ISA_SPKRIO_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_DEV_SPEAKER_SPEAKER_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #define HAVE_INTTYPES_H 1 11 | 12 | /* Define to 1 if you have the `ioperm' function. */ 13 | #undef HAVE_IOPERM 14 | 15 | /* Define to 1 if you have the `amd64' library (-lamd64). */ 16 | #undef HAVE_LIBAMD64 17 | 18 | /* Define to 1 if you have the `i386' library (-li386). */ 19 | #undef HAVE_LIBI386 20 | 21 | /* Define to 1 if you have the `m' library (-lm). */ 22 | #undef HAVE_LIBM 23 | 24 | /* Define to 1 if you have the `png' library (-lpng). */ 25 | #undef HAVE_LIBPNG 26 | 27 | /* Define to 1 if you have the `samplerate' library (-lsamplerate). */ 28 | #undef HAVE_LIBSAMPLERATE 29 | 30 | /* Define to 1 if you have the `z' library (-lz). */ 31 | #undef HAVE_LIBZ 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_LINUX_KD_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_MEMORY_H 38 | 39 | /* Define to 1 if you have the `mmap' function. */ 40 | #undef HAVE_MMAP 41 | 42 | /* Define to 1 if you have the `sched_setaffinity' function. */ 43 | #undef HAVE_SCHED_SETAFFINITY 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #define HAVE_STDINT_H 1 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #define HAVE_STDLIB_H 1 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #define HAVE_STRINGS_H 1 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #define HAVE_STRING_H 1 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_SYS_STAT_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #define HAVE_SYS_TYPES_H 1 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_UNISTD_H 65 | 66 | /* Name of package */ 67 | #define PACKAGE "Doom" 68 | 69 | /* Define to the address where bug reports for this package should be sent. */ 70 | #undef PACKAGE_BUGREPORT 71 | 72 | /* Define to the full name of this package. */ 73 | #define PACKAGE_NAME "Doom Generic" 74 | 75 | /* Define to the full name and version of this package. */ 76 | #define PACKAGE_STRING "Doom Generic 0.1" 77 | 78 | /* Define to the one symbol short name of this package. */ 79 | #define PACKAGE_TARNAME "doomgeneric.tar" 80 | 81 | /* Define to the home page for this package. */ 82 | #define PACKAGE_URL "" 83 | 84 | /* Define to the version of this package. */ 85 | #define PACKAGE_VERSION 0.1 86 | 87 | /* Change this when you create your awesome forked version */ 88 | #define PROGRAM_PREFIX "doomgeneric" 89 | 90 | /* Define to 1 if you have the ANSI C header files. */ 91 | #define STDC_HEADERS 1 92 | 93 | /* Version number of package */ 94 | #define VERSION 0.1 95 | 96 | /* Define to 1 if you want to compile the unmodified code */ 97 | #undef ORIGCODE 98 | 99 | /* Define to the directory where all game files are located */ 100 | #define FILES_DIR "." 101 | -------------------------------------------------------------------------------- /src/d_event.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // 16 | // DESCRIPTION: Event handling. 17 | // 18 | // Events are asynchronous inputs generally generated by the game user. 19 | // Events can be discarded if no responder claims them 20 | // 21 | 22 | #include 23 | #include "d_event.h" 24 | 25 | #define MAXEVENTS 64 26 | 27 | static event_t events[MAXEVENTS]; 28 | static int eventhead; 29 | static int eventtail; 30 | 31 | // 32 | // D_PostEvent 33 | // Called by the I/O functions when input is detected 34 | // 35 | void D_PostEvent (event_t* ev) 36 | { 37 | events[eventhead] = *ev; 38 | eventhead = (eventhead + 1) % MAXEVENTS; 39 | } 40 | 41 | // Read an event from the queue. 42 | 43 | event_t *D_PopEvent(void) 44 | { 45 | event_t *result; 46 | 47 | // No more events waiting. 48 | 49 | if (eventtail == eventhead) 50 | { 51 | return NULL; 52 | } 53 | 54 | result = &events[eventtail]; 55 | 56 | // Advance to the next event in the queue. 57 | 58 | eventtail = (eventtail + 1) % MAXEVENTS; 59 | 60 | return result; 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/d_event.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __D_EVENT__ 21 | #define __D_EVENT__ 22 | 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | // 28 | // Event handling. 29 | // 30 | 31 | // Input event types. 32 | typedef enum 33 | { 34 | ev_keydown, 35 | ev_keyup, 36 | ev_mouse, 37 | ev_joystick, 38 | ev_quit 39 | } evtype_t; 40 | 41 | // Event structure. 42 | typedef struct 43 | { 44 | evtype_t type; 45 | 46 | // Event-related data that depends on the type of event: 47 | // 48 | // ev_keydown/ev_keyup: 49 | // data1: Key code (from doomkeys.h) of the key that was 50 | // pressed or released. 51 | // data2: Ascii text of the character that was pressed, 52 | // shifted appropriately (eg. '$' if 4 was pressed 53 | // while shift was held). 54 | // 55 | // ev_mouse: 56 | // data1: Bitfield of buttons currently held down. 57 | // (bit 0 = left; bit 1 = right; bit 2 = middle). 58 | // data2: X axis mouse movement (turn). 59 | // data3: Y axis mouse movement (forward/backward). 60 | // 61 | // ev_joystick: 62 | // data1: Bitfield of buttons currently pressed. 63 | // data2: X axis mouse movement (turn). 64 | // data3: Y axis mouse movement (forward/backward). 65 | // data4: Third axis mouse movement (strafe). 66 | 67 | int data1, data2, data3, data4; 68 | } event_t; 69 | 70 | 71 | // 72 | // Button/action code definitions. 73 | // 74 | typedef enum 75 | { 76 | // Press "Fire". 77 | BT_ATTACK = 1, 78 | // Use button, to open doors, activate switches. 79 | BT_USE = 2, 80 | 81 | // Flag: game events, not really buttons. 82 | BT_SPECIAL = 128, 83 | BT_SPECIALMASK = 3, 84 | 85 | // Flag, weapon change pending. 86 | // If true, the next 3 bits hold weapon num. 87 | BT_CHANGE = 4, 88 | // The 3bit weapon mask and shift, convenience. 89 | BT_WEAPONMASK = (8+16+32), 90 | BT_WEAPONSHIFT = 3, 91 | 92 | // Pause the game. 93 | BTS_PAUSE = 1, 94 | // Save the game at each console. 95 | BTS_SAVEGAME = 2, 96 | 97 | // Savegame slot numbers 98 | // occupy the second byte of buttons. 99 | BTS_SAVEMASK = (4+8+16), 100 | BTS_SAVESHIFT = 2, 101 | 102 | } buttoncode_t; 103 | 104 | // villsa [STRIFE] Strife specific buttons 105 | // TODO - not finished 106 | typedef enum 107 | { 108 | // Player view look up 109 | BT2_LOOKUP = 1, 110 | // Player view look down 111 | BT2_LOOKDOWN = 2, 112 | // Center player's view 113 | BT2_CENTERVIEW = 4, 114 | // Use inventory item 115 | BT2_INVUSE = 8, 116 | // Drop inventory item 117 | BT2_INVDROP = 16, 118 | // Jump up and down 119 | BT2_JUMP = 32, 120 | // Use medkit 121 | BT2_HEALTH = 128, 122 | 123 | } buttoncode2_t; 124 | 125 | 126 | 127 | 128 | // Called by IO functions when input is detected. 129 | void D_PostEvent (event_t *ev); 130 | 131 | // Read an event from the event queue 132 | 133 | event_t *D_PopEvent(void); 134 | 135 | 136 | #endif 137 | 138 | -------------------------------------------------------------------------------- /src/d_items.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | 18 | 19 | // We are referring to sprite numbers. 20 | #include "info.h" 21 | 22 | #include "d_items.h" 23 | 24 | 25 | // 26 | // PSPRITE ACTIONS for waepons. 27 | // This struct controls the weapon animations. 28 | // 29 | // Each entry is: 30 | // ammo/amunition type 31 | // upstate 32 | // downstate 33 | // readystate 34 | // atkstate, i.e. attack/fire/hit frame 35 | // flashstate, muzzle flash 36 | // 37 | weaponinfo_t weaponinfo[NUMWEAPONS] = 38 | { 39 | { 40 | // fist 41 | am_noammo, 42 | S_PUNCHUP, 43 | S_PUNCHDOWN, 44 | S_PUNCH, 45 | S_PUNCH1, 46 | S_NULL 47 | }, 48 | { 49 | // pistol 50 | am_clip, 51 | S_PISTOLUP, 52 | S_PISTOLDOWN, 53 | S_PISTOL, 54 | S_PISTOL1, 55 | S_PISTOLFLASH 56 | }, 57 | { 58 | // shotgun 59 | am_shell, 60 | S_SGUNUP, 61 | S_SGUNDOWN, 62 | S_SGUN, 63 | S_SGUN1, 64 | S_SGUNFLASH1 65 | }, 66 | { 67 | // chaingun 68 | am_clip, 69 | S_CHAINUP, 70 | S_CHAINDOWN, 71 | S_CHAIN, 72 | S_CHAIN1, 73 | S_CHAINFLASH1 74 | }, 75 | { 76 | // missile launcher 77 | am_misl, 78 | S_MISSILEUP, 79 | S_MISSILEDOWN, 80 | S_MISSILE, 81 | S_MISSILE1, 82 | S_MISSILEFLASH1 83 | }, 84 | { 85 | // plasma rifle 86 | am_cell, 87 | S_PLASMAUP, 88 | S_PLASMADOWN, 89 | S_PLASMA, 90 | S_PLASMA1, 91 | S_PLASMAFLASH1 92 | }, 93 | { 94 | // bfg 9000 95 | am_cell, 96 | S_BFGUP, 97 | S_BFGDOWN, 98 | S_BFG, 99 | S_BFG1, 100 | S_BFGFLASH1 101 | }, 102 | { 103 | // chainsaw 104 | am_noammo, 105 | S_SAWUP, 106 | S_SAWDOWN, 107 | S_SAW, 108 | S_SAW1, 109 | S_NULL 110 | }, 111 | { 112 | // super shotgun 113 | am_shell, 114 | S_DSGUNUP, 115 | S_DSGUNDOWN, 116 | S_DSGUN, 117 | S_DSGUN1, 118 | S_DSGUNFLASH1 119 | }, 120 | }; 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/d_items.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Items: key cards, artifacts, weapon, ammunition. 17 | // 18 | 19 | 20 | #ifndef __D_ITEMS__ 21 | #define __D_ITEMS__ 22 | 23 | #include "doomdef.h" 24 | 25 | 26 | 27 | // Weapon info: sprite frames, ammunition use. 28 | typedef struct 29 | { 30 | ammotype_t ammo; 31 | int upstate; 32 | int downstate; 33 | int readystate; 34 | int atkstate; 35 | int flashstate; 36 | 37 | } weaponinfo_t; 38 | 39 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/d_iwad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Find IWAD and initialize according to IWAD type. 16 | // 17 | 18 | 19 | #ifndef __D_IWAD__ 20 | #define __D_IWAD__ 21 | 22 | #include "d_mode.h" 23 | 24 | #define IWAD_MASK_DOOM ((1 << doom) \ 25 | | (1 << doom2) \ 26 | | (1 << pack_tnt) \ 27 | | (1 << pack_plut) \ 28 | | (1 << pack_chex) \ 29 | | (1 << pack_hacx)) 30 | #define IWAD_MASK_HERETIC (1 << heretic) 31 | #define IWAD_MASK_HEXEN (1 << hexen) 32 | #define IWAD_MASK_STRIFE (1 << strife) 33 | 34 | typedef struct 35 | { 36 | char *name; 37 | GameMission_t mission; 38 | GameMode_t mode; 39 | char *description; 40 | } iwad_t; 41 | 42 | char *D_FindWADByName(char *filename); 43 | char *D_TryFindWADByName(char *filename); 44 | char *D_FindIWAD(int mask, GameMission_t *mission); 45 | const iwad_t **D_FindAllIWADs(int mask); 46 | char *D_SaveGameIWADName(GameMission_t gamemission); 47 | char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode); 48 | char *D_SuggestGameName(GameMission_t mission, GameMode_t mode); 49 | void D_CheckCorrectIWAD(GameMission_t mission); 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/d_loop.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Main loop stuff. 17 | // 18 | 19 | #ifndef __D_LOOP__ 20 | #define __D_LOOP__ 21 | 22 | #include "net_defs.h" 23 | 24 | // Callback function invoked while waiting for the netgame to start. 25 | // The callback is invoked when new players are ready. The callback 26 | // should return true, or return false to abort startup. 27 | 28 | typedef boolean (*netgame_startup_callback_t)(int ready_players, 29 | int num_players); 30 | 31 | typedef struct 32 | { 33 | // Read events from the event queue, and process them. 34 | 35 | void (*ProcessEvents)(); 36 | 37 | // Given the current input state, fill in the fields of the specified 38 | // ticcmd_t structure with data for a new tic. 39 | 40 | void (*BuildTiccmd)(ticcmd_t *cmd, int maketic); 41 | 42 | // Advance the game forward one tic, using the specified player input. 43 | 44 | void (*RunTic)(ticcmd_t *cmds, boolean *ingame); 45 | 46 | // Run the menu (runs independently of the game). 47 | 48 | void (*RunMenu)(); 49 | } loop_interface_t; 50 | 51 | // Register callback functions for the main loop code to use. 52 | void D_RegisterLoopCallbacks(loop_interface_t *i); 53 | 54 | // Create any new ticcmds and broadcast to other players. 55 | // SOKOL CHANGE 56 | // void NetUpdate (void); 57 | 58 | // Broadcasts special packets to other players 59 | // to notify of game exit 60 | void D_QuitNetGame (void); 61 | 62 | //? how many ticks to run? 63 | void TryRunTics (void); 64 | 65 | // Called at start of game loop to initialize timers 66 | void D_StartGameLoop(void); 67 | 68 | // Initialize networking code and connect to server. 69 | 70 | boolean D_InitNetGame(net_connect_data_t *connect_data); 71 | 72 | // Start game with specified settings. The structure will be updated 73 | // with the actual settings for the game. 74 | 75 | void D_StartNetGame(net_gamesettings_t *settings, 76 | netgame_startup_callback_t callback); 77 | 78 | extern boolean singletics; 79 | extern int gametic, ticdup; 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /src/d_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System specific interface stuff. 17 | // 18 | 19 | 20 | #ifndef __D_MAIN__ 21 | #define __D_MAIN__ 22 | 23 | #include "doomdef.h" 24 | 25 | 26 | 27 | 28 | // Read events from all input devices 29 | 30 | void D_ProcessEvents (void); 31 | 32 | 33 | // 34 | // BASE LEVEL 35 | // 36 | void D_PageTicker (void); 37 | void D_PageDrawer (void); 38 | void D_AdvanceDemo (void); 39 | void D_DoAdvanceDemo (void); 40 | void D_StartTitle (void); 41 | 42 | // 43 | // GLOBAL VARIABLES 44 | // 45 | 46 | extern gameaction_t gameaction; 47 | 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/d_mode.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Functions and definitions relating to the game type and operational 17 | // mode. 18 | // 19 | 20 | #ifndef __D_MODE__ 21 | #define __D_MODE__ 22 | 23 | #include "doomtype.h" 24 | 25 | // The "mission" controls what game we are playing. 26 | 27 | typedef enum 28 | { 29 | doom, // Doom 1 30 | doom2, // Doom 2 31 | pack_tnt, // Final Doom: TNT: Evilution 32 | pack_plut, // Final Doom: The Plutonia Experiment 33 | pack_chex, // Chex Quest (modded doom) 34 | pack_hacx, // Hacx (modded doom2) 35 | heretic, // Heretic 36 | hexen, // Hexen 37 | strife, // Strife 38 | 39 | none 40 | } GameMission_t; 41 | 42 | // The "mode" allows more accurate specification of the game mode we are 43 | // in: eg. shareware vs. registered. So doom1.wad and doom.wad are the 44 | // same mission, but a different mode. 45 | 46 | typedef enum 47 | { 48 | shareware, // Doom/Heretic shareware 49 | registered, // Doom/Heretic registered 50 | commercial, // Doom II/Hexen 51 | retail, // Ultimate Doom 52 | indetermined // Unknown. 53 | } GameMode_t; 54 | 55 | // What version are we emulating? 56 | 57 | typedef enum 58 | { 59 | exe_doom_1_2, // Doom 1.2: shareware and registered 60 | exe_doom_1_666, // Doom 1.666: for shareware, registered and commercial 61 | exe_doom_1_7, // Doom 1.7/1.7a: " 62 | exe_doom_1_8, // Doom 1.8: " 63 | exe_doom_1_9, // Doom 1.9: " 64 | exe_hacx, // Hacx 65 | exe_ultimate, // Ultimate Doom (retail) 66 | exe_final, // Final Doom 67 | exe_final2, // Final Doom (alternate exe) 68 | exe_chex, // Chex Quest executable (based on Final Doom) 69 | 70 | exe_heretic_1_3, // Heretic 1.3 71 | 72 | exe_hexen_1_1, // Hexen 1.1 73 | exe_strife_1_2, // Strife v1.2 74 | exe_strife_1_31 // Strife v1.31 75 | } GameVersion_t; 76 | 77 | // Skill level. 78 | 79 | typedef enum 80 | { 81 | sk_noitems = -1, // the "-skill 0" hack 82 | sk_baby = 0, 83 | sk_easy, 84 | sk_medium, 85 | sk_hard, 86 | sk_nightmare 87 | } skill_t; 88 | 89 | boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode); 90 | boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version); 91 | boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode, 92 | int episode, int map); 93 | int D_GetNumEpisodes(GameMission_t mission, GameMode_t mode); 94 | boolean D_IsEpisodeMap(GameMission_t mission); 95 | char *D_GameMissionString(GameMission_t mission); 96 | 97 | #endif /* #ifndef __D_MODE__ */ 98 | 99 | -------------------------------------------------------------------------------- /src/d_textur.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Typedefs related to to textures etc., 17 | // isolated here to make it easier separating modules. 18 | // 19 | 20 | 21 | #ifndef __D_TEXTUR__ 22 | #define __D_TEXTUR__ 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | 28 | 29 | // 30 | // Flats? 31 | // 32 | // a pic is an unmasked block of pixels 33 | typedef struct 34 | { 35 | byte width; 36 | byte height; 37 | byte data; 38 | } pic_t; 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/d_think.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // MapObj data. Map Objects or mobjs are actors, entities, 17 | // thinker, take-your-pick... anything that moves, acts, or 18 | // suffers state changes of more or less violent nature. 19 | // 20 | 21 | 22 | #ifndef __D_THINK__ 23 | #define __D_THINK__ 24 | 25 | 26 | 27 | 28 | 29 | // 30 | // Experimental stuff. 31 | // To compile this as "ANSI C with classes" 32 | // we will need to handle the various 33 | // action functions cleanly. 34 | // 35 | typedef void (*actionf_v)(); 36 | typedef void (*actionf_p1)( void* ); 37 | typedef void (*actionf_p2)( void*, void* ); 38 | 39 | typedef union 40 | { 41 | actionf_v acv; 42 | actionf_p1 acp1; 43 | actionf_p2 acp2; 44 | 45 | } actionf_t; 46 | 47 | 48 | 49 | 50 | 51 | // Historically, "think_t" is yet another 52 | // function pointer to a routine to handle 53 | // an actor. 54 | typedef actionf_t think_t; 55 | 56 | 57 | // Doubly linked list of actors. 58 | typedef struct thinker_s 59 | { 60 | struct thinker_s* prev; 61 | struct thinker_s* next; 62 | think_t function; 63 | 64 | } thinker_t; 65 | 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // Copyright(C) 2005-2014 Simon Howard 5 | // 6 | // This program is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation; either version 2 9 | // of the License, or (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // DESCRIPTION: 17 | // System specific interface stuff. 18 | // 19 | 20 | 21 | #ifndef __D_TICCMD__ 22 | #define __D_TICCMD__ 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | // The data sampled per tick (single player) 28 | // and transmitted to other peers (multiplayer). 29 | // Mainly movements/button commands per game tick, 30 | // plus a checksum for internal state consistency. 31 | 32 | typedef struct 33 | { 34 | signed char forwardmove; // *2048 for move 35 | signed char sidemove; // *2048 for move 36 | short angleturn; // <<16 for angle delta 37 | byte chatchar; 38 | byte buttons; 39 | // villsa [STRIFE] according to the asm, 40 | // consistancy is a short, not a byte 41 | byte consistancy; // checks for net game 42 | 43 | // villsa - Strife specific: 44 | 45 | byte buttons2; 46 | int inventory; 47 | 48 | // Heretic/Hexen specific: 49 | 50 | byte lookfly; // look/fly up/down/centering 51 | byte arti; // artitype_t to use 52 | } ticcmd_t; 53 | 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/deh_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dehacked entrypoint and common code 16 | // 17 | 18 | #ifndef DEH_MAIN_H 19 | #define DEH_MAIN_H 20 | 21 | #include "doomtype.h" 22 | #include "doomfeatures.h" 23 | #include "deh_str.h" 24 | #include "sha1.h" 25 | 26 | // These are the limits that dehacked uses (from dheinit.h in the dehacked 27 | // source). If these limits are exceeded, it does not generate an error, but 28 | // a warning is displayed. 29 | 30 | #define DEH_VANILLA_NUMSTATES 966 31 | #define DEH_VANILLA_NUMSFX 107 32 | 33 | void DEH_ParseCommandLine(void); 34 | int DEH_LoadFile(char *filename); 35 | int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error); 36 | int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error); 37 | 38 | boolean DEH_ParseAssignment(char *line, char **variable_name, char **value); 39 | 40 | void DEH_Checksum(sha1_digest_t digest); 41 | 42 | extern boolean deh_allow_extended_strings; 43 | extern boolean deh_allow_long_strings; 44 | extern boolean deh_allow_long_cheats; 45 | extern boolean deh_apply_cheats; 46 | 47 | #endif /* #ifndef DEH_MAIN_H */ 48 | 49 | -------------------------------------------------------------------------------- /src/deh_misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Parses "Misc" sections in dehacked files 16 | // 17 | 18 | #ifndef DEH_MISC_H 19 | #define DEH_MISC_H 20 | 21 | #include "doomfeatures.h" 22 | 23 | #define DEH_DEFAULT_INITIAL_HEALTH 100 24 | #define DEH_DEFAULT_INITIAL_BULLETS 50 25 | #define DEH_DEFAULT_MAX_HEALTH 200 26 | #define DEH_DEFAULT_MAX_ARMOR 200 27 | #define DEH_DEFAULT_GREEN_ARMOR_CLASS 1 28 | #define DEH_DEFAULT_BLUE_ARMOR_CLASS 2 29 | #define DEH_DEFAULT_MAX_SOULSPHERE 200 30 | #define DEH_DEFAULT_SOULSPHERE_HEALTH 100 31 | #define DEH_DEFAULT_MEGASPHERE_HEALTH 200 32 | #define DEH_DEFAULT_GOD_MODE_HEALTH 100 33 | #define DEH_DEFAULT_IDFA_ARMOR 200 34 | #define DEH_DEFAULT_IDFA_ARMOR_CLASS 2 35 | #define DEH_DEFAULT_IDKFA_ARMOR 200 36 | #define DEH_DEFAULT_IDKFA_ARMOR_CLASS 2 37 | #define DEH_DEFAULT_BFG_CELLS_PER_SHOT 40 38 | #define DEH_DEFAULT_SPECIES_INFIGHTING 0 39 | 40 | #ifdef FEATURE_DEHACKED 41 | 42 | extern int deh_initial_health; 43 | extern int deh_initial_bullets; 44 | extern int deh_max_health; 45 | extern int deh_max_armor; 46 | extern int deh_green_armor_class; 47 | extern int deh_blue_armor_class; 48 | extern int deh_max_soulsphere; 49 | extern int deh_soulsphere_health; 50 | extern int deh_megasphere_health; 51 | extern int deh_god_mode_health; 52 | extern int deh_idfa_armor; 53 | extern int deh_idfa_armor_class; 54 | extern int deh_idkfa_armor; 55 | extern int deh_idkfa_armor_class; 56 | extern int deh_bfg_cells_per_shot; 57 | extern int deh_species_infighting; 58 | 59 | #else 60 | 61 | // If dehacked is disabled, hard coded values 62 | 63 | #define deh_initial_health DEH_DEFAULT_INITIAL_HEALTH 64 | #define deh_initial_bullets DEH_DEFAULT_INITIAL_BULLETS 65 | #define deh_max_health DEH_DEFAULT_MAX_HEALTH 66 | #define deh_max_armor DEH_DEFAULT_MAX_ARMOR 67 | #define deh_green_armor_class DEH_DEFAULT_GREEN_ARMOR_CLASS 68 | #define deh_blue_armor_class DEH_DEFAULT_BLUE_ARMOR_CLASS 69 | #define deh_max_soulsphere DEH_DEFAULT_MAX_SOULSPHERE 70 | #define deh_soulsphere_health DEH_DEFAULT_SOULSPHERE_HEALTH 71 | #define deh_megasphere_health DEH_DEFAULT_MEGASPHERE_HEALTH 72 | #define deh_god_mode_health DEH_DEFAULT_GOD_MODE_HEALTH 73 | #define deh_idfa_armor DEH_DEFAULT_IDFA_ARMOR 74 | #define deh_idfa_armor_class DEH_DEFAULT_IDFA_ARMOR_CLASS 75 | #define deh_idkfa_armor DEH_DEFAULT_IDKFA_ARMOR 76 | #define deh_idkfa_armor_class DEH_DEFAULT_IDKFA_ARMOR_CLASS 77 | #define deh_bfg_cells_per_shot DEH_DEFAULT_BFG_CELLS_PER_SHOT 78 | #define deh_species_infighting DEH_DEFAULT_SPECIES_INFIGHTING 79 | 80 | #endif 81 | 82 | #endif /* #ifndef DEH_MISC_H */ 83 | 84 | -------------------------------------------------------------------------------- /src/deh_str.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dehacked string replacements 16 | // 17 | 18 | #ifndef DEH_STR_H 19 | #define DEH_STR_H 20 | 21 | #include 22 | 23 | #include "doomfeatures.h" 24 | 25 | // Used to do dehacked text substitutions throughout the program 26 | 27 | #ifdef FEATURE_DEHACKED 28 | 29 | char *DEH_String(char *s); 30 | void DEH_printf(char *fmt, ...); 31 | void DEH_fprintf(FILE *fstream, char *fmt, ...); 32 | void DEH_snprintf(char *buffer, size_t len, char *fmt, ...); 33 | void DEH_AddStringReplacement(char *from_text, char *to_text); 34 | 35 | 36 | #else 37 | 38 | #define DEH_String(x) (x) 39 | #define DEH_printf printf 40 | #define DEH_fprintf fprintf 41 | #define DEH_snprintf snprintf 42 | #define DEH_AddStringReplacement(x, y) 43 | 44 | #endif 45 | 46 | #endif /* #ifndef DEH_STR_H */ 47 | 48 | -------------------------------------------------------------------------------- /src/doom-assets.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # NOTE: the data have .wasm extension just so that they are compressed by github pages 3 | files: [ doom1.wad.wasm, aweromgm.sf2.wasm ] 4 | -------------------------------------------------------------------------------- /src/doom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * doom.h 3 | * 4 | * Created on: 18.02.2015 5 | * Author: Florian 6 | */ 7 | 8 | 9 | #ifndef SRC_CHOCDOOM_DOOM_H_ 10 | #define SRC_CHOCDOOM_DOOM_H_ 11 | 12 | /*---------------------------------------------------------------------* 13 | * additional includes * 14 | *---------------------------------------------------------------------*/ 15 | 16 | /*---------------------------------------------------------------------* 17 | * global definitions * 18 | *---------------------------------------------------------------------*/ 19 | 20 | /*---------------------------------------------------------------------* 21 | * type declarations * 22 | *---------------------------------------------------------------------*/ 23 | 24 | /*---------------------------------------------------------------------* 25 | * function prototypes * 26 | *---------------------------------------------------------------------*/ 27 | 28 | void D_DoomMain (void); 29 | 30 | /*---------------------------------------------------------------------* 31 | * global data * 32 | *---------------------------------------------------------------------*/ 33 | 34 | /*---------------------------------------------------------------------* 35 | * inline functions and function-like macros * 36 | *---------------------------------------------------------------------*/ 37 | 38 | /*---------------------------------------------------------------------* 39 | * eof * 40 | *---------------------------------------------------------------------*/ 41 | 42 | #endif /* SRC_CHOCDOOM_DOOM_H_ */ 43 | -------------------------------------------------------------------------------- /src/doom1.wad.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/doom-sokol/138639a66b6e40a8202e03f67957d0fd314fb565/src/doom1.wad.wasm -------------------------------------------------------------------------------- /src/doomdef.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // DoomDef - basic defines for DOOM, e.g. Version, game mode 17 | // and skill level, and display parameters. 18 | // 19 | 20 | 21 | 22 | #include "doomdef.h" 23 | 24 | // Location for any defines turned variables. 25 | 26 | // None. 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/doomdef.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Internally used data structures for virtually everything, 17 | // lots of other stuff. 18 | // 19 | 20 | #ifndef __DOOMDEF__ 21 | #define __DOOMDEF__ 22 | 23 | #include 24 | #include 25 | 26 | #include "doomtype.h" 27 | #include "i_timer.h" 28 | #include "d_mode.h" 29 | 30 | // 31 | // Global parameters/defines. 32 | // 33 | // DOOM version 34 | #define DOOM_VERSION 109 35 | 36 | // Version code for cph's longtics hack ("v1.91") 37 | #define DOOM_191_VERSION 111 38 | 39 | 40 | // If rangecheck is undefined, 41 | // most parameter validation debugging code will not be compiled 42 | #define RANGECHECK 43 | 44 | // The maximum number of players, multiplayer/networking. 45 | #define MAXPLAYERS 4 46 | 47 | // The current state of the game: whether we are 48 | // playing, gazing at the intermission screen, 49 | // the game final animation, or a demo. 50 | typedef enum 51 | { 52 | GS_LEVEL, 53 | GS_INTERMISSION, 54 | GS_FINALE, 55 | GS_DEMOSCREEN, 56 | } gamestate_t; 57 | 58 | typedef enum 59 | { 60 | ga_nothing, 61 | ga_loadlevel, 62 | ga_newgame, 63 | ga_loadgame, 64 | ga_savegame, 65 | ga_playdemo, 66 | ga_completed, 67 | ga_victory, 68 | ga_worlddone, 69 | ga_screenshot 70 | } gameaction_t; 71 | 72 | // 73 | // Difficulty/skill settings/filters. 74 | // 75 | 76 | // Skill flags. 77 | #define MTF_EASY 1 78 | #define MTF_NORMAL 2 79 | #define MTF_HARD 4 80 | 81 | // Deaf monsters/do not react to sound. 82 | #define MTF_AMBUSH 8 83 | 84 | 85 | // 86 | // Key cards. 87 | // 88 | typedef enum 89 | { 90 | it_bluecard, 91 | it_yellowcard, 92 | it_redcard, 93 | it_blueskull, 94 | it_yellowskull, 95 | it_redskull, 96 | 97 | NUMCARDS 98 | 99 | } card_t; 100 | 101 | 102 | 103 | // The defined weapons, 104 | // including a marker indicating 105 | // user has not changed weapon. 106 | typedef enum 107 | { 108 | wp_fist, 109 | wp_pistol, 110 | wp_shotgun, 111 | wp_chaingun, 112 | wp_missile, 113 | wp_plasma, 114 | wp_bfg, 115 | wp_chainsaw, 116 | wp_supershotgun, 117 | 118 | NUMWEAPONS, 119 | 120 | // No pending weapon change. 121 | wp_nochange 122 | 123 | } weapontype_t; 124 | 125 | 126 | // Ammunition types defined. 127 | typedef enum 128 | { 129 | am_clip, // Pistol / chaingun ammo. 130 | am_shell, // Shotgun / double barreled shotgun. 131 | am_cell, // Plasma rifle, BFG. 132 | am_misl, // Missile launcher. 133 | NUMAMMO, 134 | am_noammo // Unlimited for chainsaw / fist. 135 | 136 | } ammotype_t; 137 | 138 | 139 | // Power up artifacts. 140 | typedef enum 141 | { 142 | pw_invulnerability, 143 | pw_strength, 144 | pw_invisibility, 145 | pw_ironfeet, 146 | pw_allmap, 147 | pw_infrared, 148 | NUMPOWERS 149 | 150 | } powertype_t; 151 | 152 | 153 | 154 | // 155 | // Power up durations, 156 | // how many seconds till expiration, 157 | // assuming TICRATE is 35 ticks/second. 158 | // 159 | typedef enum 160 | { 161 | INVULNTICS = (30*TICRATE), 162 | INVISTICS = (60*TICRATE), 163 | INFRATICS = (120*TICRATE), 164 | IRONTICS = (60*TICRATE) 165 | 166 | } powerduration_t; 167 | 168 | #endif // __DOOMDEF__ 169 | -------------------------------------------------------------------------------- /src/doomfeatures.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // List of features which can be enabled/disabled to slim down the 16 | // program. 17 | // 18 | 19 | #ifndef DOOM_FEATURES_H 20 | #define DOOM_FEATURES_H 21 | 22 | // Enables wad merging (the '-merge' command line parameter) 23 | 24 | #undef FEATURE_WAD_MERGE 25 | 26 | // Enables dehacked support ('-deh') 27 | 28 | #undef FEATURE_DEHACKED 29 | 30 | // Enables multiplayer support (network games) 31 | 32 | #undef FEATURE_MULTIPLAYER 33 | 34 | // Enables sound output 35 | 36 | //#undef FEATURE_SOUND 37 | #define FEATURE_SOUND 38 | 39 | #endif /* #ifndef DOOM_FEATURES_H */ 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/doomgeneric.c: -------------------------------------------------------------------------------- 1 | #include "doomgeneric.h" 2 | 3 | // SOKOL CHANGE 4 | //uint32_t* DG_ScreenBuffer = 0; 5 | 6 | 7 | void dg_Create() 8 | { 9 | // SOKOL CHANGE 10 | //DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4); 11 | 12 | DG_Init(); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/doomgeneric.h: -------------------------------------------------------------------------------- 1 | #ifndef DOOM_GENERIC 2 | #define DOOM_GENERIC 3 | 4 | #include 5 | #include 6 | 7 | // SOKOL CHANGE 8 | //#define DOOMGENERIC_RESX 640 9 | //#define DOOMGENERIC_RESY 400 10 | 11 | // extern uint32_t* DG_ScreenBuffer; 12 | 13 | void DG_Init(); 14 | void DG_DrawFrame(); 15 | void DG_SleepMs(uint32_t ms); 16 | uint32_t DG_GetTicksMs(); 17 | int DG_GetKey(int* pressed, unsigned char* key); 18 | void DG_SetWindowTitle(const char * title); 19 | 20 | #endif //DOOM_GENERIC 21 | -------------------------------------------------------------------------------- /src/doomkeys.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Key definitions 17 | // 18 | 19 | #ifndef __DOOMKEYS__ 20 | #define __DOOMKEYS__ 21 | 22 | // 23 | // DOOM keyboard definition. 24 | // This is the stuff configured by Setup.Exe. 25 | // Most key data are simple ascii (uppercased). 26 | // 27 | #define KEY_RIGHTARROW 0xae 28 | #define KEY_LEFTARROW 0xac 29 | #define KEY_UPARROW 0xad 30 | #define KEY_DOWNARROW 0xaf 31 | #define KEY_STRAFE_L 0xa0 32 | #define KEY_STRAFE_R 0xa1 33 | #define KEY_USE 0xa2 34 | #define KEY_FIRE 0xa3 35 | #define KEY_ESCAPE 27 36 | #define KEY_ENTER 13 37 | #define KEY_TAB 9 38 | #define KEY_F1 (0x80+0x3b) 39 | #define KEY_F2 (0x80+0x3c) 40 | #define KEY_F3 (0x80+0x3d) 41 | #define KEY_F4 (0x80+0x3e) 42 | #define KEY_F5 (0x80+0x3f) 43 | #define KEY_F6 (0x80+0x40) 44 | #define KEY_F7 (0x80+0x41) 45 | #define KEY_F8 (0x80+0x42) 46 | #define KEY_F9 (0x80+0x43) 47 | #define KEY_F10 (0x80+0x44) 48 | #define KEY_F11 (0x80+0x57) 49 | #define KEY_F12 (0x80+0x58) 50 | 51 | #define KEY_BACKSPACE 0x7f 52 | #define KEY_PAUSE 0xff 53 | 54 | #define KEY_EQUALS 0x3d 55 | #define KEY_MINUS 0x2d 56 | 57 | #define KEY_RSHIFT (0x80+0x36) 58 | #define KEY_RCTRL (0x80+0x1d) 59 | #define KEY_RALT (0x80+0x38) 60 | 61 | #define KEY_LALT KEY_RALT 62 | 63 | // new keys: 64 | 65 | #define KEY_CAPSLOCK (0x80+0x3a) 66 | #define KEY_NUMLOCK (0x80+0x45) 67 | #define KEY_SCRLCK (0x80+0x46) 68 | #define KEY_PRTSCR (0x80+0x59) 69 | 70 | #define KEY_HOME (0x80+0x47) 71 | #define KEY_END (0x80+0x4f) 72 | #define KEY_PGUP (0x80+0x49) 73 | #define KEY_PGDN (0x80+0x51) 74 | #define KEY_INS (0x80+0x52) 75 | #define KEY_DEL (0x80+0x53) 76 | 77 | #define KEYP_0 0 78 | #define KEYP_1 KEY_END 79 | #define KEYP_2 KEY_DOWNARROW 80 | #define KEYP_3 KEY_PGDN 81 | #define KEYP_4 KEY_LEFTARROW 82 | #define KEYP_5 '5' 83 | #define KEYP_6 KEY_RIGHTARROW 84 | #define KEYP_7 KEY_HOME 85 | #define KEYP_8 KEY_UPARROW 86 | #define KEYP_9 KEY_PGUP 87 | 88 | #define KEYP_DIVIDE '/' 89 | #define KEYP_PLUS '+' 90 | #define KEYP_MINUS '-' 91 | #define KEYP_MULTIPLY '*' 92 | #define KEYP_PERIOD 0 93 | #define KEYP_EQUALS KEY_EQUALS 94 | #define KEYP_ENTER KEY_ENTER 95 | 96 | #endif // __DOOMKEYS__ 97 | 98 | -------------------------------------------------------------------------------- /src/doomstat.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Put all global tate variables here. 17 | // 18 | 19 | #include 20 | 21 | #include "doomstat.h" 22 | 23 | 24 | // Game Mode - identify IWAD as shareware, retail etc. 25 | GameMode_t gamemode = indetermined; 26 | GameMission_t gamemission = doom; 27 | GameVersion_t gameversion = exe_final2; 28 | char *gamedescription; 29 | 30 | // Set if homebrew PWAD stuff has been added. 31 | boolean modifiedgame; 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/doomtype.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Simple basic typedefs, isolated here to make it easier 17 | // separating modules. 18 | // 19 | 20 | 21 | #ifndef __DOOMTYPE__ 22 | #define __DOOMTYPE__ 23 | 24 | // #define macros to provide functions missing in Windows. 25 | // Outside Windows, we use strings.h for str[n]casecmp. 26 | 27 | 28 | #ifdef _WIN32 29 | 30 | #define strcasecmp _stricmp 31 | #define strncasecmp _strnicmp 32 | 33 | #else 34 | 35 | #include 36 | 37 | #endif 38 | 39 | 40 | // 41 | // The packed attribute forces structures to be packed into the minimum 42 | // space necessary. If this is not done, the compiler may align structure 43 | // fields differently to optimize memory access, inflating the overall 44 | // structure size. It is important to use the packed attribute on certain 45 | // structures where alignment is important, particularly data read/written 46 | // to disk. 47 | // 48 | 49 | #ifdef __GNUC__ 50 | #define PACKEDATTR __attribute__((packed)) 51 | #else 52 | #define PACKEDATTR 53 | #endif 54 | 55 | // C99 integer types; with gcc we just use this. Other compilers 56 | // should add conditional statements that define the C99 types. 57 | 58 | // What is really wanted here is stdint.h; however, some old versions 59 | // of Solaris don't have stdint.h and only have inttypes.h (the 60 | // pre-standardisation version). inttypes.h is also in the C99 61 | // standard and defined to include stdint.h, so include this. 62 | 63 | #include 64 | #include 65 | 66 | typedef uint8_t byte; 67 | 68 | // NOTE: the 'undef' is important when loading WAD files!!! 69 | typedef enum 70 | { 71 | __false = 0, 72 | __true = 1, 73 | undef = 0xFFFFFFFF 74 | } boolean; 75 | 76 | #include 77 | 78 | #ifdef _WIN32 79 | 80 | #define DIR_SEPARATOR '\\' 81 | #define DIR_SEPARATOR_S "\\" 82 | #define PATH_SEPARATOR ';' 83 | 84 | #else 85 | 86 | #define DIR_SEPARATOR '/' 87 | #define DIR_SEPARATOR_S "/" 88 | #define PATH_SEPARATOR ':' 89 | 90 | #endif 91 | 92 | #define arrlen(array) (sizeof(array) / sizeof(*array)) 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/dstrings.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Globally defined strings. 17 | // 18 | 19 | 20 | 21 | #include "dstrings.h" 22 | 23 | char *doom1_endmsg[] = 24 | { 25 | "are you sure you want to\nquit this great game?", 26 | "please don't leave, there's more\ndemons to toast!", 27 | "let's beat it -- this is turning\ninto a bloodbath!", 28 | "i wouldn't leave if i were you.\ndos is much worse.", 29 | "you're trying to say you like dos\nbetter than me, right?", 30 | "don't leave yet -- there's a\ndemon around that corner!", 31 | "ya know, next time you come in here\ni'm gonna toast ya.", 32 | "go ahead and leave. see if i care.", 33 | }; 34 | 35 | char *doom2_endmsg[] = 36 | { 37 | // QuitDOOM II messages 38 | "are you sure you want to\nquit this great game?", 39 | "you want to quit?\nthen, thou hast lost an eighth!", 40 | "don't go now, there's a \ndimensional shambler waiting\nat the dos prompt!", 41 | "get outta here and go back\nto your boring programs.", 42 | "if i were your boss, i'd \n deathmatch ya in a minute!", 43 | "look, bud. you leave now\nand you forfeit your body count!", 44 | "just leave. when you come\nback, i'll be waiting with a bat.", 45 | "you're lucky i don't smack\nyou for thinking about leaving.", 46 | }; 47 | 48 | #if 0 49 | 50 | // UNUSED messages included in the source release 51 | 52 | char* endmsg[] = 53 | { 54 | // DOOM1 55 | QUITMSG, 56 | // FinalDOOM? 57 | "fuck you, pussy!\nget the fuck out!", 58 | "you quit and i'll jizz\nin your cystholes!", 59 | "if you leave, i'll make\nthe lord drink my jizz.", 60 | "hey, ron! can we say\n'fuck' in the game?", 61 | "i'd leave: this is just\nmore monsters and levels.\nwhat a load.", 62 | "suck it down, asshole!\nyou're a fucking wimp!", 63 | "don't quit now! we're \nstill spending your money!", 64 | 65 | // Internal debug. Different style, too. 66 | "THIS IS NO MESSAGE!\nPage intentionally left blank." 67 | }; 68 | 69 | #endif 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/dstrings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // 16 | // DESCRIPTION: 17 | // DOOM strings, by language. 18 | // 19 | 20 | 21 | #ifndef __DSTRINGS__ 22 | #define __DSTRINGS__ 23 | 24 | 25 | // All important printed strings. 26 | 27 | #include "d_englsh.h" 28 | 29 | // Misc. other strings. 30 | #define SAVEGAMENAME "doomsav" 31 | 32 | 33 | // QuitDOOM messages 34 | // 8 per each game type 35 | #define NUM_QUITMESSAGES 8 36 | 37 | extern char *doom1_endmsg[]; 38 | extern char *doom2_endmsg[]; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dummy.c 3 | * 4 | * Created on: 16.02.2015 5 | * Author: Florian 6 | */ 7 | 8 | 9 | /*---------------------------------------------------------------------* 10 | * include files * 11 | *---------------------------------------------------------------------*/ 12 | 13 | #include "doomtype.h" 14 | 15 | /*---------------------------------------------------------------------* 16 | * local definitions * 17 | *---------------------------------------------------------------------*/ 18 | 19 | /*---------------------------------------------------------------------* 20 | * external declarations * 21 | *---------------------------------------------------------------------*/ 22 | 23 | /*---------------------------------------------------------------------* 24 | * public data * 25 | *---------------------------------------------------------------------*/ 26 | 27 | boolean net_client_connected = false; 28 | 29 | boolean drone = false; 30 | 31 | /*---------------------------------------------------------------------* 32 | * private data * 33 | *---------------------------------------------------------------------*/ 34 | 35 | /*---------------------------------------------------------------------* 36 | * private functions * 37 | *---------------------------------------------------------------------*/ 38 | 39 | /*---------------------------------------------------------------------* 40 | * public functions * 41 | *---------------------------------------------------------------------*/ 42 | 43 | void I_InitTimidityConfig(void) 44 | { 45 | } 46 | 47 | /*---------------------------------------------------------------------* 48 | * eof * 49 | *---------------------------------------------------------------------*/ 50 | -------------------------------------------------------------------------------- /src/f_finale.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __F_FINALE__ 21 | #define __F_FINALE__ 22 | 23 | 24 | #include "doomtype.h" 25 | #include "d_event.h" 26 | // 27 | // FINALE 28 | // 29 | 30 | // Called by main loop. 31 | boolean F_Responder (event_t* ev); 32 | 33 | // Called by main loop. 34 | void F_Ticker (void); 35 | 36 | // Called by main loop. 37 | void F_Drawer (void); 38 | 39 | 40 | void F_StartFinale (void); 41 | 42 | 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/f_wipe.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Mission start screen wipe/melt, special effects. 17 | // 18 | 19 | 20 | #ifndef __F_WIPE_H__ 21 | #define __F_WIPE_H__ 22 | 23 | // 24 | // SCREEN WIPE PACKAGE 25 | // 26 | 27 | enum 28 | { 29 | // simple gradual pixel change for 8-bit only 30 | wipe_ColorXForm, 31 | 32 | // weird screen melt 33 | wipe_Melt, 34 | 35 | wipe_NUMWIPES 36 | }; 37 | 38 | int 39 | wipe_StartScreen 40 | ( int x, 41 | int y, 42 | int width, 43 | int height ); 44 | 45 | 46 | int 47 | wipe_EndScreen 48 | ( int x, 49 | int y, 50 | int width, 51 | int height ); 52 | 53 | 54 | int 55 | wipe_ScreenWipe 56 | ( int wipeno, 57 | int x, 58 | int y, 59 | int width, 60 | int height, 61 | int ticks ); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/g_game.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Duh. 17 | // 18 | 19 | 20 | #ifndef __G_GAME__ 21 | #define __G_GAME__ 22 | 23 | #include "doomdef.h" 24 | #include "d_event.h" 25 | #include "d_ticcmd.h" 26 | 27 | 28 | // 29 | // GAME 30 | // 31 | void G_DeathMatchSpawnPlayer (int playernum); 32 | 33 | void G_InitNew (skill_t skill, int episode, int map); 34 | 35 | // Can be called by the startup code or M_Responder. 36 | // A normal game starts at map 1, 37 | // but a warp test can start elsewhere 38 | void G_DeferedInitNew (skill_t skill, int episode, int map); 39 | 40 | void G_DeferedPlayDemo (char* demo); 41 | 42 | // Can be called by the startup code or M_Responder, 43 | // calls P_SetupLevel or W_EnterWorld. 44 | void G_LoadGame (char* name); 45 | 46 | void G_DoLoadGame (void); 47 | 48 | // Called by M_Responder. 49 | void G_SaveGame (int slot, char* description); 50 | 51 | // Only called by startup code. 52 | void G_RecordDemo (char* name); 53 | 54 | void G_BeginRecording (void); 55 | 56 | void G_PlayDemo (char* name); 57 | void G_TimeDemo (char* name); 58 | boolean G_CheckDemoStatus (void); 59 | 60 | void G_ExitLevel (void); 61 | void G_SecretExitLevel (void); 62 | 63 | void G_WorldDone (void); 64 | 65 | // Read current data from inputs and build a player movement command. 66 | 67 | void G_BuildTiccmd (ticcmd_t *cmd, int maketic); 68 | 69 | void G_Ticker (void); 70 | boolean G_Responder (event_t* ev); 71 | 72 | void G_ScreenShot (void); 73 | 74 | void G_DrawMouseSpeedBox(void); 75 | int G_VanillaVersionCode(void); 76 | 77 | extern int vanilla_savegame_limit; 78 | extern int vanilla_demo_limit; 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /src/gusconf.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // GUS emulation code. 16 | // 17 | 18 | #ifndef __GUSCONF_H__ 19 | #define __GUSCONF_H__ 20 | 21 | #include "doomtype.h" 22 | 23 | extern char *gus_patch_path; 24 | extern unsigned int gus_ram_kb; 25 | 26 | boolean GUS_WriteConfig(char *path); 27 | 28 | #endif /* #ifndef __GUSCONF_H__ */ 29 | 30 | -------------------------------------------------------------------------------- /src/hu_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: none 16 | // 17 | 18 | #ifndef __HULIB__ 19 | #define __HULIB__ 20 | 21 | // We are referring to patches. 22 | #include "r_defs.h" 23 | 24 | // font stuff 25 | #define HU_CHARERASE KEY_BACKSPACE 26 | 27 | #define HU_MAXLINES 4 28 | #define HU_MAXLINELENGTH 80 29 | 30 | // 31 | // Typedefs of widgets 32 | // 33 | 34 | // Text Line widget 35 | // (parent of Scrolling Text and Input Text widgets) 36 | typedef struct 37 | { 38 | // left-justified position of scrolling text window 39 | int x; 40 | int y; 41 | 42 | patch_t** f; // font 43 | int sc; // start character 44 | char l[HU_MAXLINELENGTH+1]; // line of text 45 | int len; // current line length 46 | 47 | // whether this line needs to be udpated 48 | int needsupdate; 49 | 50 | } hu_textline_t; 51 | 52 | 53 | 54 | // Scrolling Text window widget 55 | // (child of Text Line widget) 56 | typedef struct 57 | { 58 | hu_textline_t l[HU_MAXLINES]; // text lines to draw 59 | int h; // height in lines 60 | int cl; // current line number 61 | 62 | // pointer to boolean stating whether to update window 63 | boolean* on; 64 | boolean laston; // last value of *->on. 65 | 66 | } hu_stext_t; 67 | 68 | 69 | 70 | // Input Text Line widget 71 | // (child of Text Line widget) 72 | typedef struct 73 | { 74 | hu_textline_t l; // text line to input on 75 | 76 | // left margin past which I am not to delete characters 77 | int lm; 78 | 79 | // pointer to boolean stating whether to update window 80 | boolean* on; 81 | boolean laston; // last value of *->on; 82 | 83 | } hu_itext_t; 84 | 85 | 86 | // 87 | // Widget creation, access, and update routines 88 | // 89 | 90 | // initializes heads-up widget library 91 | void HUlib_init(void); 92 | 93 | // 94 | // textline code 95 | // 96 | 97 | // clear a line of text 98 | void HUlib_clearTextLine(hu_textline_t *t); 99 | 100 | void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); 101 | 102 | // returns success 103 | boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); 104 | 105 | // returns success 106 | boolean HUlib_delCharFromTextLine(hu_textline_t *t); 107 | 108 | // draws tline 109 | void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); 110 | 111 | // erases text line 112 | void HUlib_eraseTextLine(hu_textline_t *l); 113 | 114 | 115 | // 116 | // Scrolling Text window widget routines 117 | // 118 | 119 | // ? 120 | void 121 | HUlib_initSText 122 | ( hu_stext_t* s, 123 | int x, 124 | int y, 125 | int h, 126 | patch_t** font, 127 | int startchar, 128 | boolean* on ); 129 | 130 | // add a new line 131 | void HUlib_addLineToSText(hu_stext_t* s); 132 | 133 | // ? 134 | void 135 | HUlib_addMessageToSText 136 | ( hu_stext_t* s, 137 | char* prefix, 138 | char* msg ); 139 | 140 | // draws stext 141 | void HUlib_drawSText(hu_stext_t* s); 142 | 143 | // erases all stext lines 144 | void HUlib_eraseSText(hu_stext_t* s); 145 | 146 | // Input Text Line widget routines 147 | void 148 | HUlib_initIText 149 | ( hu_itext_t* it, 150 | int x, 151 | int y, 152 | patch_t** font, 153 | int startchar, 154 | boolean* on ); 155 | 156 | // enforces left margin 157 | void HUlib_delCharFromIText(hu_itext_t* it); 158 | 159 | // enforces left margin 160 | void HUlib_eraseLineFromIText(hu_itext_t* it); 161 | 162 | // resets line and left margin 163 | void HUlib_resetIText(hu_itext_t* it); 164 | 165 | // left of left-margin 166 | void 167 | HUlib_addPrefixToIText 168 | ( hu_itext_t* it, 169 | char* str ); 170 | 171 | // whether eaten 172 | boolean 173 | HUlib_keyInIText 174 | ( hu_itext_t* it, 175 | unsigned char ch ); 176 | 177 | void HUlib_drawIText(hu_itext_t* it); 178 | 179 | // erases all itext lines 180 | void HUlib_eraseIText(hu_itext_t* it); 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /src/hu_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: Head up display 16 | // 17 | 18 | #ifndef __HU_STUFF_H__ 19 | #define __HU_STUFF_H__ 20 | 21 | #include "d_event.h" 22 | 23 | 24 | // 25 | // Globally visible constants. 26 | // 27 | #define HU_FONTSTART '!' // the first font characters 28 | #define HU_FONTEND '_' // the last font characters 29 | 30 | // Calculate # of glyphs in font. 31 | #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) 32 | 33 | #define HU_BROADCAST 5 34 | 35 | #define HU_MSGX 0 36 | #define HU_MSGY 0 37 | #define HU_MSGWIDTH 64 // in characters 38 | #define HU_MSGHEIGHT 1 // in lines 39 | 40 | #define HU_MSGTIMEOUT (4*TICRATE) 41 | 42 | // 43 | // HEADS UP TEXT 44 | // 45 | 46 | void HU_Init(void); 47 | void HU_Start(void); 48 | 49 | boolean HU_Responder(event_t* ev); 50 | 51 | void HU_Ticker(void); 52 | void HU_Drawer(void); 53 | char HU_dequeueChatChar(void); 54 | void HU_Erase(void); 55 | 56 | extern char *chat_macros[10]; 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /src/i_cdmus.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | 16 | // i_cdmus.h 17 | 18 | #ifndef __ICDMUS__ 19 | #define __ICDMUS__ 20 | 21 | #define CDERR_NOTINSTALLED 10 // MSCDEX not installed 22 | #define CDERR_NOAUDIOSUPPORT 11 // CD-ROM Doesn't support audio 23 | #define CDERR_NOAUDIOTRACKS 12 // Current CD has no audio tracks 24 | #define CDERR_BADDRIVE 20 // Bad drive number 25 | #define CDERR_BADTRACK 21 // Bad track number 26 | #define CDERR_IOCTLBUFFMEM 22 // Not enough low memory for IOCTL 27 | #define CDERR_DEVREQBASE 100 // DevReq errors 28 | 29 | extern int cd_Error; 30 | 31 | int I_CDMusInit(void); 32 | void I_CDMusPrintStartup(void); 33 | int I_CDMusPlay(int track); 34 | int I_CDMusStop(void); 35 | int I_CDMusResume(void); 36 | int I_CDMusSetVolume(int volume); 37 | int I_CDMusFirstTrack(void); 38 | int I_CDMusLastTrack(void); 39 | int I_CDMusTrackLength(int track); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/i_endoom.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Exit text-mode ENDOOM screen. 16 | // 17 | 18 | #include 19 | #include 20 | 21 | #include "config.h" 22 | #include "doomtype.h" 23 | #include "i_video.h" 24 | 25 | #ifdef ORIGCODE 26 | #include "txt_main.h" 27 | #endif 28 | 29 | #define ENDOOM_W 80 30 | #define ENDOOM_H 25 31 | 32 | // 33 | // Displays the text mode ending screen after the game quits 34 | // 35 | 36 | void I_Endoom(byte *endoom_data) 37 | { 38 | #ifdef ORIGCODE 39 | unsigned char *screendata; 40 | int y; 41 | int indent; 42 | 43 | // Set up text mode screen 44 | 45 | TXT_Init(); 46 | I_InitWindowTitle(); 47 | I_InitWindowIcon(); 48 | 49 | // Write the data to the screen memory 50 | 51 | screendata = TXT_GetScreenData(); 52 | 53 | indent = (ENDOOM_W - TXT_SCREEN_W) / 2; 54 | 55 | for (y=0; y 0) 69 | { 70 | break; 71 | } 72 | 73 | TXT_Sleep(0); 74 | } 75 | 76 | // Shut down text mode screen 77 | 78 | TXT_Shutdown(); 79 | #endif 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/i_endoom.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Exit text-mode ENDOOM screen. 17 | // 18 | 19 | 20 | #ifndef __I_ENDOOM__ 21 | #define __I_ENDOOM__ 22 | 23 | // Display the Endoom screen on shutdown. Pass a pointer to the 24 | // ENDOOM lump. 25 | 26 | void I_Endoom(byte *data); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/i_joystick.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // System-specific joystick interface. 16 | // 17 | 18 | 19 | #ifndef __I_JOYSTICK__ 20 | #define __I_JOYSTICK__ 21 | 22 | // Number of "virtual" joystick buttons defined in configuration files. 23 | // This needs to be at least as large as the number of different key 24 | // bindings supported by the higher-level game code (joyb* variables). 25 | #define NUM_VIRTUAL_BUTTONS 10 26 | 27 | // If this bit is set in a configuration file axis value, the axis is 28 | // not actually a joystick axis, but instead is a "button axis". This 29 | // means that instead of reading an SDL joystick axis, we read the 30 | // state of two buttons to get the axis value. This is needed for eg. 31 | // the PS3 SIXAXIS controller, where the D-pad buttons register as 32 | // buttons, not as two axes. 33 | #define BUTTON_AXIS 0x10000 34 | 35 | // Query whether a given axis value describes a button axis. 36 | #define IS_BUTTON_AXIS(axis) ((axis) >= 0 && ((axis) & BUTTON_AXIS) != 0) 37 | 38 | // Get the individual buttons from a button axis value. 39 | #define BUTTON_AXIS_NEG(axis) ((axis) & 0xff) 40 | #define BUTTON_AXIS_POS(axis) (((axis) >> 8) & 0xff) 41 | 42 | // Create a button axis value from two button values. 43 | #define CREATE_BUTTON_AXIS(neg, pos) (BUTTON_AXIS | (neg) | ((pos) << 8)) 44 | 45 | // If this bit is set in an axis value, the axis is not actually a 46 | // joystick axis, but is a "hat" axis. This means that we read (one of) 47 | // the hats on the joystick. 48 | #define HAT_AXIS 0x20000 49 | 50 | #define IS_HAT_AXIS(axis) ((axis) >= 0 && ((axis) & HAT_AXIS) != 0) 51 | 52 | // Get the hat number from a hat axis value. 53 | #define HAT_AXIS_HAT(axis) ((axis) & 0xff) 54 | // Which axis of the hat? (horizonal or vertical) 55 | #define HAT_AXIS_DIRECTION(axis) (((axis) >> 8) & 0xff) 56 | 57 | #define CREATE_HAT_AXIS(hat, direction) \ 58 | (HAT_AXIS | (hat) | ((direction) << 8)) 59 | 60 | #define HAT_AXIS_HORIZONTAL 1 61 | #define HAT_AXIS_VERTICAL 2 62 | 63 | void I_InitJoystick(void); 64 | void I_ShutdownJoystick(void); 65 | void I_UpdateJoystick(void); 66 | 67 | void I_BindJoystickVariables(void); 68 | 69 | #endif /* #ifndef __I_JOYSTICK__ */ 70 | 71 | -------------------------------------------------------------------------------- /src/i_main.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Main program, simply calls D_DoomMain high level loop. 17 | // 18 | 19 | //#include "config.h" 20 | 21 | #include 22 | 23 | //#include "doomtype.h" 24 | //#include "i_system.h" 25 | #include "m_argv.h" 26 | 27 | // 28 | // D_DoomMain() 29 | // Not a globally visible function, just included for source reference, 30 | // calls all startup code, parses command line options. 31 | // 32 | 33 | void D_DoomMain (void); 34 | 35 | void M_FindResponseFile(void); 36 | 37 | void dg_Create(); 38 | 39 | 40 | int main(int argc, char **argv) 41 | { 42 | // save arguments 43 | 44 | myargc = argc; 45 | myargv = argv; 46 | 47 | M_FindResponseFile(); 48 | 49 | // start doom 50 | printf("Starting D_DoomMain\r\n"); 51 | 52 | dg_Create(); 53 | 54 | D_DoomMain (); 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/i_scale.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Pixel-doubling scale up functions. 17 | // 18 | 19 | 20 | #ifndef __I_SCALE__ 21 | #define __I_SCALE__ 22 | 23 | #include "doomtype.h" 24 | 25 | void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch); 26 | void I_ResetScaleTables(byte *palette); 27 | 28 | // Scaled modes (direct multiples of 320x200) 29 | 30 | extern screen_mode_t mode_scale_1x; 31 | extern screen_mode_t mode_scale_2x; 32 | extern screen_mode_t mode_scale_3x; 33 | extern screen_mode_t mode_scale_4x; 34 | extern screen_mode_t mode_scale_5x; 35 | 36 | // Vertically stretched modes (320x200 -> multiples of 320x240) 37 | 38 | extern screen_mode_t mode_stretch_1x; 39 | extern screen_mode_t mode_stretch_2x; 40 | extern screen_mode_t mode_stretch_3x; 41 | extern screen_mode_t mode_stretch_4x; 42 | extern screen_mode_t mode_stretch_5x; 43 | 44 | // Horizontally squashed modes (320x200 -> multiples of 256x200) 45 | 46 | extern screen_mode_t mode_squash_1x; 47 | extern screen_mode_t mode_squash_2x; 48 | extern screen_mode_t mode_squash_3x; 49 | extern screen_mode_t mode_squash_4x; 50 | extern screen_mode_t mode_squash_5x; 51 | 52 | #endif /* #ifndef __I_SCALE__ */ 53 | 54 | -------------------------------------------------------------------------------- /src/i_swap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Endianess handling, swapping 16bit and 32bit. 17 | // 18 | 19 | 20 | #ifndef __I_SWAP__ 21 | #define __I_SWAP__ 22 | 23 | #ifdef ORIGCODE 24 | #include "SDL_endian.h" 25 | 26 | // Endianess handling. 27 | // WAD files are stored little endian. 28 | 29 | // Just use SDL's endianness swapping functions. 30 | 31 | // These are deliberately cast to signed values; this is the behaviour 32 | // of the macros in the original source and some code relies on it. 33 | 34 | #define SHORT(x) ((signed short) SDL_SwapLE16(x)) 35 | #define LONG(x) ((signed int) SDL_SwapLE32(x)) 36 | 37 | // Defines for checking the endianness of the system. 38 | 39 | #if SDL_BYTEORDER == SYS_LIL_ENDIAN 40 | #define SYS_LITTLE_ENDIAN 41 | #elif SDL_BYTEORDER == SYS_BIG_ENDIAN 42 | #define SYS_BIG_ENDIAN 43 | #endif 44 | 45 | #else 46 | 47 | #define SHORT(x) ((signed short) (x)) 48 | #define LONG(x) ((signed int) (x)) 49 | 50 | #define SYS_LITTLE_ENDIAN 51 | 52 | #endif 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /src/i_system.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System specific interface stuff. 17 | // 18 | 19 | 20 | #ifndef __I_SYSTEM__ 21 | #define __I_SYSTEM__ 22 | 23 | #include "d_ticcmd.h" 24 | #include "d_event.h" 25 | 26 | 27 | typedef void (*atexit_func_t)(void); 28 | 29 | // Called by DoomMain. 30 | void I_Init (void); 31 | 32 | // Called by startup code 33 | // to get the ammount of memory to malloc 34 | // for the zone management. 35 | byte* I_ZoneBase (int *size); 36 | 37 | boolean I_ConsoleStdout(void); 38 | 39 | 40 | // Asynchronous interrupt functions should maintain private queues 41 | // that are read by the synchronous functions 42 | // to be converted into events. 43 | 44 | // Either returns a null ticcmd, 45 | // or calls a loadable driver to build it. 46 | // This ticcmd will then be modified by the gameloop 47 | // for normal input. 48 | ticcmd_t* I_BaseTiccmd (void); 49 | 50 | 51 | // Called by M_Responder when quit is selected. 52 | // Clean exit, displays sell blurb. 53 | void I_Quit (void); 54 | 55 | void I_Error (char *error, ...); 56 | 57 | void I_Tactile (int on, int off, int total); 58 | 59 | boolean I_GetMemoryValue(unsigned int offset, void *value, int size); 60 | 61 | // Schedule a function to be called when the program exits. 62 | // If run_if_error is true, the function is called if the exit 63 | // is due to an error (I_Error) 64 | 65 | void I_AtExit(atexit_func_t func, boolean run_if_error); 66 | 67 | // Add all system-specific config file variable bindings. 68 | 69 | void I_BindVariables(void); 70 | 71 | // Print startup banner copyright message. 72 | 73 | void I_PrintStartupBanner(char *gamedescription); 74 | 75 | // Print a centered text banner displaying the given string. 76 | 77 | void I_PrintBanner(char *text); 78 | 79 | // Print a dividing line for startup banners. 80 | 81 | void I_PrintDivider(void); 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /src/i_timer.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Timer functions. 17 | // 18 | 19 | #include "i_timer.h" 20 | #include "doomtype.h" 21 | 22 | #include "doomgeneric.h" 23 | 24 | #include 25 | //#include 26 | //#include 27 | 28 | 29 | // 30 | // I_GetTime 31 | // returns time in 1/35th second tics 32 | // 33 | 34 | static uint32_t basetime = 0; 35 | 36 | 37 | int I_GetTicks(void) 38 | { 39 | return DG_GetTicksMs(); 40 | } 41 | 42 | int I_GetTime (void) 43 | { 44 | uint32_t ticks; 45 | 46 | ticks = I_GetTicks(); 47 | 48 | if (basetime == 0) 49 | basetime = ticks; 50 | 51 | ticks -= basetime; 52 | 53 | return (ticks * TICRATE) / 1000; 54 | } 55 | 56 | 57 | // 58 | // Same as I_GetTime, but returns time in milliseconds 59 | // 60 | 61 | int I_GetTimeMS(void) 62 | { 63 | uint32_t ticks; 64 | 65 | ticks = I_GetTicks(); 66 | 67 | if (basetime == 0) 68 | basetime = ticks; 69 | 70 | return ticks - basetime; 71 | } 72 | 73 | // Sleep for a specified number of ms 74 | 75 | void I_Sleep(int ms) 76 | { 77 | //SDL_Delay(ms); 78 | //usleep (ms * 1000); 79 | 80 | DG_SleepMs(ms); 81 | } 82 | 83 | void I_WaitVBL(int count) 84 | { 85 | //I_Sleep((count * 1000) / 70); 86 | } 87 | 88 | 89 | void I_InitTimer(void) 90 | { 91 | // initialize timer 92 | 93 | //SDL_Init(SDL_INIT_TIMER); 94 | } 95 | 96 | -------------------------------------------------------------------------------- /src/i_timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // System-specific timer interface 17 | // 18 | 19 | 20 | #ifndef __I_TIMER__ 21 | #define __I_TIMER__ 22 | 23 | #define TICRATE 35 24 | 25 | // Called by D_DoomLoop, 26 | // returns current time in tics. 27 | int I_GetTime (void); 28 | 29 | // returns current time in ms 30 | int I_GetTimeMS (void); 31 | 32 | // Pause for a specified number of ms 33 | void I_Sleep(int ms); 34 | 35 | // Initialize timer 36 | void I_InitTimer(void); 37 | 38 | // Wait for vertical retrace or pause a bit. 39 | void I_WaitVBL(int count); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /src/m_argv.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Nil. 17 | // 18 | 19 | 20 | #ifndef __M_ARGV__ 21 | #define __M_ARGV__ 22 | 23 | #include "doomtype.h" 24 | 25 | // 26 | // MISC 27 | // 28 | extern int myargc; 29 | extern char** myargv; 30 | 31 | // Returns the position of the given parameter 32 | // in the arg list (0 if not found). 33 | int M_CheckParm (char* check); 34 | 35 | // Same as M_CheckParm, but checks that num_args arguments are available 36 | // following the specified argument. 37 | int M_CheckParmWithArgs(char *check, int num_args); 38 | 39 | void M_FindResponseFile(void); 40 | 41 | // Parameter has been specified? 42 | 43 | boolean M_ParmExists(char *check); 44 | 45 | // Get name of executable used to run this program: 46 | 47 | char *M_GetExecutableName(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/m_bbox.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Main loop menu stuff. 17 | // Random number LUT. 18 | // Default Config File. 19 | // PCX Screenshots. 20 | // 21 | 22 | 23 | 24 | #include "m_bbox.h" 25 | 26 | 27 | 28 | 29 | void M_ClearBox (fixed_t *box) 30 | { 31 | box[BOXTOP] = box[BOXRIGHT] = INT_MIN; 32 | box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX; 33 | } 34 | 35 | void 36 | M_AddToBox 37 | ( fixed_t* box, 38 | fixed_t x, 39 | fixed_t y ) 40 | { 41 | if (xbox[BOXRIGHT]) 44 | box[BOXRIGHT] = x; 45 | if (ybox[BOXTOP]) 48 | box[BOXTOP] = y; 49 | } 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/m_bbox.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Nil. 17 | // 18 | 19 | 20 | #ifndef __M_BBOX__ 21 | #define __M_BBOX__ 22 | 23 | #include 24 | 25 | #include "m_fixed.h" 26 | 27 | 28 | // Bounding box coordinate storage. 29 | enum 30 | { 31 | BOXTOP, 32 | BOXBOTTOM, 33 | BOXLEFT, 34 | BOXRIGHT 35 | }; // bbox coordinates 36 | 37 | // Bounding box functions. 38 | void M_ClearBox (fixed_t* box); 39 | 40 | void 41 | M_AddToBox 42 | ( fixed_t* box, 43 | fixed_t x, 44 | fixed_t y ); 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/m_cheat.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Cheat sequence checking. 17 | // 18 | 19 | 20 | 21 | #include 22 | 23 | #include "doomtype.h" 24 | #include "m_cheat.h" 25 | 26 | // 27 | // CHEAT SEQUENCE PACKAGE 28 | // 29 | 30 | // 31 | // Called in st_stuff module, which handles the input. 32 | // Returns a 1 if the cheat was successful, 0 if failed. 33 | // 34 | int 35 | cht_CheckCheat 36 | ( cheatseq_t* cht, 37 | char key ) 38 | { 39 | // if we make a short sequence on a cheat with parameters, this 40 | // will not work in vanilla doom. behave the same. 41 | 42 | if (cht->parameter_chars > 0 && strlen(cht->sequence) < cht->sequence_len) 43 | return false; 44 | 45 | if (cht->chars_read < strlen(cht->sequence)) 46 | { 47 | // still reading characters from the cheat code 48 | // and verifying. reset back to the beginning 49 | // if a key is wrong 50 | 51 | if (key == cht->sequence[cht->chars_read]) 52 | ++cht->chars_read; 53 | else 54 | cht->chars_read = 0; 55 | 56 | cht->param_chars_read = 0; 57 | } 58 | else if (cht->param_chars_read < cht->parameter_chars) 59 | { 60 | // we have passed the end of the cheat sequence and are 61 | // entering parameters now 62 | 63 | cht->parameter_buf[cht->param_chars_read] = key; 64 | 65 | ++cht->param_chars_read; 66 | } 67 | 68 | if (cht->chars_read >= strlen(cht->sequence) 69 | && cht->param_chars_read >= cht->parameter_chars) 70 | { 71 | cht->chars_read = cht->param_chars_read = 0; 72 | 73 | return true; 74 | } 75 | 76 | // cheat not matched yet 77 | 78 | return false; 79 | } 80 | 81 | void 82 | cht_GetParam 83 | ( cheatseq_t* cht, 84 | char* buffer ) 85 | { 86 | memcpy(buffer, cht->parameter_buf, cht->parameter_chars); 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/m_cheat.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Cheat code checking. 17 | // 18 | 19 | 20 | #ifndef __M_CHEAT__ 21 | #define __M_CHEAT__ 22 | 23 | // 24 | // CHEAT SEQUENCE PACKAGE 25 | // 26 | 27 | // declaring a cheat 28 | 29 | #define CHEAT(value, parameters) \ 30 | { value, sizeof(value) - 1, parameters, 0, 0, "" } 31 | 32 | #define MAX_CHEAT_LEN 25 33 | #define MAX_CHEAT_PARAMS 5 34 | 35 | typedef struct 36 | { 37 | // settings for this cheat 38 | 39 | char sequence[MAX_CHEAT_LEN]; 40 | size_t sequence_len; 41 | int parameter_chars; 42 | 43 | // state used during the game 44 | 45 | size_t chars_read; 46 | int param_chars_read; 47 | char parameter_buf[MAX_CHEAT_PARAMS]; 48 | } cheatseq_t; 49 | 50 | int 51 | cht_CheckCheat 52 | ( cheatseq_t* cht, 53 | char key ); 54 | 55 | 56 | void 57 | cht_GetParam 58 | ( cheatseq_t* cht, 59 | char* buffer ); 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/m_config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Configuration file interface. 17 | // 18 | 19 | 20 | #ifndef __M_CONFIG__ 21 | #define __M_CONFIG__ 22 | 23 | #include "doomtype.h" 24 | 25 | void M_LoadDefaults(void); 26 | void M_SaveDefaults(void); 27 | void M_SaveDefaultsAlternate(char *main, char *extra); 28 | void M_SetConfigDir(char *dir); 29 | void M_BindVariable(char *name, void *variable); 30 | boolean M_SetVariable(char *name, char *value); 31 | int M_GetIntVariable(char *name); 32 | const char *M_GetStrVariable(char *name); 33 | float M_GetFloatVariable(char *name); 34 | void M_SetConfigFilenames(char *main_config, char *extra_config); 35 | char *M_GetSaveGameDir(char *iwadname); 36 | 37 | extern char *configdir; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/m_controls.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // Copyright(C) 2005-2014 Simon Howard 5 | // 6 | // This program is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation; either version 2 9 | // of the License, or (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | 17 | #ifndef __M_CONTROLS_H__ 18 | #define __M_CONTROLS_H__ 19 | 20 | extern int key_right; 21 | extern int key_left; 22 | 23 | extern int key_up; 24 | extern int key_down; 25 | extern int key_strafeleft; 26 | extern int key_straferight; 27 | extern int key_fire; 28 | extern int key_use; 29 | extern int key_strafe; 30 | extern int key_speed; 31 | 32 | extern int key_jump; 33 | 34 | extern int key_flyup; 35 | extern int key_flydown; 36 | extern int key_flycenter; 37 | extern int key_lookup; 38 | extern int key_lookdown; 39 | extern int key_lookcenter; 40 | extern int key_invleft; 41 | extern int key_invright; 42 | extern int key_useartifact; 43 | 44 | // villsa [STRIFE] strife keys 45 | extern int key_usehealth; 46 | extern int key_invquery; 47 | extern int key_mission; 48 | extern int key_invpop; 49 | extern int key_invkey; 50 | extern int key_invhome; 51 | extern int key_invend; 52 | extern int key_invuse; 53 | extern int key_invdrop; 54 | 55 | extern int key_message_refresh; 56 | extern int key_pause; 57 | 58 | extern int key_multi_msg; 59 | extern int key_multi_msgplayer[8]; 60 | 61 | extern int key_weapon1; 62 | extern int key_weapon2; 63 | extern int key_weapon3; 64 | extern int key_weapon4; 65 | extern int key_weapon5; 66 | extern int key_weapon6; 67 | extern int key_weapon7; 68 | extern int key_weapon8; 69 | 70 | extern int key_arti_all; 71 | extern int key_arti_health; 72 | extern int key_arti_poisonbag; 73 | extern int key_arti_blastradius; 74 | extern int key_arti_teleport; 75 | extern int key_arti_teleportother; 76 | extern int key_arti_egg; 77 | extern int key_arti_invulnerability; 78 | 79 | extern int key_demo_quit; 80 | extern int key_spy; 81 | extern int key_prevweapon; 82 | extern int key_nextweapon; 83 | 84 | extern int key_map_north; 85 | extern int key_map_south; 86 | extern int key_map_east; 87 | extern int key_map_west; 88 | extern int key_map_zoomin; 89 | extern int key_map_zoomout; 90 | extern int key_map_toggle; 91 | extern int key_map_maxzoom; 92 | extern int key_map_follow; 93 | extern int key_map_grid; 94 | extern int key_map_mark; 95 | extern int key_map_clearmark; 96 | 97 | // menu keys: 98 | 99 | extern int key_menu_activate; 100 | extern int key_menu_up; 101 | extern int key_menu_down; 102 | extern int key_menu_left; 103 | extern int key_menu_right; 104 | extern int key_menu_back; 105 | extern int key_menu_forward; 106 | extern int key_menu_confirm; 107 | extern int key_menu_abort; 108 | 109 | extern int key_menu_help; 110 | extern int key_menu_save; 111 | extern int key_menu_load; 112 | extern int key_menu_volume; 113 | extern int key_menu_detail; 114 | extern int key_menu_qsave; 115 | extern int key_menu_endgame; 116 | extern int key_menu_messages; 117 | extern int key_menu_qload; 118 | extern int key_menu_quit; 119 | extern int key_menu_gamma; 120 | 121 | extern int key_menu_incscreen; 122 | extern int key_menu_decscreen; 123 | extern int key_menu_screenshot; 124 | 125 | extern int mousebfire; 126 | extern int mousebstrafe; 127 | extern int mousebforward; 128 | 129 | extern int mousebjump; 130 | 131 | extern int mousebstrafeleft; 132 | extern int mousebstraferight; 133 | extern int mousebbackward; 134 | extern int mousebuse; 135 | 136 | extern int mousebprevweapon; 137 | extern int mousebnextweapon; 138 | 139 | extern int joybfire; 140 | extern int joybstrafe; 141 | extern int joybuse; 142 | extern int joybspeed; 143 | 144 | extern int joybjump; 145 | 146 | extern int joybstrafeleft; 147 | extern int joybstraferight; 148 | 149 | extern int joybprevweapon; 150 | extern int joybnextweapon; 151 | 152 | extern int joybmenu; 153 | 154 | extern int dclick_use; 155 | 156 | void M_BindBaseControls(void); 157 | void M_BindHereticControls(void); 158 | void M_BindHexenControls(void); 159 | void M_BindStrifeControls(void); 160 | void M_BindWeaponControls(void); 161 | void M_BindMapControls(void); 162 | void M_BindMenuControls(void); 163 | void M_BindChatControls(unsigned int num_players); 164 | 165 | void M_ApplyPlatformDefaults(void); 166 | 167 | #endif /* #ifndef __M_CONTROLS_H__ */ 168 | 169 | -------------------------------------------------------------------------------- /src/m_fixed.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Fixed point implementation. 17 | // 18 | 19 | 20 | 21 | #include "stdlib.h" 22 | 23 | #include "doomtype.h" 24 | #include "i_system.h" 25 | 26 | #include "m_fixed.h" 27 | 28 | 29 | 30 | 31 | // Fixme. __USE_C_FIXED__ or something. 32 | 33 | fixed_t 34 | FixedMul 35 | ( fixed_t a, 36 | fixed_t b ) 37 | { 38 | return ((int64_t) a * (int64_t) b) >> FRACBITS; 39 | } 40 | 41 | 42 | 43 | // 44 | // FixedDiv, C version. 45 | // 46 | 47 | fixed_t FixedDiv(fixed_t a, fixed_t b) 48 | { 49 | if ((abs(a) >> 14) >= abs(b)) 50 | { 51 | return (a^b) < 0 ? INT_MIN : INT_MAX; 52 | } 53 | else 54 | { 55 | int64_t result; 56 | 57 | result = ((int64_t) a << 16) / b; 58 | 59 | return (fixed_t) result; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/m_fixed.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Fixed point arithemtics, implementation. 17 | // 18 | 19 | 20 | #ifndef __M_FIXED__ 21 | #define __M_FIXED__ 22 | 23 | 24 | 25 | 26 | // 27 | // Fixed point, 32bit as 16.16. 28 | // 29 | #define FRACBITS 16 30 | #define FRACUNIT (1< 24 | #include 25 | 26 | #include "doomtype.h" 27 | 28 | boolean M_WriteFile(char *name, void *source, int length); 29 | int M_ReadFile(char *name, byte **buffer); 30 | void M_MakeDirectory(char *dir); 31 | char *M_TempFile(char *s); 32 | boolean M_FileExists(char *file); 33 | long M_FileLength(FILE *handle); 34 | boolean M_StrToInt(const char *str, int *result); 35 | void M_ExtractFileBase(char *path, char *dest); 36 | void M_ForceUppercase(char *text); 37 | char *M_StrCaseStr(char *haystack, char *needle); 38 | char *M_StringDuplicate(const char *orig); 39 | boolean M_StringCopy(char *dest, const char *src, size_t dest_size); 40 | boolean M_StringConcat(char *dest, const char *src, size_t dest_size); 41 | char *M_StringReplace(const char *haystack, const char *needle, 42 | const char *replacement); 43 | char *M_StringJoin(const char *s, ...); 44 | boolean M_StringStartsWith(const char *s, const char *prefix); 45 | boolean M_StringEndsWith(const char *s, const char *suffix); 46 | int M_vsnprintf(char *buf, size_t buf_len, const char *s, va_list args); 47 | int M_snprintf(char *buf, size_t buf_len, const char *s, ...); 48 | char *M_OEMToUTF8(const char *ansi); 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/m_random.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Random number LUT. 17 | // 18 | 19 | // 20 | // M_Random 21 | // Returns a 0-255 number 22 | // 23 | 24 | static const unsigned char rndtable[256] = { 25 | 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 , 26 | 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 , 27 | 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 , 28 | 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 , 29 | 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 , 30 | 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 , 31 | 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 , 32 | 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 , 33 | 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 , 34 | 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 , 35 | 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 , 36 | 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 , 37 | 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 , 38 | 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 , 39 | 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 , 40 | 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 , 41 | 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 , 42 | 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 43 | 120, 163, 236, 249 44 | }; 45 | 46 | int rndindex = 0; 47 | int prndindex = 0; 48 | 49 | // Which one is deterministic? 50 | int P_Random (void) 51 | { 52 | prndindex = (prndindex+1)&0xff; 53 | return rndtable[prndindex]; 54 | } 55 | 56 | int M_Random (void) 57 | { 58 | rndindex = (rndindex+1)&0xff; 59 | return rndtable[rndindex]; 60 | } 61 | 62 | void M_ClearRandom (void) 63 | { 64 | rndindex = prndindex = 0; 65 | } 66 | -------------------------------------------------------------------------------- /src/m_random.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __M_RANDOM__ 21 | #define __M_RANDOM__ 22 | 23 | 24 | #include "doomtype.h" 25 | 26 | 27 | 28 | // Returns a number from 0 to 255, 29 | // from a lookup table. 30 | int M_Random (void); 31 | 32 | // As M_Random, but used only by the play simulation. 33 | int P_Random (void); 34 | 35 | // Fix randoms for demos. 36 | void M_ClearRandom (void); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/memio.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // Emulates the IO functions in C stdio.h reading and writing to 16 | // memory. 17 | // 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "memio.h" 24 | 25 | #include "z_zone.h" 26 | 27 | typedef enum { 28 | MODE_READ, 29 | MODE_WRITE, 30 | } memfile_mode_t; 31 | 32 | struct _MEMFILE { 33 | unsigned char *buf; 34 | size_t buflen; 35 | size_t alloced; 36 | unsigned int position; 37 | memfile_mode_t mode; 38 | }; 39 | 40 | // Open a memory area for reading 41 | 42 | MEMFILE *mem_fopen_read(void *buf, size_t buflen) 43 | { 44 | MEMFILE *file; 45 | 46 | file = Z_Malloc(sizeof(MEMFILE), PU_STATIC, 0); 47 | 48 | file->buf = (unsigned char *) buf; 49 | file->buflen = buflen; 50 | file->position = 0; 51 | file->mode = MODE_READ; 52 | 53 | return file; 54 | } 55 | 56 | // Read bytes 57 | 58 | size_t mem_fread(void *buf, size_t size, size_t nmemb, MEMFILE *stream) 59 | { 60 | size_t items; 61 | 62 | if (stream->mode != MODE_READ) 63 | { 64 | printf("not a read stream\n"); 65 | return -1; 66 | } 67 | 68 | // Trying to read more bytes than we have left? 69 | 70 | items = nmemb; 71 | 72 | if (items * size > stream->buflen - stream->position) 73 | { 74 | items = (stream->buflen - stream->position) / size; 75 | } 76 | 77 | // Copy bytes to buffer 78 | 79 | memcpy(buf, stream->buf + stream->position, items * size); 80 | 81 | // Update position 82 | 83 | stream->position += items * size; 84 | 85 | return items; 86 | } 87 | 88 | // Open a memory area for writing 89 | 90 | MEMFILE *mem_fopen_write(void) 91 | { 92 | MEMFILE *file; 93 | 94 | file = Z_Malloc(sizeof(MEMFILE), PU_STATIC, 0); 95 | 96 | file->alloced = 1024; 97 | file->buf = Z_Malloc(file->alloced, PU_STATIC, 0); 98 | file->buflen = 0; 99 | file->position = 0; 100 | file->mode = MODE_WRITE; 101 | 102 | return file; 103 | } 104 | 105 | // Write bytes to stream 106 | 107 | size_t mem_fwrite(const void *ptr, size_t size, size_t nmemb, MEMFILE *stream) 108 | { 109 | size_t bytes; 110 | 111 | if (stream->mode != MODE_WRITE) 112 | { 113 | return -1; 114 | } 115 | 116 | // More bytes than can fit in the buffer? 117 | // If so, reallocate bigger. 118 | 119 | bytes = size * nmemb; 120 | 121 | while (bytes > stream->alloced - stream->position) 122 | { 123 | unsigned char *newbuf; 124 | 125 | newbuf = Z_Malloc(stream->alloced * 2, PU_STATIC, 0); 126 | memcpy(newbuf, stream->buf, stream->alloced); 127 | Z_Free(stream->buf); 128 | stream->buf = newbuf; 129 | stream->alloced *= 2; 130 | } 131 | 132 | // Copy into buffer 133 | 134 | memcpy(stream->buf + stream->position, ptr, bytes); 135 | stream->position += bytes; 136 | 137 | if (stream->position > stream->buflen) 138 | stream->buflen = stream->position; 139 | 140 | return nmemb; 141 | } 142 | 143 | void mem_get_buf(MEMFILE *stream, void **buf, size_t *buflen) 144 | { 145 | *buf = stream->buf; 146 | *buflen = stream->buflen; 147 | } 148 | 149 | void mem_fclose(MEMFILE *stream) 150 | { 151 | if (stream->mode == MODE_WRITE) 152 | { 153 | Z_Free(stream->buf); 154 | } 155 | 156 | Z_Free(stream); 157 | } 158 | 159 | long mem_ftell(MEMFILE *stream) 160 | { 161 | return stream->position; 162 | } 163 | 164 | int mem_fseek(MEMFILE *stream, signed long position, mem_rel_t whence) 165 | { 166 | unsigned int newpos; 167 | 168 | switch (whence) 169 | { 170 | case MEM_SEEK_SET: 171 | newpos = (int) position; 172 | break; 173 | 174 | case MEM_SEEK_CUR: 175 | newpos = (int) (stream->position + position); 176 | break; 177 | 178 | case MEM_SEEK_END: 179 | newpos = (int) (stream->buflen + position); 180 | break; 181 | default: 182 | return -1; 183 | } 184 | 185 | if (newpos < stream->buflen) 186 | { 187 | stream->position = newpos; 188 | return 0; 189 | } 190 | else 191 | { 192 | printf("Error seeking to %i\n", newpos); 193 | return -1; 194 | } 195 | } 196 | 197 | 198 | -------------------------------------------------------------------------------- /src/memio.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | 16 | #ifndef MEMIO_H 17 | #define MEMIO_H 18 | 19 | typedef struct _MEMFILE MEMFILE; 20 | 21 | typedef enum 22 | { 23 | MEM_SEEK_SET, 24 | MEM_SEEK_CUR, 25 | MEM_SEEK_END, 26 | } mem_rel_t; 27 | 28 | MEMFILE *mem_fopen_read(void *buf, size_t buflen); 29 | size_t mem_fread(void *buf, size_t size, size_t nmemb, MEMFILE *stream); 30 | MEMFILE *mem_fopen_write(void); 31 | size_t mem_fwrite(const void *ptr, size_t size, size_t nmemb, MEMFILE *stream); 32 | void mem_get_buf(MEMFILE *stream, void **buf, size_t *buflen); 33 | void mem_fclose(MEMFILE *stream); 34 | long mem_ftell(MEMFILE *stream); 35 | int mem_fseek(MEMFILE *stream, signed long offset, mem_rel_t whence); 36 | 37 | #endif /* #ifndef MEMIO_H */ 38 | 39 | -------------------------------------------------------------------------------- /src/net_client.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Network client code 15 | // 16 | 17 | #ifndef NET_CLIENT_H 18 | #define NET_CLIENT_H 19 | 20 | #include "doomtype.h" 21 | #include "d_ticcmd.h" 22 | #include "sha1.h" 23 | #include "net_defs.h" 24 | 25 | boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data); 26 | void NET_CL_Disconnect(void); 27 | void NET_CL_Run(void); 28 | void NET_CL_Init(void); 29 | void NET_CL_LaunchGame(void); 30 | void NET_CL_StartGame(net_gamesettings_t *settings); 31 | void NET_CL_SendTiccmd(ticcmd_t *ticcmd, int maketic); 32 | boolean NET_CL_GetSettings(net_gamesettings_t *_settings); 33 | void NET_Init(void); 34 | 35 | void NET_BindVariables(void); 36 | 37 | extern boolean net_client_connected; 38 | extern boolean net_client_received_wait_data; 39 | extern net_waitdata_t net_client_wait_data; 40 | extern boolean net_waiting_for_launch; 41 | extern char *net_player_name; 42 | 43 | extern sha1_digest_t net_server_wad_sha1sum; 44 | extern sha1_digest_t net_server_deh_sha1sum; 45 | extern unsigned int net_server_is_freedoom; 46 | extern sha1_digest_t net_local_wad_sha1sum; 47 | extern sha1_digest_t net_local_deh_sha1sum; 48 | extern unsigned int net_local_is_freedoom; 49 | 50 | extern boolean drone; 51 | 52 | #endif /* #ifndef NET_CLIENT_H */ 53 | -------------------------------------------------------------------------------- /src/net_dedicated.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // 15 | // Dedicated server code. 16 | // 17 | 18 | #ifndef NET_DEDICATED_H 19 | #define NET_DEDICATED_H 20 | 21 | void NET_DedicatedServer(void); 22 | 23 | #endif /* #ifndef NET_DEDICATED_H */ 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/net_gui.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Graphical stuff related to the networking code: 15 | // 16 | // * The client waiting screen when we are waiting for the server to 17 | // start the game. 18 | // 19 | 20 | 21 | #ifndef NET_GUI_H 22 | #define NET_GUI_H 23 | 24 | #include "doomtype.h" 25 | 26 | extern void NET_WaitForLaunch(void); 27 | 28 | #endif /* #ifndef NET_GUI_H */ 29 | 30 | -------------------------------------------------------------------------------- /src/net_io.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Network packet manipulation (net_packet_t) 16 | // 17 | 18 | #ifndef NET_IO_H 19 | #define NET_IO_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_addr_t net_broadcast_addr; 24 | 25 | net_context_t *NET_NewContext(void); 26 | void NET_AddModule(net_context_t *context, net_module_t *module); 27 | void NET_SendPacket(net_addr_t *addr, net_packet_t *packet); 28 | void NET_SendBroadcast(net_context_t *context, net_packet_t *packet); 29 | boolean NET_RecvPacket(net_context_t *context, net_addr_t **addr, 30 | net_packet_t **packet); 31 | char *NET_AddrToString(net_addr_t *addr); 32 | void NET_FreeAddress(net_addr_t *addr); 33 | net_addr_t *NET_ResolveAddress(net_context_t *context, char *address); 34 | 35 | #endif /* #ifndef NET_IO_H */ 36 | 37 | -------------------------------------------------------------------------------- /src/net_loop.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Loopback network module for server compiled into the client 16 | // 17 | 18 | #ifndef NET_LOOP_H 19 | #define NET_LOOP_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_module_t net_loop_client_module; 24 | extern net_module_t net_loop_server_module; 25 | 26 | #endif /* #ifndef NET_LOOP_H */ 27 | 28 | -------------------------------------------------------------------------------- /src/net_packet.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Definitions for use in networking code. 16 | // 17 | 18 | #ifndef NET_PACKET_H 19 | #define NET_PACKET_H 20 | 21 | #include "net_defs.h" 22 | 23 | net_packet_t *NET_NewPacket(int initial_size); 24 | net_packet_t *NET_PacketDup(net_packet_t *packet); 25 | void NET_FreePacket(net_packet_t *packet); 26 | 27 | boolean NET_ReadInt8(net_packet_t *packet, unsigned int *data); 28 | boolean NET_ReadInt16(net_packet_t *packet, unsigned int *data); 29 | boolean NET_ReadInt32(net_packet_t *packet, unsigned int *data); 30 | 31 | boolean NET_ReadSInt8(net_packet_t *packet, signed int *data); 32 | boolean NET_ReadSInt16(net_packet_t *packet, signed int *data); 33 | boolean NET_ReadSInt32(net_packet_t *packet, signed int *data); 34 | 35 | char *NET_ReadString(net_packet_t *packet); 36 | 37 | void NET_WriteInt8(net_packet_t *packet, unsigned int i); 38 | void NET_WriteInt16(net_packet_t *packet, unsigned int i); 39 | void NET_WriteInt32(net_packet_t *packet, unsigned int i); 40 | 41 | void NET_WriteString(net_packet_t *packet, char *string); 42 | 43 | #endif /* #ifndef NET_PACKET_H */ 44 | 45 | -------------------------------------------------------------------------------- /src/net_query.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Querying servers to find their current status. 16 | // 17 | 18 | #ifndef NET_QUERY_H 19 | #define NET_QUERY_H 20 | 21 | #include "net_defs.h" 22 | 23 | typedef void (*net_query_callback_t)(net_addr_t *addr, 24 | net_querydata_t *querydata, 25 | unsigned int ping_time, 26 | void *user_data); 27 | 28 | extern int NET_StartLANQuery(void); 29 | extern int NET_StartMasterQuery(void); 30 | 31 | extern void NET_LANQuery(void); 32 | extern void NET_MasterQuery(void); 33 | extern void NET_QueryAddress(char *addr); 34 | extern net_addr_t *NET_FindLANServer(void); 35 | 36 | extern int NET_Query_Poll(net_query_callback_t callback, void *user_data); 37 | 38 | extern net_addr_t *NET_Query_ResolveMaster(net_context_t *context); 39 | extern void NET_Query_AddToMaster(net_addr_t *master_addr); 40 | extern boolean NET_Query_CheckAddedToMaster(boolean *result); 41 | extern void NET_Query_MasterResponse(net_packet_t *packet); 42 | 43 | #endif /* #ifndef NET_QUERY_H */ 44 | 45 | -------------------------------------------------------------------------------- /src/net_sdl.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Networking module which uses SDL_net 16 | // 17 | 18 | #ifndef NET_SDL_H 19 | #define NET_SDL_H 20 | 21 | #include "net_defs.h" 22 | 23 | extern net_module_t net_sdl_module; 24 | 25 | #endif /* #ifndef NET_SDL_H */ 26 | 27 | -------------------------------------------------------------------------------- /src/net_server.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // Network server code 15 | // 16 | 17 | #ifndef NET_SERVER_H 18 | #define NET_SERVER_H 19 | 20 | // initialize server and wait for connections 21 | 22 | void NET_SV_Init(void); 23 | 24 | // run server: check for new packets received etc. 25 | 26 | void NET_SV_Run(void); 27 | 28 | // Shut down the server 29 | // Blocks until all clients disconnect, or until a 5 second timeout 30 | 31 | void NET_SV_Shutdown(void); 32 | 33 | // Add a network module to the context used by the server 34 | 35 | void NET_SV_AddModule(net_module_t *module); 36 | 37 | // Register server with master server. 38 | 39 | void NET_SV_RegisterWithMaster(void); 40 | 41 | #endif /* #ifndef NET_SERVER_H */ 42 | 43 | -------------------------------------------------------------------------------- /src/p_inter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // 17 | // 18 | 19 | 20 | #ifndef __P_INTER__ 21 | #define __P_INTER__ 22 | 23 | 24 | 25 | 26 | boolean P_GivePower(player_t*, int); 27 | 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/p_pspr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Sprite animation. 17 | // 18 | 19 | 20 | #ifndef __P_PSPR__ 21 | #define __P_PSPR__ 22 | 23 | // Basic data types. 24 | // Needs fixed point, and BAM angles. 25 | #include "m_fixed.h" 26 | #include "tables.h" 27 | 28 | 29 | // 30 | // Needs to include the precompiled 31 | // sprite animation tables. 32 | // Header generated by multigen utility. 33 | // This includes all the data for thing animation, 34 | // i.e. the Thing Atrributes table 35 | // and the Frame Sequence table. 36 | #include "info.h" 37 | 38 | 39 | 40 | // 41 | // Frame flags: 42 | // handles maximum brightness (torches, muzzle flare, light sources) 43 | // 44 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 45 | #define FF_FRAMEMASK 0x7fff 46 | 47 | 48 | 49 | // 50 | // Overlay psprites are scaled shapes 51 | // drawn directly on the view screen, 52 | // coordinates are given for a 320*200 view screen. 53 | // 54 | typedef enum 55 | { 56 | ps_weapon, 57 | ps_flash, 58 | NUMPSPRITES 59 | 60 | } psprnum_t; 61 | 62 | typedef struct 63 | { 64 | state_t* state; // a NULL state means not active 65 | int tics; 66 | fixed_t sx; 67 | fixed_t sy; 68 | 69 | } pspdef_t; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/p_saveg.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Savegame I/O, archiving, persistence. 17 | // 18 | 19 | 20 | #ifndef __P_SAVEG__ 21 | #define __P_SAVEG__ 22 | 23 | #include 24 | 25 | // maximum size of a savegame description 26 | 27 | #define SAVESTRINGSIZE 24 28 | 29 | // temporary filename to use while saving. 30 | 31 | char *P_TempSaveGameFile(void); 32 | 33 | // filename to use for a savegame slot 34 | 35 | char *P_SaveGameFile(int slot); 36 | 37 | // Savegame file header read/write functions 38 | 39 | boolean P_ReadSaveGameHeader(void); 40 | void P_WriteSaveGameHeader(char *description); 41 | 42 | // Savegame end-of-file read/write functions 43 | 44 | boolean P_ReadSaveGameEOF(void); 45 | void P_WriteSaveGameEOF(void); 46 | 47 | // Persistent storage/archiving. 48 | // These are the load / save game routines. 49 | void P_ArchivePlayers (void); 50 | void P_UnArchivePlayers (void); 51 | void P_ArchiveWorld (void); 52 | void P_UnArchiveWorld (void); 53 | void P_ArchiveThinkers (void); 54 | void P_UnArchiveThinkers (void); 55 | void P_ArchiveSpecials (void); 56 | void P_UnArchiveSpecials (void); 57 | 58 | extern FILE *save_stream; 59 | extern boolean savegame_error; 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/p_setup.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Setup a game, startup stuff. 17 | // 18 | 19 | 20 | #ifndef __P_SETUP__ 21 | #define __P_SETUP__ 22 | 23 | 24 | 25 | 26 | // NOT called by W_Ticker. Fixme. 27 | void 28 | P_SetupLevel 29 | ( int episode, 30 | int map, 31 | int playermask, 32 | skill_t skill); 33 | 34 | // Called by startup code. 35 | void P_Init (void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/p_telept.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Teleportation. 17 | // 18 | 19 | 20 | 21 | 22 | #include "doomdef.h" 23 | #include "doomstat.h" 24 | 25 | #include "s_sound.h" 26 | 27 | #include "p_local.h" 28 | 29 | 30 | // Data. 31 | #include "sounds.h" 32 | 33 | // State. 34 | #include "r_state.h" 35 | 36 | 37 | 38 | // 39 | // TELEPORTATION 40 | // 41 | int 42 | EV_Teleport 43 | ( line_t* line, 44 | int side, 45 | mobj_t* thing ) 46 | { 47 | int i; 48 | int tag; 49 | mobj_t* m; 50 | mobj_t* fog; 51 | unsigned an; 52 | thinker_t* thinker; 53 | sector_t* sector; 54 | fixed_t oldx; 55 | fixed_t oldy; 56 | fixed_t oldz; 57 | 58 | // don't teleport missiles 59 | if (thing->flags & MF_MISSILE) 60 | return 0; 61 | 62 | // Don't teleport if hit back of line, 63 | // so you can get out of teleporter. 64 | if (side == 1) 65 | return 0; 66 | 67 | 68 | tag = line->tag; 69 | for (i = 0; i < numsectors; i++) 70 | { 71 | if (sectors[ i ].tag == tag ) 72 | { 73 | thinker = thinkercap.next; 74 | for (thinker = thinkercap.next; 75 | thinker != &thinkercap; 76 | thinker = thinker->next) 77 | { 78 | // not a mobj 79 | if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) 80 | continue; 81 | 82 | m = (mobj_t *)thinker; 83 | 84 | // not a teleportman 85 | if (m->type != MT_TELEPORTMAN ) 86 | continue; 87 | 88 | sector = m->subsector->sector; 89 | // wrong sector 90 | if (sector-sectors != i ) 91 | continue; 92 | 93 | oldx = thing->x; 94 | oldy = thing->y; 95 | oldz = thing->z; 96 | 97 | if (!P_TeleportMove (thing, m->x, m->y)) 98 | return 0; 99 | 100 | // The first Final Doom executable does not set thing->z 101 | // when teleporting. This quirk is unique to this 102 | // particular version; the later version included in 103 | // some versions of the Id Anthology fixed this. 104 | 105 | if (gameversion != exe_final) 106 | thing->z = thing->floorz; 107 | 108 | if (thing->player) 109 | thing->player->viewz = thing->z+thing->player->viewheight; 110 | 111 | // spawn teleport fog at source and destination 112 | fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 113 | S_StartSound (fog, sfx_telept); 114 | an = m->angle >> ANGLETOFINESHIFT; 115 | fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] 116 | , thing->z, MT_TFOG); 117 | 118 | // emit sound, where? 119 | S_StartSound (fog, sfx_telept); 120 | 121 | // don't move for a bit 122 | if (thing->player) 123 | thing->reactiontime = 18; 124 | 125 | thing->angle = m->angle; 126 | thing->momx = thing->momy = thing->momz = 0; 127 | return 1; 128 | } 129 | } 130 | } 131 | return 0; 132 | } 133 | 134 | -------------------------------------------------------------------------------- /src/p_tick.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Archiving: SaveGame I/O. 17 | // Thinker, Ticker. 18 | // 19 | 20 | 21 | #include "z_zone.h" 22 | #include "p_local.h" 23 | 24 | #include "doomstat.h" 25 | 26 | 27 | int leveltime; 28 | 29 | // 30 | // THINKERS 31 | // All thinkers should be allocated by Z_Malloc 32 | // so they can be operated on uniformly. 33 | // The actual structures will vary in size, 34 | // but the first element must be thinker_t. 35 | // 36 | 37 | 38 | 39 | // Both the head and tail of the thinker list. 40 | thinker_t thinkercap; 41 | 42 | 43 | // 44 | // P_InitThinkers 45 | // 46 | void P_InitThinkers (void) 47 | { 48 | thinkercap.prev = thinkercap.next = &thinkercap; 49 | } 50 | 51 | 52 | 53 | 54 | // 55 | // P_AddThinker 56 | // Adds a new thinker at the end of the list. 57 | // 58 | void P_AddThinker (thinker_t* thinker) 59 | { 60 | thinkercap.prev->next = thinker; 61 | thinker->next = &thinkercap; 62 | thinker->prev = thinkercap.prev; 63 | thinkercap.prev = thinker; 64 | } 65 | 66 | 67 | 68 | // 69 | // P_RemoveThinker 70 | // Deallocation is lazy -- it will not actually be freed 71 | // until its thinking turn comes up. 72 | // 73 | void P_RemoveThinker (thinker_t* thinker) 74 | { 75 | // FIXME: NOP. 76 | thinker->function.acv = (actionf_v)(-1); 77 | } 78 | 79 | 80 | 81 | // 82 | // P_AllocateThinker 83 | // Allocates memory and adds a new thinker at the end of the list. 84 | // 85 | void P_AllocateThinker (thinker_t* thinker) 86 | { 87 | } 88 | 89 | 90 | 91 | // 92 | // P_RunThinkers 93 | // 94 | void P_RunThinkers (void) 95 | { 96 | thinker_t* currentthinker; 97 | 98 | currentthinker = thinkercap.next; 99 | while (currentthinker != &thinkercap) 100 | { 101 | if ( currentthinker->function.acv == (actionf_v)(-1) ) 102 | { 103 | // time to remove it 104 | currentthinker->next->prev = currentthinker->prev; 105 | currentthinker->prev->next = currentthinker->next; 106 | Z_Free (currentthinker); 107 | } 108 | else 109 | { 110 | if (currentthinker->function.acp1) 111 | currentthinker->function.acp1 (currentthinker); 112 | } 113 | currentthinker = currentthinker->next; 114 | } 115 | } 116 | 117 | 118 | 119 | // 120 | // P_Ticker 121 | // 122 | 123 | void P_Ticker (void) 124 | { 125 | int i; 126 | 127 | // run the tic 128 | if (paused) 129 | return; 130 | 131 | // pause if in menu and at least one tic has been run 132 | if ( !netgame 133 | && menuactive 134 | && !demoplayback 135 | && players[consoleplayer].viewz != 1) 136 | { 137 | return; 138 | } 139 | 140 | 141 | for (i=0 ; i 51 | // using from sounds.h 52 | // 53 | 54 | void S_StartSound(void *origin, int sound_id); 55 | 56 | // Stop sound for thing at 57 | void S_StopSound(mobj_t *origin); 58 | 59 | 60 | // Start music using from sounds.h 61 | void S_StartMusic(int music_id); 62 | 63 | // Start music using from sounds.h, 64 | // and set whether looping 65 | void S_ChangeMusic(int music_id, int looping); 66 | 67 | // query if music is playing 68 | boolean S_MusicPlaying(void); 69 | 70 | // Stops the music fer sure. 71 | void S_StopMusic(void); 72 | 73 | // Stop and resume music, during game PAUSE. 74 | void S_PauseSound(void); 75 | void S_ResumeSound(void); 76 | 77 | 78 | // 79 | // Updates music & sounds 80 | // 81 | void S_UpdateSounds(mobj_t *listener); 82 | 83 | void S_SetMusicVolume(int volume); 84 | void S_SetSfxVolume(int volume); 85 | 86 | extern int snd_channels; 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /src/sha1.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // SHA-1 digest. 16 | // 17 | 18 | #ifndef __SHA1_H__ 19 | #define __SHA1_H__ 20 | 21 | #include "doomtype.h" 22 | 23 | typedef struct sha1_context_s sha1_context_t; 24 | typedef byte sha1_digest_t[20]; 25 | 26 | struct sha1_context_s { 27 | uint32_t h0,h1,h2,h3,h4; 28 | uint32_t nblocks; 29 | byte buf[64]; 30 | int count; 31 | }; 32 | 33 | void SHA1_Init(sha1_context_t *context); 34 | void SHA1_Update(sha1_context_t *context, byte *buf, size_t len); 35 | void SHA1_Final(sha1_digest_t digest, sha1_context_t *context); 36 | void SHA1_UpdateInt32(sha1_context_t *context, unsigned int val); 37 | void SHA1_UpdateString(sha1_context_t *context, char *str); 38 | 39 | #endif /* #ifndef __SHA1_H__ */ 40 | 41 | -------------------------------------------------------------------------------- /src/shell.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DOOM on Sokol 6 | 7 | 55 | 56 | 57 | 58 | 84 | {{{ SCRIPT }}} 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/sokol.c: -------------------------------------------------------------------------------- 1 | #define SOKOL_IMPL 2 | #include "sokol_app.h" 3 | #include "sokol_gfx.h" 4 | #include "sokol_debugtext.h" 5 | #include "sokol_fetch.h" 6 | #include "sokol_audio.h" 7 | #include "sokol_log.h" 8 | #include "sokol_glue.h" 9 | -------------------------------------------------------------------------------- /src/sokol_shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs offscreen_vs 2 | layout(location=0) in vec2 in_pos; 3 | out vec2 uv; 4 | 5 | void main() { 6 | gl_Position = vec4(in_pos * 2.0 - 1.0, 0.5, 1.0); 7 | uv = vec2(in_pos.x, 1.0 - in_pos.y); 8 | } 9 | @end 10 | 11 | // pixel shader to perform color palette lookup 12 | @fs offscreen_fs 13 | 14 | layout(binding=0) uniform texture2D pix_img; 15 | layout(binding=1) uniform texture2D pal_img; 16 | layout(binding=0) uniform sampler smp; 17 | 18 | in vec2 uv; 19 | out vec4 frag_color; 20 | 21 | void main() { 22 | float pix = texture(sampler2D(pix_img, smp), uv).x; 23 | frag_color = vec4(texture(sampler2D(pal_img, smp), vec2(pix,0)).xyz, 1.0); 24 | } 25 | @end 26 | 27 | @vs display_vs 28 | @glsl_options flip_vert_y 29 | layout(location=0) in vec2 in_pos; 30 | out vec2 uv; 31 | 32 | void main() { 33 | gl_Position = vec4(in_pos * 2.0 - 1.0, 0.5, 1.0); 34 | uv = vec2(in_pos.x, 1.0 - in_pos.y); 35 | } 36 | @end 37 | 38 | // pixel shader to perform upscale-rendering to display framebuffer 39 | @fs display_fs 40 | 41 | layout(binding=0) uniform texture2D rgba_img; 42 | layout(binding=0) uniform sampler smp; 43 | in vec2 uv; 44 | out vec4 frag_color; 45 | 46 | void main() { 47 | frag_color = texture(sampler2D(rgba_img, smp), uv); 48 | } 49 | @end 50 | 51 | @program offscreen offscreen_vs offscreen_fs 52 | @program display display_vs display_fs 53 | -------------------------------------------------------------------------------- /src/st_lib.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // The status bar widget code. 17 | // 18 | 19 | #ifndef __STLIB__ 20 | #define __STLIB__ 21 | 22 | 23 | // We are referring to patches. 24 | #include "r_defs.h" 25 | 26 | // 27 | // Typedefs of widgets 28 | // 29 | 30 | // Number widget 31 | 32 | typedef struct 33 | { 34 | // upper right-hand corner 35 | // of the number (right-justified) 36 | int x; 37 | int y; 38 | 39 | // max # of digits in number 40 | int width; 41 | 42 | // last number value 43 | int oldnum; 44 | 45 | // pointer to current value 46 | int* num; 47 | 48 | // pointer to boolean stating 49 | // whether to update number 50 | boolean* on; 51 | 52 | // list of patches for 0-9 53 | patch_t** p; 54 | 55 | // user data 56 | int data; 57 | 58 | } st_number_t; 59 | 60 | 61 | 62 | // Percent widget ("child" of number widget, 63 | // or, more precisely, contains a number widget.) 64 | typedef struct 65 | { 66 | // number information 67 | st_number_t n; 68 | 69 | // percent sign graphic 70 | patch_t* p; 71 | 72 | } st_percent_t; 73 | 74 | 75 | 76 | // Multiple Icon widget 77 | typedef struct 78 | { 79 | // center-justified location of icons 80 | int x; 81 | int y; 82 | 83 | // last icon number 84 | int oldinum; 85 | 86 | // pointer to current icon 87 | int* inum; 88 | 89 | // pointer to boolean stating 90 | // whether to update icon 91 | boolean* on; 92 | 93 | // list of icons 94 | patch_t** p; 95 | 96 | // user data 97 | int data; 98 | 99 | } st_multicon_t; 100 | 101 | 102 | 103 | 104 | // Binary Icon widget 105 | 106 | typedef struct 107 | { 108 | // center-justified location of icon 109 | int x; 110 | int y; 111 | 112 | // last icon value 113 | boolean oldval; 114 | 115 | // pointer to current icon status 116 | boolean* val; 117 | 118 | // pointer to boolean 119 | // stating whether to update icon 120 | boolean* on; 121 | 122 | 123 | patch_t* p; // icon 124 | int data; // user data 125 | 126 | } st_binicon_t; 127 | 128 | 129 | 130 | // 131 | // Widget creation, access, and update routines 132 | // 133 | 134 | // Initializes widget library. 135 | // More precisely, initialize STMINUS, 136 | // everything else is done somewhere else. 137 | // 138 | void STlib_init(void); 139 | 140 | 141 | 142 | // Number widget routines 143 | void 144 | STlib_initNum 145 | ( st_number_t* n, 146 | int x, 147 | int y, 148 | patch_t** pl, 149 | int* num, 150 | boolean* on, 151 | int width ); 152 | 153 | void 154 | STlib_updateNum 155 | ( st_number_t* n, 156 | boolean refresh ); 157 | 158 | 159 | // Percent widget routines 160 | void 161 | STlib_initPercent 162 | ( st_percent_t* p, 163 | int x, 164 | int y, 165 | patch_t** pl, 166 | int* num, 167 | boolean* on, 168 | patch_t* percent ); 169 | 170 | 171 | void 172 | STlib_updatePercent 173 | ( st_percent_t* per, 174 | int refresh ); 175 | 176 | 177 | // Multiple Icon widget routines 178 | void 179 | STlib_initMultIcon 180 | ( st_multicon_t* mi, 181 | int x, 182 | int y, 183 | patch_t** il, 184 | int* inum, 185 | boolean* on ); 186 | 187 | 188 | void 189 | STlib_updateMultIcon 190 | ( st_multicon_t* mi, 191 | boolean refresh ); 192 | 193 | // Binary Icon widget routines 194 | 195 | void 196 | STlib_initBinIcon 197 | ( st_binicon_t* b, 198 | int x, 199 | int y, 200 | patch_t* i, 201 | boolean* val, 202 | boolean* on ); 203 | 204 | void 205 | STlib_updateBinIcon 206 | ( st_binicon_t* bi, 207 | boolean refresh ); 208 | 209 | #endif 210 | -------------------------------------------------------------------------------- /src/st_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Status bar code. 17 | // Does the face/direction indicator animatin. 18 | // Does palette indicators as well (red pain/berserk, bright pickup) 19 | // 20 | 21 | #ifndef __STSTUFF_H__ 22 | #define __STSTUFF_H__ 23 | 24 | #include "doomtype.h" 25 | #include "d_event.h" 26 | #include "m_cheat.h" 27 | 28 | // Size of statusbar. 29 | // Now sensitive for scaling. 30 | #define ST_HEIGHT 32 31 | #define ST_WIDTH SCREENWIDTH 32 | #define ST_Y (SCREENHEIGHT - ST_HEIGHT) 33 | 34 | 35 | // 36 | // STATUS BAR 37 | // 38 | 39 | // Called by main loop. 40 | boolean ST_Responder (event_t* ev); 41 | 42 | // Called by main loop. 43 | void ST_Ticker (void); 44 | 45 | // Called by main loop. 46 | void ST_Drawer (boolean fullscreen, boolean refresh); 47 | 48 | // Called when the console player is spawned on each level. 49 | void ST_Start (void); 50 | 51 | // Called by startup code. 52 | void ST_Init (void); 53 | 54 | 55 | 56 | // States for status bar code. 57 | typedef enum 58 | { 59 | AutomapState, 60 | FirstPersonState 61 | 62 | } st_stateenum_t; 63 | 64 | 65 | // States for the chat code. 66 | typedef enum 67 | { 68 | StartChatState, 69 | WaitDestState, 70 | GetChatState 71 | 72 | } st_chatstateenum_t; 73 | 74 | 75 | 76 | extern byte *st_backing_screen; 77 | extern cheatseq_t cheat_mus; 78 | extern cheatseq_t cheat_god; 79 | extern cheatseq_t cheat_ammo; 80 | extern cheatseq_t cheat_ammonokey; 81 | extern cheatseq_t cheat_noclip; 82 | extern cheatseq_t cheat_commercial_noclip; 83 | extern cheatseq_t cheat_powerup[7]; 84 | extern cheatseq_t cheat_choppers; 85 | extern cheatseq_t cheat_clev; 86 | extern cheatseq_t cheat_mypos; 87 | 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/statdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(C) 2005-2014 Simon Howard 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | */ 16 | 17 | #ifndef DOOM_STATDUMP_H 18 | #define DOOM_STATDUMP_H 19 | 20 | void StatCopy(wbstartstruct_t *stats); 21 | void StatDump(void); 22 | 23 | #endif /* #ifndef DOOM_STATDUMP_H */ 24 | -------------------------------------------------------------------------------- /src/tables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 1993-2008 Raven Software 4 | // Copyright(C) 2005-2014 Simon Howard 5 | // 6 | // This program is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation; either version 2 9 | // of the License, or (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // DESCRIPTION: 17 | // Lookup tables. 18 | // Do not try to look them up :-). 19 | // In the order of appearance: 20 | // 21 | // int finetangent[4096] - Tangens LUT. 22 | // Should work with BAM fairly well (12 of 16bit, 23 | // effectively, by shifting). 24 | // 25 | // int finesine[10240] - Sine lookup. 26 | // Guess what, serves as cosine, too. 27 | // Remarkable thing is, how to use BAMs with this? 28 | // 29 | // int tantoangle[2049] - ArcTan LUT, 30 | // maps tan(angle) to angle fast. Gotta search. 31 | // 32 | 33 | 34 | #ifndef __TABLES__ 35 | #define __TABLES__ 36 | 37 | #include "doomtype.h" 38 | 39 | #include "m_fixed.h" 40 | 41 | #define FINEANGLES 8192 42 | #define FINEMASK (FINEANGLES-1) 43 | 44 | 45 | // 0x100000000 to 0x2000 46 | #define ANGLETOFINESHIFT 19 47 | 48 | // Effective size is 10240. 49 | extern const fixed_t finesine[5*FINEANGLES/4]; 50 | 51 | // Re-use data, is just PI/2 pahse shift. 52 | extern const fixed_t *finecosine; 53 | 54 | 55 | // Effective size is 4096. 56 | extern const fixed_t finetangent[FINEANGLES/2]; 57 | 58 | // Gamma correction tables. 59 | extern const byte gammatable[5][256]; 60 | 61 | // Binary Angle Measument, BAM. 62 | 63 | #define ANG45 0x20000000 64 | #define ANG90 0x40000000 65 | #define ANG180 0x80000000 66 | #define ANG270 0xc0000000 67 | #define ANG_MAX 0xffffffff 68 | 69 | #define ANG1 (ANG45 / 45) 70 | #define ANG60 (ANG180 / 3) 71 | 72 | // Heretic code uses this definition as though it represents one 73 | // degree, but it is not! This is actually ~1.40 degrees. 74 | 75 | #define ANG1_X 0x01000000 76 | 77 | #define SLOPERANGE 2048 78 | #define SLOPEBITS 11 79 | #define DBITS (FRACBITS-SLOPEBITS) 80 | 81 | typedef unsigned angle_t; 82 | 83 | 84 | // Effective size is 2049; 85 | // The +1 size is to handle the case when x==y 86 | // without additional checking. 87 | extern const angle_t tantoangle[SLOPERANGE+1]; 88 | 89 | 90 | // Utility function, 91 | // called by R_PointToAngle. 92 | int SlopeDiv(unsigned int num, unsigned int den); 93 | 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /src/v_patch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Refresh/rendering module, shared data struct definitions. 17 | // 18 | 19 | 20 | #ifndef V_PATCH_H 21 | #define V_PATCH_H 22 | 23 | // Patches. 24 | // A patch holds one or more columns. 25 | // Patches are used for sprites and all masked pictures, 26 | // and we compose textures from the TEXTURE1/2 lists 27 | // of patches. 28 | 29 | typedef struct 30 | { 31 | short width; // bounding box size 32 | short height; 33 | short leftoffset; // pixels to the left of origin 34 | short topoffset; // pixels below the origin 35 | int columnofs[8]; // only [width] used 36 | // the [0] is &columnofs[width] 37 | } PACKEDATTR patch_t; 38 | 39 | // posts are runs of non masked source pixels 40 | typedef struct 41 | { 42 | byte topdelta; // -1 is the last post in a column 43 | byte length; // length data bytes follows 44 | } PACKEDATTR post_t; 45 | 46 | // column_t is a list of 0 or more post_t, (byte)-1 terminated 47 | typedef post_t column_t; 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/v_video.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Gamma correction LUT. 17 | // Functions to draw patches (by post) directly to screen. 18 | // Functions to blit a block to the screen. 19 | // 20 | 21 | 22 | #ifndef __V_VIDEO__ 23 | #define __V_VIDEO__ 24 | 25 | #include "doomtype.h" 26 | 27 | // Needed because we are refering to patches. 28 | #include "v_patch.h" 29 | 30 | // 31 | // VIDEO 32 | // 33 | 34 | #define CENTERY (SCREENHEIGHT/2) 35 | 36 | 37 | extern int dirtybox[4]; 38 | 39 | extern byte *tinttable; 40 | 41 | // haleyjd 08/28/10: implemented for Strife support 42 | // haleyjd 08/28/10: Patch clipping callback, implemented to support Choco 43 | // Strife. 44 | typedef boolean (*vpatchclipfunc_t)(patch_t *, int, int); 45 | void V_SetPatchClipCallback(vpatchclipfunc_t func); 46 | 47 | 48 | // Allocates buffer screens, call before R_Init. 49 | void V_Init (void); 50 | 51 | // Draw a block from the specified source screen to the screen. 52 | 53 | void V_CopyRect(int srcx, int srcy, byte *source, 54 | int width, int height, 55 | int destx, int desty); 56 | 57 | void V_DrawPatch(int x, int y, patch_t *patch); 58 | void V_DrawPatchFlipped(int x, int y, patch_t *patch); 59 | void V_DrawTLPatch(int x, int y, patch_t *patch); 60 | void V_DrawAltTLPatch(int x, int y, patch_t * patch); 61 | void V_DrawShadowedPatch(int x, int y, patch_t *patch); 62 | void V_DrawXlaPatch(int x, int y, patch_t * patch); // villsa [STRIFE] 63 | void V_DrawPatchDirect(int x, int y, patch_t *patch); 64 | 65 | // Draw a linear block of pixels into the view buffer. 66 | 67 | void V_DrawBlock(int x, int y, int width, int height, byte *src); 68 | 69 | void V_MarkRect(int x, int y, int width, int height); 70 | 71 | void V_DrawFilledBox(int x, int y, int w, int h, int c); 72 | void V_DrawHorizLine(int x, int y, int w, int c); 73 | void V_DrawVertLine(int x, int y, int h, int c); 74 | void V_DrawBox(int x, int y, int w, int h, int c); 75 | 76 | // Draw a raw screen lump 77 | 78 | void V_DrawRawScreen(byte *raw); 79 | 80 | // Temporarily switch to using a different buffer to draw graphics, etc. 81 | 82 | void V_UseBuffer(byte *buffer); 83 | 84 | // Return to using the normal screen buffer to draw graphics. 85 | 86 | void V_RestoreBuffer(void); 87 | 88 | // Save a screenshot of the current screen to a file, named in the 89 | // format described in the string passed to the function, eg. 90 | // "DOOM%02i.pcx" 91 | 92 | void V_ScreenShot(char *format); 93 | 94 | // Load the lookup table for translucency calculations from the TINTTAB 95 | // lump. 96 | 97 | void V_LoadTintTable(void); 98 | 99 | // villsa [STRIFE] 100 | // Load the lookup table for translucency calculations from the XLATAB 101 | // lump. 102 | 103 | void V_LoadXlaTable(void); 104 | 105 | void V_DrawMouseSpeedBox(int speed); 106 | 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /src/w_checksum.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Generate a checksum of the WAD directory. 17 | // 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "m_misc.h" 24 | #include "sha1.h" 25 | #include "w_checksum.h" 26 | #include "w_wad.h" 27 | 28 | static wad_file_t **open_wadfiles = NULL; 29 | static int num_open_wadfiles = 0; 30 | 31 | static int GetFileNumber(wad_file_t *handle) 32 | { 33 | int i; 34 | int result; 35 | 36 | for (i=0; iname, sizeof(buf)); 62 | SHA1_UpdateString(sha1_context, buf); 63 | SHA1_UpdateInt32(sha1_context, GetFileNumber(lump->wad_file)); 64 | SHA1_UpdateInt32(sha1_context, lump->position); 65 | SHA1_UpdateInt32(sha1_context, lump->size); 66 | } 67 | 68 | void W_Checksum(sha1_digest_t digest) 69 | { 70 | sha1_context_t sha1_context; 71 | unsigned int i; 72 | 73 | SHA1_Init(&sha1_context); 74 | 75 | num_open_wadfiles = 0; 76 | 77 | // Go through each entry in the WAD directory, adding information 78 | // about each entry to the SHA1 hash. 79 | 80 | for (i=0; i 20 | 21 | #include "config.h" 22 | 23 | #include "doomtype.h" 24 | #include "m_argv.h" 25 | 26 | #include "w_file.h" 27 | 28 | 29 | extern wad_file_class_t memio_wad_file; 30 | 31 | /* SOKOL CHANGE 32 | extern wad_file_class_t stdc_wad_file; 33 | #ifdef _WIN32 34 | extern wad_file_class_t win32_wad_file; 35 | #endif 36 | 37 | #ifdef HAVE_MMAP 38 | extern wad_file_class_t posix_wad_file; 39 | #endif 40 | 41 | static wad_file_class_t *wad_file_classes[] = 42 | { 43 | #ifdef _WIN32 44 | &win32_wad_file, 45 | #endif 46 | #ifdef HAVE_MMAP 47 | &posix_wad_file, 48 | #endif 49 | &stdc_wad_file, 50 | }; 51 | */ 52 | 53 | wad_file_t *W_OpenFile(char *path) 54 | { 55 | return memio_wad_file.OpenFile(path); 56 | 57 | /* SOKOL CHANGE 58 | wad_file_t *result; 59 | int i; 60 | 61 | //! 62 | // Use the OS's virtual memory subsystem to map WAD files 63 | // directly into memory. 64 | // 65 | 66 | if (!M_CheckParm("-mmap")) 67 | { 68 | return stdc_wad_file.OpenFile(path); 69 | } 70 | 71 | // Try all classes in order until we find one that works 72 | 73 | result = NULL; 74 | 75 | for (i = 0; i < arrlen(wad_file_classes); ++i) 76 | { 77 | result = wad_file_classes[i]->OpenFile(path); 78 | 79 | if (result != NULL) 80 | { 81 | break; 82 | } 83 | } 84 | 85 | return result; 86 | */ 87 | } 88 | 89 | void W_CloseFile(wad_file_t *wad) 90 | { 91 | wad->file_class->CloseFile(wad); 92 | } 93 | 94 | size_t W_Read(wad_file_t *wad, unsigned int offset, 95 | void *buffer, size_t buffer_len) 96 | { 97 | return wad->file_class->Read(wad, offset, buffer, buffer_len); 98 | } 99 | 100 | -------------------------------------------------------------------------------- /src/w_file.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | 20 | #ifndef __W_FILE__ 21 | #define __W_FILE__ 22 | 23 | #include 24 | #include "doomtype.h" 25 | 26 | typedef struct _wad_file_s wad_file_t; 27 | 28 | typedef struct 29 | { 30 | // Open a file for reading. 31 | 32 | wad_file_t *(*OpenFile)(char *path); 33 | 34 | // Close the specified file. 35 | 36 | void (*CloseFile)(wad_file_t *file); 37 | 38 | // Read data from the specified position in the file into the 39 | // provided buffer. Returns the number of bytes read. 40 | 41 | size_t (*Read)(wad_file_t *file, unsigned int offset, 42 | void *buffer, size_t buffer_len); 43 | 44 | } wad_file_class_t; 45 | 46 | struct _wad_file_s 47 | { 48 | // Class of this file. 49 | 50 | wad_file_class_t *file_class; 51 | 52 | // If this is NULL, the file cannot be mapped into memory. If this 53 | // is non-NULL, it is a pointer to the mapped file. 54 | 55 | byte *mapped; 56 | 57 | // Length of the file, in bytes. 58 | 59 | unsigned int length; 60 | }; 61 | 62 | // Open the specified file. Returns a pointer to a new wad_file_t 63 | // handle for the WAD file, or NULL if it could not be opened. 64 | 65 | wad_file_t *W_OpenFile(char *path); 66 | 67 | // Close the specified WAD file. 68 | 69 | void W_CloseFile(wad_file_t *wad); 70 | 71 | // Read data from the specified file into the provided buffer. The 72 | // data is read from the specified offset from the start of the file. 73 | // Returns the number of bytes read. 74 | 75 | size_t W_Read(wad_file_t *wad, unsigned int offset, 76 | void *buffer, size_t buffer_len); 77 | 78 | #endif /* #ifndef __W_FILE__ */ 79 | -------------------------------------------------------------------------------- /src/w_file_stdc.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | #include 20 | 21 | #include "m_misc.h" 22 | #include "w_file.h" 23 | #include "z_zone.h" 24 | 25 | typedef struct 26 | { 27 | wad_file_t wad; 28 | FILE *fstream; 29 | } stdc_wad_file_t; 30 | 31 | extern wad_file_class_t stdc_wad_file; 32 | 33 | static wad_file_t *W_StdC_OpenFile(char *path) 34 | { 35 | stdc_wad_file_t *result; 36 | FILE *fstream; 37 | 38 | fstream = fopen(path, "rb"); 39 | 40 | if (fstream == NULL) 41 | { 42 | return NULL; 43 | } 44 | 45 | // Create a new stdc_wad_file_t to hold the file handle. 46 | 47 | result = Z_Malloc(sizeof(stdc_wad_file_t), PU_STATIC, 0); 48 | result->wad.file_class = &stdc_wad_file; 49 | result->wad.mapped = NULL; 50 | result->wad.length = M_FileLength(fstream); 51 | result->fstream = fstream; 52 | 53 | return &result->wad; 54 | } 55 | 56 | static void W_StdC_CloseFile(wad_file_t *wad) 57 | { 58 | stdc_wad_file_t *stdc_wad; 59 | 60 | stdc_wad = (stdc_wad_file_t *) wad; 61 | 62 | fclose(stdc_wad->fstream); 63 | Z_Free(stdc_wad); 64 | } 65 | 66 | // Read data from the specified position in the file into the 67 | // provided buffer. Returns the number of bytes read. 68 | 69 | size_t W_StdC_Read(wad_file_t *wad, unsigned int offset, 70 | void *buffer, size_t buffer_len) 71 | { 72 | stdc_wad_file_t *stdc_wad; 73 | size_t result; 74 | 75 | stdc_wad = (stdc_wad_file_t *) wad; 76 | 77 | // Jump to the specified position in the file. 78 | 79 | fseek(stdc_wad->fstream, offset, SEEK_SET); 80 | 81 | // Read into the buffer. 82 | 83 | result = fread(buffer, 1, buffer_len, stdc_wad->fstream); 84 | 85 | return result; 86 | } 87 | 88 | 89 | wad_file_class_t stdc_wad_file = 90 | { 91 | W_StdC_OpenFile, 92 | W_StdC_CloseFile, 93 | W_StdC_Read, 94 | }; 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/w_main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Common code to parse command line, identifying WAD files to load. 16 | // 17 | 18 | #ifndef W_MAIN_H 19 | #define W_MAIN_H 20 | 21 | boolean W_ParseCommandLine(void); 22 | 23 | #endif /* #ifndef W_MAIN_H */ 24 | 25 | -------------------------------------------------------------------------------- /src/w_merge.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 2005-2014 Simon Howard 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either version 2 7 | // of the License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // DESCRIPTION: 15 | // Handles merging of PWADs, similar to deutex's -merge option 16 | // 17 | // Ideally this should work exactly the same as in deutex, but trying to 18 | // read the deutex source code made my brain hurt. 19 | // 20 | 21 | #ifndef W_MERGE_H 22 | #define W_MERGE_H 23 | 24 | #define W_NWT_MERGE_SPRITES 0x1 25 | #define W_NWT_MERGE_FLATS 0x2 26 | 27 | // Add a new WAD and merge it into the main directory 28 | 29 | void W_MergeFile(char *filename); 30 | 31 | // NWT-style merging 32 | 33 | void W_NWTMergeFile(char *filename, int flags); 34 | 35 | // Acts the same as NWT's "-merge" option. 36 | 37 | void W_NWTDashMerge(char *filename); 38 | 39 | // Debug function that prints the WAD directory. 40 | 41 | void W_PrintDirectory(void); 42 | 43 | #endif /* #ifndef W_MERGE_H */ 44 | 45 | -------------------------------------------------------------------------------- /src/w_wad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // WAD I/O functions. 17 | // 18 | 19 | 20 | #ifndef __W_WAD__ 21 | #define __W_WAD__ 22 | 23 | #include 24 | 25 | #include "doomtype.h" 26 | #include "d_mode.h" 27 | 28 | #include "w_file.h" 29 | 30 | 31 | // 32 | // TYPES 33 | // 34 | 35 | // 36 | // WADFILE I/O related stuff. 37 | // 38 | 39 | typedef struct lumpinfo_s lumpinfo_t; 40 | 41 | struct lumpinfo_s 42 | { 43 | char name[8]; 44 | wad_file_t *wad_file; 45 | int position; 46 | int size; 47 | void *cache; 48 | 49 | // Used for hash table lookups 50 | 51 | lumpinfo_t *next; 52 | }; 53 | 54 | 55 | extern lumpinfo_t *lumpinfo; 56 | extern unsigned int numlumps; 57 | 58 | wad_file_t *W_AddFile (char *filename); 59 | 60 | int W_CheckNumForName (char* name); 61 | int W_GetNumForName (char* name); 62 | 63 | int W_LumpLength (unsigned int lump); 64 | void W_ReadLump (unsigned int lump, void *dest); 65 | 66 | void* W_CacheLumpNum (int lump, int tag); 67 | void* W_CacheLumpName (char* name, int tag); 68 | 69 | void W_GenerateHashTable(void); 70 | 71 | extern unsigned int W_LumpNameHash(const char *s); 72 | 73 | void W_ReleaseLumpNum(int lump); 74 | void W_ReleaseLumpName(char *name); 75 | 76 | void W_CheckCorrectIWAD(GameMission_t mission); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/wi_stuff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Intermission. 17 | // 18 | 19 | #ifndef __WI_STUFF__ 20 | #define __WI_STUFF__ 21 | 22 | //#include "v_video.h" 23 | 24 | #include "doomdef.h" 25 | 26 | // States for the intermission 27 | 28 | typedef enum 29 | { 30 | NoState = -1, 31 | StatCount, 32 | ShowNextLoc, 33 | } stateenum_t; 34 | 35 | // Called by main loop, animate the intermission. 36 | void WI_Ticker (void); 37 | 38 | // Called by main loop, 39 | // draws the intermission directly into the screen buffer. 40 | void WI_Drawer (void); 41 | 42 | // Setup for an intermission screen. 43 | void WI_Start(wbstartstruct_t* wbstartstruct); 44 | 45 | // Shut down the intermission screen 46 | void WI_End(void); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/z_zone.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(C) 1993-1996 Id Software, Inc. 3 | // Copyright(C) 2005-2014 Simon Howard 4 | // 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // DESCRIPTION: 16 | // Zone Memory Allocation, perhaps NeXT ObjectiveC inspired. 17 | // Remark: this was the only stuff that, according 18 | // to John Carmack, might have been useful for 19 | // Quake. 20 | // 21 | 22 | 23 | 24 | #ifndef __Z_ZONE__ 25 | #define __Z_ZONE__ 26 | 27 | #include 28 | 29 | // 30 | // ZONE MEMORY 31 | // PU - purge tags. 32 | 33 | enum 34 | { 35 | PU_STATIC = 1, // static entire execution time 36 | PU_SOUND, // static while playing 37 | PU_MUSIC, // static while playing 38 | PU_FREE, // a free block 39 | PU_LEVEL, // static until level exited 40 | PU_LEVSPEC, // a special thinker in a level 41 | 42 | // Tags >= PU_PURGELEVEL are purgable whenever needed. 43 | 44 | PU_PURGELEVEL, 45 | PU_CACHE, 46 | 47 | // Total number of different tag types 48 | 49 | PU_NUM_TAGS 50 | }; 51 | 52 | 53 | void Z_Init (void); 54 | void* Z_Malloc (int size, int tag, void *ptr); 55 | void Z_Free (void *ptr); 56 | void Z_FreeTags (int lowtag, int hightag); 57 | void Z_DumpHeap (int lowtag, int hightag); 58 | void Z_FileDumpHeap (FILE *f); 59 | void Z_CheckHeap (void); 60 | void Z_ChangeTag2 (void *ptr, int tag, char *file, int line); 61 | void Z_ChangeUser(void *ptr, void **user); 62 | int Z_FreeMemory (void); 63 | unsigned int Z_ZoneSize(void); 64 | 65 | // 66 | // This is used to get the local FILE:LINE info from CPP 67 | // prior to really call the function in question. 68 | // 69 | #define Z_ChangeTag(p,t) \ 70 | Z_ChangeTag2((p), (t), __FILE__, __LINE__) 71 | 72 | 73 | #endif 74 | --------------------------------------------------------------------------------