├── README.md ├── doc ├── CREDITS.TXT ├── DOOMLIC.TXT ├── GPLV3.TXT ├── LICENSE_generic-hashtable.TXT ├── LICENSE_lzfx.txt ├── ORIGINAL_README.TXT └── README_generic-hashtable.TXT └── src ├── Makefile ├── am_map.c ├── am_map.h ├── d_englsh.h ├── d_event.h ├── d_french.h ├── d_items.c ├── d_items.h ├── d_main.c ├── d_main.h ├── d_net.c ├── d_net.h ├── d_player.h ├── d_textur.h ├── d_think.h ├── d_ticcmd.h ├── dll.c ├── dll.h ├── doomdata.h ├── doomdef.c ├── doomdef.h ├── doomstat.c ├── doomstat.h ├── doomtype.h ├── dstrings.c ├── dstrings.h ├── endoom.c ├── f_finale.c ├── f_finale.h ├── f_wipe.c ├── f_wipe.h ├── filesystem ├── MIDI_Instruments └── menulumps │ ├── gamma.bin │ ├── resoluti.bin │ ├── rzhigh.bin │ ├── rzlow.bin │ ├── videoset.bin │ └── vidttl.bin ├── g_game.c ├── g_game.h ├── hash.c ├── hash.h ├── hu_lib.c ├── hu_lib.h ├── hu_stuff.c ├── hu_stuff.h ├── i_input.c ├── i_input.h ├── i_main.c ├── i_net.c ├── i_net.h ├── i_sound.c ├── i_sound.h ├── i_system.c ├── i_system.h ├── i_video.c ├── i_video.h ├── info.c ├── info.h ├── lzfx.c ├── lzfx.h ├── m_argv.c ├── m_argv.h ├── m_bbox.c ├── m_bbox.h ├── m_cheat.c ├── m_cheat.h ├── m_fixed.h ├── m_menu.c ├── m_menu.h ├── m_misc.c ├── m_misc.h ├── m_random.c ├── m_random.h ├── m_swap.h ├── nodereorder.c ├── 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 ├── regsinternal.h ├── s_sound.c ├── s_sound.h ├── sounds.c ├── sounds.h ├── st_lib.c ├── st_lib.h ├── st_stuff.c ├── st_stuff.h ├── tables.h ├── v_video.c ├── v_video.h ├── w_wad.c ├── w_wad.h ├── wi_stuff.c ├── wi_stuff.h ├── z_zone.c └── z_zone.h /README.md: -------------------------------------------------------------------------------- 1 | --------------- 2 | -64DOOM README- 3 | --------------- 4 | 5 | 6 | Updated 2023/05/21 7 | 8 | 9 | ------------------------- 10 | -git repository contents- 11 | ------------------------- 12 | 13 | `README.md` is this file 14 | 15 | `src` directory contains all 64Doom C source, header files, menu graphics and Makefile used to build 64Doom 16 | 17 | `doc` directory contains many text files including 18 | 19 | ` ORIGINAL_README.TXT` is the original `README.TXT` from the 1990s DOOM open source release 20 | 21 | ` DOOMLIC.TXT` is the DOOM open source license documentation 22 | 23 | ` CREDITS.TXT` which provides attribution for various components and code contributors 24 | 25 | ` LICENSE_generic-hashtable.TXT`, `README_generic-hashtable.TXT` required attribution for Hashtable implementation used 26 | 27 | ` GPLV3.TXT` is a copy of the GPL V3 License as required 28 | 29 | -------------- 30 | -how to build- 31 | -------------- 32 | Setup libdragon UNSTABLE branch: https://github.com/DragonMinded/libdragon/wiki/Installing-libdragon 33 | 34 | Get a copy of a supported version of Doom (Doom shareware, retail, Ultimate Doom, Doom II, Plutonia, TNT). 35 | 36 | Export two environment variables: 37 | 38 | `IWAD_DIRECTORY` -- the path of the directory that contains your IWAD file 39 | 40 | `IWAD_PREFIX` -- the actual IWAD filename prefix (one of `DOOM1`, `DOOM`, `DOOMU`, `DOOM2`, `PLUTONIA`, `TNT` - these are case sensitive. Must be uppercase and your wad filename must be uppercase i.e. `DOOM2.WAD`) 41 | 42 | And run make. 43 | 44 | Result is `$(IWAD_PREFIX).z64` ready to copy to dev cart or run in emulator. 45 | 46 | Example for building DOOM2 from repo directory, with IWAD files located in your home directory under `IWADS`: 47 | 48 | `cd src` 49 | 50 | `env IWAD_DIRECTORY="~/IWADS" IWAD_PREFIX="DOOM2" make` 51 | 52 | resulting in `DOOM2.z64` 53 | 54 | If you want to build for a different game version, be sure to run make clean first. Environment variables must be set for make clean as well. 55 | 56 | `env IWAD_DIRECTORY="." IWAD_PREFIX="." make clean` 57 | 58 | 59 | ----------- 60 | -SAVEGAMES- 61 | ----------- 62 | 63 | 64Doom uses the Controller Pak to save and load your game progress from the Save Game / Load Game menu options. 64 | 65 | One savegame slot is presented, mapped to a single note on the Controller Pak. 66 | 67 | The name of the note is the same as the game version (`$IWAD_PREFIX`) you are playing. 68 | 69 | When you save or load a game, you will see a message in the Doom HUD if it is successful: 70 | 71 | `SAVED GAME TO MEMPAK` 72 | 73 | `LOADED GAME FROM MEMPAK` 74 | 75 | Savegames are compressed using the lzfx library. However, the compressed saves are still large relative to the capacity of a fully-formatted Controller Pak. 76 | 77 | In the event that there is not enough free space on the Controller Pak to save the game, you will see a message in the Doom HUD: 78 | 79 | `NOT ENOUGH SPACE FOR SAVE (NEED #, HAVE #)` 80 | 81 | It is very likely you will see this message if you have notes from other games on your Controller Pak, so it is desirable to play with a dedicated, initially empty 82 | Controller Pak. 83 | 84 | It is possible that there are rare occasions where this may happen even with an empty Controller Pak. 85 | 86 | If it does, kill some more enemies, pick up some more items, try again. :-) 87 | 88 | ---------- 89 | -CONTROLS- 90 | ---------- 91 | 92 | D-PAD UP / ANALOG STICK UP :: move forward 93 | 94 | D-PAD DOWN / ANALOG STICK DOWN :: move backward 95 | 96 | D-PAD LEFT / ANALOG STICK LEFT :: turn left 97 | 98 | D-PAD RIGHT / ANALOG STICK RIGHT :: turn right 99 | 100 | L TRIGGER :: strafe left 101 | 102 | R TRIGGER :: strafe right 103 | 104 | C LEFT :: switch to previous weapon 105 | 106 | C RIGHT :: switch to next weapon 107 | 108 | C UP :: toggle auto-map 109 | 110 | C DOWN :: ENTER key 111 | 112 | Z :: toggle run on/off (defaults to on) 113 | 114 | A :: shoot 115 | 116 | B :: use (open doors, flip switches) 117 | 118 | START :: ESCAPE key 119 | 120 | 121 | Enjoy. 122 | -------------------------------------------------------------------------------- /doc/CREDITS.TXT: -------------------------------------------------------------------------------- 1 | Doom source from here: https://github.com/id-Software/DOOM 2 | 3 | Sample-based MUS playback and digital sound code along with tons of moral and technical support from: ChillyWilly 4 | 5 | Generic C hashtable from here: https://github.com/dennisfrancis/generic-hashtable 6 | 7 | LZFX codec from here: http://lzfx.googlecode.com (dead link) 8 | 9 | screen wipe code from Chocolate Doom: https://github.com/chocolate-doom/chocolate-doom/blob/master/src/doom/f_wipe.c 10 | 11 | more improvements and testing: thekovic, Immorpher 12 | -------------------------------------------------------------------------------- /doc/DOOMLIC.TXT: -------------------------------------------------------------------------------- 1 | 2 | 3 | LIMITED USE SOFTWARE LICENSE AGREEMENT 4 | 5 | This Limited Use Software License Agreement (the "Agreement") 6 | is a legal agreement between you, the end-user, and Id Software, Inc. 7 | ("ID"). By downloading or purchasing the software material, which 8 | includes source code (the "Source Code"), artwork data, music and 9 | software tools (collectively, the "Software"), you are agreeing to 10 | be bound by the terms of this Agreement. If you do not agree to the 11 | terms of this Agreement, promptly destroy the Software you may have 12 | downloaded or copied. 13 | 14 | ID SOFTWARE LICENSE 15 | 16 | 1. Grant of License. ID grants to you the right to use the 17 | Software. You have no ownership or proprietary rights in or to the 18 | Software, or the Trademark. For purposes of this section, "use" means 19 | loading the Software into RAM, as well as installation on a hard disk 20 | or other storage device. The Software, together with any archive copy 21 | thereof, shall be destroyed when no longer used in accordance with 22 | this Agreement, or when the right to use the Software is terminated. 23 | You agree that the Software will not be shipped, transferred or 24 | exported into any country in violation of the U.S. Export 25 | Administration Act (or any other law governing such matters) and that 26 | you will not utilize, in any other manner, the Software in violation 27 | of any applicable law. 28 | 29 | 2. Permitted Uses. For educational purposes only, you, the 30 | end-user, may use portions of the Source Code, such as particular 31 | routines, to develop your own software, but may not duplicate the 32 | Source Code, except as noted in paragraph 4. The limited right 33 | referenced in the preceding sentence is hereinafter referred to as 34 | "Educational Use." By so exercising the Educational Use right you 35 | shall not obtain any ownership, copyright, proprietary or other 36 | interest in or to the Source Code, or any portion of the Source 37 | Code. You may dispose of your own software in your sole discretion. 38 | With the exception of the Educational Use right, you may not 39 | otherwise use the Software, or an portion of the Software, which 40 | includes the Source Code, for commercial gain. 41 | 42 | 3. Prohibited Uses: Under no circumstances shall you, the 43 | end-user, be permitted, allowed or authorized to commercially exploit 44 | the Software. Neither you nor anyone at your direction shall do any 45 | of the following acts with regard to the Software, or any portion 46 | thereof: 47 | 48 | Rent; 49 | 50 | Sell; 51 | 52 | Lease; 53 | 54 | Offer on a pay-per-play basis; 55 | 56 | Distribute for money or any other consideration; or 57 | 58 | In any other manner and through any medium whatsoever 59 | commercially exploit or use for any commercial purpose. 60 | 61 | Notwithstanding the foregoing prohibitions, you may commercially 62 | exploit the software you develop by exercising the Educational Use 63 | right, referenced in paragraph 2. hereinabove. 64 | 65 | 4. Copyright. The Software and all copyrights related thereto 66 | (including all characters and other images generated by the Software 67 | or depicted in the Software) are owned by ID and is protected by 68 | United States copyright laws and international treaty provisions. 69 | Id shall retain exclusive ownership and copyright in and to the 70 | Software and all portions of the Software and you shall have no 71 | ownership or other proprietary interest in such materials. You must 72 | treat the Software like any other copyrighted material. You may not 73 | otherwise reproduce, copy or disclose to others, in whole or in any 74 | part, the Software. You may not copy the written materials 75 | accompanying the Software. You agree to use your best efforts to 76 | see that any user of the Software licensed hereunder complies with 77 | this Agreement. 78 | 79 | 5. NO WARRANTIES. ID DISCLAIMS ALL WARRANTIES, BOTH EXPRESS 80 | IMPLIED, INCLUDING BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 81 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT 82 | TO THE SOFTWARE. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL 83 | RIGHTS. YOU MAY HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO 84 | JURISDICTION. ID DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE 85 | WILL BE UNINTERRUPTED, ERROR FREE OR MEET YOUR SPECIFIC REQUIREMENTS. 86 | THE WARRANTY SET FORTH ABOVE IS IN LIEU OF ALL OTHER EXPRESS 87 | WARRANTIES WHETHER ORAL OR WRITTEN. THE AGENTS, EMPLOYEES, 88 | DISTRIBUTORS, AND DEALERS OF ID ARE NOT AUTHORIZED TO MAKE 89 | MODIFICATIONS TO THIS WARRANTY, OR ADDITIONAL WARRANTIES ON BEHALF 90 | OF ID. 91 | 92 | Exclusive Remedies. The Software is being offered to you 93 | free of any charge. You agree that you have no remedy against ID, its 94 | affiliates, contractors, suppliers, and agents for loss or damage 95 | caused by any defect or failure in the Software regardless of the form 96 | of action, whether in contract, tort, includinegligence, strict 97 | liability or otherwise, with regard to the Software. This Agreement 98 | shall be construed in accordance with and governed by the laws of the 99 | State of Texas. Copyright and other proprietary matters will be 100 | governed by United States laws and international treaties. IN ANY 101 | CASE, ID SHALL NOT BE LIABLE FOR LOSS OF DATA, LOSS OF PROFITS, LOST 102 | SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR OTHER 103 | SIMILAR DAMAGES ARISING FROM BREACH OF WARRANTY, BREACH OF CONTRACT, 104 | NEGLIGENCE, OR OTHER LEGAL THEORY EVEN IF ID OR ITS AGENT HAS BEEN 105 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY 106 | OTHER PARTY. Some jurisdictions do not allow the exclusion or 107 | limitation of incidental or consequential damages, so the above 108 | limitation or exclusion may not apply to you. 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /doc/LICENSE_generic-hashtable.TXT: -------------------------------------------------------------------------------- 1 | Generic-HashTable : General Purpose Hash Table in pure C 2 | Copyright (C) 2012 Dennis Francis 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (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 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | -------------------------------------------------------------------------------- /doc/LICENSE_lzfx.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Andrew Collette 2 | http://lzfx.googlecode.com 3 | 4 | Implements an LZF-compatible compressor/decompressor based on the liblzf 5 | codebase written by Marc Lehmann. This code is released under the BSD 6 | license. License and original copyright statement follow. 7 | 8 | 9 | Copyright (c) 2000-2008 Marc Alexander Lehmann 10 | 11 | Redistribution and use in source and binary forms, with or without modifica- 12 | tion, are permitted provided that the following conditions are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 23 | CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 24 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 25 | CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 29 | ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /doc/ORIGINAL_README.TXT: -------------------------------------------------------------------------------- 1 | 2 | Here it is, at long last. The DOOM source code is released for your 3 | non-profit use. You still need real DOOM data to work with this code. 4 | If you don't actually own a real copy of one of the DOOMs, you should 5 | still be able to find them at software stores. 6 | 7 | Many thanks to Bernd Kreimeier for taking the time to clean up the 8 | project and make sure that it actually works. Projects tends to rot if 9 | you leave it alone for a few years, and it takes effort for someone to 10 | deal with it again. 11 | 12 | The bad news: this code only compiles and runs on linux. We couldn't 13 | release the dos code because of a copyrighted sound library we used 14 | (wow, was that a mistake -- I write my own sound code now), and I 15 | honestly don't even know what happened to the port that microsoft did 16 | to windows. 17 | 18 | Still, the code is quite portable, and it should be straightforward to 19 | bring it up on just about any platform. 20 | 21 | I wrote this code a long, long time ago, and there are plenty of things 22 | that seem downright silly in retrospect (using polar coordinates for 23 | clipping comes to mind), but overall it should still be a usefull base 24 | to experiment and build on. 25 | 26 | The basic rendering concept -- horizontal and vertical lines of constant 27 | Z with fixed light shading per band was dead-on, but the implementation 28 | could be improved dramatically from the original code if it were 29 | revisited. The way the rendering proceded from walls to floors to 30 | sprites could be collapsed into a single front-to-back walk of the bsp 31 | tree to collect information, then draw all the contents of a subsector 32 | on the way back up the tree. It requires treating floors and ceilings 33 | as polygons, rather than just the gaps between walls, and it requires 34 | clipping sprite billboards into subsector fragments, but it would be 35 | The Right Thing. 36 | 37 | The movement and line of sight checking against the lines is one of the 38 | bigger misses that I look back on. It is messy code that had some 39 | failure cases, and there was a vastly simpler (and faster) solution 40 | sitting in front of my face. I used the BSP tree for rendering things, 41 | but I didn't realize at the time that it could also be used for 42 | environment testing. Replacing the line of sight test with a bsp line 43 | clip would be pretty easy. Sweeping volumes for movement gets a bit 44 | tougher, and touches on many of the challenges faced in quake / quake2 45 | with edge bevels on polyhedrons. 46 | 47 | Some project ideas: 48 | 49 | Port it to your favorite operating system. 50 | 51 | Add some rendering features -- transparency, look up / down, slopes, 52 | etc. 53 | 54 | Add some game features -- weapons, jumping, ducking, flying, etc. 55 | 56 | Create a packet server based internet game. 57 | 58 | Create a client / server based internet game. 59 | 60 | Do a 3D accelerated version. On modern hardware (fast pentium + 3DFX) 61 | you probably wouldn't even need to be clever -- you could just draw the 62 | entire level and get reasonable speed. With a touch of effort, it should 63 | easily lock at 60 fps (well, there are some issues with DOOM's 35 hz 64 | timebase...). The biggest issues would probably be the non-power of two 65 | texture sizes and the walls composed of multiple textures. 66 | 67 | 68 | I don't have a real good guess at how many people are going to be 69 | playing with this, but if significant projects are undertaken, it would 70 | be cool to see a level of community cooperation. I know that most early 71 | projects are going to be rough hacks done in isolation, but I would be 72 | very pleased to see a coordinated 'net release of an improved, backwards 73 | compatable version of DOOM on multiple platforms next year. 74 | 75 | Have fun. 76 | 77 | John Carmack 78 | 12-23-97 79 | -------------------------------------------------------------------------------- /doc/README_generic-hashtable.TXT: -------------------------------------------------------------------------------- 1 | generic-hashtable 2 | ================= 3 | 4 | A generic hash table in C 5 | 6 | Files 7 | ===== 8 | dll.h - Doubly linked list header 9 | dll.c - Doubly linked list implementation 10 | 11 | hash.h - Hash table header 12 | hash.c - hash table implementation using chaining 13 | 14 | test_ll.c - A sample program used to test the functionality of doubly linked list library. 15 | test_hash.c - A sample program used to test the functionality of hash table library. 16 | 17 | 18 | To compile the test_ll.c, type in terminal, 19 | 20 | make -f make_test_ll 21 | 22 | And to run, 23 | ./test_ll 24 | 25 | 26 | To compile the test_hash.c, type in terminal, 27 | 28 | make -f make_test_hash 29 | 30 | And to run, 31 | ./test_hash 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(IWAD_DIRECTORY),) 2 | $(error IWAD_DIRECTORY is not set) 3 | endif 4 | ifeq ($(IWAD_PREFIX),) 5 | $(error IWAD_PREFIX is not set) 6 | endif 7 | 8 | ROOTDIR = $(N64_INST) 9 | GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf- 10 | CHKSUM64PATH = $(ROOTDIR)/bin/chksum64 11 | MKDFSPATH = $(ROOTDIR)/bin/mkdfs 12 | MKSPRITEPATH = $(ROOTDIR)/bin/mksprite 13 | HEADERPATH = $(ROOTDIR)/mips64-elf/lib 14 | N64TOOL = $(ROOTDIR)/bin/n64tool 15 | N64_SYM = $(ROOTDIR)/bin/n64sym 16 | N64_DSO = $(ROOTDIR)/bin/n64dso 17 | N64_DSOEXTERN = $(ROOTDIR)/bin/n64dso-extern 18 | N64_DSOMSYM = $(ROOTDIR)/bin/n64dso-msym 19 | HEADERNAME = header 20 | LIBS = -ldragon -lc -lm -ldragonsys 21 | PROG_NAME = $(IWAD_PREFIX) 22 | OPTFLAG = -O3 23 | 24 | # function/data sections + gc-sections saves about ~200kb from output binary 25 | CFLAGS = -ffunction-sections -fdata-sections -falign-functions=32 -ffile-prefix-map=$(CURDIR)= -DN64 -fdiagnostics-color=always -Wno-error=switch -Wall -g -mabi=o64 -mno-shared -mno-abicalls -mno-branch-likely -mno-llsc -mno-check-zero-division -mfix4300 -std=gnu99 -march=vr4300 -mtune=vr4300 -mips3 -G4 $(OPTFLAG) -I$(ROOTDIR)/mips64-elf/include 26 | #-DRANGECHECK 27 | LINK_FLAGS = --gc-sections -G4 -g -L$(ROOTDIR)/mips64-elf/lib $(LIBS) -Tn64.ld 28 | 29 | CC = $(GCCN64PREFIX)gcc 30 | AS = $(GCCN64PREFIX)as 31 | LD = $(GCCN64PREFIX)ld 32 | OBJCOPY = $(GCCN64PREFIX)objcopy 33 | OBJDUMP = $(GCCN64PREFIX)objdump 34 | 35 | 36 | 37 | O=obj 38 | 39 | OBJS= \ 40 | $(O)/i_sound.o \ 41 | $(O)/endoom.o \ 42 | $(O)/dll.o \ 43 | $(O)/hash.o \ 44 | $(O)/lzfx.o \ 45 | $(O)/i_video.o \ 46 | $(O)/i_input.o \ 47 | $(O)/doomdef.o \ 48 | $(O)/doomstat.o \ 49 | $(O)/dstrings.o \ 50 | $(O)/i_system.o \ 51 | $(O)/i_net.o \ 52 | $(O)/r_draw.o \ 53 | $(O)/v_video.o \ 54 | $(O)/f_finale.o \ 55 | $(O)/f_wipe.o \ 56 | $(O)/d_main.o \ 57 | $(O)/d_net.o \ 58 | $(O)/d_items.o \ 59 | $(O)/g_game.o \ 60 | $(O)/p_saveg.o \ 61 | $(O)/m_menu.o \ 62 | $(O)/m_misc.o \ 63 | $(O)/m_argv.o \ 64 | $(O)/m_bbox.o \ 65 | $(O)/m_cheat.o \ 66 | $(O)/m_random.o \ 67 | $(O)/am_map.o \ 68 | $(O)/p_ceilng.o \ 69 | $(O)/p_doors.o \ 70 | $(O)/p_enemy.o \ 71 | $(O)/p_floor.o \ 72 | $(O)/p_inter.o \ 73 | $(O)/p_lights.o \ 74 | $(O)/p_map.o \ 75 | $(O)/p_maputl.o \ 76 | $(O)/p_plats.o \ 77 | $(O)/p_pspr.o \ 78 | $(O)/nodereorder.o \ 79 | $(O)/p_setup.o \ 80 | $(O)/p_sight.o \ 81 | $(O)/p_spec.o \ 82 | $(O)/p_switch.o \ 83 | $(O)/p_mobj.o \ 84 | $(O)/p_telept.o \ 85 | $(O)/p_tick.o \ 86 | $(O)/p_user.o \ 87 | $(O)/r_bsp.o \ 88 | $(O)/r_data.o \ 89 | $(O)/r_main.o \ 90 | $(O)/r_plane.o \ 91 | $(O)/r_segs.o \ 92 | $(O)/r_sky.o \ 93 | $(O)/r_things.o \ 94 | $(O)/w_wad.o \ 95 | $(O)/wi_stuff.o \ 96 | $(O)/z_zone.o \ 97 | $(O)/st_lib.o \ 98 | $(O)/st_stuff.o \ 99 | $(O)/hu_stuff.o \ 100 | $(O)/hu_lib.o \ 101 | $(O)/s_sound.o \ 102 | $(O)/info.o \ 103 | $(O)/sounds.o \ 104 | $(O)/i_main.o 105 | 106 | $(PROG_NAME).z64: $(PROG_NAME).elf 107 | $(OBJCOPY) $(PROG_NAME).elf $(PROG_NAME).bin -O binary 108 | $(N64_SYM) $(PROG_NAME).elf $(PROG_NAME).sym 109 | $(N64_DSOMSYM) $(PROG_NAME).elf $(PROG_NAME).msym 110 | rm -f $(PROG_NAME).z64 111 | rm -f rom.dfs 112 | cp $(IWAD_DIRECTORY)/$(IWAD_PREFIX).WAD filesystem 113 | echo $(IWAD_PREFIX).WAD > filesystem/identifier 114 | $(MKDFSPATH) rom.dfs ./filesystem/ 115 | $(N64TOOL) \ 116 | --header $(HEADERPATH)/$(HEADERNAME) --title $(PROG_NAME) --toc --output $(PROG_NAME).z64 $(PROG_NAME).bin --align 8 $(PROG_NAME).sym --align 8 $(PROG_NAME).msym --align 16 rom.dfs 117 | chmod ugo=rw $(PROG_NAME).z64 118 | $(CHKSUM64PATH) $(PROG_NAME).z64 119 | 120 | $(PROG_NAME).elf : $(OBJS) 121 | $(LD) -o $(PROG_NAME).elf $(OBJS) $(LINK_FLAGS) 122 | 123 | copy: $(PROG_NAME).z64 124 | cp $(PROG_NAME).z64 ~/ 125 | 126 | all: $(PROG_NAME).z64 127 | 128 | clean: 129 | rm -f *.z64 *.elf *.msym *.sym *.bin *.dfs 130 | rm -f $(O)/* 131 | 132 | $(O)/%.o: %.c 133 | $(CC) $(CFLAGS) -c $< -o $@ 134 | 135 | ############################################################# 136 | # 137 | ############################################################# 138 | -------------------------------------------------------------------------------- /src/am_map.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // AutoMap module. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __AMMAP_H__ 24 | #define __AMMAP_H__ 25 | 26 | // Used by ST StatusBar stuff. 27 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 28 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 29 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 30 | 31 | 32 | // Called by main loop. 33 | boolean AM_Responder (event_t* ev); 34 | 35 | // Called by main loop. 36 | void AM_Ticker (void); 37 | 38 | // Called by main loop, 39 | // called instead of view drawer if automap active. 40 | void AM_Drawer (void); 41 | 42 | // Called to force the automap to quit 43 | // if the level is completed while it is up. 44 | void AM_Stop (void); 45 | 46 | 47 | 48 | #endif 49 | //----------------------------------------------------------------------------- 50 | // 51 | // $Log:$ 52 | // 53 | //----------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /src/d_event.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __D_EVENT__ 25 | #define __D_EVENT__ 26 | 27 | 28 | #include "doomtype.h" 29 | 30 | 31 | // 32 | // Event handling. 33 | // 34 | 35 | // Input event types. 36 | typedef enum 37 | { 38 | ev_keydown, 39 | ev_keyup, 40 | ev_mouse, 41 | ev_joystick 42 | } evtype_t; 43 | 44 | // Event structure. 45 | typedef struct 46 | { 47 | evtype_t type; 48 | int data1; // keys / mouse/joystick buttons 49 | int data2; // mouse/joystick x move 50 | int data3; // mouse/joystick y move 51 | int player; // 0 or 1 52 | } event_t; 53 | 54 | 55 | typedef enum 56 | { 57 | ga_nothing, 58 | ga_loadlevel, 59 | ga_newgame, 60 | ga_loadgame, 61 | ga_savegame, 62 | ga_playdemo, 63 | ga_completed, 64 | ga_victory, 65 | ga_worlddone, 66 | ga_screenshot 67 | } gameaction_t; 68 | 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 | 105 | 106 | 107 | // 108 | // GLOBAL VARIABLES 109 | // 110 | #define MAXEVENTS 64 111 | 112 | extern event_t events[MAXEVENTS]; 113 | extern int eventhead; 114 | extern int eventtail; 115 | 116 | extern gameaction_t gameaction; 117 | 118 | 119 | #endif 120 | //----------------------------------------------------------------------------- 121 | // 122 | // $Log:$ 123 | // 124 | //----------------------------------------------------------------------------- 125 | -------------------------------------------------------------------------------- /src/d_items.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | // We are referring to sprite numbers. 25 | #include "info.h" 26 | 27 | #ifdef __GNUG__ 28 | #pragma implementation "d_items.h" 29 | #endif 30 | #include "d_items.h" 31 | 32 | #include "doomdef.h" 33 | 34 | // 35 | // PSPRITE ACTIONS for waepons. 36 | // This struct controls the weapon animations. 37 | // 38 | // Each entry is: 39 | // ammo/amunition type 40 | // upstate 41 | // downstate 42 | // readystate 43 | // atkstate, i.e. attack/fire/hit frame 44 | // flashstate, muzzle flash 45 | // 46 | weaponinfo_t weaponinfo[NUMWEAPONS] = 47 | { 48 | { 49 | // fist 50 | am_noammo, 51 | S_PUNCHUP, 52 | S_PUNCHDOWN, 53 | S_PUNCH, 54 | S_PUNCH1, 55 | S_NULL 56 | }, 57 | { 58 | // pistol 59 | am_clip, 60 | S_PISTOLUP, 61 | S_PISTOLDOWN, 62 | S_PISTOL, 63 | S_PISTOL1, 64 | S_PISTOLFLASH 65 | }, 66 | { 67 | // shotgun 68 | am_shell, 69 | S_SGUNUP, 70 | S_SGUNDOWN, 71 | S_SGUN, 72 | S_SGUN1, 73 | S_SGUNFLASH1 74 | }, 75 | { 76 | // chaingun 77 | am_clip, 78 | S_CHAINUP, 79 | S_CHAINDOWN, 80 | S_CHAIN, 81 | S_CHAIN1, 82 | S_CHAINFLASH1 83 | }, 84 | { 85 | // missile launcher 86 | am_misl, 87 | S_MISSILEUP, 88 | S_MISSILEDOWN, 89 | S_MISSILE, 90 | S_MISSILE1, 91 | S_MISSILEFLASH1 92 | }, 93 | { 94 | // plasma rifle 95 | am_cell, 96 | S_PLASMAUP, 97 | S_PLASMADOWN, 98 | S_PLASMA, 99 | S_PLASMA1, 100 | S_PLASMAFLASH1 101 | }, 102 | { 103 | // bfg 9000 104 | am_cell, 105 | S_BFGUP, 106 | S_BFGDOWN, 107 | S_BFG, 108 | S_BFG1, 109 | S_BFGFLASH1 110 | }, 111 | { 112 | // chainsaw 113 | am_noammo, 114 | S_SAWUP, 115 | S_SAWDOWN, 116 | S_SAW, 117 | S_SAW1, 118 | S_NULL 119 | }, 120 | { 121 | // super shotgun 122 | am_shell, 123 | S_DSGUNUP, 124 | S_DSGUNDOWN, 125 | S_DSGUN, 126 | S_DSGUN1, 127 | S_DSGUNFLASH1 128 | }, 129 | }; 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /src/d_items.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Items: key cards, artifacts, weapon, ammunition. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __D_ITEMS__ 25 | #define __D_ITEMS__ 26 | 27 | #include "doomdef.h" 28 | 29 | #ifdef __GNUG__ 30 | #pragma interface 31 | #endif 32 | 33 | 34 | // Weapon info: sprite frames, ammunition use. 35 | typedef struct 36 | { 37 | ammotype_t ammo; 38 | int upstate; 39 | int downstate; 40 | int readystate; 41 | int atkstate; 42 | int flashstate; 43 | 44 | } weaponinfo_t; 45 | 46 | extern weaponinfo_t weaponinfo[NUMWEAPONS]; 47 | 48 | #endif 49 | //----------------------------------------------------------------------------- 50 | // 51 | // $Log:$ 52 | // 53 | //----------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /src/d_main.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // System specific interface stuff. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | 26 | #ifndef __D_MAIN__ 27 | #define __D_MAIN__ 28 | 29 | #include "d_event.h" 30 | 31 | #ifdef __GNUG__ 32 | #pragma interface 33 | #endif 34 | 35 | 36 | 37 | #define MAXWADFILES 20 38 | extern char* wadfiles[MAXWADFILES]; 39 | 40 | void D_AddFile (char *file); 41 | 42 | 43 | 44 | // 45 | // D_DoomMain() 46 | // Not a globally visible function, just included for source reference, 47 | // calls all startup code, parses command line options. 48 | // If not overrided by user input, calls N_AdvanceDemo. 49 | // 50 | void D_DoomMain (void); 51 | 52 | // Called by IO functions when input is detected. 53 | void D_PostEvent (event_t* ev); 54 | 55 | 56 | 57 | // 58 | // BASE LEVEL 59 | // 60 | void D_PageTicker (void); 61 | void D_PageDrawer (void); 62 | void D_AdvanceDemo (void); 63 | void D_StartTitle (void); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/d_net.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Networking stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __D_NET__ 25 | #define __D_NET__ 26 | 27 | #include "d_player.h" 28 | 29 | 30 | #ifdef __GNUG__ 31 | #pragma interface 32 | #endif 33 | 34 | 35 | // 36 | // Network play related stuff. 37 | // There is a data struct that stores network 38 | // communication related stuff, and another 39 | // one that defines the actual packets to 40 | // be transmitted. 41 | // 42 | 43 | #define DOOMCOM_ID 0x12345678l 44 | 45 | // Max computers/players in a game. 46 | #define MAXNETNODES 2 47 | //8 48 | 49 | 50 | // Networking and tick handling related. 51 | #define BACKUPTICS 14 52 | 53 | typedef enum 54 | { 55 | CMD_SEND = 1, 56 | CMD_GET = 2 57 | 58 | } command_t; 59 | 60 | 61 | // 62 | // Network packet data. 63 | // 64 | // always 128 bytes 65 | typedef struct 66 | { 67 | // High bit is retransmit request. 68 | uint32_t checksum; 69 | // Only valid if NCMD_RETRANSMIT. 70 | byte retransmitfrom; 71 | 72 | byte starttic; 73 | byte player; 74 | byte numtics; 75 | 76 | ticcmd_t cmds[BACKUPTICS]; 77 | char bufpad[388]; 78 | } doomdata_t; 79 | 80 | 81 | 82 | 83 | typedef struct 84 | { 85 | // Supposed to be DOOMCOM_ID? 86 | long id; 87 | 88 | // DOOM executes an int to execute commands. 89 | short intnum; 90 | // Communication between DOOM and the driver. 91 | // Is CMD_SEND or CMD_GET. 92 | short command; 93 | // Is dest for send, set by get (-1 = no packet). 94 | short remotenode; 95 | 96 | // Number of bytes in doomdata to be sent 97 | short datalength; 98 | 99 | // Info common to all nodes. 100 | // Console is allways node 0. 101 | unsigned short numnodes; 102 | // Flag: 1 = no duplication, 2-5 = dup for slow nets. 103 | short ticdup; 104 | // Flag: 1 = send a backup tic in every packet. 105 | short extratics; 106 | // Flag: 1 = deathmatch. 107 | short deathmatch; 108 | // Flag: -1 = new game, 0-5 = load savegame 109 | short savegame; 110 | short episode; // 1-3 111 | short map; // 1-9 112 | short skill; // 1-5 113 | 114 | // Info specific to this node. 115 | short consoleplayer; 116 | short numplayers; 117 | 118 | // These are related to the 3-display mode, 119 | // in which two drones looking left and right 120 | // were used to render two additional views 121 | // on two additional computers. 122 | // Probably not operational anymore. 123 | // 1 = left, 0 = center, -1 = right 124 | short angleoffset; 125 | // 1 = drone 126 | short drone; 127 | 128 | // The packet data to be sent. 129 | doomdata_t data; 130 | 131 | } doomcom_t; 132 | 133 | 134 | 135 | // Create any new ticcmds and broadcast to other players. 136 | void NetUpdate (void); 137 | 138 | // Broadcasts special packets to other players 139 | // to notify of game exit 140 | void D_QuitNetGame (void); 141 | 142 | //? how many ticks to run? 143 | void TryRunTics (void); 144 | 145 | 146 | #endif 147 | 148 | //----------------------------------------------------------------------------- 149 | // 150 | // $Log:$ 151 | // 152 | //----------------------------------------------------------------------------- 153 | 154 | -------------------------------------------------------------------------------- /src/d_player.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __D_PLAYER__ 25 | #define __D_PLAYER__ 26 | 27 | 28 | // The player data structure depends on a number 29 | // of other structs: items (internal inventory), 30 | // animation states (closely tied to the sprites 31 | // used to represent them, unfortunately). 32 | #include "d_items.h" 33 | #include "p_pspr.h" 34 | 35 | // In addition, the player is just a special 36 | // case of the generic moving object/actor. 37 | #include "p_mobj.h" 38 | 39 | // Finally, for odd reasons, the player input 40 | // is buffered within the player data struct, 41 | // as commands per game tick. 42 | #include "d_ticcmd.h" 43 | 44 | #ifdef __GNUG__ 45 | #pragma interface 46 | #endif 47 | 48 | 49 | 50 | 51 | // 52 | // Player states. 53 | // 54 | typedef enum 55 | { 56 | // Playing or camping. 57 | PST_LIVE, 58 | // Dead on the ground, view follows killer. 59 | PST_DEAD, 60 | // Ready to restart/respawn??? 61 | PST_REBORN 62 | 63 | } playerstate_t; 64 | 65 | 66 | // 67 | // Player internal flags, for cheats and debug. 68 | // 69 | typedef enum 70 | { 71 | // No clipping, walk through barriers. 72 | CF_NOCLIP = 1, 73 | // No damage, no health loss. 74 | CF_GODMODE = 2, 75 | // Not really a cheat, just a debug aid. 76 | CF_NOMOMENTUM = 4 77 | 78 | } cheat_t; 79 | 80 | 81 | // 82 | // Extended player object info: player_t 83 | // 84 | typedef struct player_s 85 | { 86 | mobj_t* mo; 87 | playerstate_t playerstate; 88 | ticcmd_t cmd; 89 | 90 | // Determine POV, 91 | // including viewpoint bobbing during movement. 92 | // Focal origin above r.z 93 | fixed_t viewz; 94 | // Base height above floor for viewz. 95 | fixed_t viewheight; 96 | // Bob/squat speed. 97 | fixed_t deltaviewheight; 98 | // bounded/scaled total momentum. 99 | fixed_t bob; 100 | 101 | // This is only used between levels, 102 | // mo->health is used during levels. 103 | int health; 104 | int armorpoints; 105 | // Armor type is 0-2. 106 | int armortype; 107 | 108 | // Power ups. invinc and invis are tic counters. 109 | int powers[NUMPOWERS]; 110 | boolean cards[NUMCARDS]; 111 | boolean backpack; 112 | 113 | // Frags, kills of other players. 114 | int frags[MAXPLAYERS]; 115 | weapontype_t readyweapon; 116 | 117 | // Is wp_nochange if not changing. 118 | weapontype_t pendingweapon; 119 | 120 | boolean weaponowned[NUMWEAPONS]; 121 | int ammo[NUMAMMO]; 122 | int maxammo[NUMAMMO]; 123 | 124 | // True if button down last tic. 125 | int attackdown; 126 | int usedown; 127 | 128 | // Bit flags, for cheats and debug. 129 | // See cheat_t, above. 130 | int cheats; 131 | 132 | // Refired shots are less accurate. 133 | int refire; 134 | 135 | // For intermission stats. 136 | int killcount; 137 | int itemcount; 138 | int secretcount; 139 | 140 | // Hint messages. 141 | char* message; 142 | 143 | // For screen flashing (red or bright). 144 | int damagecount; 145 | int bonuscount; 146 | 147 | // Who did damage (NULL for floors/ceilings). 148 | mobj_t* attacker; 149 | 150 | // So gun flashes light up areas. 151 | int extralight; 152 | 153 | // Current PLAYPAL, ??? 154 | // can be set to REDCOLORMAP for pain, etc. 155 | int fixedcolormap; 156 | 157 | // Player skin colorshift, 158 | // 0-3 for which color to draw player. 159 | int colormap; 160 | 161 | // Overlay view sprites (gun, etc). 162 | pspdef_t psprites[NUMPSPRITES]; 163 | 164 | // True if secret level has been done. 165 | boolean didsecret; 166 | 167 | } player_t; 168 | 169 | 170 | // 171 | // INTERMISSION 172 | // Structure passed e.g. to WI_Start(wb) 173 | // 174 | typedef struct 175 | { 176 | boolean in; // whether the player is in game 177 | 178 | // Player stats, kills, collected items etc. 179 | int skills; 180 | int sitems; 181 | int ssecret; 182 | int stime; 183 | int frags[4]; 184 | int score; // current score on entry, modified on return 185 | 186 | } wbplayerstruct_t; 187 | 188 | typedef struct 189 | { 190 | unsigned int epsd; // episode # (0-2) 191 | 192 | // if true, splash the secret level 193 | boolean didsecret; 194 | 195 | // previous and next levels, origin 0 196 | unsigned int last; 197 | unsigned int next; 198 | 199 | int maxkills; 200 | int maxitems; 201 | int maxsecret; 202 | int maxfrags; 203 | 204 | // the par time 205 | int partime; 206 | 207 | // index of this player in game 208 | int pnum; 209 | 210 | wbplayerstruct_t plyr[MAXPLAYERS]; 211 | 212 | } wbstartstruct_t; 213 | 214 | 215 | #endif 216 | //----------------------------------------------------------------------------- 217 | // 218 | // $Log:$ 219 | // 220 | //----------------------------------------------------------------------------- 221 | -------------------------------------------------------------------------------- /src/d_textur.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Typedefs related to to textures etc., 20 | // isolated here to make it easier separating modules. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #ifndef __D_TEXTUR__ 26 | #define __D_TEXTUR__ 27 | 28 | #include "doomtype.h" 29 | 30 | 31 | 32 | 33 | // 34 | // Flats? 35 | // 36 | // a pic is an unmasked block of pixels 37 | typedef struct 38 | { 39 | byte width; 40 | byte height; 41 | byte data; 42 | } pic_t; 43 | 44 | 45 | 46 | 47 | #endif 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /src/d_think.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // MapObj data. Map Objects or mobjs are actors, entities, 20 | // thinker, take-your-pick... anything that moves, acts, or 21 | // suffers state changes of more or less violent nature. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | 26 | #ifndef __D_THINK__ 27 | #define __D_THINK__ 28 | 29 | 30 | #ifdef __GNUG__ 31 | #pragma interface 32 | #endif 33 | 34 | 35 | 36 | // 37 | // Experimental stuff. 38 | // To compile this as "ANSI C with classes" 39 | // we will need to handle the various 40 | // action functions cleanly. 41 | // 42 | typedef void (*actionf_v)(); 43 | typedef void (*actionf_p1)( void* ); 44 | typedef void (*actionf_p2)( void*, void* ); 45 | 46 | typedef union 47 | { 48 | actionf_p1 acp1; 49 | actionf_v acv; 50 | actionf_p2 acp2; 51 | 52 | } actionf_t; 53 | 54 | 55 | 56 | 57 | 58 | // Historically, "think_t" is yet another 59 | // function pointer to a routine to handle 60 | // an actor. 61 | typedef actionf_t think_t; 62 | 63 | 64 | // Doubly linked list of actors. 65 | typedef struct thinker_s 66 | { 67 | struct thinker_s* prev; 68 | struct thinker_s* next; 69 | think_t function; 70 | 71 | } thinker_t; 72 | 73 | 74 | 75 | #endif 76 | //----------------------------------------------------------------------------- 77 | // 78 | // $Log:$ 79 | // 80 | //----------------------------------------------------------------------------- 81 | -------------------------------------------------------------------------------- /src/d_ticcmd.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // System specific interface stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __D_TICCMD__ 25 | #define __D_TICCMD__ 26 | 27 | #include "doomtype.h" 28 | 29 | #ifdef __GNUG__ 30 | #pragma interface 31 | #endif 32 | 33 | // The data sampled per tick (single player) 34 | // and transmitted to other peers (multiplayer). 35 | // Mainly movements/button commands per game tick, 36 | // plus a checksum for internal state consistency. 37 | typedef struct 38 | { 39 | char forwardmove; // *2048 for move 40 | char sidemove; // *2048 for move 41 | short angleturn; // <<16 for angle delta 42 | short consistancy; // checks for net game 43 | byte chatchar; 44 | byte buttons; 45 | } ticcmd_t; 46 | 47 | 48 | 49 | #endif 50 | //----------------------------------------------------------------------------- 51 | // 52 | // $Log:$ 53 | // 54 | //----------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /src/dll.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Dennis Francis 2 | 3 | #include "dll.h" 4 | 5 | #include 6 | #include 7 | 8 | #include "doomdef.h" 9 | 10 | static int __create_node( void *element, NODEptr *new_node ); 11 | 12 | /* 13 | list_init() 14 | ----------- 15 | Initializes a list structure 16 | lst : pointer to list structure 17 | comp_keys : pointer to a function which returns 0 when the keys of the arguments are same 18 | */ 19 | void list_init(list_t *lst, int (* comp_keys)(void *, void *)) 20 | { 21 | lst->head = NULL; 22 | lst->count = 0; 23 | lst->comp_keys = comp_keys; 24 | } 25 | 26 | 27 | /* 28 | __create_node(): 29 | ---------------- 30 | Creates a new node which encapsulates the data element given as argument 31 | 32 | element : pointer to data element to be stored in the new node 33 | new_node : pointer to node pointer variable where the allocated memory address is to 34 | be stored. 35 | 36 | */ 37 | static int __create_node(void *element, NODEptr *new_node) 38 | { 39 | *new_node = (NODEptr)malloc(sizeof(NODE)); 40 | 41 | if ( *new_node ) 42 | { 43 | (*new_node)->element = element; 44 | (*new_node)->next = NULL; 45 | (*new_node)->prev = NULL; 46 | 47 | return 0; 48 | } 49 | 50 | return -1; 51 | } 52 | 53 | 54 | /* 55 | list_insert(): 56 | ------------- 57 | Inserts and element in the list 58 | 59 | lst : pointer to list structure 60 | element : data element to be inserted in the list. 61 | 62 | Returns : 63 | -1 if memory allocation error 64 | 0 on success 65 | */ 66 | int list_insert(list_t *lst, void *element) 67 | { 68 | NODEptr new_node; 69 | 70 | if ( __create_node( element, &new_node ) == 0 ) 71 | { 72 | if ( lst->count == 0 ) 73 | { 74 | lst->head = new_node; 75 | } 76 | else 77 | { 78 | NODEptr next = lst->head; 79 | lst->head = new_node; 80 | lst->head->next = next; 81 | next->prev = lst->head; 82 | } 83 | 84 | ++( lst->count ); 85 | 86 | return 0; 87 | } 88 | 89 | return -1; 90 | } 91 | 92 | 93 | /* 94 | 95 | isPresent() 96 | ----------- 97 | Checks if there is an node which contains an element that matches a given element. 98 | 99 | lst : pointer to list structure 100 | ref_element : Data to be checked against all the list elements. 101 | ret_node (return parameter) : if there is a match, *ret_node is assigned the pointer to the matched node 102 | 103 | Returns: 104 | NULL if no match 105 | pointer to matching element 106 | */ 107 | void *isPresent(list_t *lst, void *ref_element, void **ret_node) 108 | { 109 | NODEptr node = lst->head; 110 | 111 | int flag = 0; 112 | 113 | if ( !node ) 114 | { 115 | if ( ret_node ) 116 | { 117 | *(NODEptr *)ret_node = NULL; 118 | } 119 | 120 | return NULL; 121 | } 122 | 123 | while ( !flag && node ) 124 | { 125 | if (lst->comp_keys(node->element, ref_element) == 0) 126 | { 127 | flag = 1; 128 | } 129 | else 130 | { 131 | node = node->next; 132 | } 133 | } 134 | 135 | if ( ret_node ) 136 | { 137 | if ( flag ) 138 | { 139 | *(NODEptr *)ret_node = ( void * )node; 140 | } 141 | else 142 | { 143 | *(NODEptr *)ret_node = NULL; 144 | } 145 | } 146 | 147 | return ((node)?node->element:NULL); 148 | } 149 | 150 | 151 | /* 152 | 153 | list_delete() 154 | -------------- 155 | Deletes a node from the list 156 | 157 | lst : pointer to the list structure 158 | node : pointer to the node to be deleted 159 | */ 160 | void list_delete(list_t *lst, void *node) 161 | { 162 | NODEptr save = node; 163 | NODEptr prev, next; 164 | 165 | if (!node) 166 | { 167 | return; 168 | } 169 | 170 | if (save) { 171 | 172 | prev = save->prev; 173 | next = save->next; 174 | 175 | if (!prev && !next) 176 | { 177 | lst->head = NULL; 178 | } 179 | else if(!prev && next) 180 | { 181 | lst->head = next; 182 | next->prev = NULL; 183 | } 184 | else if(prev && !next) 185 | { 186 | prev->next = NULL; 187 | } 188 | else 189 | { 190 | prev->next = next; 191 | next->prev = prev; 192 | } 193 | 194 | free( save->element ); 195 | free( save ); 196 | 197 | --(lst->count); 198 | } 199 | } 200 | 201 | 202 | /* 203 | list_cleanup() 204 | ------------- 205 | 206 | Frees all nodes in the given list 207 | */ 208 | void list_cleanup(list_t *lst) 209 | { 210 | NODEptr node, next; 211 | node = lst->head; 212 | 213 | while ( node ) 214 | { 215 | next = node->next; 216 | 217 | free(node->element); 218 | free(node); 219 | 220 | node = next; 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /src/dll.h: -------------------------------------------------------------------------------- 1 | #ifndef __DLL_H 2 | #define __DLL_H 3 | // Copyright (C) 2012 Dennis Francis 4 | 5 | typedef struct ND { 6 | 7 | struct ND *prev; 8 | struct ND *next; 9 | void *element; 10 | 11 | } NODE, *NODEptr; 12 | 13 | 14 | typedef struct { 15 | 16 | NODEptr head; 17 | int count; 18 | int (* comp_keys )(void *, void *); 19 | 20 | } list_t; 21 | 22 | 23 | void list_init( list_t *lst, int (* comp_keys)(void *, void *) ); 24 | int list_insert( list_t *lst, void *element ); 25 | void *isPresent( list_t *lst, void *ref_element, void **ret_node ); 26 | 27 | void list_delete( list_t *lst, void *node ); 28 | void list_cleanup( list_t *lst ); 29 | #endif // __DLL_H 30 | -------------------------------------------------------------------------------- /src/doomdata.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // all external data is defined here 20 | // most of the data is loaded into different structures at run time 21 | // some internal structures shared by many modules are here 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifndef __DOOMDATA__ 26 | #define __DOOMDATA__ 27 | 28 | // The most basic types we use, portability. 29 | #include "doomtype.h" 30 | 31 | // Some global defines, that configure the game. 32 | #include "doomdef.h" 33 | 34 | 35 | 36 | // 37 | // Map level types. 38 | // The following data structures define the persistent format 39 | // used in the lumps of the WAD files. 40 | // 41 | 42 | // Lump order in a map WAD: each map needs a couple of lumps 43 | // to provide a complete scene geometry description. 44 | enum 45 | { 46 | ML_LABEL, // A separator, name, ExMx or MAPxx 47 | ML_THINGS, // Monsters, items.. 48 | ML_LINEDEFS, // LineDefs, from editing 49 | ML_SIDEDEFS, // SideDefs, from editing 50 | ML_VERTEXES, // Vertices, edited and BSP splits generated 51 | ML_SEGS, // LineSegs, from LineDefs split by BSP 52 | ML_SSECTORS, // SubSectors, list of LineSegs 53 | ML_NODES, // BSP nodes 54 | ML_SECTORS, // Sectors, from editing 55 | ML_REJECT, // LUT, sector-sector visibility 56 | ML_BLOCKMAP // LUT, motion clipping, walls/grid element 57 | }; 58 | 59 | 60 | // A single Vertex. 61 | typedef struct 62 | { 63 | short x; 64 | short y; 65 | } mapvertex_t; 66 | 67 | 68 | // A SideDef, defining the visual appearance of a wall, 69 | // by setting textures and offsets. 70 | typedef struct 71 | { 72 | short textureoffset; 73 | short rowoffset; 74 | char toptexture[8]; 75 | char bottomtexture[8]; 76 | char midtexture[8]; 77 | // Front sector, towards viewer. 78 | short sector; 79 | } mapsidedef_t; 80 | 81 | 82 | 83 | // A LineDef, as used for editing, and as input 84 | // to the BSP builder. 85 | typedef struct 86 | { 87 | short v1; 88 | short v2; 89 | short flags; 90 | short special; 91 | short tag; 92 | // sidenum[1] will be -1 if one sided 93 | short sidenum[2]; 94 | } maplinedef_t; 95 | 96 | 97 | // 98 | // LineDef attributes. 99 | // 100 | 101 | // Solid, is an obstacle. 102 | #define ML_BLOCKING 1 103 | 104 | // Blocks monsters only. 105 | #define ML_BLOCKMONSTERS 2 106 | 107 | // Backside will not be present at all 108 | // if not two sided. 109 | #define ML_TWOSIDED 4 110 | 111 | // If a texture is pegged, the texture will have 112 | // the end exposed to air held constant at the 113 | // top or bottom of the texture (stairs or pulled 114 | // down things) and will move with a height change 115 | // of one of the neighbor sectors. 116 | // Unpegged textures allways have the first row of 117 | // the texture at the top pixel of the line for both 118 | // top and bottom textures (use next to windows). 119 | 120 | // upper texture unpegged 121 | #define ML_DONTPEGTOP 8 122 | 123 | // lower texture unpegged 124 | #define ML_DONTPEGBOTTOM 16 125 | 126 | // In AutoMap: don't map as two sided: IT'S A SECRET! 127 | #define ML_SECRET 32 128 | 129 | // Sound rendering: don't let sound cross two of these. 130 | #define ML_SOUNDBLOCK 64 131 | 132 | // Don't draw on the automap at all. 133 | #define ML_DONTDRAW 128 134 | 135 | // Set if already seen, thus drawn in automap. 136 | #define ML_MAPPED 256 137 | 138 | 139 | 140 | 141 | // Sector definition, from editing. 142 | typedef struct 143 | { 144 | short floorheight; 145 | short ceilingheight; 146 | char floorpic[8]; 147 | char ceilingpic[8]; 148 | short lightlevel; 149 | short special; 150 | short tag; 151 | } mapsector_t; 152 | 153 | // SubSector, as generated by BSP. 154 | typedef struct 155 | { 156 | short numsegs; 157 | // Index of first one, segs are stored sequentially. 158 | short firstseg; 159 | } mapsubsector_t; 160 | 161 | 162 | // LineSeg, generated by splitting LineDefs 163 | // using partition lines selected by BSP builder. 164 | typedef struct 165 | { 166 | short v1; 167 | short v2; 168 | short angle; 169 | short linedef; 170 | short side; 171 | short offset; 172 | } mapseg_t; 173 | 174 | 175 | 176 | // BSP node structure. 177 | 178 | // Indicate a leaf. 179 | #define NF_SUBSECTOR 0x8000 180 | 181 | typedef struct 182 | { 183 | // Partition line from (x,y) to x+dx,y+dy) 184 | short x; 185 | short y; 186 | short dx; 187 | short dy; 188 | 189 | // Bounding box for each child, 190 | // clip against view frustum. 191 | short bbox[2][4]; 192 | 193 | // If NF_SUBSECTOR its a subsector, 194 | // else it's a node of another subtree. 195 | unsigned short children[2]; 196 | 197 | } mapnode_t; 198 | 199 | 200 | 201 | 202 | // Thing definition, position, orientation and type, 203 | // plus skill/visibility flags and attributes. 204 | typedef struct 205 | { 206 | short x; 207 | short y; 208 | short angle; 209 | short type; 210 | short options; 211 | } mapthing_t; 212 | 213 | 214 | 215 | 216 | 217 | #endif // __DOOMDATA__ 218 | //----------------------------------------------------------------------------- 219 | // 220 | // $Log:$ 221 | // 222 | //----------------------------------------------------------------------------- 223 | 224 | -------------------------------------------------------------------------------- /src/doomdef.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // DoomDef - basic defines for DOOM, e.g. Version, game mode 22 | // and skill level, and display parameters. 23 | // 24 | //----------------------------------------------------------------------------- 25 | 26 | #ifdef __GNUG__ 27 | #pragma implementation "doomdef.h" 28 | #endif 29 | #include "doomdef.h" 30 | 31 | // Location for any defines turned variables. 32 | 33 | // None. 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/doomstat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Put all global tate variables here. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifdef __GNUG__ 26 | #pragma implementation "doomstat.h" 27 | #endif 28 | #include "doomstat.h" 29 | 30 | 31 | // Game Mode - identify IWAD as shareware, retail etc. 32 | GameMode_t gamemode = indetermined; 33 | GameMission_t gamemission = doom; 34 | 35 | // Language. 36 | Language_t language = english; 37 | 38 | // Set if homebrew PWAD stuff has been added. 39 | boolean modifiedgame; 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/doomtype.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Simple basic typedefs, isolated here to make it easier 20 | // separating modules. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #ifndef __DOOMTYPE__ 26 | #define __DOOMTYPE__ 27 | 28 | 29 | #ifndef __BYTEBOOL__ 30 | #define __BYTEBOOL__ 31 | // Fixed to use builtin bool type with C++. 32 | //#ifdef __cplusplus 33 | //typedef bool boolean; 34 | //#else 35 | //typedef enum {false, true} boolean; 36 | typedef long boolean; 37 | #define true 1 38 | #define false 0 39 | //#endif 40 | typedef unsigned char byte; 41 | #endif 42 | 43 | 44 | // Predefined with some OS. 45 | #ifdef LINUX 46 | #include 47 | #else 48 | #define MAXCHAR ((char)0x7f) 49 | #define MAXSHORT ((short)0x7fff) 50 | 51 | // Max pos 32-bit int. 52 | #define MAXINT ((int)0x7fffffff) 53 | #define MAXLONG ((long)0x7fffffff) 54 | #define MINCHAR ((char)0x80) 55 | #define MINSHORT ((short)0x8000) 56 | 57 | // Max negative 32-bit integer. 58 | #define MININT ((int)0x80000000) 59 | #define MINLONG ((long)0x80000000) 60 | #endif 61 | 62 | 63 | 64 | 65 | #endif 66 | //----------------------------------------------------------------------------- 67 | // 68 | // $Log:$ 69 | // 70 | //----------------------------------------------------------------------------- 71 | -------------------------------------------------------------------------------- /src/dstrings.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Globally defined strings. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifdef __GNUG__ 26 | #pragma implementation "dstrings.h" 27 | #endif 28 | #include "dstrings.h" 29 | 30 | char* endmsg[NUM_QUITMESSAGES+1]= 31 | { 32 | // DOOM1 33 | QUITMSG, 34 | "please don't leave, there's more\ndemons to toast!", 35 | "let's beat it -- this is turning\ninto a bloodbath!", 36 | "i wouldn't leave if i were you.\ndos is much worse.", 37 | "you're trying to say you like dos\nbetter than me, right?", 38 | "don't leave yet -- there's a\ndemon around that corner!", 39 | "ya know, next time you come in here\ni'm gonna toast ya.", 40 | "go ahead and leave. see if i care." 41 | 42 | // QuitDOOM II messages 43 | "you want to quit?\nthen, thou hast lost an eighth!", 44 | "don't go now, there's a \ndimensional shambler waiting\nat the dos prompt!", 45 | "get outta here and go back\nto your boring programs.", 46 | "if i were your boss, i'd \n deathmatch ya in a minute!", 47 | "look, bud. you leave now\nand you forfeit your body count!", 48 | "just leave. when you come\nback, i'll be waiting with a bat.", 49 | "you're lucky i don't smack\nyou for thinking about leaving." 50 | 51 | // FinalDOOM? 52 | "fuck you, pussy!\nget the fuck out!", 53 | "you quit and i'll jizz\nin your cystholes!", 54 | "if you leave, i'll make\nthe lord drink my jizz.", 55 | "hey, ron! can we say\n'fuck' in the game?", 56 | "i'd leave: this is just\nmore monsters and levels.\nwhat a load.", 57 | "suck it down, asshole!\nyou're a fucking wimp!", 58 | "don't quit now! we're \nstill spending your money!", 59 | 60 | // Internal debug. Different style, too. 61 | "THIS IS NO MESSAGE!\nPage intentionally left blank." 62 | }; 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/dstrings.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // 19 | // $Log:$ 20 | // 21 | // DESCRIPTION: 22 | // DOOM strings, by language. 23 | // 24 | //----------------------------------------------------------------------------- 25 | 26 | 27 | #ifndef __DSTRINGS__ 28 | #define __DSTRINGS__ 29 | 30 | 31 | // All important printed strings. 32 | // Language selection (message strings). 33 | // Use -DFRENCH etc. 34 | 35 | #ifdef FRENCH 36 | #include "d_french.h" 37 | #else 38 | #include "d_englsh.h" 39 | #endif 40 | 41 | // Misc. other strings. 42 | #define SAVEGAMENAME "doomsav" 43 | 44 | 45 | // 46 | // File locations, 47 | // relative to current position. 48 | // Path names are OS-sensitive. 49 | // 50 | #define DEVMAPS "devmaps" 51 | #define DEVDATA "devdata" 52 | 53 | 54 | // Not done in french? 55 | 56 | // QuitDOOM messages 57 | #define NUM_QUITMESSAGES 22 58 | 59 | extern char* endmsg[]; 60 | 61 | 62 | #endif 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /src/endoom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "z_zone.h" 4 | #include "i_system.h" 5 | 6 | #include "doomdef.h" 7 | #include "w_wad.h" 8 | 9 | extern void unlockVideo(surface_t* _dc); 10 | extern surface_t* lockVideo(int i); 11 | extern surface_t* _dc; 12 | 13 | extern int mus_playing; 14 | extern void *mainzone; 15 | 16 | static uint32_t __attribute__((aligned(8))) cga_pal[16]; 17 | static uint8_t ENDOOM_BYTES[2*25*80]; 18 | 19 | void DoomIsOver(void) 20 | { 21 | set_AI_interrupt(0); 22 | mus_playing = -1; 23 | audio_close(); 24 | 25 | cga_pal[ 0] = graphics_make_color(0x00,0x00,0x00,0xFF); 26 | cga_pal[ 1] = graphics_make_color(0x00,0x00,0xAA-20,0xFF); 27 | cga_pal[ 2] = graphics_make_color(0x00,0xAA-20,0x00,0xFF); 28 | cga_pal[ 3] = graphics_make_color(0x00,0xAA-20,0xAA-20,0xFF); 29 | cga_pal[ 4] = graphics_make_color(0xAA-20,0x00,0x00,0xFF); 30 | cga_pal[ 5] = graphics_make_color(0xAA-20,0x00,0xAA-20,0xFF); 31 | cga_pal[ 6] = graphics_make_color(0xAA-20,0x55-20,0x00,0xFF); 32 | cga_pal[ 7] = graphics_make_color(0xAA-20,0xAA-20,0xAA-20,0xFF); 33 | cga_pal[ 8] = graphics_make_color(0x55-20,0x55-20,0x55-20,0xFF); 34 | cga_pal[ 9] = graphics_make_color(0x55-20,0x55-20,0xFF-20,0xFF); 35 | cga_pal[ 9] = graphics_make_color(0x55-20,0x55-20,0xFF-20,0xFF); 36 | cga_pal[10] = graphics_make_color(0x55-20,0xFF-20,0x55-20,0xFF); 37 | cga_pal[11] = graphics_make_color(0x55-20,0xFF-20,0xFF-20,0xFF); 38 | cga_pal[12] = graphics_make_color(0xFF-20,0x55-20,0x55-20,0xFF); 39 | cga_pal[13] = graphics_make_color(0xFF-20,0x55-20,0xFF-20,0xFF); 40 | cga_pal[14] = graphics_make_color(0xFF-20,0xFF-20,0x55-20,0xFF); 41 | cga_pal[15] = graphics_make_color(0xFF-20,0xFF-20,0xFF-20,0xFF); 42 | 43 | int ENDOOM_NUM = W_GetNumForName("ENDOOM"); 44 | if(-1 == ENDOOM_NUM) 45 | { 46 | I_Error("DoomIsOver: Could not load ENDOOM lump.\n"); 47 | } 48 | 49 | display_close(); 50 | 51 | // last thing we do with any of the Doom engine, get the text data lump 52 | W_ReadLump(ENDOOM_NUM, ENDOOM_BYTES); 53 | // done with using Doom subsystems here 54 | // need to free the entire zone memory block that got allocated during init 55 | free((void*)((uintptr_t)mainzone & (uintptr_t)0x8FFFFFFF)); 56 | // otherwise there isn't enough memory to reallocate the frame buffers 57 | // and nothing else works 58 | display_init(RESOLUTION_640x480, DEPTH_16_BPP, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE); 59 | 60 | for (int i=0;i<2;i++) 61 | { 62 | char indexstr[2] = {0}; 63 | uint8_t attr; 64 | uint32_t color0; 65 | uint32_t color1; 66 | int y; int x; 67 | int n = 0; 68 | 69 | _dc = lockVideo(1); 70 | graphics_fill_screen(_dc, cga_pal[4]); 71 | for (y=0;y<25;y++) 72 | { 73 | for (x=0;x<80;x++) 74 | { 75 | indexstr[0] = ENDOOM_BYTES[n]; 76 | attr = ENDOOM_BYTES[n+1]; 77 | color0 = cga_pal[attr >> 4]; 78 | color1 = cga_pal[attr & 0x0F]; 79 | graphics_set_color(color1, color0); 80 | graphics_draw_text(_dc, (x*8), (y*16)+40, indexstr); 81 | n += 2; 82 | } 83 | } 84 | 85 | unlockVideo(_dc); 86 | } 87 | 88 | while (1) 89 | { 90 | // show's over, go home 91 | } 92 | } -------------------------------------------------------------------------------- /src/f_finale.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __F_FINALE__ 25 | #define __F_FINALE__ 26 | 27 | 28 | #include "doomtype.h" 29 | #include "d_event.h" 30 | // 31 | // FINALE 32 | // 33 | 34 | // Called by main loop. 35 | boolean F_Responder (event_t* ev); 36 | 37 | // Called by main loop. 38 | void F_Ticker (void); 39 | 40 | // Called by main loop. 41 | void F_Drawer (void); 42 | 43 | 44 | void F_StartFinale (void); 45 | 46 | 47 | 48 | 49 | #endif 50 | //----------------------------------------------------------------------------- 51 | // 52 | // $Log:$ 53 | // 54 | //----------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /src/f_wipe.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Mission start screen wipe/melt, special effects. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __F_WIPE_H__ 25 | #define __F_WIPE_H__ 26 | 27 | // 28 | // SCREEN WIPE PACKAGE 29 | // 30 | 31 | enum 32 | { 33 | // simple gradual pixel change for 8-bit only 34 | wipe_ColorXForm, 35 | 36 | // weird screen melt 37 | wipe_Melt, 38 | 39 | wipe_NUMWIPES 40 | }; 41 | 42 | int 43 | wipe_StartScreen 44 | ( int x, 45 | int y, 46 | int width, 47 | int height ); 48 | 49 | 50 | int 51 | wipe_EndScreen 52 | ( int x, 53 | int y, 54 | int width, 55 | int height ); 56 | 57 | 58 | int 59 | wipe_ScreenWipe 60 | ( int wipeno, 61 | int x, 62 | int y, 63 | int width, 64 | int height, 65 | int ticks ); 66 | 67 | #endif 68 | //----------------------------------------------------------------------------- 69 | // 70 | // $Log:$ 71 | // 72 | //----------------------------------------------------------------------------- 73 | -------------------------------------------------------------------------------- /src/filesystem/MIDI_Instruments: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/MIDI_Instruments -------------------------------------------------------------------------------- /src/filesystem/menulumps/gamma.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/gamma.bin -------------------------------------------------------------------------------- /src/filesystem/menulumps/resoluti.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/resoluti.bin -------------------------------------------------------------------------------- /src/filesystem/menulumps/rzhigh.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/rzhigh.bin -------------------------------------------------------------------------------- /src/filesystem/menulumps/rzlow.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/rzlow.bin -------------------------------------------------------------------------------- /src/filesystem/menulumps/videoset.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/videoset.bin -------------------------------------------------------------------------------- /src/filesystem/menulumps/vidttl.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jnmartin84/64doom/a1212bb0583c3818479b58576e259224d8516f25/src/filesystem/menulumps/vidttl.bin -------------------------------------------------------------------------------- /src/g_game.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Duh. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __G_GAME__ 25 | #define __G_GAME__ 26 | 27 | #include "doomdef.h" 28 | #include "d_event.h" 29 | 30 | 31 | #define SAVEGAMESIZE 0x2c000 32 | #define SAVESTRINGSIZE 24 33 | 34 | 35 | // 36 | // GAME 37 | // 38 | void G_DeathMatchSpawnPlayer (int playernum); 39 | 40 | void G_InitNew (skill_t skill, int episode, int map); 41 | 42 | // Can be called by the startup code or M_Responder. 43 | // A normal game starts at map 1, 44 | // but a warp test can start elsewhere 45 | void G_DeferedInitNew (skill_t skill, int episode, int map); 46 | 47 | void G_DeferedPlayDemo (char* demo); 48 | 49 | // Can be called by the startup code or M_Responder, 50 | // calls P_SetupLevel or W_EnterWorld. 51 | void G_LoadGame (char* name); 52 | 53 | void G_DoLoadGame (void); 54 | 55 | // Called by M_Responder. 56 | void G_SaveGame (int slot, char* description); 57 | 58 | // Only called by startup code. 59 | void G_RecordDemo (char* name); 60 | 61 | void G_BeginRecording (void); 62 | 63 | void G_PlayDemo (char* name); 64 | void G_TimeDemo (char* name); 65 | boolean G_CheckDemoStatus (void); 66 | 67 | void G_ExitLevel (void); 68 | void G_SecretExitLevel (void); 69 | 70 | void G_WorldDone (void); 71 | 72 | void G_Ticker (void); 73 | boolean G_Responder (event_t* ev); 74 | 75 | void G_ScreenShot (void); 76 | 77 | 78 | #endif 79 | //----------------------------------------------------------------------------- 80 | // 81 | // $Log:$ 82 | // 83 | //----------------------------------------------------------------------------- 84 | -------------------------------------------------------------------------------- /src/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef __HASH_H 2 | #define __HASH_H 3 | 4 | #include "dll.h" 5 | 6 | // Copyright (C) 2012 Dennis Francis 7 | 8 | typedef struct HASHTABLE 9 | { 10 | list_t *list_arr; 11 | int slots; 12 | unsigned int num_elements; 13 | int element_size; 14 | 15 | // params may be any generic data type containing parameters required 16 | // for calculation of hash value. 17 | unsigned long int (* hash)( void *element, void *params ); 18 | 19 | void **element_list; 20 | void *hash_params; // Must be dynamically allocated 21 | char memFreed; // Y or N ; Before calling hashtable_init() set this to 'Y' 22 | } 23 | hashtable_t; 24 | 25 | int hashtable_init( hashtable_t *ht, int slots, 26 | int (* comp_str_keys )(void *, void *), 27 | unsigned long int (* hash)( void *element, void *params ), 28 | void *hash_params ); 29 | 30 | void hashtable_destroy( hashtable_t *ht ); 31 | int hashtable_insert( hashtable_t *ht, void *element, long int slot ); 32 | 33 | /* 34 | Returns pointer to the element if found a match, else returns NULL 35 | If ht_node != NULL, 36 | *ht_node is assigned the address of the matching node 37 | if no match is found, *ht_node will have NULL 38 | */ 39 | void *is_in_hashtable( hashtable_t *ht, void *ref_element, void **ht_node ); 40 | 41 | /* 42 | Deletes the node pointed to by ht_node 43 | */ 44 | void hashtable_delete( hashtable_t *ht, unsigned int slot, void *ht_node ); 45 | 46 | // Returns an array of pointers to elements in the hashtable 47 | // User should not free the array 48 | void **get_elements_in_hashtable( hashtable_t *ht, int *num_elements, void *(* get_field )(void *), unsigned int (* get_index )(void *) ); 49 | 50 | #endif // __HASH_H 51 | -------------------------------------------------------------------------------- /src/hu_lib.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: none 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __HULIB__ 23 | #define __HULIB__ 24 | 25 | // We are referring to patches. 26 | #include "r_defs.h" 27 | 28 | 29 | // background and foreground screen numbers 30 | // different from other modules. 31 | #define BG 1 32 | #define FG 0 33 | 34 | // font stuff 35 | #define HU_CHARERASE KEY_BACKSPACE 36 | 37 | #define HU_MAXLINES 4 38 | #define HU_MAXLINELENGTH 80 39 | 40 | // 41 | // Typedefs of widgets 42 | // 43 | 44 | // Text Line widget 45 | // (parent of Scrolling Text and Input Text widgets) 46 | typedef struct 47 | { 48 | // left-justified position of scrolling text window 49 | int x; 50 | int y; 51 | 52 | patch_t** f; // font 53 | int sc; // start character 54 | char l[HU_MAXLINELENGTH+1]; // line of text 55 | int len; // current line length 56 | 57 | // whether this line needs to be udpated 58 | int needsupdate; 59 | 60 | } hu_textline_t; 61 | 62 | 63 | 64 | // Scrolling Text window widget 65 | // (child of Text Line widget) 66 | typedef struct 67 | { 68 | hu_textline_t l[HU_MAXLINES]; // text lines to draw 69 | int h; // height in lines 70 | int cl; // current line number 71 | 72 | // pointer to boolean stating whether to update window 73 | boolean* on; 74 | boolean laston; // last value of *->on. 75 | 76 | } hu_stext_t; 77 | 78 | 79 | 80 | // Input Text Line widget 81 | // (child of Text Line widget) 82 | typedef struct 83 | { 84 | hu_textline_t l; // text line to input on 85 | 86 | // left margin past which I am not to delete characters 87 | int lm; 88 | 89 | // pointer to boolean stating whether to update window 90 | boolean* on; 91 | boolean laston; // last value of *->on; 92 | 93 | } hu_itext_t; 94 | 95 | 96 | // 97 | // Widget creation, access, and update routines 98 | // 99 | 100 | // initializes heads-up widget library 101 | void HUlib_init(void); 102 | 103 | // 104 | // textline code 105 | // 106 | 107 | // clear a line of text 108 | void HUlib_clearTextLine(hu_textline_t *t); 109 | 110 | void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); 111 | 112 | // returns success 113 | boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); 114 | 115 | // returns success 116 | boolean HUlib_delCharFromTextLine(hu_textline_t *t); 117 | 118 | // draws tline 119 | void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); 120 | 121 | // erases text line 122 | void HUlib_eraseTextLine(hu_textline_t *l); 123 | 124 | 125 | // 126 | // Scrolling Text window widget routines 127 | // 128 | 129 | // ? 130 | void 131 | HUlib_initSText 132 | ( hu_stext_t* s, 133 | int x, 134 | int y, 135 | int h, 136 | patch_t** font, 137 | int startchar, 138 | boolean* on ); 139 | 140 | // add a new line 141 | void HUlib_addLineToSText(hu_stext_t* s); 142 | 143 | // ? 144 | void 145 | HUlib_addMessageToSText 146 | ( hu_stext_t* s, 147 | char* prefix, 148 | char* msg ); 149 | 150 | // draws stext 151 | void HUlib_drawSText(hu_stext_t* s); 152 | 153 | // erases all stext lines 154 | void HUlib_eraseSText(hu_stext_t* s); 155 | 156 | // Input Text Line widget routines 157 | void 158 | HUlib_initIText 159 | ( hu_itext_t* it, 160 | int x, 161 | int y, 162 | patch_t** font, 163 | int startchar, 164 | boolean* on ); 165 | 166 | // enforces left margin 167 | void HUlib_delCharFromIText(hu_itext_t* it); 168 | 169 | // enforces left margin 170 | void HUlib_eraseLineFromIText(hu_itext_t* it); 171 | 172 | // resets line and left margin 173 | void HUlib_resetIText(hu_itext_t* it); 174 | 175 | // left of left-margin 176 | void 177 | HUlib_addPrefixToIText 178 | ( hu_itext_t* it, 179 | char* str ); 180 | 181 | // whether eaten 182 | boolean 183 | HUlib_keyInIText 184 | ( hu_itext_t* it, 185 | unsigned char ch ); 186 | 187 | void HUlib_drawIText(hu_itext_t* it); 188 | 189 | // erases all itext lines 190 | void HUlib_eraseIText(hu_itext_t* it); 191 | 192 | #endif 193 | //----------------------------------------------------------------------------- 194 | // 195 | // $Log:$ 196 | // 197 | //----------------------------------------------------------------------------- 198 | -------------------------------------------------------------------------------- /src/hu_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: Head up display 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __HU_STUFF_H__ 23 | #define __HU_STUFF_H__ 24 | 25 | #include "d_event.h" 26 | 27 | 28 | // 29 | // Globally visible constants. 30 | // 31 | #define HU_FONTSTART '!' // the first font characters 32 | #define HU_FONTEND '_' // the last font characters 33 | 34 | // Calculate # of glyphs in font. 35 | #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) 36 | 37 | #define HU_BROADCAST 5 38 | 39 | #define HU_MSGREFRESH KEY_ENTER 40 | #define HU_MSGX 0 41 | #define HU_MSGY 0 42 | #define HU_MSGWIDTH 64 // in characters 43 | #define HU_MSGHEIGHT 1 // in lines 44 | 45 | #define HU_MSGTIMEOUT (4*TICRATE) 46 | 47 | // 48 | // HEADS UP TEXT 49 | // 50 | 51 | void HU_Init(void); 52 | void HU_Start(void); 53 | 54 | boolean HU_Responder(event_t* ev); 55 | 56 | void HU_Ticker(void); 57 | void HU_Drawer(void); 58 | char HU_dequeueChatChar(void); 59 | void HU_Erase(void); 60 | 61 | 62 | #endif 63 | //----------------------------------------------------------------------------- 64 | // 65 | // $Log:$ 66 | // 67 | //----------------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /src/i_input.h: -------------------------------------------------------------------------------- 1 | #ifndef __I_INPUT_H 2 | #define __I_INPUT_H 3 | 4 | #endif // __I_INPUT_H 5 | -------------------------------------------------------------------------------- /src/i_main.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Main program, simply calls D_DoomMain high level loop. 22 | // 23 | //----------------------------------------------------------------------------- 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "doomdef.h" 32 | #include "m_argv.h" 33 | #include "d_main.h" 34 | #include "g_game.h" 35 | 36 | extern void DoomIsOver(); 37 | 38 | void check_and_init_mempak(void) 39 | { 40 | struct controller_data output; 41 | get_accessories_present(&output); 42 | 43 | switch (identify_accessory(0)) 44 | { 45 | case ACCESSORY_NONE: 46 | { 47 | printf("No accessory inserted!\n"); 48 | break; 49 | } 50 | case ACCESSORY_MEMPAK: 51 | { 52 | int err; 53 | // I left the below in the code #ifdef'd out for when I needed an easy way to nuke a controller pak 54 | #if 0 55 | if (format_mempak(0)) 56 | { 57 | printf("Error formatting mempak!\n"); 58 | } 59 | else 60 | { 61 | printf("Memory card formatted!\n"); 62 | } 63 | #endif 64 | if ((err = validate_mempak(0))) 65 | { 66 | if (err == -3) 67 | { 68 | printf("Mempak is not formatted! Formatting it automatically.\n"); 69 | 70 | if (format_mempak(0)) 71 | { 72 | printf("Error formatting mempak!\n"); 73 | } 74 | else 75 | { 76 | printf("Memory card formatted!\n"); 77 | } 78 | } 79 | else 80 | { 81 | printf("Mempak bad or removed during read!\n"); 82 | } 83 | } 84 | else 85 | { 86 | // this will print the details of each entry on the controller pak 87 | #if 0 88 | for(int j = 0; j < 16; j++) 89 | { 90 | entry_structure_t entry; 91 | 92 | get_mempak_entry(0, j, &entry); 93 | 94 | if(entry.valid) 95 | { 96 | printf("%s - %d blocks\n", entry.name, entry.blocks); 97 | } 98 | else 99 | { 100 | printf("(EMPTY)\n"); 101 | } 102 | } 103 | #endif 104 | printf("\nFree space: %d blocks\n", get_mempak_free_space(0)); 105 | } 106 | 107 | break; 108 | } 109 | case ACCESSORY_RUMBLEPAK: 110 | { 111 | printf("Cannot read data off of rumblepak!\n"); 112 | break; 113 | } 114 | } 115 | } 116 | 117 | 118 | extern int center_x, center_y; 119 | 120 | int main(int argc, char **argv) 121 | { 122 | console_init(); 123 | console_set_render_mode(RENDER_AUTOMATIC); 124 | if (dfs_init( DFS_DEFAULT_LOCATION ) != DFS_ESUCCESS) 125 | { 126 | printf("Could not initialize filesystem!\n"); 127 | while(1); 128 | } 129 | controller_init(); 130 | 131 | // center joystick... 132 | controller_scan(); 133 | struct controller_data keys_pressed = get_keys_down(); 134 | struct SI_condat pressed = keys_pressed.c[0]; 135 | center_x = pressed.x; 136 | center_y = pressed.y; 137 | 138 | printf("64Doom by jnmartin84\n"); 139 | printf("github.com/jnmartin84/64doom/\n"); 140 | printf("built %s %s\n", __DATE__, __TIME__); 141 | 142 | int available_memory_size = get_memory_size(); 143 | //printf("Available memory: %d bytes\n", *(int *)(0x80000318)); 144 | 145 | if(available_memory_size != 0x800000) 146 | { 147 | printf("\n***********************************"); 148 | printf("Expansion Pak not found.\n"); 149 | printf("It is required to run 64Doom.\n"); 150 | printf("Please turn off the Nintendo 64,\ninstall Expansion Pak,\nand try again.\n"); 151 | printf("***********************************\n"); 152 | while(1) {} 153 | } 154 | 155 | //printf("Expansion Pak found.\n"); 156 | 157 | printf("Checking for Mempak:\n"); 158 | check_and_init_mempak(); 159 | 160 | D_DoomMain(); 161 | DoomIsOver(); 162 | 163 | return 0; 164 | } 165 | -------------------------------------------------------------------------------- /src/i_net.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // System specific network interface stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __I_NET__ 25 | #define __I_NET__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | 32 | 33 | 34 | // Called by D_DoomMain. 35 | 36 | 37 | void I_InitNetwork (void); 38 | void I_NetCmd (void); 39 | 40 | 41 | #endif 42 | //----------------------------------------------------------------------------- 43 | // 44 | // $Log:$ 45 | // 46 | //----------------------------------------------------------------------------- 47 | -------------------------------------------------------------------------------- /src/i_sound.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // 19 | // DESCRIPTION: 20 | // System interface, sound. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #ifndef __I_SOUND__ 25 | #define __I_SOUND__ 26 | 27 | #include "doomdef.h" 28 | 29 | // UNIX hack, to be removed. 30 | #ifdef SNDSERV 31 | #include 32 | extern FILE* sndserver; 33 | extern char* sndserver_filename; 34 | #endif 35 | 36 | #include "doomstat.h" 37 | #include "sounds.h" 38 | 39 | 40 | 41 | // Init at program start... 42 | void I_InitSound(); 43 | 44 | // ... update sound buffer and audio device at runtime... 45 | void I_UpdateSound(void); 46 | void I_SubmitSound(void); 47 | 48 | // ... shut down and relase at program termination. 49 | void I_ShutdownSound(void); 50 | 51 | 52 | // 53 | // SFX I/O 54 | // 55 | 56 | // Initialize channels? 57 | void I_SetChannels(); 58 | 59 | // Get raw data lump index for sound descriptor. 60 | int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ); 61 | 62 | 63 | // Starts a sound in a particular sound channel. 64 | /*int 65 | I_StartSound 66 | ( int id, 67 | int vol, 68 | int sep, 69 | int pitch, 70 | int priority );*/ 71 | 72 | int I_StartSound ( 73 | int id, 74 | int cnum, 75 | int vol, 76 | int sep, 77 | int pitch, 78 | int priority ); 79 | 80 | // Stops a sound channel. 81 | void I_StopSound(int handle); 82 | 83 | // Called by S_*() functions 84 | // to see if a channel is still playing. 85 | // Returns 0 if no longer playing, 1 if playing. 86 | int I_SoundIsPlaying(int handle); 87 | 88 | // Updates the volume, separation, 89 | // and pitch of a sound channel. 90 | void 91 | I_UpdateSoundParams 92 | ( int handle, 93 | int vol, 94 | int sep, 95 | int pitch ); 96 | 97 | 98 | // 99 | // MUSIC I/O 100 | // 101 | void I_InitMusic(void); 102 | void I_ShutdownMusic(void); 103 | // Volume. 104 | void I_SetMusicVolume(int volume); 105 | // PAUSE game handling. 106 | void I_PauseSong(int handle); 107 | void I_ResumeSong(int handle); 108 | // Registers a song handle to song data. 109 | int I_RegisterSong(void *data); 110 | // Called by anything that wishes to start music. 111 | // plays a song, and when the song is done, 112 | // starts playing it again in an endless loop. 113 | // Horrible thing to do, considering. 114 | void 115 | I_PlaySong 116 | ( int handle, 117 | int looping ); 118 | // Stops a song over 3 seconds. 119 | void I_StopSong(int handle); 120 | // See above (register), then think backwards 121 | void I_UnRegisterSong(int handle); 122 | 123 | 124 | 125 | #endif 126 | //----------------------------------------------------------------------------- 127 | // 128 | // $Log:$ 129 | // 130 | //----------------------------------------------------------------------------- 131 | -------------------------------------------------------------------------------- /src/i_system.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "doomdef.h" 33 | #include "m_misc.h" 34 | #include "i_video.h" 35 | #include "i_sound.h" 36 | 37 | #include "d_net.h" 38 | #include "g_game.h" 39 | 40 | #ifdef __GNUG__ 41 | #pragma implementation "i_system.h" 42 | #endif 43 | #include "i_system.h" 44 | 45 | extern surface_t* _dc; 46 | extern void unlockVideo(surface_t* _dc); 47 | extern surface_t* lockVideo(int i); 48 | 49 | void DebugOutput_String_For_IError(const char *str, int lineNumber, int good); 50 | 51 | volatile uint32_t timekeeping; 52 | 53 | // freed up enough space through gc-sections to give 5.5 MB to zone 54 | // this also allowed me to get screen wipe working again 55 | #define MB_FOR_ZONE 5 56 | #define BYTES_PER_MB 1048576 57 | const size_t zone_size = MB_FOR_ZONE * BYTES_PER_MB; 58 | int based_zone = 0; 59 | 60 | void I_Tactile(int on, int off, int total) 61 | { 62 | // UNUSED. 63 | on = off = total = 0; 64 | } 65 | 66 | 67 | ticcmd_t emptycmd; 68 | inline ticcmd_t* I_BaseTiccmd(void) 69 | { 70 | return &emptycmd; 71 | } 72 | 73 | 74 | int I_GetHeapSize(void) 75 | { 76 | if (0 == based_zone) 77 | { 78 | return 0; 79 | } 80 | 81 | return zone_size; 82 | } 83 | 84 | 85 | byte* I_ZoneBase(int* size) 86 | { 87 | based_zone = 1; 88 | 89 | *size = zone_size; 90 | 91 | byte *ptr = (byte *)malloc(*size); 92 | 93 | return ptr; 94 | } 95 | 96 | 97 | // 98 | // I_GetTime 99 | // returns time in 1/70th second tics 100 | // 101 | unsigned long I_GetTime(void) 102 | { 103 | return timekeeping; 104 | } 105 | 106 | 107 | void tickercb(int ovfl) { 108 | timekeeping++; 109 | } 110 | 111 | 112 | // 113 | // I_Init 114 | // 115 | void I_Init(void) 116 | { 117 | I_InitSound(); 118 | I_InitMusic(); 119 | 120 | timer_init(); 121 | timekeeping = 0; 122 | 123 | // 70 times per second 124 | // 93750000 / 70 125 | new_timer(1339286, TF_CONTINUOUS, tickercb); 126 | 127 | I_InitGraphics(); 128 | } 129 | 130 | int return_from_D_DoomMain = 0; 131 | 132 | // 133 | // I_Quit 134 | // 135 | void I_Quit(void) 136 | { 137 | timer_close(); 138 | D_QuitNetGame(); 139 | I_ShutdownSound(); 140 | I_ShutdownMusic(); 141 | M_SaveDefaults(); 142 | I_ShutdownGraphics(); 143 | return_from_D_DoomMain = 1; 144 | } 145 | 146 | void I_WaitVBL(int count) 147 | { 148 | volatile uint32_t start = I_GetTime(); 149 | while(((volatile uint32_t)I_GetTime() - start) < ((uint32_t)count)) {} 150 | } 151 | 152 | 153 | void I_BeginRead(void) 154 | { 155 | } 156 | 157 | 158 | void I_EndRead(void) 159 | { 160 | } 161 | 162 | 163 | byte* I_AllocLow(int length) 164 | { 165 | byte* mem; 166 | 167 | mem = (byte *)malloc(length); 168 | 169 | return mem; 170 | } 171 | 172 | 173 | // 174 | // I_Error 175 | // 176 | extern boolean demorecording; 177 | 178 | 179 | void DebugOutput_String_For_IError(const char *str, int lineNumber, int good) 180 | { 181 | #define ERROR_LINE_LEN 36 182 | int error_string_length = strlen(str); 183 | int error_string_line_count = (error_string_length / ERROR_LINE_LEN) + 1; 184 | 185 | graphics_set_color(graphics_make_color(0xFF,0xFF,0xFF,0x00), graphics_make_color(0x00,0x00,0x00,0x00)); 186 | 187 | for (int i=0;i<=error_string_line_count;i++) 188 | { 189 | if (!good) 190 | { 191 | graphics_draw_box(_dc, 16, 12+((lineNumber+i)*8), display_get_width()-32, 16, graphics_make_color(0xFF,0x00,0x00,0x00)); 192 | } 193 | else 194 | { 195 | graphics_draw_box(_dc, 16, 12+((lineNumber+i)*8), display_get_width()-32, 16, graphics_make_color(0x00,0x00,0xFF,0x00)); 196 | } 197 | } 198 | 199 | for (int i=0;i<=error_string_line_count;i++) 200 | { 201 | char copied_line[ERROR_LINE_LEN + 1] = {'\0'}; 202 | if (0 == i) 203 | { 204 | strncpy(copied_line, "I_Error:", ERROR_LINE_LEN); 205 | } 206 | else 207 | { 208 | strncpy(copied_line, str + ((i-1)*ERROR_LINE_LEN), ERROR_LINE_LEN); 209 | } 210 | graphics_draw_text(_dc, 16, 16+((lineNumber+i)*8), copied_line); 211 | } 212 | } 213 | 214 | 215 | void I_Error(const char *fmt, ...) 216 | { 217 | char errstr[256]; 218 | va_list args; 219 | va_start(args, fmt); 220 | vsnprintf(errstr, sizeof(errstr), fmt, args); 221 | // in case we haven't reached I_InitGraphics yet 222 | printf("I_Error: %s\n", errstr); 223 | #if 1 224 | unlockVideo(_dc); 225 | for(int i=0;i<2;i++) 226 | { 227 | _dc = lockVideo(1); 228 | DebugOutput_String_For_IError(errstr, 0, 0); 229 | unlockVideo(_dc); 230 | } 231 | #endif 232 | D_QuitNetGame(); 233 | I_ShutdownMusic(); 234 | I_ShutdownSound(); 235 | I_ShutdownGraphics(); 236 | 237 | while (1) 238 | {} 239 | } -------------------------------------------------------------------------------- /src/i_system.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // System specific interface stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __I_SYSTEM__ 25 | #define __I_SYSTEM__ 26 | 27 | #include "d_ticcmd.h" 28 | #include "d_event.h" 29 | 30 | #ifdef __GNUG__ 31 | #pragma interface 32 | #endif 33 | 34 | 35 | // Called by DoomMain. 36 | void I_Init(void); 37 | 38 | 39 | // Called by startup code 40 | // to get the ammount of memory to malloc 41 | // for the zone management. 42 | byte* I_ZoneBase(int *size); 43 | 44 | 45 | // Called by D_DoomLoop, 46 | // returns current time in tics. 47 | unsigned long I_GetTime(void); 48 | 49 | 50 | // 51 | // Called by D_DoomLoop, 52 | // called before processing any tics in a frame 53 | // (just after displaying a frame). 54 | // Time consuming syncronous operations 55 | // are performed here (joystick reading). 56 | // Can call D_PostEvent. 57 | // 58 | void I_StartFrame(void); 59 | 60 | 61 | // 62 | // Called by D_DoomLoop, 63 | // called before processing each tic in a frame. 64 | // Quick syncronous operations are performed here. 65 | // Can call D_PostEvent. 66 | void I_StartTic(void); 67 | 68 | 69 | // Asynchronous interrupt functions should maintain private queues 70 | // that are read by the synchronous functions 71 | // to be converted into events. 72 | 73 | 74 | // Either returns a null ticcmd, 75 | // or calls a loadable driver to build it. 76 | // This ticcmd will then be modified by the gameloop 77 | // for normal input. 78 | ticcmd_t* I_BaseTiccmd(void); 79 | 80 | 81 | // Called by M_Responder when quit is selected. 82 | // Clean exit, displays sell blurb. 83 | void I_Quit(void); 84 | 85 | 86 | // Allocates from low memory under dos, 87 | // just mallocs under unix 88 | byte* I_AllocLow(int length); 89 | 90 | 91 | void I_Tactile(int on, int off, int total); 92 | 93 | 94 | void I_Error(const char *fmt, ...); 95 | 96 | #endif 97 | //----------------------------------------------------------------------------- 98 | // 99 | // $Log:$ 100 | // 101 | //----------------------------------------------------------------------------- 102 | -------------------------------------------------------------------------------- /src/i_video.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- h 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // $Log:$ 18 | // 19 | // DESCRIPTION: 20 | // DOOM graphics stuff for Nintendo 64, libdragon 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "doomstat.h" 29 | #include "i_system.h" 30 | #include "v_video.h" 31 | #include "m_argv.h" 32 | #include "d_main.h" 33 | 34 | #include "doomdef.h" 35 | 36 | // function prototypes 37 | 38 | void I_SetPalette(byte* palette); 39 | 40 | void I_FinishUpdate(void); 41 | 42 | 43 | // globals 44 | 45 | // I don't want to rename this across the code base, it used to be display_context_t 46 | // I started this port with libdragon in 2014 47 | // it did not expose a pointer to the buffer display_context_t was associated with 48 | // and I had to use __safe_buffer[_dc-1] to access it directly 49 | // I really like libdragon 9 years later though, much nicer 50 | surface_t *_dc; 51 | 52 | surface_t *lockVideo(int wait) 53 | { 54 | if (wait) 55 | { 56 | return display_get(); 57 | } 58 | else 59 | { 60 | return display_try_get(); 61 | } 62 | } 63 | 64 | void unlockVideo(surface_t *dc) 65 | { 66 | if (dc) 67 | { 68 | display_show(dc); 69 | } 70 | } 71 | 72 | extern void* bufptr; 73 | 74 | void I_StartFrame(void) 75 | { 76 | _dc = lockVideo(1); 77 | // get the buffer address pointer from the surface once per frame instead of per every column/span 78 | bufptr = (void*)_dc->buffer; 79 | } 80 | 81 | void I_ShutdownGraphics(void) 82 | { 83 | } 84 | 85 | 86 | void I_UpdateNoBlit(void) 87 | { 88 | } 89 | 90 | void I_FinishUpdate(void) 91 | { 92 | unlockVideo(_dc); 93 | } 94 | extern void* bufptr; 95 | // 96 | // I_ReadScreen 97 | // 98 | void I_ReadScreen(uint16_t* scr) 99 | { 100 | memcpy(scr,bufptr,320*200*2); 101 | } 102 | 103 | // 104 | // Palette stuff. 105 | // 106 | 107 | 108 | void I_ForcePaletteUpdate(void) 109 | { 110 | } 111 | 112 | 113 | // 114 | // I_SetPalette 115 | // 116 | // this is intentionally uint32_t 117 | // graphics_make_color will pack two 16-bit colors into a 32-bit word 118 | // and we use that full word when rendering columns and spans in low-detail mode 119 | // the color lookup is a single index into palarray 120 | // no shifting and masking necessary to create a doubled pixel 121 | // and it gets written to the 16-bit framebuffer as two pixels with a single 32-bit write 122 | uint32_t* palarray; 123 | static uint32_t __attribute__((aligned(8))) default_palarray[256]; 124 | static uint32_t __attribute__((aligned(8))) current_palarray[256]; 125 | static uint32_t *old_palarray = NULL; 126 | 127 | void I_SavePalette(void) 128 | { 129 | old_palarray = current_palarray; 130 | palarray = default_palarray; 131 | } 132 | 133 | void I_RestorePalette(void) 134 | { 135 | palarray = current_palarray; 136 | old_palarray = default_palarray; 137 | } 138 | 139 | void I_SetPalette(byte* palette) 140 | { 141 | const byte *gammaptr = gammatable[usegamma]; 142 | 143 | unsigned int i; 144 | 145 | for (i = 0; i < 256; i++) 146 | { 147 | int r = *palette++; 148 | int g = *palette++; 149 | int b = *palette++; 150 | 151 | r = gammaptr[r]; 152 | g = gammaptr[g]; 153 | b = gammaptr[b]; 154 | 155 | uint16_t unpackedcol = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1); 156 | uint32_t packedcol = (unpackedcol << 16) | unpackedcol; 157 | current_palarray[i] = packedcol; 158 | } 159 | } 160 | 161 | #include "z_zone.h" 162 | #include "w_wad.h" 163 | void I_SetDefaultPalette(void) 164 | { 165 | I_SetPalette(W_CacheLumpName ("PLAYPAL",PU_CACHE)); 166 | memcpy(default_palarray, current_palarray, sizeof(current_palarray)); 167 | } 168 | 169 | void I_InitGraphics(void) 170 | { 171 | display_init( (resolution_t) 172 | { 173 | .width = SCREENWIDTH, 174 | .height = SCREENHEIGHT, 175 | .interlaced = false, 176 | }, DEPTH_16_BPP, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE ); 177 | 178 | I_SetDefaultPalette(); 179 | 180 | palarray = current_palarray; 181 | } -------------------------------------------------------------------------------- /src/i_video.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // System specific interface stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __I_VIDEO__ 25 | #define __I_VIDEO__ 26 | 27 | 28 | #include "doomtype.h" 29 | 30 | #ifdef __GNUG__ 31 | #pragma interface 32 | #endif 33 | 34 | #include 35 | 36 | // Called by D_DoomMain, 37 | // determines the hardware configuration 38 | // and sets up the video mode 39 | void I_InitGraphics (void); 40 | 41 | 42 | void I_ShutdownGraphics(void); 43 | 44 | // Takes full 8 bit values. 45 | void I_SetPalette (byte* palette); 46 | 47 | void I_UpdateNoBlit (void); 48 | void I_FinishUpdate (void); 49 | 50 | // Wait for vertical retrace or pause a bit. 51 | void I_WaitVBL(int count); 52 | 53 | void I_ReadScreen (uint16_t* scr); 54 | 55 | void I_BeginRead (void); 56 | void I_EndRead (void); 57 | 58 | 59 | 60 | #endif 61 | //----------------------------------------------------------------------------- 62 | // 63 | // $Log:$ 64 | // 65 | //----------------------------------------------------------------------------- 66 | -------------------------------------------------------------------------------- /src/lzfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Andrew Collette 3 | * http://lzfx.googlecode.com 4 | * 5 | * Implements an LZF-compatible compressor/decompressor based on the liblzf 6 | * codebase written by Marc Lehmann. This code is released under the BSD 7 | * license. License and original copyright statement follow. 8 | * 9 | * 10 | * Copyright (c) 2000-2008 Marc Alexander Lehmann 11 | * 12 | * Redistribution and use in source and binary forms, with or without modifica- 13 | * tion, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 24 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 25 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 26 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- 30 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef LZFX_H 35 | #define LZFX_H 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Documented behavior, including function signatures and error codes, 42 | is guaranteed to remain unchanged for releases with the same major 43 | version number. Releases of the same major version are also able 44 | to read each other's output, although the output itself is not 45 | guaranteed to be byte-for-byte identical. 46 | */ 47 | #define LZFX_VERSION_MAJOR 0 48 | #define LZFX_VERSION_MINOR 1 49 | #define LZFX_VERSION_STRING "0.1" 50 | 51 | /* Hashtable size (2**LZFX_HLOG entries) */ 52 | #ifndef LZFX_HLOG 53 | # define LZFX_HLOG 16 54 | #endif 55 | 56 | /* Predefined errors. */ 57 | #define LZFX_ESIZE -1 /* Output buffer too small */ 58 | #define LZFX_ECORRUPT -2 /* Invalid data for decompression */ 59 | #define LZFX_EARGS -3 /* Arguments invalid (NULL) */ 60 | 61 | #define LZFX_ESIZE2 -4 /* Output buffer too small */ 62 | #define LZFX_ESIZE3 -5 /* Output buffer too small */ 63 | #define LZFX_ESIZE4 -6 /* Output buffer too small */ 64 | 65 | /* Buffer-to buffer compression. 66 | 67 | Supply pre-allocated input and output buffers via ibuf and obuf, and 68 | their size in bytes via ilen and olen. Buffers may not overlap. 69 | 70 | On success, the function returns a non-negative value and the argument 71 | olen contains the compressed size in bytes. On failure, a negative 72 | value is returned and olen is not modified. 73 | */ 74 | int lzfx_compress(const void* ibuf, unsigned int ilen, 75 | void* obuf, unsigned int *olen); 76 | 77 | /* Buffer-to-buffer decompression. 78 | 79 | Supply pre-allocated input and output buffers via ibuf and obuf, and 80 | their size in bytes via ilen and olen. Buffers may not overlap. 81 | 82 | On success, the function returns a non-negative value and the argument 83 | olen contains the uncompressed size in bytes. On failure, a negative 84 | value is returned. 85 | 86 | If the failure code is LZFX_ESIZE, olen contains the minimum buffer size 87 | required to hold the decompressed data. Otherwise, olen is not modified. 88 | 89 | Supplying a zero *olen is a valid and supported strategy to determine the 90 | required buffer size. This does not require decompression of the entire 91 | stream and is consequently very fast. Argument obuf may be NULL in 92 | this case only. 93 | */ 94 | int lzfx_decompress(const void* ibuf, unsigned int ilen, 95 | void* obuf, unsigned int *olen); 96 | 97 | 98 | #ifdef __cplusplus 99 | } /* extern "C" */ 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/m_argv.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | #include 25 | 26 | int myargc; 27 | char** myargv; 28 | 29 | // 30 | // M_CheckParm 31 | // Checks for the given parameter 32 | // in the program's command line arguments. 33 | // Returns the argument number (1 to argc-1) 34 | // or 0 if not present 35 | int M_CheckParm (char *check) 36 | { 37 | int i; 38 | 39 | for (i = 1;ibox[BOXRIGHT]) 51 | box[BOXRIGHT] = x; 52 | if (ybox[BOXTOP]) 55 | box[BOXTOP] = y; 56 | } 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/m_bbox.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Nil. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_BBOX__ 25 | #define __M_BBOX__ 26 | 27 | #include 28 | //#include 29 | 30 | /*#ifndef MAXINT 31 | #define MAXINT INT_MAX 32 | #endif // MAXINT 33 | 34 | #ifndef MININT 35 | #define MININT INT_MIN 36 | #endif // MININT 37 | */ 38 | #include "m_fixed.h" 39 | #include "doomtype.h" 40 | 41 | 42 | // Bounding box coordinate storage. 43 | enum 44 | { 45 | BOXTOP, 46 | BOXBOTTOM, 47 | BOXLEFT, 48 | BOXRIGHT 49 | }; // bbox coordinates 50 | 51 | // Bounding box functions. 52 | void M_ClearBox (fixed_t* box); 53 | 54 | void 55 | M_AddToBox 56 | ( fixed_t* box, 57 | fixed_t x, 58 | fixed_t y ); 59 | 60 | 61 | #endif 62 | //----------------------------------------------------------------------------- 63 | // 64 | // $Log:$ 65 | // 66 | //----------------------------------------------------------------------------- 67 | -------------------------------------------------------------------------------- /src/m_cheat.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Cheat sequence checking. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #include "m_cheat.h" 26 | 27 | // 28 | // CHEAT SEQUENCE PACKAGE 29 | // 30 | 31 | static int firsttime = 1; 32 | static unsigned char cheat_xlate_table[256]; 33 | 34 | 35 | // 36 | // Called in st_stuff module, which handles the input. 37 | // Returns a 1 if the cheat was successful, 0 if failed. 38 | // 39 | int 40 | cht_CheckCheat 41 | ( cheatseq_t* cht, 42 | char key ) 43 | { 44 | int i; 45 | int rc = 0; 46 | 47 | if (firsttime) 48 | { 49 | firsttime = 0; 50 | for (i=0;i<256;i++) 51 | cheat_xlate_table[i] = SCRAMBLE(i); 52 | } 53 | 54 | if (!cht->p) 55 | cht->p = cht->sequence; // initialize if first time 56 | 57 | if (*cht->p == 0) 58 | *(cht->p++) = key; 59 | else if (cheat_xlate_table[(unsigned char)key] == *cht->p) 60 | cht->p++; 61 | else 62 | cht->p = cht->sequence; 63 | 64 | if (*cht->p == 1) 65 | cht->p++; 66 | else if (*cht->p == 0xff) // end of sequence character 67 | { 68 | cht->p = cht->sequence; 69 | rc = 1; 70 | } 71 | 72 | return rc; 73 | } 74 | 75 | void 76 | cht_GetParam 77 | ( cheatseq_t* cht, 78 | char* buffer ) 79 | { 80 | 81 | unsigned char *p, c; 82 | 83 | p = cht->sequence; 84 | while (*(p++) != 1); 85 | 86 | do 87 | { 88 | c = *p; 89 | *(buffer++) = c; 90 | *(p++) = 0; 91 | } 92 | while (c && *p!=0xff ); 93 | 94 | if (*p==0xff) 95 | *buffer = 0; 96 | } 97 | 98 | 99 | -------------------------------------------------------------------------------- /src/m_cheat.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Cheat code checking. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_CHEAT__ 25 | #define __M_CHEAT__ 26 | 27 | // 28 | // CHEAT SEQUENCE PACKAGE 29 | // 30 | 31 | #define SCRAMBLE(a) \ 32 | ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ 33 | + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) 34 | 35 | typedef struct 36 | { 37 | unsigned char* sequence; 38 | unsigned char* p; 39 | 40 | } cheatseq_t; 41 | 42 | int 43 | cht_CheckCheat 44 | ( cheatseq_t* cht, 45 | char key ); 46 | 47 | 48 | void 49 | cht_GetParam 50 | ( cheatseq_t* cht, 51 | char* buffer ); 52 | 53 | 54 | #endif 55 | //----------------------------------------------------------------------------- 56 | // 57 | // $Log:$ 58 | // 59 | //----------------------------------------------------------------------------- 60 | -------------------------------------------------------------------------------- /src/m_fixed.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Fixed point arithemtics, implementation. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_FIXED__ 25 | #define __M_FIXED__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | #include 32 | 33 | // 34 | // Fixed point, 32bit as 16.16. 35 | // 36 | #define FRACBITS 16 37 | #define FRACUNIT (1<> 31; 44 | return (x ^ _s) - _s; 45 | } 46 | 47 | static inline fixed_t __attribute__((always_inline)) FixedMul(fixed_t a, fixed_t b) 48 | { 49 | return (fixed_t)(((uint64_t)a * (uint64_t)b) >> 16); 50 | } 51 | 52 | static inline fixed_t __attribute__((always_inline)) FixedDiv(fixed_t a, fixed_t b) 53 | { 54 | return (fixed_t) ((int64_t)((int64_t)a<<16) / ((int64_t)b)); 55 | } 56 | 57 | // http://www.coranac.com/2009/07/sines/ 58 | // third-order approximation 59 | static inline int32_t __attribute__((always_inline)) finesine(int32_t x) 60 | { 61 | // original has qA = 12 (output range [-4095,4095]) 62 | // we need 16 (output range [-65535,65535]) 63 | // static const int qN = 13, qA= 16, qP= 15, qR= 2*qN-qP, qS= qN+qP+1-qA; 64 | 65 | // scale the input range 66 | // this makes it work as a replacement for the old finesine table 67 | // x <<= 2; 68 | // x = (x << (30 - qN)); 69 | 70 | x = x << 19; 71 | 72 | if ((x ^ (x << 1)) < 0) 73 | x = (1 << 31) - x; 74 | 75 | // x = x >> (30 - qN); 76 | x = x >> 17; 77 | 78 | // return x * ((3 << qP) - ((x * x) >> qR)) >> qS; 79 | return x * (98304 - ((x * x) >> 11)) >> 13; 80 | } 81 | 82 | static inline int32_t __attribute__((always_inline)) finecosine(int32_t x) 83 | { 84 | return finesine(x + 2048); 85 | } 86 | 87 | #if 0 88 | extern int32_t finetangentf(int32_t x); 89 | #endif 90 | #if 1 91 | // I don't want this to use floating point but I haven't figured out how to convert it to fixed-point yet 92 | static inline int32_t __attribute__((always_inline)) finetangentf(int32_t x) 93 | { 94 | // [0,4095] -> [-2048,2047] -> [-1.0,1.0] 95 | float inx = (((float)x - 2048.0f)/2048.0f); 96 | float y = (1.0f - (inx*inx)); 97 | // avoid div by zero 98 | if(y == 0) y = 0.0001f; 99 | float ret = inx * ((-0.0187108f * y) + 0.31583526f + (1.27365776f / y)); 100 | // float to fixed 101 | return (int32_t)(ret*65536); 102 | } 103 | #endif 104 | #endif 105 | //----------------------------------------------------------------------------- 106 | // 107 | // $Log:$ 108 | // 109 | //----------------------------------------------------------------------------- 110 | -------------------------------------------------------------------------------- /src/m_menu.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Menu widget stuff, episode selection and such. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_MENU__ 25 | #define __M_MENU__ 26 | 27 | 28 | 29 | #include "d_event.h" 30 | 31 | // 32 | // MENUS 33 | // 34 | // Called by main loop, 35 | // saves config file and calls I_Quit when user exits. 36 | // Even when the menu is not displayed, 37 | // this can resize the view and change game parameters. 38 | // Does all the real work of the menu interaction. 39 | boolean M_Responder (event_t *ev); 40 | 41 | 42 | // Called by main loop, 43 | // only used for menu (skull cursor) animation. 44 | void M_Ticker (void); 45 | 46 | // Called by main loop, 47 | // draws the menus directly into the screen buffer. 48 | void M_Drawer (void); 49 | 50 | // Called by D_DoomMain, 51 | // loads the config file. 52 | void M_Init (void); 53 | 54 | // Called by intro code to force menu up upon a keypress, 55 | // does nothing if menu is already up. 56 | void M_StartControlPanel (void); 57 | 58 | 59 | 60 | 61 | 62 | 63 | #endif 64 | //----------------------------------------------------------------------------- 65 | // 66 | // $Log:$ 67 | // 68 | //----------------------------------------------------------------------------- 69 | -------------------------------------------------------------------------------- /src/m_misc.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_MISC__ 25 | #define __M_MISC__ 26 | 27 | 28 | #include "doomtype.h" 29 | // 30 | // MISC 31 | // 32 | 33 | 34 | 35 | boolean 36 | M_WriteFile 37 | ( char const* name, 38 | void* source, 39 | int length ); 40 | 41 | int 42 | M_ReadFile 43 | ( char const* name, 44 | byte** buffer ); 45 | 46 | void M_ScreenShot (void); 47 | 48 | void M_LoadDefaults (void); 49 | 50 | void M_SaveDefaults (void); 51 | 52 | #endif 53 | //----------------------------------------------------------------------------- 54 | // 55 | // $Log:$ 56 | // 57 | //----------------------------------------------------------------------------- 58 | -------------------------------------------------------------------------------- /src/m_random.c: -------------------------------------------------------------------------------- 1 | // DESCRIPTION: 2 | // Random number LUT. 3 | // 4 | //----------------------------------------------------------------------------- 5 | 6 | // 7 | // M_Random 8 | // Returns a 0-255 number 9 | // 10 | unsigned char rndtable[256] = { 11 | 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 , 12 | 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 , 13 | 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 , 14 | 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 , 15 | 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 , 16 | 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 , 17 | 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 , 18 | 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 , 19 | 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 , 20 | 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 , 21 | 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 , 22 | 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 , 23 | 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 , 24 | 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 , 25 | 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 , 26 | 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 , 27 | 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 , 28 | 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 29 | 120, 163, 236, 249 30 | }; 31 | 32 | static int rndindex = 0; 33 | static int prndindex = 0; 34 | 35 | int M_GetRndindex(void) { 36 | return rndindex; 37 | } 38 | 39 | // Which one is deterministic? 40 | int P_Random (void) 41 | { 42 | prndindex = (prndindex+1)&0xff; 43 | return rndtable[prndindex]; 44 | } 45 | 46 | int M_Random (void) 47 | { 48 | rndindex = (rndindex+1)&0xff; 49 | return rndtable[rndindex]; 50 | } 51 | 52 | void M_ClearRandom (void) 53 | { 54 | rndindex = prndindex = 0; 55 | } 56 | -------------------------------------------------------------------------------- /src/m_random.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_RANDOM__ 25 | #define __M_RANDOM__ 26 | 27 | 28 | #include "doomtype.h" 29 | 30 | 31 | 32 | // Returns a number from 0 to 255, 33 | // from a lookup table. 34 | int M_Random (void); 35 | 36 | // As M_Random, but used only by the play simulation. 37 | int P_Random (void); 38 | 39 | // Fix randoms for demos. 40 | void M_ClearRandom (void); 41 | 42 | 43 | #endif 44 | //----------------------------------------------------------------------------- 45 | // 46 | // $Log:$ 47 | // 48 | //----------------------------------------------------------------------------- 49 | -------------------------------------------------------------------------------- /src/m_swap.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Endianess handling, swapping 16bit and 32bit. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __M_SWAP__ 25 | #define __M_SWAP__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | 32 | // Endianess handling. 33 | // WAD files are stored little endian. 34 | 35 | #define SHORT(x) ((int16_t)(((uint16_t)(x)>>8)|((uint16_t)(x)<<8))) 36 | #define LONG(x) ((int32_t)((((uint32_t)(x)>>24)&0xff) | \ 37 | (((uint32_t)(x)<<8)&0xff0000) | \ 38 | (((uint32_t)(x)>>8)&0xff00) | \ 39 | (((uint32_t)(x)<<24)))) 40 | #endif 41 | //----------------------------------------------------------------------------- 42 | // 43 | // $Log:$ 44 | // 45 | //----------------------------------------------------------------------------- 46 | -------------------------------------------------------------------------------- /src/nodereorder.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "z_zone.h" 4 | 5 | #include "m_swap.h" 6 | #include "m_bbox.h" 7 | 8 | #include "g_game.h" 9 | 10 | #include "i_system.h" 11 | #include "w_wad.h" 12 | 13 | #include "doomdef.h" 14 | #include "p_local.h" 15 | 16 | #include "s_sound.h" 17 | 18 | #include "doomstat.h" 19 | 20 | static void node_enqueue(uint16_t *qarray, uint32_t *qsize, uint16_t val) 21 | { 22 | if (*qsize == 0) { 23 | qarray[0] = val; 24 | } 25 | else 26 | { 27 | for (int i=*qsize;i>0;i--) 28 | { 29 | qarray[i] = qarray[i-1]; 30 | } 31 | 32 | qarray[0] = val; 33 | } 34 | 35 | *qsize += 1; 36 | } 37 | 38 | // assuming it has data 39 | static uint16_t node_dequeue(uint16_t *qarray, uint32_t *qsize) 40 | { 41 | uint16_t val = qarray[0]; 42 | 43 | for (int i=0;i<*qsize-1;i++) 44 | { 45 | qarray[i] = qarray[i+1]; 46 | } 47 | *qsize -= 1; 48 | 49 | return val; 50 | } 51 | 52 | static inline void copy_node_data_as_is(void *dn, void *sn, uint16_t dsti, uint16_t srci) 53 | { 54 | node_t* dstn = ((node_t *)dn); // + (dsti*sizeof(node_t)); 55 | for (int i=0;i 0) 104 | { 105 | node_index = node_dequeue(qarray,&qsize); 106 | 107 | node_t* n = (node_t *)&np[node_index]; 108 | 109 | uint16_t child1_idx = n->children[0]; 110 | uint16_t child0_idx = n->children[1]; 111 | // NF_SUBSECTOR 112 | if (child0_idx < (uint16_t)numn) 113 | { 114 | rewrites[child0_idx] = numNodesExplored; 115 | copy_node_data_as_is(new_nodes, np, numNodesExplored, child0_idx); 116 | numNodesExplored-=1; 117 | node_enqueue(qarray,&qsize,child0_idx); 118 | } 119 | 120 | if (child1_idx < (uint16_t)numn) 121 | { 122 | rewrites[child1_idx] = numNodesExplored; 123 | copy_node_data_as_is(new_nodes, np, numNodesExplored, child1_idx); 124 | numNodesExplored-=1; 125 | node_enqueue(qarray,&qsize,child1_idx); 126 | } 127 | } 128 | 129 | #if 1 130 | // do the rewrites here 131 | node_t *n = new_nodes; 132 | for (int i=0;ichildren[0]; 135 | uint16_t child0_idx = n->children[1]; 136 | if(child0_idx < (uint16_t)numn) 137 | n->children[1] = rewrites[child0_idx]; 138 | if(child1_idx < (uint16_t)numn) 139 | n->children[0] = rewrites[child1_idx]; 140 | } 141 | 142 | Z_Free(qarray); 143 | Z_Free(rewrites); 144 | 145 | // finally swap new nodes for old 146 | node_t *old_nodes = nodes; 147 | nodes = new_nodes; 148 | Z_Free(old_nodes); 149 | #endif 150 | } -------------------------------------------------------------------------------- /src/p_inter.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __P_INTER__ 25 | #define __P_INTER__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | 32 | 33 | boolean P_GivePower(player_t*, int); 34 | 35 | 36 | 37 | #endif 38 | //----------------------------------------------------------------------------- 39 | // 40 | // $Log:$ 41 | // 42 | //----------------------------------------------------------------------------- 43 | -------------------------------------------------------------------------------- /src/p_pspr.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Sprite animation. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __P_PSPR__ 25 | #define __P_PSPR__ 26 | 27 | // Basic data types. 28 | // Needs fixed point, and BAM angles. 29 | #include "m_fixed.h" 30 | #include "tables.h" 31 | 32 | 33 | // 34 | // Needs to include the precompiled 35 | // sprite animation tables. 36 | // Header generated by multigen utility. 37 | // This includes all the data for thing animation, 38 | // i.e. the Thing Atrributes table 39 | // and the Frame Sequence table. 40 | #include "info.h" 41 | 42 | #ifdef __GNUG__ 43 | #pragma interface 44 | #endif 45 | 46 | 47 | // 48 | // Frame flags: 49 | // handles maximum brightness (torches, muzzle flare, light sources) 50 | // 51 | #define FF_FULLBRIGHT 0x8000 // flag in thing->frame 52 | #define FF_FRAMEMASK 0x7fff 53 | 54 | 55 | 56 | // 57 | // Overlay psprites are scaled shapes 58 | // drawn directly on the view screen, 59 | // coordinates are given for a 320*200 view screen. 60 | // 61 | typedef enum 62 | { 63 | ps_weapon, 64 | ps_flash, 65 | NUMPSPRITES 66 | 67 | } psprnum_t; 68 | 69 | typedef struct 70 | { 71 | state_t* state; // a NULL state means not active 72 | int tics; 73 | fixed_t sx; 74 | fixed_t sy; 75 | 76 | } pspdef_t; 77 | 78 | #endif 79 | //----------------------------------------------------------------------------- 80 | // 81 | // $Log:$ 82 | // 83 | //----------------------------------------------------------------------------- 84 | -------------------------------------------------------------------------------- /src/p_saveg.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Savegame I/O, archiving, persistence. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __P_SAVEG__ 25 | #define __P_SAVEG__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | 32 | 33 | // Persistent storage/archiving. 34 | // These are the load / save game routines. 35 | void P_ArchivePlayers (void); 36 | void P_UnArchivePlayers (void); 37 | void P_ArchiveWorld (void); 38 | void P_UnArchiveWorld (void); 39 | void P_ArchiveThinkers (void); 40 | void P_UnArchiveThinkers (void); 41 | void P_ArchiveSpecials (void); 42 | void P_UnArchiveSpecials (void); 43 | 44 | extern byte* save_p; 45 | 46 | 47 | #endif 48 | //----------------------------------------------------------------------------- 49 | // 50 | // $Log:$ 51 | // 52 | //----------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /src/p_setup.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Setup a game, startup stuff. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | 24 | #ifndef __P_SETUP__ 25 | #define __P_SETUP__ 26 | 27 | 28 | #ifdef __GNUG__ 29 | #pragma interface 30 | #endif 31 | 32 | 33 | // NOT called by W_Ticker. Fixme. 34 | void 35 | P_SetupLevel 36 | ( unsigned int episode, 37 | unsigned int map, 38 | int playermask, 39 | skill_t skill); 40 | 41 | // Called by startup code. 42 | void P_Init (void); 43 | 44 | #endif 45 | //----------------------------------------------------------------------------- 46 | // 47 | // $Log:$ 48 | // 49 | //----------------------------------------------------------------------------- 50 | -------------------------------------------------------------------------------- /src/p_telept.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Teleportation. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #include "doomdef.h" 26 | 27 | #include "s_sound.h" 28 | 29 | #include "p_local.h" 30 | 31 | 32 | // Data. 33 | #include "sounds.h" 34 | 35 | // State. 36 | #include "r_state.h" 37 | 38 | 39 | 40 | // 41 | // TELEPORTATION 42 | // 43 | int 44 | EV_Teleport 45 | ( line_t* line, 46 | int side, 47 | mobj_t* thing ) 48 | { 49 | int i; 50 | int tag; 51 | mobj_t* m; 52 | mobj_t* fog; 53 | unsigned an; 54 | thinker_t* thinker; 55 | sector_t* sector; 56 | fixed_t oldx; 57 | fixed_t oldy; 58 | fixed_t oldz; 59 | 60 | // don't teleport missiles 61 | if (thing->flags & MF_MISSILE) 62 | return 0; 63 | 64 | // Don't teleport if hit back of line, 65 | // so you can get out of teleporter. 66 | if (side == 1) 67 | return 0; 68 | 69 | 70 | tag = line->tag; 71 | for (i = 0; i < numsectors; i++) 72 | { 73 | if (sectors[ i ].tag == tag ) 74 | { 75 | thinker = thinkercap.next; 76 | for (thinker = thinkercap.next; 77 | thinker != &thinkercap; 78 | thinker = thinker->next) 79 | { 80 | // not a mobj 81 | if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) 82 | continue; 83 | 84 | m = (mobj_t *)thinker; 85 | 86 | // not a teleportman 87 | if (m->type != MT_TELEPORTMAN ) 88 | continue; 89 | 90 | sector = m->subsector->sector; 91 | // wrong sector 92 | if (sector-sectors != i ) 93 | continue; 94 | 95 | oldx = thing->x; 96 | oldy = thing->y; 97 | oldz = thing->z; 98 | 99 | if (!P_TeleportMove (thing, m->x, m->y)) 100 | return 0; 101 | 102 | thing->z = thing->floorz; //fixme: not needed? 103 | if (thing->player) 104 | thing->player->viewz = thing->z+thing->player->viewheight; 105 | 106 | // spawn teleport fog at source and destination 107 | fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 108 | S_StartSound (fog, sfx_telept); 109 | an = m->angle >> ANGLETOFINESHIFT; 110 | fog = P_SpawnMobj (m->x+20*finecosine(an), m->y+20*finesine(an) 111 | , thing->z, MT_TFOG); 112 | 113 | // emit sound, where? 114 | S_StartSound (fog, sfx_telept); 115 | 116 | // don't move for a bit 117 | if (thing->player) 118 | thing->reactiontime = 18; 119 | 120 | thing->angle = m->angle; 121 | thing->momx = thing->momy = thing->momz = 0; 122 | return 1; 123 | } 124 | } 125 | } 126 | return 0; 127 | } 128 | 129 | -------------------------------------------------------------------------------- /src/p_tick.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // Archiving: SaveGame I/O. 22 | // Thinker, Ticker. 23 | // 24 | //----------------------------------------------------------------------------- 25 | 26 | #include "z_zone.h" 27 | #include "p_local.h" 28 | 29 | #include "doomstat.h" 30 | 31 | 32 | int leveltime; 33 | 34 | // 35 | // THINKERS 36 | // All thinkers should be allocated by Z_Malloc 37 | // so they can be operated on uniformly. 38 | // The actual structures will vary in size, 39 | // but the first element must be thinker_t. 40 | // 41 | 42 | 43 | 44 | // Both the head and tail of the thinker list. 45 | thinker_t thinkercap; 46 | 47 | 48 | // 49 | // P_InitThinkers 50 | // 51 | void P_InitThinkers (void) 52 | { 53 | thinkercap.prev = thinkercap.next = &thinkercap; 54 | } 55 | 56 | 57 | 58 | 59 | // 60 | // P_AddThinker 61 | // Adds a new thinker at the end of the list. 62 | // 63 | void P_AddThinker (thinker_t* thinker) 64 | { 65 | thinkercap.prev->next = thinker; 66 | thinker->next = &thinkercap; 67 | thinker->prev = thinkercap.prev; 68 | thinkercap.prev = thinker; 69 | } 70 | 71 | 72 | 73 | // 74 | // P_RemoveThinker 75 | // Deallocation is lazy -- it will not actually be freed 76 | // until its thinking turn comes up. 77 | // 78 | void P_RemoveThinker (thinker_t* thinker) 79 | { 80 | // FIXME: NOP. 81 | thinker->function.acv = (actionf_v)(-1); 82 | } 83 | 84 | 85 | 86 | // 87 | // P_AllocateThinker 88 | // Allocates memory and adds a new thinker at the end of the list. 89 | // 90 | void P_AllocateThinker (thinker_t* thinker) 91 | { 92 | } 93 | 94 | 95 | 96 | // 97 | // P_RunThinkers 98 | // 99 | void P_RunThinkers (void) 100 | { 101 | thinker_t* currentthinker; 102 | 103 | currentthinker = thinkercap.next; 104 | while (currentthinker != &thinkercap) 105 | { 106 | if ( currentthinker->function.acv == (actionf_v)(-1) ) 107 | { 108 | // time to remove it 109 | currentthinker->next->prev = currentthinker->prev; 110 | currentthinker->prev->next = currentthinker->next; 111 | Z_Free (currentthinker); 112 | } 113 | else 114 | { 115 | if (currentthinker->function.acp1) 116 | currentthinker->function.acp1 (currentthinker); 117 | } 118 | currentthinker = currentthinker->next; 119 | } 120 | } 121 | 122 | 123 | 124 | // 125 | // P_Ticker 126 | // 127 | 128 | void P_Ticker (void) 129 | { 130 | int i; 131 | 132 | // run the tic 133 | if (paused) 134 | return; 135 | 136 | // pause if in menu and at least one tic has been run 137 | if ( !netgame 138 | && menuactive 139 | && !demoplayback 140 | && players[consoleplayer].viewz != 1) 141 | { 142 | return; 143 | } 144 | 145 | 146 | for (i=0 ; i 50 | // using from sounds.h 51 | // 52 | void S_StartSound(void* origin, int sound_id); 53 | 54 | 55 | // Will start a sound at a given volume. 56 | void S_StartSoundAtVolume(void* origin, int sound_id, int volume); 57 | 58 | 59 | // Stop sound for thing at 60 | void S_StopSound(void* origin); 61 | 62 | 63 | // Start music using from sounds.h 64 | void S_StartMusic(int music_id); 65 | 66 | 67 | // Start music using from sounds.h, 68 | // and set whether looping 69 | void S_ChangeMusic(int music_id, int looping); 70 | 71 | 72 | // Stops the music fer sure. 73 | void S_StopMusic(void); 74 | 75 | 76 | // Stop and resume music, during game PAUSE. 77 | void S_PauseSound(void); 78 | void S_ResumeSound(void); 79 | 80 | 81 | // 82 | // Updates music & sounds 83 | // 84 | void S_UpdateSounds(void* listener); 85 | 86 | 87 | void S_SetMusicVolume(int volume); 88 | void S_SetSfxVolume(int volume); 89 | 90 | 91 | #endif 92 | //----------------------------------------------------------------------------- 93 | // 94 | // $Log:$ 95 | // 96 | //----------------------------------------------------------------------------- 97 | -------------------------------------------------------------------------------- /src/st_lib.c: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // $Log:$ 19 | // 20 | // DESCRIPTION: 21 | // The status bar widget code. 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #include 26 | 27 | #include "doomdef.h" 28 | 29 | #include "z_zone.h" 30 | #include "v_video.h" 31 | 32 | #include "m_swap.h" 33 | 34 | #include "i_system.h" 35 | 36 | #include "w_wad.h" 37 | 38 | #include "st_stuff.h" 39 | #include "st_lib.h" 40 | #include "r_local.h" 41 | 42 | 43 | // in AM_map.c 44 | extern boolean automapactive; 45 | 46 | // 47 | // Hack display negative frags. 48 | // Loads and store the stminus lump. 49 | // 50 | patch_t* sttminus; 51 | 52 | 53 | void STlib_init(void) 54 | { 55 | sttminus = (patch_t *) W_CacheLumpName("STTMINUS", PU_STATIC); 56 | } 57 | 58 | 59 | // ? 60 | void STlib_initNum(st_number_t* n, int x, int y, patch_t** pl, int* num, boolean* on, int width) 61 | { 62 | n->x = x; 63 | n->y = y; 64 | n->oldnum = 0; 65 | n->width = width; 66 | n->num = num; 67 | n->on = on; 68 | n->p = pl; 69 | } 70 | 71 | 72 | // 73 | // A fairly efficient way to draw a number 74 | // based on differences from the old number. 75 | // Note: worth the trouble? 76 | // 77 | void STlib_drawNum(st_number_t* n, boolean refresh) 78 | { 79 | int x = n->x; 80 | int y = n->y; 81 | int w = SHORT(n->p[0]->width); 82 | int neg; 83 | int numdigits = n->width; 84 | int num = *n->num; 85 | 86 | refresh = false; 87 | 88 | n->oldnum = *n->num; 89 | 90 | neg = num < 0; 91 | 92 | if (neg) 93 | { 94 | if (numdigits == 2 && num < -9) 95 | { 96 | num = -9; 97 | } 98 | else if (numdigits == 3 && num < -99) 99 | { 100 | num = -99; 101 | } 102 | num = -num; 103 | } 104 | 105 | // clear the area 106 | x = n->x - numdigits*w; 107 | 108 | #ifdef RANGECHECK 109 | unsigned int c = y - ST_Y; 110 | 111 | if (c > y) 112 | { 113 | I_Error("STlib_drawNum: n->y - ST_Y < 0; %d - %d < 0", y, ST_Y); 114 | } 115 | #endif 116 | 117 | // if non-number, do not draw it 118 | if (num == 1994) 119 | { 120 | return; 121 | } 122 | x = n->x; 123 | 124 | // in the special case of 0, you draw 0 125 | if (!num) 126 | { 127 | V_DrawPatch(x - w, y, n->p[0]); 128 | } 129 | 130 | // draw the new number 131 | while (num && numdigits--) 132 | { 133 | x -= w; 134 | V_DrawPatch(x, y, n->p[ num % 10 ]); 135 | num /= 10; 136 | } 137 | 138 | // draw a minus sign if necessary 139 | if (neg) 140 | { 141 | V_DrawPatch(x - 8, y, sttminus); 142 | } 143 | } 144 | 145 | 146 | // 147 | void STlib_updateNum(st_number_t* n, boolean refresh) 148 | { 149 | if (*n->on) 150 | { 151 | STlib_drawNum(n, refresh); 152 | } 153 | } 154 | 155 | 156 | // 157 | void STlib_initPercent(st_percent_t* p, int x, int y, patch_t** pl, int* num, boolean* on, patch_t* percent) 158 | { 159 | STlib_initNum(&p->n, x, y, pl, num, on, 3); 160 | p->p = percent; 161 | } 162 | 163 | 164 | void STlib_updatePercent(st_percent_t* per, int refresh) 165 | { 166 | if (refresh && *per->n.on) 167 | { 168 | V_DrawPatch(per->n.x, per->n.y, per->p); 169 | } 170 | 171 | STlib_updateNum(&per->n, refresh); 172 | } 173 | 174 | void STlib_initMultIcon(st_multicon_t* i, int x, int y, patch_t** il, int* inum, boolean* on) 175 | { 176 | i->x = x; 177 | i->y = y; 178 | i->oldinum = -1; 179 | i->inum = inum; 180 | i->on = on; 181 | i->p = il; 182 | } 183 | 184 | 185 | void STlib_updateMultIcon(st_multicon_t* mi, boolean refresh) 186 | { 187 | if (*mi->on && (mi->oldinum != *mi->inum || refresh) && (*mi->inum!=-1)) 188 | { 189 | V_DrawPatch(mi->x, mi->y, mi->p[*mi->inum]); 190 | mi->oldinum = *mi->inum; 191 | } 192 | } 193 | 194 | 195 | void STlib_initBinIcon(st_binicon_t* b, int x, int y, patch_t* i, boolean* val, boolean* on) 196 | { 197 | b->x = x; 198 | b->y = y; 199 | b->oldval = 0; 200 | b->val = val; 201 | b->on = on; 202 | b->p = i; 203 | } 204 | 205 | 206 | void STlib_updateBinIcon(st_binicon_t* bi, boolean refresh) 207 | { 208 | if (*bi->on && (bi->oldval != *bi->val || refresh)) 209 | { 210 | if (*bi->val) 211 | { 212 | V_DrawPatch(bi->x, bi->y, bi->p); 213 | } 214 | bi->oldval = *bi->val; 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /src/st_lib.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // The status bar widget code. 20 | // 21 | //----------------------------------------------------------------------------- 22 | 23 | #ifndef __STLIB__ 24 | #define __STLIB__ 25 | 26 | 27 | // We are referring to patches. 28 | #include "r_defs.h" 29 | 30 | 31 | // 32 | // Typedefs of widgets 33 | // 34 | 35 | // Number widget 36 | typedef struct 37 | { 38 | // upper right-hand corner 39 | // of the number (right-justified) 40 | int x; 41 | int y; 42 | 43 | // max # of digits in number 44 | int width; 45 | 46 | // last number value 47 | int oldnum; 48 | 49 | // pointer to current value 50 | int* num; 51 | 52 | // pointer to boolean stating 53 | // whether to update number 54 | boolean* on; 55 | 56 | // list of patches for 0-9 57 | patch_t** p; 58 | 59 | // user data 60 | int data; 61 | 62 | } st_number_t; 63 | 64 | 65 | 66 | // Percent widget ("child" of number widget, 67 | // or, more precisely, contains a number widget.) 68 | typedef struct 69 | { 70 | // number information 71 | st_number_t n; 72 | 73 | // percent sign graphic 74 | patch_t* p; 75 | 76 | } st_percent_t; 77 | 78 | 79 | // Multiple Icon widget 80 | typedef struct 81 | { 82 | // center-justified location of icons 83 | int x; 84 | int y; 85 | 86 | // last icon number 87 | int oldinum; 88 | 89 | // pointer to current icon 90 | int* inum; 91 | 92 | // pointer to boolean stating 93 | // whether to update icon 94 | boolean* on; 95 | 96 | // list of icons 97 | patch_t** p; 98 | 99 | // user data 100 | int data; 101 | 102 | } st_multicon_t; 103 | 104 | 105 | // Binary Icon widget 106 | typedef struct 107 | { 108 | // center-justified location of icon 109 | int x; 110 | int y; 111 | 112 | // last icon value 113 | int 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 | // Widget creation, access, and update routines 131 | // 132 | 133 | // Initializes widget library. 134 | // More precisely, initialize STMINUS, 135 | // everything else is done somewhere else. 136 | // 137 | void STlib_init(void); 138 | 139 | 140 | // Number widget routines 141 | void STlib_initNum(st_number_t* n, int x, int y, patch_t** pl, int* num, boolean* on, int width); 142 | 143 | 144 | void STlib_updateNum(st_number_t* n, boolean refresh); 145 | 146 | 147 | // Percent widget routines 148 | void STlib_initPercent(st_percent_t* p, int x, int y, patch_t** pl, int* num, boolean* on, patch_t* percent); 149 | 150 | 151 | void STlib_updatePercent (st_percent_t* per, int refresh); 152 | 153 | 154 | // Multiple Icon widget routines 155 | void STlib_initMultIcon(st_multicon_t* mi, int x, int y, patch_t** il, int* inum, boolean* on); 156 | 157 | 158 | void STlib_updateMultIcon(st_multicon_t* mi, boolean refresh); 159 | 160 | // Binary Icon widget routines 161 | 162 | void STlib_initBinIcon(st_binicon_t* b, int x, int y, patch_t* i, boolean* val, boolean* on); 163 | 164 | 165 | void STlib_updateBinIcon(st_binicon_t* bi, boolean refresh); 166 | 167 | #endif 168 | //----------------------------------------------------------------------------- 169 | // 170 | // $Log:$ 171 | // 172 | //----------------------------------------------------------------------------- 173 | -------------------------------------------------------------------------------- /src/st_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This program is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU General Public License 10 | // as published by the Free Software Foundation; either version 2 11 | // of the License, or (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // DESCRIPTION: 19 | // Status bar code. 20 | // Does the face/direction indicator animatin. 21 | // Does palette indicators as well (red pain/berserk, bright pickup) 22 | // 23 | //----------------------------------------------------------------------------- 24 | 25 | #ifndef __STSTUFF_H__ 26 | #define __STSTUFF_H__ 27 | 28 | #include "doomtype.h" 29 | #include "d_event.h" 30 | 31 | // Size of statusbar. 32 | // Now sensitive for scaling. 33 | #define ST_HEIGHT 32*SCREEN_MUL 34 | #define ST_WIDTH 320 35 | #define ST_Y 168 36 | 37 | 38 | // 39 | // STATUS BAR 40 | // 41 | 42 | // Called by main loop. 43 | boolean ST_Responder (event_t* ev); 44 | 45 | // Called by main loop. 46 | void ST_Ticker (void); 47 | 48 | // Called by main loop. 49 | void ST_Drawer (boolean fullscreen, boolean refresh); 50 | 51 | // Called when the console player is spawned on each level. 52 | void ST_Start (void); 53 | 54 | // Called by startup code. 55 | void ST_Init (void); 56 | 57 | 58 | 59 | // States for status bar code. 60 | typedef enum 61 | { 62 | AutomapState, 63 | FirstPersonState 64 | 65 | } st_stateenum_t; 66 | 67 | 68 | // States for the chat code. 69 | typedef enum 70 | { 71 | StartChatState, 72 | WaitDestState, 73 | GetChatState 74 | 75 | } st_chatstateenum_t; 76 | 77 | 78 | boolean ST_Responder(event_t* ev); 79 | 80 | 81 | 82 | #endif 83 | //----------------------------------------------------------------------------- 84 | // 85 | // $Log:$ 86 | // 87 | //----------------------------------------------------------------------------- 88 | -------------------------------------------------------------------------------- /src/tables.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Lookup tables. 19 | // Do not try to look them up :-). 20 | // In the order of appearance: 21 | // 22 | // int finetangent[4096] - Tangens LUT. 23 | // Should work with BAM fairly well (12 of 16bit, 24 | // effectively, by shifting). 25 | // 26 | // int finesine(10240) - Sine lookup. 27 | // Guess what, serves as cosine, too. 28 | // Remarkable thing is, how to use BAMs with this? 29 | // 30 | // int tantoangle[2049] - ArcTan LUT, 31 | // maps tan(angle) to angle fast. Gotta search. 32 | // 33 | //----------------------------------------------------------------------------- 34 | 35 | 36 | #ifndef __TABLES__ 37 | #define __TABLES__ 38 | 39 | #ifdef LINUX 40 | #include 41 | #else 42 | #define PI 3.141592657 43 | #endif 44 | 45 | 46 | #include "m_fixed.h" 47 | 48 | #define FINEANGLES 8192 49 | #define FINEMASK (FINEANGLES-1) 50 | 51 | 52 | // 0x100000000 to 0x2000 53 | #define ANGLETOFINESHIFT 19 54 | 55 | // Binary Angle Measument, BAM. 56 | #define ANG45 0x20000000 57 | #define ANG90 0x40000000 58 | #define ANG180 0x80000000 59 | #define ANG270 0xc0000000 60 | 61 | 62 | #define SLOPERANGE 2048 63 | #define SLOPEBITS 11 64 | #define DBITS (FRACBITS-SLOPEBITS) 65 | 66 | typedef unsigned angle_t; 67 | 68 | #endif 69 | //----------------------------------------------------------------------------- 70 | // 71 | // $Log:$ 72 | // 73 | //----------------------------------------------------------------------------- 74 | -------------------------------------------------------------------------------- /src/v_video.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Gamma correction LUT. 19 | // Functions to draw patches (by post) directly to screen. 20 | // Functions to blit a block to the screen. 21 | // 22 | //----------------------------------------------------------------------------- 23 | 24 | 25 | #ifndef __V_VIDEO__ 26 | #define __V_VIDEO__ 27 | 28 | #include "doomtype.h" 29 | 30 | #include "doomdef.h" 31 | 32 | // Needed because we are refering to patches. 33 | #include "r_data.h" 34 | 35 | // 36 | // VIDEO 37 | // 38 | 39 | #define CENTERY (SCREENHEIGHT/2) 40 | 41 | 42 | // Screen 0 is the screen updated by I_Update screen. 43 | // Screen 1 is an extra buffer. 44 | 45 | 46 | 47 | extern byte* screens[5]; 48 | 49 | extern int dirtybox[4]; 50 | 51 | extern byte gammatable[5][256]; 52 | extern int usegamma; 53 | 54 | 55 | 56 | // Allocates buffer screens, call before R_Init. 57 | void V_Init (void); 58 | 59 | 60 | void 61 | V_CopyRect 62 | ( int srcx, 63 | int srcy, 64 | int srcscrn, 65 | int width, 66 | int height, 67 | int destx, 68 | int desty, 69 | int destscrn ); 70 | 71 | 72 | void 73 | V_DrawPatch 74 | ( int x, 75 | int y, 76 | patch_t* patch); 77 | 78 | void 79 | V_DrawPatchBuf 80 | ( int x, 81 | int y, 82 | patch_t* patch, 83 | uint16_t* buf); 84 | 85 | // Draw a linear block of pixels into the view buffer. 86 | void 87 | V_DrawBlock 88 | ( int x, 89 | int y, 90 | int width, 91 | int height, 92 | uint16_t* src ); 93 | 94 | 95 | // Reads a linear block of pixels into the view buffer. 96 | void 97 | V_GetBlock 98 | ( int x, 99 | int y, 100 | int width, 101 | int height, 102 | uint16_t* dest ); 103 | 104 | 105 | void 106 | V_MarkRect 107 | ( int x, 108 | int y, 109 | int width, 110 | int height ); 111 | 112 | #endif 113 | //----------------------------------------------------------------------------- 114 | // 115 | // $Log:$ 116 | // 117 | //----------------------------------------------------------------------------- 118 | -------------------------------------------------------------------------------- /src/w_wad.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // WAD I/O functions. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | 23 | #ifndef __W_WAD__ 24 | #define __W_WAD__ 25 | 26 | 27 | #ifdef __GNUG__ 28 | #pragma interface 29 | #endif 30 | 31 | 32 | // 33 | // TYPES 34 | // 35 | typedef struct 36 | { 37 | // Should be "IWAD" or "PWAD". 38 | char identification[4]; 39 | int numlumps; 40 | int infotableofs; 41 | 42 | } wadinfo_t; 43 | 44 | 45 | typedef struct 46 | { 47 | int filepos; 48 | int size; 49 | char name[8]; 50 | 51 | } filelump_t; 52 | 53 | // 54 | // WADFILE I/O related stuff. 55 | // 56 | typedef struct 57 | { 58 | int handle; 59 | int position; 60 | int size; 61 | char name[9]; 62 | } lumpinfo_t; 63 | 64 | 65 | extern void** lumpcache; 66 | extern lumpinfo_t* lumpinfo; 67 | extern int numlumps; 68 | 69 | void W_InitMultipleFiles (char** filenames); 70 | void W_Reload (void); 71 | 72 | int W_CheckNumForName (char* name); 73 | int W_GetNumForName (char* name); 74 | 75 | int W_LumpLength (int lump); 76 | void W_ReadLump (int lump, void *dest); 77 | 78 | void* W_CacheLumpNum (int lump, int tag); 79 | void* W_CacheLumpName (char* name, int tag); 80 | 81 | 82 | 83 | 84 | #endif 85 | //----------------------------------------------------------------------------- 86 | // 87 | // $Log:$ 88 | // 89 | //----------------------------------------------------------------------------- 90 | -------------------------------------------------------------------------------- /src/wi_stuff.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Intermission. 19 | // 20 | //----------------------------------------------------------------------------- 21 | 22 | #ifndef __WI_STUFF__ 23 | #define __WI_STUFF__ 24 | 25 | //#include "v_video.h" 26 | 27 | #include "doomdef.h" 28 | 29 | // States for the intermission 30 | 31 | typedef enum 32 | { 33 | NoState = -1, 34 | StatCount, 35 | ShowNextLoc 36 | 37 | } stateenum_t; 38 | 39 | // Called by main loop, animate the intermission. 40 | void WI_Ticker (void); 41 | 42 | // Called by main loop, 43 | // draws the intermission directly into the screen buffer. 44 | void WI_Drawer (void); 45 | 46 | // Setup for an intermission screen. 47 | void WI_Start(wbstartstruct_t* wbstartstruct); 48 | 49 | #endif 50 | //----------------------------------------------------------------------------- 51 | // 52 | // $Log:$ 53 | // 54 | //----------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /src/z_zone.h: -------------------------------------------------------------------------------- 1 | // Emacs style mode select -*- C++ -*- 2 | //----------------------------------------------------------------------------- 3 | // 4 | // $Id:$ 5 | // 6 | // Copyright (C) 1993-1996 by id Software, Inc. 7 | // 8 | // This source is available for distribution and/or modification 9 | // only under the terms of the DOOM Source Code License as 10 | // published by id Software. All rights reserved. 11 | // 12 | // The source is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 | // for more details. 16 | // 17 | // DESCRIPTION: 18 | // Zone Memory Allocation, perhaps NeXT ObjectiveC inspired. 19 | // Remark: this was the only stuff that, according 20 | // to John Carmack, might have been useful for 21 | // Quake. 22 | // 23 | //--------------------------------------------------------------------- 24 | 25 | 26 | 27 | #ifndef __Z_ZONE__ 28 | #define __Z_ZONE__ 29 | 30 | #include 31 | 32 | // 33 | // ZONE MEMORY 34 | // PU - purge tags. 35 | // Tags < 100 are not overwritten until freed. 36 | #define PU_STATIC 1 // static entire execution time 37 | #define PU_SOUND 2 // static while playing 38 | #define PU_MUSIC 3 // static while playing 39 | #define PU_DAVE 4 // anything else Dave wants static 40 | #define PU_LEVEL 50 // static until level exited 41 | #define PU_LEVSPEC 51 // a special thinker in a level 42 | // Tags >= 100 are purgable whenever needed. 43 | #define PU_PURGELEVEL 100 44 | #define PU_CACHE 101 45 | 46 | void Z_Init (void); 47 | void* Z_Malloc (int size, int tag, void *ptr); 48 | void Z_Free (void *ptr); 49 | void Z_FreeTags (int lowtag, int hightag); 50 | void Z_DumpHeap (int lowtag, int hightag); 51 | void Z_CheckHeap (void); 52 | void Z_ChangeTag (void *ptr, int tag);//, char *file, int line); 53 | int Z_FreeMemory (void); 54 | 55 | typedef struct memblock_s 56 | { 57 | int size; // including the header and possibly tiny fragments 58 | void** user; // NULL if a free block 59 | int tag; // purgelevel 60 | int id; // should be ZONEID 61 | struct memblock_s* next; 62 | struct memblock_s* prev; 63 | uint32_t pad1; 64 | uint32_t pad2; 65 | } memblock_t; 66 | 67 | #endif 68 | 69 | //----------------------------------------------------------------------------- 70 | // 71 | // $Log:$ 72 | // 73 | //----------------------------------------------------------------------------- 74 | --------------------------------------------------------------------------------