doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

commit bbf26755d34df958b1990f250d051e896956389c
parent 0ff58e8b175a51562047958b47886003a2657f3e
Author: ssnf <ssnf@ssnf.xyz>
Date:   Sun, 17 Oct 2021 01:24:31 +0000

synchronize with actual work dir

previous commits were made to try to keep a history of changes
back then, I was making changes to the code without commiting them
but honestly, it's too much of a drag to reenact everything

Diffstat:
Msndserv/Makefile | 50++++++++++++--------------------------------------
Dsndserv/README.sndserv | 16----------------
Msndserv/linux.c | 102++++++++++++++++---------------------------------------------------------------
Msndserv/sounds.c | 415++++++++++++++++++++++++++++++++++---------------------------------------------
Msndserv/sounds.h | 156+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Msndserv/soundsrv.c | 279+++++++------------------------------------------------------------------------
Msndserv/soundsrv.h | 59+++++++----------------------------------------------------
Dsndserv/soundst.h | 312-------------------------------------------------------------------------------
Msndserv/wadread.c | 147++++++++++---------------------------------------------------------------------
Dsndserv/wadread.h | 62--------------------------------------------------------------
Msrc/Makefile | 112+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/am_map.c | 1478++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/am_map.h | 11+++++++----
Dsrc/d_englsh.h | 522-------------------------------------------------------------------------------
Msrc/d_event.h | 95++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/d_french.h | 139++++++++++---------------------------------------------------------------------
Msrc/d_items.c | 92++++++++++++-------------------------------------------------------------------
Msrc/d_items.h | 35+++++++++++++++++++++++++++++++++++
Msrc/d_main.c | 982++++++++++++++++++++-----------------------------------------------------------
Msrc/d_main.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_net.c | 871+++++++++++++++++++++++++++++++++++++------------------------------------------
Msrc/d_net.h | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_player.h | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/d_textur.h | 43++++++++++++++++++++++++++++++++++++++++++-
Msrc/d_think.h | 31++++++++++++++++++-------------
Msrc/d_ticcmd.h | 39++++++++++++++++++++++++++++++++++++++-
Msrc/doom1.wad | 0
Msrc/doomdata.h | 131++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/doomdef.h | 460+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/doomstat.c | 6++----
Msrc/doomstat.h | 152+++++++++++++++++++++++++++++++++++++++----------------------------------------
Dsrc/doomtype.h | 9---------
Dsrc/dstrings.c | 26--------------------------
Msrc/dstrings.h | 12+++++-------
Msrc/f_finale.c | 827++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/f_finale.h | 5++++-
Msrc/f_wipe.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/f_wipe.h | 42++++++++++++++++++++++++++++++++++++++++++
Msrc/g_game.c | 2016++++++++++++++++++++++++++++++++++---------------------------------------------
Msrc/g_game.h | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/hu_lib.c | 99++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Msrc/hu_lib.h | 89++++++++++++++++++++++++++++++-------------------------------------------------
Msrc/hu_stuff.c | 1006+++++++++++++++++++++++++++++++++++++------------------------------------------
Msrc/hu_stuff.h | 6+++++-
Msrc/i_main.c | 8++++----
Msrc/i_net.c | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Msrc/i_net.h | 37+++++++++++++++++++++++++++++++++++++
Msrc/i_sound.c | 499++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/i_sound.h | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/i_system.c | 105+++++++++++++++++++++++++++----------------------------------------------------
Msrc/i_system.h | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/i_video.h | 49++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/info.c | 6994++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/info.h | 45++++++++++++++++++++++++++++++++-------------
Asrc/lang-gen.sh | 1+
Asrc/lang.c | 550+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/m_argv.c | 19++++++++++---------
Msrc/m_argv.h | 36++++++++++++++++++++++++++++++++++++
Msrc/m_bbox.c | 33+++++++++++++++------------------
Msrc/m_bbox.h | 16++++++++--------
Msrc/m_cheat.c | 24++++++++++++++++++++++++
Msrc/m_cheat.h | 39+++++++++++++++++++++++++++++++++++++++
Msrc/m_fixed.c | 37++++++++++++++-----------------------
Msrc/m_fixed.h | 17+++++++++--------
Msrc/m_menu.c | 2165++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/m_menu.h | 9++++++---
Msrc/m_misc.c | 431++++++++++++++++++++-----------------------------------------------------------
Msrc/m_misc.h | 26+++++++-------------------
Msrc/m_random.c | 9+++++++++
Msrc/m_random.h | 42+++++++++++++++++++++++++++++++++++++++++-
Msrc/m_swap.c | 15+++++++++------
Msrc/m_swap.h | 5++---
Msrc/p_ceilng.c | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_doors.c | 311++++++++++++++++++++++++++++---------------------------------------------------
Msrc/p_enemy.c | 2278++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/p_floor.c | 402+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/p_inter.c | 998+++++++++++++++++++++++++++++++++----------------------------------------------
Msrc/p_inter.h | 5++---
Msrc/p_lights.c | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_local.h | 127++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Msrc/p_map.c | 1388++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Msrc/p_maputl.c | 334++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Msrc/p_mobj.c | 333+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_mobj.h | 215+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_plats.c | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_pspr.c | 760++++++++++++++++++++++++++++++++++---------------------------------------------
Msrc/p_pspr.h | 27+++++++++++++++++++++++++++
Msrc/p_saveg.c | 151+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Msrc/p_saveg.h | 36++++++++++++++++++++++++++++++++++++
Msrc/p_setup.h | 14++++----------
Msrc/p_sight.c | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_spec.c | 1313++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/p_spec.h | 265+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_switch.c | 739++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/p_telept.c | 37+++++++++++++++++++++++++++++++++++++
Msrc/p_tick.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/p_tick.h | 37+++++++++++++++++++++++++++++++++++++
Msrc/p_user.c | 348+++++++++++++++++++++++++++++++++++--------------------------------------------
Asrc/parameters | 38++++++++++++++++++++++++++++++++++++++
Msrc/r_bsp.c | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_bsp.h | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_data.c | 1-
Msrc/r_data.h | 21+++++++++------------
Msrc/r_defs.h | 142++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/r_draw.c | 728++++++++++++++++++++++++++++---------------------------------------------------
Msrc/r_draw.h | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_local.h | 5+++++
Msrc/r_main.c | 812++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/r_main.h | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_plane.c | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
Msrc/r_plane.h | 47+++++++++++++++++++++++++++++++++++++++++++++++
Msrc/r_segs.c | 735+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/r_segs.h | 33+++++++++++++++++++++++++++++++++
Dsrc/r_sky.c | 13-------------
Dsrc/r_sky.h | 11-----------
Msrc/r_state.h | 11++++++++---
Msrc/r_things.c | 1010++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/r_things.h | 23+++++++++++++++++++++++
Msrc/s_sound.c | 732++++++++++++++++++++++++++++++-------------------------------------------------
Msrc/s_sound.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/sndserver | 0
Msrc/sounds.c | 356++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/sounds.h | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_lib.c | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_lib.h | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/st_stuff.c | 1173+++++++++++++++++++++++++++++++------------------------------------------------
Msrc/st_stuff.h | 63++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/tables.c | 4125+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/tables.h | 24++++++++++++------------
Asrc/todo | 2++
Msrc/v_video.c | 377+++++++++++++++++++++++++------------------------------------------------------
Msrc/v_video.h | 69++++++++++++++++++---------------------------------------------------
Msrc/w_wad.c | 193++++++++++++++++++++++---------------------------------------------------------
Msrc/wi_stuff.c | 1897+++++++++++++++++++++++++++++++++++--------------------------------------------
Msrc/wi_stuff.h | 41+++++++++++++++++++++++++++++++++++++++++
Msrc/z_zone.c | 322+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/z_zone.h | 61++++++++++++++++++++++++++++++++++---------------------------
137 files changed, 24339 insertions(+), 23085 deletions(-)

diff --git a/sndserv/Makefile b/sndserv/Makefile @@ -1,39 +1,13 @@ -########################################################## -# -# $Id:$ -# -# $Log:$ -# -# - -CC=gcc -CFLAGS=-O -DNORMALUNIX -DLINUX -LDFLAGS= -LIBS=-lm - -O=linux - -all: $(O)/sndserver - +CC = c89 +CFLAGS = -Os +LIBS = +LDFLAGS = ${LIBS} +SRC = soundsrv.c sounds.c wadread.c linux.c +OBJ = ${SRC:.c=.o} +all: sndserver clean: - rm -f *.o *~ *.flc - rm -f linux/* - -# Target -$(O)/sndserver: \ - $(O)/soundsrv.o \ - $(O)/sounds.o \ - $(O)/wadread.o \ - $(O)/linux.o - $(CC) $(CFLAGS) $(LDFLAGS) \ - $(O)/soundsrv.o \ - $(O)/sounds.o \ - $(O)/wadread.o \ - $(O)/linux.o -o $(O)/sndserver $(LIBS) - echo make complete. - -# Rule -$(O)/%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - - + rm -f *.o sndserver +%.o: %.c + ${CC} ${CFLAGS} -c $< -o $@ +sndserver: ${OBJ} + ${CC} ${LDFLAGS} ${OBJ} -o sndserver diff --git a/sndserv/README.sndserv b/sndserv/README.sndserv @@ -1,15 +0,0 @@ - -This is the soundserver as used by the original -Linuxdoom release. I separated the source from -the actual Linuxduum source. For various reasons -the separate sound process seems to give the -best results - both synchronous and timer driven -output demonstrate glitches. These might either -be timing issues, or introduced by the changes -I made to the linux sound code while merging it -back into the main tree. - -Note that neither John Carmack nor Dave Taylor -are responsible for the current sound handling. - - -\ No newline at end of file diff --git a/sndserv/linux.c b/sndserv/linux.c @@ -1,118 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static const char rcsid[] = "$Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $"; - - +#include <errno.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> - +#include <sys/ioctl.h> #include <linux/soundcard.h> - #include "soundsrv.h" - int audio_fd; - void -myioctl -( int fd, - int command, - int* arg ) +myioctl(int fd, int command, int* arg) { - int rc; - extern int errno; - + int rc; rc = ioctl(fd, command, arg); - if (rc < 0) - { - fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command); - fprintf(stderr, "errno=%d\n", errno); - exit(-1); + if (rc < 0) { + fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command); + fprintf(stderr, "errno=%d\n", errno); + exit(-1); } } - -void I_InitMusic(void) +void +I_InitMusic(void) { } - void -I_InitSound -( int samplerate, - int samplesize ) +I_InitSound(int samplerate, int samplesize) { - int i; - audio_fd = open("/dev/dsp", O_WRONLY); - if (audio_fd<0) - fprintf(stderr, "Could not open /dev/dsp\n"); - - - i = 11 | (2<<16); + if (audio_fd < 0) fprintf(stderr, "Could not open /dev/dsp\n"); + i = 11 | (2 << 16); myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); - myioctl(audio_fd, SNDCTL_DSP_RESET, 0); i=11025; myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); i=1; myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); - myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); - if (i&=AFMT_S16_LE) - myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); - else - fprintf(stderr, "Could not play signed 16 data\n"); - + if (i&=AFMT_S16_LE) myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); + else fprintf(stderr, "Could not play signed 16 data\n"); } - void -I_SubmitOutputBuffer -( void* samples, - int samplecount ) +I_SubmitOutputBuffer(void* samples, int samplecount) { write(audio_fd, samples, samplecount*4); } - -void I_ShutdownSound(void) +void +I_ShutdownSound(void) { - close(audio_fd); - } - -void I_ShutdownMusic(void) +void +I_ShutdownMusic(void) { } diff --git a/sndserv/sounds.c b/sndserv/sounds.c @@ -1,239 +1,184 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: sounds.c,v 1.3 1997/01/29 22:40:44 b1 Exp $"; - - - - -enum { false, true }; - #include "sounds.h" - - - - -musicinfo_t S_music[] = -{ - { 0 }, - { "e1m1", 0 }, - { "e1m2", 0 }, - { "e1m3", 0 }, - { "e1m4", 0 }, - { "e1m5", 0 }, - { "e1m6", 0 }, - { "e1m7", 0 }, - { "e1m8", 0 }, - { "e1m9", 0 }, - { "e2m1", 0 }, - { "e2m2", 0 }, - { "e2m3", 0 }, - { "e2m4", 0 }, - { "e2m5", 0 }, - { "e2m6", 0 }, - { "e2m7", 0 }, - { "e2m8", 0 }, - { "e2m9", 0 }, - { "e3m1", 0 }, - { "e3m2", 0 }, - { "e3m3", 0 }, - { "e3m4", 0 }, - { "e3m5", 0 }, - { "e3m6", 0 }, - { "e3m7", 0 }, - { "e3m8", 0 }, - { "e3m9", 0 }, - { "inter", 0 }, - { "intro", 0 }, - { "bunny", 0 }, - { "victor", 0 }, - { "introa", 0 }, - { "runnin", 0 }, - { "stalks", 0 }, - { "countd", 0 }, - { "betwee", 0 }, - { "doom", 0 }, - { "the_da", 0 }, - { "shawn", 0 }, - { "ddtblu", 0 }, - { "in_cit", 0 }, - { "dead", 0 }, - { "stlks2", 0 }, - { "theda2", 0 }, - { "doom2", 0 }, - { "ddtbl2", 0 }, - { "runni2", 0 }, - { "dead2", 0 }, - { "stlks3", 0 }, - { "romero", 0 }, - { "shawn2", 0 }, - { "messag", 0 }, - { "count2", 0 }, - { "ddtbl3", 0 }, - { "ampie", 0 }, - { "theda3", 0 }, - { "adrian", 0 }, - { "messg2", 0 }, - { "romer2", 0 }, - { "tense", 0 }, - { "shawn3", 0 }, - { "openin", 0 }, - { "evil", 0 }, - { "ultima", 0 }, - { "read_m", 0 }, - { "dm2ttl", 0 }, - { "dm2int", 0 } +enum { false, true }; +MusicInfo S_music[] = { + { 0 }, + { "e1m1", 0 }, + { "e1m2", 0 }, + { "e1m3", 0 }, + { "e1m4", 0 }, + { "e1m5", 0 }, + { "e1m6", 0 }, + { "e1m7", 0 }, + { "e1m8", 0 }, + { "e1m9", 0 }, + { "e2m1", 0 }, + { "e2m2", 0 }, + { "e2m3", 0 }, + { "e2m4", 0 }, + { "e2m5", 0 }, + { "e2m6", 0 }, + { "e2m7", 0 }, + { "e2m8", 0 }, + { "e2m9", 0 }, + { "e3m1", 0 }, + { "e3m2", 0 }, + { "e3m3", 0 }, + { "e3m4", 0 }, + { "e3m5", 0 }, + { "e3m6", 0 }, + { "e3m7", 0 }, + { "e3m8", 0 }, + { "e3m9", 0 }, + { "inter", 0 }, + { "intro", 0 }, + { "bunny", 0 }, + { "victor", 0 }, + { "introa", 0 }, + { "runnin", 0 }, + { "stalks", 0 }, + { "countd", 0 }, + { "betwee", 0 }, + { "doom", 0 }, + { "the_da", 0 }, + { "shawn", 0 }, + { "ddtblu", 0 }, + { "in_cit", 0 }, + { "dead", 0 }, + { "stlks2", 0 }, + { "theda2", 0 }, + { "doom2", 0 }, + { "ddtbl2", 0 }, + { "runni2", 0 }, + { "dead2", 0 }, + { "stlks3", 0 }, + { "romero", 0 }, + { "shawn2", 0 }, + { "messag", 0 }, + { "count2", 0 }, + { "ddtbl3", 0 }, + { "ampie", 0 }, + { "theda3", 0 }, + { "adrian", 0 }, + { "messg2", 0 }, + { "romer2", 0 }, + { "tense", 0 }, + { "shawn3", 0 }, + { "openin", 0 }, + { "evil", 0 }, + { "ultima", 0 }, + { "read_m", 0 }, + { "dm2ttl", 0 }, + { "dm2int", 0 } }; - - - - - - -sfxinfo_t S_sfx[] = -{ - { 0 }, - { "pistol", false, 64, 0, -1, -1, 0 }, - { "shotgn", false, 64, 0, -1, -1, 0 }, - { "sgcock", false, 64, 0, -1, -1, 0 }, - { "dshtgn", false, 64, 0, -1, -1, 0 }, - { "dbopn", false, 64, 0, -1, -1, 0 }, - { "dbcls", false, 64, 0, -1, -1, 0 }, - { "dbload", false, 64, 0, -1, -1, 0 }, - { "plasma", false, 64, 0, -1, -1, 0 }, - { "bfg", false, 64, 0, -1, -1, 0 }, - { "sawup", false, 64, 0, -1, -1, 0 }, - { "sawidl", false, 118, 0, -1, -1, 0 }, - { "sawful", false, 64, 0, -1, -1, 0 }, - { "sawhit", false, 64, 0, -1, -1, 0 }, - { "rlaunc", false, 64, 0, -1, -1, 0 }, - { "rxplod", false, 70, 0, -1, -1, 0 }, - { "firsht", false, 70, 0, -1, -1, 0 }, - { "firxpl", false, 70, 0, -1, -1, 0 }, - { "pstart", false, 100, 0, -1, -1, 0 }, - { "pstop", false, 100, 0, -1, -1, 0 }, - { "doropn", false, 100, 0, -1, -1, 0 }, - { "dorcls", false, 100, 0, -1, -1, 0 }, - { "stnmov", false, 119, 0, -1, -1, 0 }, - { "swtchn", false, 78, 0, -1, -1, 0 }, - { "swtchx", false, 78, 0, -1, -1, 0 }, - { "plpain", false, 96, 0, -1, -1, 0 }, - { "dmpain", false, 96, 0, -1, -1, 0 }, - { "popain", false, 96, 0, -1, -1, 0 }, - { "vipain", false, 96, 0, -1, -1, 0 }, - { "mnpain", false, 96, 0, -1, -1, 0 }, - { "pepain", false, 96, 0, -1, -1, 0 }, - { "slop", false, 78, 0, -1, -1, 0 }, - { "itemup", true, 78, 0, -1, -1, 0 }, - { "wpnup", true, 78, 0, -1, -1, 0 }, - { "oof", false, 96, 0, -1, -1, 0 }, - { "telept", false, 32, 0, -1, -1, 0 }, - { "posit1", true, 98, 0, -1, -1, 0 }, - { "posit2", true, 98, 0, -1, -1, 0 }, - { "posit3", true, 98, 0, -1, -1, 0 }, - { "bgsit1", true, 98, 0, -1, -1, 0 }, - { "bgsit2", true, 98, 0, -1, -1, 0 }, - { "sgtsit", true, 98, 0, -1, -1, 0 }, - { "cacsit", true, 98, 0, -1, -1, 0 }, - { "brssit", true, 94, 0, -1, -1, 0 }, - { "cybsit", true, 92, 0, -1, -1, 0 }, - { "spisit", true, 90, 0, -1, -1, 0 }, - { "bspsit", true, 90, 0, -1, -1, 0 }, - { "kntsit", true, 90, 0, -1, -1, 0 }, - { "vilsit", true, 90, 0, -1, -1, 0 }, - { "mansit", true, 90, 0, -1, -1, 0 }, - { "pesit", true, 90, 0, -1, -1, 0 }, - { "sklatk", false, 70, 0, -1, -1, 0 }, - { "sgtatk", false, 70, 0, -1, -1, 0 }, - { "skepch", false, 70, 0, -1, -1, 0 }, - { "vilatk", false, 70, 0, -1, -1, 0 }, - { "claw", false, 70, 0, -1, -1, 0 }, - { "skeswg", false, 70, 0, -1, -1, 0 }, - { "pldeth", false, 32, 0, -1, -1, 0 }, - { "pdiehi", false, 32, 0, -1, -1, 0 }, - { "podth1", false, 70, 0, -1, -1, 0 }, - { "podth2", false, 70, 0, -1, -1, 0 }, - { "podth3", false, 70, 0, -1, -1, 0 }, - { "bgdth1", false, 70, 0, -1, -1, 0 }, - { "bgdth2", false, 70, 0, -1, -1, 0 }, - { "sgtdth", false, 70, 0, -1, -1, 0 }, - { "cacdth", false, 70, 0, -1, -1, 0 }, - { "skldth", false, 70, 0, -1, -1, 0 }, - { "brsdth", false, 32, 0, -1, -1, 0 }, - { "cybdth", false, 32, 0, -1, -1, 0 }, - { "spidth", false, 32, 0, -1, -1, 0 }, - { "bspdth", false, 32, 0, -1, -1, 0 }, - { "vildth", false, 32, 0, -1, -1, 0 }, - { "kntdth", false, 32, 0, -1, -1, 0 }, - { "pedth", false, 32, 0, -1, -1, 0 }, - { "skedth", false, 32, 0, -1, -1, 0 }, - { "posact", true, 120, 0, -1, -1, 0 }, - { "bgact", true, 120, 0, -1, -1, 0 }, - { "dmact", true, 120, 0, -1, -1, 0 }, - { "bspact", true, 100, 0, -1, -1, 0 }, - { "bspwlk", true, 100, 0, -1, -1, 0 }, - { "vilact", true, 100, 0, -1, -1, 0 }, - { "noway", false, 78, 0, -1, -1, 0 }, - { "barexp", false, 60, 0, -1, -1, 0 }, - { "punch", false, 64, 0, -1, -1, 0 }, - { "hoof", false, 70, 0, -1, -1, 0 }, - { "metal", false, 70, 0, -1, -1, 0 }, - { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, - { "tink", false, 60, 0, -1, -1, 0 }, - { "bdopn", false, 100, 0, -1, -1, 0 }, - { "bdcls", false, 100, 0, -1, -1, 0 }, - { "itmbk", false, 100, 0, -1, -1, 0 }, - { "flame", false, 32, 0, -1, -1, 0 }, - { "flamst", false, 32, 0, -1, -1, 0 }, - { "getpow", false, 60, 0, -1, -1, 0 }, - { "bospit", false, 70, 0, -1, -1, 0 }, - { "boscub", false, 70, 0, -1, -1, 0 }, - { "bossit", false, 70, 0, -1, -1, 0 }, - { "bospn", false, 70, 0, -1, -1, 0 }, - { "bosdth", false, 70, 0, -1, -1, 0 }, - { "manatk", false, 70, 0, -1, -1, 0 }, - { "mandth", false, 70, 0, -1, -1, 0 }, - { "sssit", false, 70, 0, -1, -1, 0 }, - { "ssdth", false, 70, 0, -1, -1, 0 }, - { "keenpn", false, 70, 0, -1, -1, 0 }, - { "keendt", false, 70, 0, -1, -1, 0 }, - { "skeact", false, 70, 0, -1, -1, 0 }, - { "skesit", false, 70, 0, -1, -1, 0 }, - { "skeatk", false, 70, 0, -1, -1, 0 }, - { "radio", false, 60, 0, -1, -1, 0 } +SfxInfo S_sfx[] = { + { 0 }, + { "pistol", false, 64, 0, -1, -1, 0 }, + { "shotgn", false, 64, 0, -1, -1, 0 }, + { "sgcock", false, 64, 0, -1, -1, 0 }, + { "dshtgn", false, 64, 0, -1, -1, 0 }, + { "dbopn", false, 64, 0, -1, -1, 0 }, + { "dbcls", false, 64, 0, -1, -1, 0 }, + { "dbload", false, 64, 0, -1, -1, 0 }, + { "plasma", false, 64, 0, -1, -1, 0 }, + { "bfg", false, 64, 0, -1, -1, 0 }, + { "sawup", false, 64, 0, -1, -1, 0 }, + { "sawidl", false, 118, 0, -1, -1, 0 }, + { "sawful", false, 64, 0, -1, -1, 0 }, + { "sawhit", false, 64, 0, -1, -1, 0 }, + { "rlaunc", false, 64, 0, -1, -1, 0 }, + { "rxplod", false, 70, 0, -1, -1, 0 }, + { "firsht", false, 70, 0, -1, -1, 0 }, + { "firxpl", false, 70, 0, -1, -1, 0 }, + { "pstart", false, 100, 0, -1, -1, 0 }, + { "pstop", false, 100, 0, -1, -1, 0 }, + { "doropn", false, 100, 0, -1, -1, 0 }, + { "dorcls", false, 100, 0, -1, -1, 0 }, + { "stnmov", false, 119, 0, -1, -1, 0 }, + { "swtchn", false, 78, 0, -1, -1, 0 }, + { "swtchx", false, 78, 0, -1, -1, 0 }, + { "plpain", false, 96, 0, -1, -1, 0 }, + { "dmpain", false, 96, 0, -1, -1, 0 }, + { "popain", false, 96, 0, -1, -1, 0 }, + { "vipain", false, 96, 0, -1, -1, 0 }, + { "mnpain", false, 96, 0, -1, -1, 0 }, + { "pepain", false, 96, 0, -1, -1, 0 }, + { "slop", false, 78, 0, -1, -1, 0 }, + { "itemup", true, 78, 0, -1, -1, 0 }, + { "wpnup", true, 78, 0, -1, -1, 0 }, + { "oof", false, 96, 0, -1, -1, 0 }, + { "telept", false, 32, 0, -1, -1, 0 }, + { "posit1", true, 98, 0, -1, -1, 0 }, + { "posit2", true, 98, 0, -1, -1, 0 }, + { "posit3", true, 98, 0, -1, -1, 0 }, + { "bgsit1", true, 98, 0, -1, -1, 0 }, + { "bgsit2", true, 98, 0, -1, -1, 0 }, + { "sgtsit", true, 98, 0, -1, -1, 0 }, + { "cacsit", true, 98, 0, -1, -1, 0 }, + { "brssit", true, 94, 0, -1, -1, 0 }, + { "cybsit", true, 92, 0, -1, -1, 0 }, + { "spisit", true, 90, 0, -1, -1, 0 }, + { "bspsit", true, 90, 0, -1, -1, 0 }, + { "kntsit", true, 90, 0, -1, -1, 0 }, + { "vilsit", true, 90, 0, -1, -1, 0 }, + { "mansit", true, 90, 0, -1, -1, 0 }, + { "pesit", true, 90, 0, -1, -1, 0 }, + { "sklatk", false, 70, 0, -1, -1, 0 }, + { "sgtatk", false, 70, 0, -1, -1, 0 }, + { "skepch", false, 70, 0, -1, -1, 0 }, + { "vilatk", false, 70, 0, -1, -1, 0 }, + { "claw", false, 70, 0, -1, -1, 0 }, + { "skeswg", false, 70, 0, -1, -1, 0 }, + { "pldeth", false, 32, 0, -1, -1, 0 }, + { "pdiehi", false, 32, 0, -1, -1, 0 }, + { "podth1", false, 70, 0, -1, -1, 0 }, + { "podth2", false, 70, 0, -1, -1, 0 }, + { "podth3", false, 70, 0, -1, -1, 0 }, + { "bgdth1", false, 70, 0, -1, -1, 0 }, + { "bgdth2", false, 70, 0, -1, -1, 0 }, + { "sgtdth", false, 70, 0, -1, -1, 0 }, + { "cacdth", false, 70, 0, -1, -1, 0 }, + { "skldth", false, 70, 0, -1, -1, 0 }, + { "brsdth", false, 32, 0, -1, -1, 0 }, + { "cybdth", false, 32, 0, -1, -1, 0 }, + { "spidth", false, 32, 0, -1, -1, 0 }, + { "bspdth", false, 32, 0, -1, -1, 0 }, + { "vildth", false, 32, 0, -1, -1, 0 }, + { "kntdth", false, 32, 0, -1, -1, 0 }, + { "pedth", false, 32, 0, -1, -1, 0 }, + { "skedth", false, 32, 0, -1, -1, 0 }, + { "posact", true, 120, 0, -1, -1, 0 }, + { "bgact", true, 120, 0, -1, -1, 0 }, + { "dmact", true, 120, 0, -1, -1, 0 }, + { "bspact", true, 100, 0, -1, -1, 0 }, + { "bspwlk", true, 100, 0, -1, -1, 0 }, + { "vilact", true, 100, 0, -1, -1, 0 }, + { "noway", false, 78, 0, -1, -1, 0 }, + { "barexp", false, 60, 0, -1, -1, 0 }, + { "punch", false, 64, 0, -1, -1, 0 }, + { "hoof", false, 70, 0, -1, -1, 0 }, + { "metal", false, 70, 0, -1, -1, 0 }, + { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 }, + { "tink", false, 60, 0, -1, -1, 0 }, + { "bdopn", false, 100, 0, -1, -1, 0 }, + { "bdcls", false, 100, 0, -1, -1, 0 }, + { "itmbk", false, 100, 0, -1, -1, 0 }, + { "flame", false, 32, 0, -1, -1, 0 }, + { "flamst", false, 32, 0, -1, -1, 0 }, + { "getpow", false, 60, 0, -1, -1, 0 }, + { "bospit", false, 70, 0, -1, -1, 0 }, + { "boscub", false, 70, 0, -1, -1, 0 }, + { "bossit", false, 70, 0, -1, -1, 0 }, + { "bospn", false, 70, 0, -1, -1, 0 }, + { "bosdth", false, 70, 0, -1, -1, 0 }, + { "manatk", false, 70, 0, -1, -1, 0 }, + { "mandth", false, 70, 0, -1, -1, 0 }, + { "sssit", false, 70, 0, -1, -1, 0 }, + { "ssdth", false, 70, 0, -1, -1, 0 }, + { "keenpn", false, 70, 0, -1, -1, 0 }, + { "keendt", false, 70, 0, -1, -1, 0 }, + { "skeact", false, 70, 0, -1, -1, 0 }, + { "skesit", false, 70, 0, -1, -1, 0 }, + { "skeatk", false, 70, 0, -1, -1, 0 }, + { "radio", false, 60, 0, -1, -1, 0 } }; - diff --git a/sndserv/sounds.h b/sndserv/sounds.h @@ -1,49 +1,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __SOUNDSH__ -#define __SOUNDSH__ - -#include "soundst.h" - - - - - -typedef enum -{ +#define S_MAX_VOLUME 127 +#define S_CLIPPING_DIST (1200*0x10000) +#define S_CLOSE_DIST (200*0x10000) +#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) +#define NORM_PITCH 128 +#define NORM_PRIORITY 64 +#define NORM_VOLUME snd_MaxVolume +#define S_PITCH_PERTURB 1 +#define NORM_SEP 128 +#define S_STEREO_SWING (96*0x10000) +#define S_IFRACVOL 30 +#define NA 0 +#define S_NUMCHANNELS 2 +#define FREQ_LOW 0x40 +#define FREQ_NORM 0x80 +#define FREQ_HIGH 0xff +typedef struct MusicInfo MusicInfo; +typedef struct SfxInfo SfxInfo; +typedef struct Channel Channel; +typedef enum MusicEnum MusicEnum; +typedef enum SfxEnum SfxEnum; +struct MusicInfo { + char* name; /*up to 6 chars*/ + long lumpnum; + void* data; + long handle; +}; +struct SfxInfo { + char* name; /*up to 6*/ + int singularity; + int priority; + SfxInfo* link; + int pitch; + int volume; + void* data; + int usefulness; + int lumpnum; +}; +struct Channel { + SfxInfo* sfxinfo; + void* origin; + int handle; +}; +enum { + Music, + Sfx, + SfxLink +}; +enum { + PC = 1, + Adlib = 2, + SB = 4, + Midi = 8 +}; +enum { + sfxThrowOut = -1, + sfxNotUsed = 0 +}; +void S_Init(int, int); +void S_Start(); +void S_Pause(); +void S_Resume(); +void S_SetMusicVolume(int volume); +void S_SetSfxVolume(int volume); +extern void S_StartSound(void* origin, int sound_id); +extern void S_StartSoundAtVolume(void* origin, int sound_id, int volume); +extern void S_StopSound(void* origin); +extern void S_StartMusic(int music_id); +extern void S_ChangeMusic(int music_id, int looping); +extern void S_StopMusic(); +extern void S_UpdateSounds(void* listener); +void I_SetMusicVolume(int volume); +void I_SetSfxVolume(int volume); +void I_PauseSong(int handle); +void I_ResumeSong(int handle); +void I_PlaySong(int handle, int looping); +void I_StopSong(int handle); +int I_RegisterSong(void *data); +void I_UnRegisterSong(int handle); +int I_IsSongPlaying(int handle); +void I_SetChannels(int channels); +int I_GetSfxLumpNum (SfxInfo*); +int I_StartSound(int id, void* data, int vol, int sep, int pitch, int priority); +void I_UpdateSoundParams(int handle, int vol, int sep, int pitch); +void I_StopSound(int handle); +int I_IsSoundPlaying(int handle); +enum MusicEnum { mus_None, mus_e1m1, mus_e1m2, @@ -112,16 +153,9 @@ typedef enum mus_read_m, mus_dm2ttl, mus_dm2int, - NUMMUSIC -} musicenum_t; - - - - - - -typedef enum -{ + MUS_COUNT +}; +enum SfxEnum { sfx_None, sfx_pistol, sfx_shotgn, @@ -232,10 +266,6 @@ typedef enum sfx_skeatk, sfx_radio, NUMSFX -} sfxenum_t; - -extern musicinfo_t S_music[]; -extern sfxinfo_t S_sfx[]; - -#endif - +}; +extern SfxInfo S_sfx[]; +extern MusicInfo S_music[]; diff --git a/sndserv/soundsrv.c b/sndserv/soundsrv.c @@ -1,46 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $"; - - - -#include <math.h> +#define LENGTH(x) (sizeof(x)/sizeof(x[0])) +#include <string.h> #include <sys/types.h> #include <stdio.h> #include <fcntl.h> @@ -50,121 +9,66 @@ static const char rcsid[] = "$Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $" #include <malloc.h> #include <sys/stat.h> #include <sys/time.h> - #include "sounds.h" #include "soundsrv.h" -#include "wadread.h" - - - - - typedef struct wadinfo_struct { - char identification[4]; int numlumps; int infotableofs; - } wadinfo_t; - typedef struct filelump_struct { int filepos; int size; char name[8]; - } filelump_t; - - static int mytime = 0; - - int numsounds; - - int longsound; - - int lengths[NUMSFX]; - - signed short mixbuffer[MIXBUFFERSIZE]; - - int sfxdevice; - - int musdevice; - - unsigned char* channels[8]; - - unsigned int channelstep[8]; - - unsigned int channelstepremainder[8]; - - unsigned char* channelsend[8]; - - int channelstart[8]; - - int channelhandles[8]; - - int* channelleftvol_lookup[8]; - - int* channelrightvol_lookup[8]; - - int channelids[8]; - int snd_verbose=1; - -int steptable[256]; - +int steptable[256] = { +16384, 16562, 16742, 16925, 17109, 17295, 17484, 17674, 17866, 18061, 18258, 18456, 18657, 18861, 19066, 19274, 19483, 19696, 19910, 20127, 20346, 20568, 20792, 21018, 21247, 21478, 21712, 21949, 22188, 22429, 22673, 22920, 23170, 23422, 23677, 23935, 24196, 24459, 24726, 24995, 25267, 25542, 25820, 26102, 26386, 26673, 26964, 27257, 27554, 27854, 28157, 28464, 28774, 29087, 29404, 29724, 30048, 30375, 30706, 31040, 31378, 31720, 32065, 32415, 32768, 33124, 33485, 33850, 34218, 34591, 34968, 35348, 35733, 36122, 36516, 36913, 37315, 37722, 38132, 38548, 38967, 39392, 39821, 40254, 40693, 41136, 41584, 42037, 42494, 42957, 43425, 43898, 44376, 44859, 45347, 45841, 46340, 46845, 47355, 47871, 48392, 48919, 49452, 49990, 50535, 51085, 51641, 52204, 52772, 53347, 53928, 54515, 55108, 55709, 56315, 56928, 57548, 58175, 58809, 59449, 60096, 60751, 61412, 62081, 62757, 63440, 64131, 64830, 65536, 66249, 66971, 67700, 68437, 69182, 69936, 70697, 71467, 72245, 73032, 73827, 74631, 75444, 76265, 77096, 77935, 78784, 79642, 80509, 81386, 82272, 83168, 84074, 84989, 85915, 86850, 87796, 88752, 89718, 90695, 91683, 92681, 93691, 94711, 95742, 96785, 97839, 98904, 99981, 101070, 102170, 103283, 104408, 105545, 106694, 107856, 109030, 110217, 111418, 112631, 113857, 115097, 116351, 117618, 118898, 120193, 121502, 122825, 124162, 125514, 126881, 128263, 129660, 131072, 132499, 133942, 135400, 136875, 138365, 139872, 141395, 142935, 144491, 146064, 147655, 149263, 150888, 152531, 154192, 155871, 157569, 159284, 161019, 162772, 164545, 166337, 168148, 169979, 171830, 173701, 175592, 177504, 179437, 181391, 183367, 185363, 187382, 189422, 191485, 193570, 195678, 197809, 199963, 202140, 204341, 206566, 208816, 211090, 213388, 215712, 218061, 220435, 222836, 225262, 227715, 230195, 232702, 235236, 237797, 240387, 243004, 245650, 248325, 251029, 253763, 256526, 259320 +}; int vol_lookup[128*256]; - static void derror(char* msg) { fprintf(stderr, "error: %s\n", msg); exit(-1); } - int mix(void) { - register int dl; register int dr; register unsigned int sample; - signed short* leftout; signed short* rightout; signed short* leftend; - int step; - leftout = mixbuffer; rightout = mixbuffer+1; step = 2; - leftend = mixbuffer + SAMPLECOUNT*step; - - while (leftout != leftend) { - dl = 0; dr = 0; - if (channels[0]) { sample = *channels[0]; @@ -173,11 +77,9 @@ int mix(void) channelstepremainder[0] += channelstep[0]; channels[0] += channelstepremainder[0] >> 16; channelstepremainder[0] &= 65536-1; - if (channels[0] >= channelsend[0]) channels[0] = 0; } - if (channels[1]) { sample = *channels[1]; @@ -186,11 +88,9 @@ int mix(void) channelstepremainder[1] += channelstep[1]; channels[1] += channelstepremainder[1] >> 16; channelstepremainder[1] &= 65536-1; - if (channels[1] >= channelsend[1]) channels[1] = 0; } - if (channels[2]) { sample = *channels[2]; @@ -199,7 +99,6 @@ int mix(void) channelstepremainder[2] += channelstep[2]; channels[2] += channelstepremainder[2] >> 16; channelstepremainder[2] &= 65536-1; - if (channels[2] >= channelsend[2]) channels[2] = 0; } @@ -212,7 +111,6 @@ int mix(void) channelstepremainder[3] += channelstep[3]; channels[3] += channelstepremainder[3] >> 16; channelstepremainder[3] &= 65536-1; - if (channels[3] >= channelsend[3]) channels[3] = 0; } @@ -225,7 +123,6 @@ int mix(void) channelstepremainder[4] += channelstep[4]; channels[4] += channelstepremainder[4] >> 16; channelstepremainder[4] &= 65536-1; - if (channels[4] >= channelsend[4]) channels[4] = 0; } @@ -238,7 +135,6 @@ int mix(void) channelstepremainder[5] += channelstep[5]; channels[5] += channelstepremainder[5] >> 16; channelstepremainder[5] &= 65536-1; - if (channels[5] >= channelsend[5]) channels[5] = 0; } @@ -251,7 +147,6 @@ int mix(void) channelstepremainder[6] += channelstep[6]; channels[6] += channelstepremainder[6] >> 16; channelstepremainder[6] &= 65536-1; - if (channels[6] >= channelsend[6]) channels[6] = 0; } @@ -263,16 +158,13 @@ int mix(void) channelstepremainder[7] += channelstep[7]; channels[7] += channelstepremainder[7] >> 16; channelstepremainder[7] &= 65536-1; - if (channels[7] >= channelsend[7]) channels[7] = 0; } - - @@ -283,25 +175,21 @@ int mix(void) *leftout = -0x8000; else *leftout = dl; - if (dr > 0x7fff) *rightout = 0x7fff; else if (dr < -0x8000) *rightout = -0x8000; else *rightout = dr; - leftout += step; rightout += step; - } return 1; } - - - void -grabdata(int argc, char** argv) +grabdata +( int c, + char** v ) { int i; char* name; @@ -310,48 +198,29 @@ grabdata(int argc, char** argv) char* doomuwad; char* doom2wad; char* doom2fwad; - - - char* doomwaddir; - doomwaddir = getenv("DOOMWADDIR"); - if (!doomwaddir) doomwaddir = "."; - doom1wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom1wad, "%s/doom1.wad", doomwaddir); - doom2wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom2wad, "%s/doom2.wad", doomwaddir); - doom2fwad = malloc(strlen(doomwaddir)+1+10+1); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - doomuwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomuwad, "%s/doomu.wad", doomwaddir); - doomwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomwad, "%s/doom.wad", doomwaddir); - - - - - - - - for (i=1 ; i<argc ; i++) + for (i=1 ; i<c ; i++) { - if (!strcmp(argv[i], "-quiet")) + if (!strcmp(v[i], "-quiet")) { snd_verbose = 0; } } - numsounds = NUMSFX; longsound = 0; - if (! access(doom2fwad, R_OK) ) name = doom2fwad; else if (! access(doom2wad, R_OK) ) @@ -362,21 +231,14 @@ grabdata(int argc, char** argv) name = doomwad; else if (! access(doom1wad, R_OK) ) name = doom1wad; - - - - else { fprintf(stderr, "Could not find wadfile anywhere\n"); exit(-1); } - - openwad(name); if (snd_verbose) fprintf(stderr, "loading from [%s]\n", name); - for (i=1 ; i<NUMSFX ; i++) { if (!S_sfx[i].link) @@ -385,7 +247,7 @@ grabdata(int argc, char** argv) if (longsound < lengths[i]) longsound = lengths[i]; } else { S_sfx[i].data = S_sfx[i].link->data; - lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)]; + lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(SfxInfo)]; } @@ -397,22 +259,12 @@ grabdata(int argc, char** argv) } - } - -static struct timeval last={0,0}; - - -static struct timezone whocares; - void updatesounds(void) { - mix(); I_SubmitOutputBuffer(mixbuffer, SAMPLECOUNT); - } - int addsfx ( int sfxid, @@ -421,18 +273,13 @@ addsfx int seperation ) { static unsigned short handlenums = 0; - int i; int rc = -1; - int oldest = mytime; int oldestnum = 0; int slot; int rightvol; int leftvol; - - - if ( sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful @@ -449,7 +296,6 @@ addsfx } } } - for (i=0 ; i<8 && channels[i] ; i++) { if (channelstart[i] < oldest) @@ -458,62 +304,37 @@ addsfx oldest = channelstart[i]; } } - if (i == 8) slot = oldestnum; else slot = i; - channels[slot] = (unsigned char *) S_sfx[sfxid].data; channelsend[slot] = channels[slot] + lengths[sfxid]; - if (!handlenums) handlenums = 100; - channelhandles[slot] = rc = handlenums++; channelstep[slot] = step; channelstepremainder[slot] = 0; channelstart[slot] = mytime; - - seperation += 1; - - leftvol = volume - (volume*seperation*seperation)/(256*256); - seperation = seperation - 257; - - rightvol = volume - (volume*seperation*seperation)/(256*256); - - if (rightvol < 0 || rightvol > 127) derror("rightvol out of bounds"); - if (leftvol < 0 || leftvol > 127) derror("leftvol out of bounds"); - - - channelleftvol_lookup[slot] = &vol_lookup[leftvol*256]; channelrightvol_lookup[slot] = &vol_lookup[rightvol*256]; - channelids[slot] = sfxid; - return rc; - } - - void outputushort(int num) { - static unsigned char buff[5] = { 0, 0, 0, 0, '\n' }; static char* badbuff = "xxxx\n"; - - if (num < 0) { write(1, badbuff, 5); @@ -531,109 +352,62 @@ void outputushort(int num) write(1, buff, 5); } } - void initdata(void) { - - int i; - int j; - - int* steptablemid = steptable + 128; - - for (i=0 ; - i<sizeof(channels)/sizeof(unsigned char *) ; - i++) - { - channels[i] = 0; - } - - gettimeofday(&last, &whocares); - - for (i=-128 ; i<128 ; i++) - steptablemid[i] = pow(2.0, (i/64.0))*65536.0; - - - - - - - - - for (i=0 ; i<128 ; i++) - for (j=0 ; j<256 ; j++) - vol_lookup[i*256+j] = (i*(j-128)*256)/127; - + int i, j; + int* steptablemid; + steptablemid = steptable + 128; + for (i = 0 ; i < LENGTH(channels); ++i) + channels[i] = 0; + for (i = 0; i < 128; ++i) + for (j=0 ; j<256 ; j++) + vol_lookup[i*256+j] = (i*(j-128)*256)/127; } - - - - void quit(void) { I_ShutdownMusic(); I_ShutdownSound(); exit(0); } - - - fd_set fdset; fd_set scratchset; - - int -main(int argc, char** argv) +main(int c, char** v) { int done = 0; int rc; int nrc; int sndnum; int handle = 0; - unsigned char commandbuf[10]; struct timeval zerowait = { 0, 0 }; - int step; int vol; int sep; - int i; int waitingtofinish=0; - - - grabdata(argc, argv); - - + grabdata(c, v); initdata(); - I_InitSound(11025, 16); - I_InitMusic(); - if (snd_verbose) fprintf(stderr, "ready\n"); - - FD_ZERO(&fdset); FD_SET(0, &fdset); - while (!done) { mytime++; - if (!waitingtofinish) { do { scratchset = fdset; rc = select(FD_SETSIZE, &scratchset, 0, 0, &zerowait); - if (rc > 0) { nrc = read(0, commandbuf, 1); - if (!nrc) { done = 1; @@ -642,20 +416,17 @@ main(int argc, char** argv) else { if (snd_verbose) - fprintf(stderr, "cmd: %argc", commandbuf[0]); - + fprintf(stderr, "cmd: %c", commandbuf[0]); switch (commandbuf[0]) { case 'p': read(0, commandbuf, 9); - if (snd_verbose) { commandbuf[9]=0; fprintf(stderr, "%s\n", commandbuf); } - commandbuf[0] -= commandbuf[0]>='a' ? 'a'-10 : '0'; commandbuf[1] -= @@ -672,14 +443,12 @@ main(int argc, char** argv) commandbuf[6]>='a' ? 'a'-10 : '0'; commandbuf[7] -= commandbuf[7]>='a' ? 'a'-10 : '0'; - sndnum = (commandbuf[0]<<4) + commandbuf[1]; step = (commandbuf[2]<<4) + commandbuf[3]; step = steptable[step]; vol = (commandbuf[4]<<4) + commandbuf[5]; sep = (commandbuf[6]<<4) + commandbuf[7]; - handle = addsfx(sndnum, vol, step, sep); @@ -716,9 +485,7 @@ main(int argc, char** argv) } } while (rc > 0); } - updatesounds(); - if (waitingtofinish) { for(i=0 ; i<8 && !channels[i] ; i++); @@ -726,9 +493,7 @@ main(int argc, char** argv) if (i==8) done=1; } - } - quit(); return 0; } diff --git a/sndserv/soundsrv.h b/sndserv/soundsrv.h @@ -1,58 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __SNDSERVER_H__ #define __SNDSERVER_H__ - #define SAMPLECOUNT 512 #define MIXBUFFERSIZE (SAMPLECOUNT*2*2) #define SPEED 11025 - - -void I_InitMusic(void); - -void -I_InitSound -( int samplerate, - int samplesound ); - -void -I_SubmitOutputBuffer -( void* samples, - int samplecount ); - -void I_ShutdownSound(void); -void I_ShutdownMusic(void); - +void I_InitMusic(); +void I_InitSound(int samplerate, int samplesound); +void I_SubmitOutputBuffer(void* samples, int samplecount); +void I_ShutdownSound(); +void I_ShutdownMusic(); +extern void openwad(char* wadname); +extern void* getsfx(char* sfxname, int* len); #endif diff --git a/sndserv/soundst.h b/sndserv/soundst.h @@ -1,312 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __SOUNDSTH__ -#define __SOUNDSTH__ - -#define S_MAX_VOLUME 127 - - - -#define S_CLIPPING_DIST (1200*0x10000) - - -#define S_CLOSE_DIST (200*0x10000) - - -#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) - -#define NORM_PITCH 128 -#define NORM_PRIORITY 64 -#define NORM_VOLUME snd_MaxVolume - -#define S_PITCH_PERTURB 1 -#define NORM_SEP 128 -#define S_STEREO_SWING (96*0x10000) - - -#define S_IFRACVOL 30 - -#define NA 0 -#define S_NUMCHANNELS 2 - - - - - - - -typedef struct -{ - - char* name; - - - int lumpnum; - - - void* data; - - - int handle; - -} musicinfo_t; - - - - - - -typedef struct sfxinfo_struct sfxinfo_t; - -struct sfxinfo_struct -{ - - char* name; - - - int singularity; - - - int priority; - - - sfxinfo_t* link; - - - int pitch; - - - int volume; - - - void* data; - - - - - int usefulness; - - - int lumpnum; -}; - - - -typedef struct -{ - - sfxinfo_t* sfxinfo; - - - void* origin; - - - int handle; - -} channel_t; - - - -enum -{ - Music, - Sfx, - SfxLink -}; - -enum -{ - PC=1, - Adlib=2, - SB=4, - Midi=8 -}; - -enum -{ - sfxThrowOut=-1, - sfxNotUsed=0 -}; - - - - - -void S_Start(void); - - - - - -extern void -S_StartSound -( void* origin, - int sound_id ); - - - - -extern void -S_StartSoundAtVolume -( void* origin, - int sound_id, - int volume ); - - - -extern void S_StopSound(void* origin); - - -extern void S_StartMusic(int music_id); - - - -extern void -S_ChangeMusic -( int music_id, - int looping ); - - - -extern void S_StopMusic(void); - -void S_PauseSound(void); -void S_ResumeSound(void); - - - - - -extern void S_UpdateSounds(void* listener); - -void S_SetMusicVolume(int volume); -void S_SetSfxVolume(int volume); - - - - -void -S_Init -( int , - int ); - - - - - - -#define FREQ_LOW 0x40 -#define FREQ_NORM 0x80 -#define FREQ_HIGH 0xff - - -void I_SetMusicVolume(int volume); -void I_SetSfxVolume(int volume); - - - - -void I_PauseSong(int handle); -void I_ResumeSong(int handle); - - - - - - -void -I_PlaySong -( int handle, - int looping ); - - - -void I_StopSong(int handle); - - -int I_RegisterSong(void *data); - - -void I_UnRegisterSong(int handle); - - -int I_QrySongPlaying(int handle); - - - - - -void I_SetChannels(int channels); - -int I_GetSfxLumpNum (sfxinfo_t*); - - - -int -I_StartSound -( int id, - void* data, - int vol, - int sep, - int pitch, - int priority ); - - - - -void -I_UpdateSoundParams -( int handle, - int vol, - int sep, - int pitch ); - - - -void I_StopSound(int handle); - - - -int I_SoundIsPlaying(int handle); - - - -extern sfxinfo_t S_sfx[]; - - -extern musicinfo_t S_music[]; - -#endif diff --git a/sndserv/wadread.c b/sndserv/wadread.c @@ -1,45 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static const char rcsid[] = "$Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $"; - - - -#include <malloc.h> #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> @@ -47,64 +5,35 @@ static const char rcsid[] = "$Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $"; #include <stdlib.h> #include <ctype.h> #include <unistd.h> - #include "soundsrv.h" -#include "wadread.h" - - -int* sfxlengths; - -typedef struct wadinfo_struct -{ - char identification[4]; - int numlumps; - int infotableofs; - +int* sfxlengths; +typedef struct wadinfo_struct { + char identification[4]; + int numlumps; + int infotableofs; } wadinfo_t; - -typedef struct filelump_struct -{ - int filepos; - int size; - char name[8]; - +typedef struct filelump_struct { + int filepos; + int size; + char name[8]; } filelump_t; - -typedef struct lumpinfo_struct -{ - int handle; - int filepos; - int size; - char name[8]; - +typedef struct lumpinfo_struct { + int handle; + int filepos; + int size; + char name[8]; } lumpinfo_t; - - - -lumpinfo_t* lumpinfo; -int numlumps; - -void** lumpcache; - - +lumpinfo_t* lumpinfo; +int numlumps; +void** lumpcache; #define strcmpi strcasecmp - - - - - - #ifndef __BIG_ENDIAN__ - #define LONG(x) (x) #define SHORT(x) (x) - #else - #define LONG(x) ((long)SwapLONG((unsigned long) (x))) #define SHORT(x) ((short)SwapSHORT((unsigned short) (x))) - -unsigned long SwapLONG(unsigned long x) +ulong SwapLONG(unsigned long x) { return (x>>24) @@ -112,46 +41,31 @@ unsigned long SwapLONG(unsigned long x) | ((x<<8) & 0xff0000) | (x<<24); } - unsigned short SwapSHORT(unsigned short x) { return (x>>8) | (x<<8); } - #endif - - - - static void derror(char* msg) { fprintf(stderr, "\nwadread error: %s\n", msg); exit(-1); } - - void strupr (char *s) { while (*s) *s++ = toupper(*s); } - int filelength (int handle) { struct stat fileinfo; - if (fstat (handle,&fileinfo) == -1) fprintf (stderr, "Error fstating\n"); - return fileinfo.st_size; } - - - void openwad(char* wadname) { - int wadfile; int tableoffset; int tablelength; @@ -159,30 +73,20 @@ void openwad(char* wadname) int i; wadinfo_t header; filelump_t* filetable; - - wadfile = open(wadname, O_RDONLY); - if (wadfile < 0) derror("Could not open wadfile"); - read(wadfile, &header, sizeof header); - if (strncmp(header.identification, "IWAD", 4)) derror("wadfile has weirdo header"); - numlumps = LONG(header.numlumps); tableoffset = LONG(header.infotableofs); tablelength = numlumps * sizeof(lumpinfo_t); tablefilelength = numlumps * sizeof(filelump_t); lumpinfo = (lumpinfo_t *) malloc(tablelength); filetable = (filelump_t *) ((char*)lumpinfo + tablelength - tablefilelength); - - lseek(wadfile, tableoffset, SEEK_SET); read(wadfile, filetable, tablefilelength); - - for (i=0 ; i<numlumps ; i++) { strncpy(lumpinfo[i].name, filetable[i].name, 8); @@ -191,24 +95,19 @@ void openwad(char* wadname) lumpinfo[i].size = LONG(filetable[i].size); } - } - void* loadlump ( char* lumpname, int* size ) { - int i; void* lump; - for (i=0 ; i<numlumps ; i++) { if (!strncasecmp(lumpinfo[i].name, lumpname, 8)) break; } - if (i == numlumps) { @@ -222,35 +121,25 @@ loadlump read(lumpinfo[i].handle, lump, lumpinfo[i].size); *size = lumpinfo[i].size; } - return lump; - } - void* getsfx ( char* sfxname, int* len ) { - unsigned char* sfx; unsigned char* paddedsfx; int i; int size; int paddedsize; char name[20]; - sprintf(name, "ds%s", sfxname); - sfx = (unsigned char *) loadlump(name, &size); - - paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT; paddedsfx = (unsigned char *) realloc(sfx, paddedsize+8); for (i=size ; i<paddedsize+8 ; i++) paddedsfx[i] = 128; - *len = paddedsize; return (void *) (paddedsfx + 8); - } diff --git a/sndserv/wadread.h b/sndserv/wadread.h @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef __WADREAD_H__ -#define __WADREAD_H__ - - - - - - -void openwad(char* wadname); - - - - - - - - - -void* -getsfx -( char* sfxname, - int* len ); - -#endif diff --git a/src/Makefile b/src/Makefile @@ -1,75 +1,79 @@ CC = c89 CFLAGS = -g -Wall -Wpedantic -D_DEFAULT_SOURCE -Wno-deprecated-declarations -LIBS = -lXext -lX11 -lnsl -lm +LIBS = -lXext -lX11 -lm LDFLAGS = ${LIBS} -L/usr/X11R6/lib -SRC = am_map.c \ - d_items.c \ - d_main.c \ - d_net.c \ - doomstat.c \ - dstrings.c \ - f_finale.c \ - f_wipe.c \ - g_game.c \ - hu_lib.c \ - hu_stuff.c \ - i_main.c \ - i_net.c \ - i_sound.c \ + +SRC = doomstat.c \ i_system.c \ - i_video.c \ - info.c \ - m_argv.c \ - m_bbox.c \ - m_cheat.c \ - m_fixed.c \ - m_menu.c \ - m_misc.c \ + i_sound.c \ + i_video.c \ + i_net.c \ + i_main.c \ + tables.c \ + f_finale.c \ + f_wipe.c \ + d_main.c \ + d_net.c \ + d_items.c \ + g_game.c \ + m_menu.c \ + m_misc.c \ + m_argv.c \ + m_bbox.c \ + m_fixed.c \ + m_swap.c \ + m_cheat.c \ m_random.c \ - m_swap.c \ + am_map.c \ p_ceilng.c \ - p_doors.c \ - p_enemy.c \ - p_floor.c \ - p_inter.c \ + p_doors.c \ + p_enemy.c \ + p_floor.c \ + p_inter.c \ p_lights.c \ - p_map.c \ + p_map.c \ p_maputl.c \ - p_mobj.c \ - p_plats.c \ - p_pspr.c \ - p_saveg.c \ - p_setup.c \ - p_sight.c \ - p_spec.c \ + p_plats.c \ + p_pspr.c \ + p_setup.c \ + p_sight.c \ + p_spec.c \ p_switch.c \ + p_mobj.c \ p_telept.c \ - p_tick.c \ - p_user.c \ - r_bsp.c \ - r_data.c \ - r_draw.c \ - r_main.c \ - r_plane.c \ - r_segs.c \ - r_sky.c \ + p_tick.c \ + p_saveg.c \ + p_user.c \ + r_bsp.c \ + r_data.c \ + r_draw.c \ + r_main.c \ + r_plane.c \ + r_segs.c \ r_things.c \ - s_sound.c \ - sounds.c \ - st_lib.c \ - st_stuff.c \ - tables.c \ - v_video.c \ - w_wad.c \ + w_wad.c \ wi_stuff.c \ - z_zone.c + v_video.c \ + st_lib.c \ + st_stuff.c \ + hu_stuff.c \ + hu_lib.c \ + s_sound.c \ + z_zone.c \ + info.c \ + lang.c \ + sounds.c + OBJ = ${SRC:.c=.o} + all: doom + clean: rm -f *.o doom + doom: ${OBJ} ${CC} ${CFLAGS} ${LDFLAGS} ${OBJ} -o $@ + %.o: %.c ${CC} ${CFLAGS} -c $< -o $@ - diff --git a/src/am_map.c b/src/am_map.c @@ -1,4 +1,6 @@ #include <stdio.h> +#include <limits.h> + #include "z_zone.h" #include "doomdef.h" #include "st_stuff.h" @@ -11,6 +13,7 @@ #include "r_state.h" #include "dstrings.h" #include "am_map.h" + #define REDS (256-5*16) #define REDRANGE 16 #define BLUES (256-4*16+8) @@ -67,78 +70,91 @@ #define CXMTOF(x) (f_x + MTOF((x)-m_x)) #define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) #define LINE_NEVERSEE ML_DONTDRAW -typedef struct -{ - int x, y; -} fpoint_t; -typedef struct -{ - fpoint_t a, b; -} fline_t; -typedef struct -{ - fixed_t x,y; -} mpoint_t; -typedef struct -{ - mpoint_t a, b; -} mline_t; -typedef struct -{ - fixed_t slp, islp; -} islope_t; +#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) +#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) +#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) +#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) +#define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) +#define DOOUTCODE(oc, mx, my) \ + (oc) = 0; \ + if ((my) < 0) (oc) |= TOP; \ + if ((my) >= f_h) (oc) |= BOTTOM; \ + if ((mx) < 0) (oc) |= LEFT; \ + if ((mx) >= f_w) (oc) |= RIGHT; + +typedef struct { + int x, y; +}fpoint_t; + +typedef struct { + fpoint_t a, b; +}fline_t; + +typedef struct { + fixed_t x,y; +}mpoint_t; + +typedef struct { + mpoint_t a, b; +}mline_t; + +typedef struct { + fixed_t slp, islp; +}islope_t; + #define R ((8*PLAYERRADIUS)/7) + mline_t player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, - { { R, 0 }, { R-R/2, R/4 } }, - { { R, 0 }, { R-R/2, -R/4 } }, - { { -R+R/8, 0 }, { -R-R/8, R/4 } }, - { { -R+R/8, 0 }, { -R-R/8, -R/4 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, - { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } + {{ -R+R/8, 0 }, { R, 0 }}, + {{ R, 0 }, { R-R/2, R/4 }}, + {{ R, 0 }, { R-R/2, -R/4 }}, + {{ -R+R/8, 0 }, { -R-R/8, R/4 }}, + {{ -R+R/8, 0 }, { -R-R/8, -R/4 }}, + {{ -R+3*R/8, 0 }, { -R+R/8, R/4 }}, + {{ -R+3*R/8, 0 }, { -R+R/8, -R/4 }} }; #undef R -#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) + #define R ((8*PLAYERRADIUS)/7) mline_t cheat_player_arrow[] = { - { { -R+R/8, 0 }, { R, 0 } }, - { { R, 0 }, { R-R/2, R/6 } }, - { { R, 0 }, { R-R/2, -R/6 } }, - { { -R+R/8, 0 }, { -R-R/8, R/6 } }, - { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, - { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, - { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, - { { -R/2, 0 }, { -R/2, -R/6 } }, - { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, - { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, - { { -R/6, 0 }, { -R/6, -R/6 } }, - { { -R/6, -R/6 }, { 0, -R/6 } }, - { { 0, -R/6 }, { 0, R/4 } }, - { { R/6, R/4 }, { R/6, -R/7 } }, - { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, - { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } + { { -R+R/8, 0 }, { R, 0 } }, + { { R, 0 }, { R-R/2, R/6 } }, + { { R, 0 }, { R-R/2, -R/6 } }, + { { -R+R/8, 0 }, { -R-R/8, R/6 } }, + { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, + { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, + { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, + { { -R/2, 0 }, { -R/2, -R/6 } }, + { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, + { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, + { { -R/6, 0 }, { -R/6, -R/6 } }, + { { -R/6, -R/6 }, { 0, -R/6 } }, + { { 0, -R/6 }, { 0, R/4 } }, + { { R/6, R/4 }, { R/6, -R/7 } }, + { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, + { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } }; #undef R -#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) + #define R (FRACUNIT) mline_t triangle_guy[] = { - { { -.867*R, -.5*R }, { .867*R, -.5*R } }, - { { .867*R, -.5*R } , { 0, R } }, - { { 0, R }, { -.867*R, -.5*R } } + { { -.867*R, -.5*R }, { .867*R, -.5*R } }, + { { .867*R, -.5*R } , { 0, R } }, + { { 0, R }, { -.867*R, -.5*R } } }; #undef R -#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) + #define R (FRACUNIT) mline_t thintriangle_guy[] = { - { { -.5*R, -.7*R }, { R, 0 } }, - { { R, 0 }, { -.5*R, .7*R } }, - { { -.5*R, .7*R }, { -.5*R, -.7*R } } + { { -.5*R, -.7*R }, { R, 0 } }, + { { R, 0 }, { -.5*R, .7*R } }, + { { -.5*R, .7*R }, { -.5*R, -.7*R } } }; #undef R -#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) + static int cheating = 0; static int grid = 0; -static int leveljuststarted = 1; +static int leveljuststarted = 1; boolean automapactive = false; static int finit_width = SCREENWIDTH; static int finit_height = SCREENHEIGHT - 32; @@ -146,794 +162,716 @@ static int f_x; static int f_y; static int f_w; static int f_h; -static int lightlev; -static byte* fb; +static int lightlev; +static byte* fb; static int amclock; -static mpoint_t m_paninc; -static fixed_t mtof_zoommul; -static fixed_t ftom_zoommul; -static fixed_t m_x, m_y; -static fixed_t m_x2, m_y2; +static mpoint_t m_paninc; +static fixed_t mtof_zoommul; +static fixed_t ftom_zoommul; +static fixed_t m_x, m_y; +static fixed_t m_x2, m_y2; static fixed_t m_w; static fixed_t m_h; static fixed_t min_x; -static fixed_t min_y; +static fixed_t min_y; static fixed_t max_x; static fixed_t max_y; -static fixed_t max_w; -static fixed_t max_h; +static fixed_t max_w; +static fixed_t max_h; static fixed_t min_w; static fixed_t min_h; -static fixed_t min_scale_mtof; -static fixed_t max_scale_mtof; +static fixed_t min_scale_mtof; +static fixed_t max_scale_mtof; static fixed_t old_m_w, old_m_h; static fixed_t old_m_x, old_m_y; static mpoint_t f_oldloc; static fixed_t scale_mtof = INITSCALEMTOF; static fixed_t scale_ftom; -static player_t *plr; -static patch_t *marknums[10]; -static mpoint_t markpoints[AM_NUMMARKPOINTS]; -static int markpointnum = 0; -static int followplayer = 1; +static player_t *plr; +static patch_t *marknums[10]; +static mpoint_t markpoints[AM_NUMMARKPOINTS]; +static int markpointnum = 0; +static int followplayer = 1; static unsigned char cheat_amap_seq[] = { 0xb2, 0x26, 0x26, 0x2e, 0xff }; static cheatseq_t cheat_amap = { cheat_amap_seq, 0 }; static boolean stopped = true; extern boolean viewactive; + +void V_MarkRect(int x, int y, int width, int height); + +void +AM_getIslope(mline_t* ml, islope_t* is) +{ + int dx, dy; + + dy = ml->a.y - ml->b.y; + dx = ml->b.x - ml->a.x; + if (!dy) is->islp = (dx<0?-INT_MAX:INT_MAX); + else is->islp = FixedDiv(dx, dy); + if (!dx) is->slp = (dy<0?-INT_MAX:INT_MAX); + else is->slp = FixedDiv(dy, dx); +} + +void +AM_activateNewScale() +{ + m_x += m_w/2; + m_y += m_h/2; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + m_x -= m_w/2; + m_y -= m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; +} + void -V_MarkRect -( int x, - int y, - int width, - int height ); +AM_saveScaleAndLoc() +{ + old_m_x = m_x; + old_m_y = m_y; + old_m_w = m_w; + old_m_h = m_h; +} + void -AM_getIslope -( mline_t* ml, - islope_t* is ) -{ - int dx, dy; - dy = ml->a.y - ml->b.y; - dx = ml->b.x - ml->a.x; - if (!dy) is->islp = (dx<0?-MAXINT:MAXINT); - else is->islp = FixedDiv(dx, dy); - if (!dx) is->slp = (dy<0?-MAXINT:MAXINT); - else is->slp = FixedDiv(dy, dx); -} -void AM_activateNewScale(void) -{ - m_x += m_w/2; - m_y += m_h/2; - m_w = FTOM(f_w); - m_h = FTOM(f_h); - m_x -= m_w/2; - m_y -= m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; -} -void AM_saveScaleAndLoc(void) -{ - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; -} -void AM_restoreScaleAndLoc(void) -{ - m_w = old_m_w; - m_h = old_m_h; - if (!followplayer) - { - m_x = old_m_x; - m_y = old_m_y; - } else { +AM_restoreScaleAndLoc() +{ + m_w = old_m_w; + m_h = old_m_h; + if (!followplayer) { + m_x = old_m_x; + m_y = old_m_y; + } else { + m_x = plr->mo->x - m_w/2; + m_y = plr->mo->y - m_h/2; + } + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; + scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); +} + +void +AM_addMark() +{ + markpoints[markpointnum].x = m_x + m_w/2; + markpoints[markpointnum].y = m_y + m_h/2; + markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; +} + +void +AM_findMinMaxBoundaries() +{ + int i; + fixed_t a; + fixed_t b; + + min_x = min_y = INT_MAX; + max_x = max_y = -INT_MAX; + for (i = 0; i < numvertexes; ++i) { + if (vertexes[i].x < min_x) min_x = vertexes[i].x; + if (vertexes[i].x > max_x) max_x = vertexes[i].x; + if (vertexes[i].y < min_y) min_y = vertexes[i].y; + if (vertexes[i].y > max_y) max_y = vertexes[i].y; + } + max_w = max_x - min_x; + max_h = max_y - min_y; + min_w = 2 * PLAYERRADIUS; + min_h = 2 * PLAYERRADIUS; + a = FixedDiv(f_w << FRACBITS, max_w); + b = FixedDiv(f_h << FRACBITS, max_h); + min_scale_mtof = a < b ? a : b; + max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS); +} + +void +AM_changeWindowLoc() +{ + if (m_paninc.x || m_paninc.y) { + followplayer = 0; + f_oldloc.x = INT_MAX; + } + m_x += m_paninc.x; + m_y += m_paninc.y; + if (m_x + m_w/2 > max_x) m_x = max_x - m_w/2; + if (m_x + m_w/2 < min_x) m_x = min_x - m_w/2; + if (m_y + m_h/2 > max_y) m_y = max_y - m_h/2; + if (m_y + m_h/2 < min_y) m_y = min_y - m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; +} + +void +AM_initVariables() +{ + static event_t st_notify = { ev_keyup, AM_MSGENTERED }; + int pnum; + + automapactive = true; + fb = screens[0]; + f_oldloc.x = INT_MAX; + amclock = 0; + lightlev = 0; + m_paninc.x = m_paninc.y = 0; + ftom_zoommul = FRACUNIT; + mtof_zoommul = FRACUNIT; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + if (!playeringame[pnum = consoleplayer]) + for (pnum=0;pnum<MAXPLAYERS;pnum++) + if (playeringame[pnum]) break; + plr = &players[pnum]; m_x = plr->mo->x - m_w/2; m_y = plr->mo->y - m_h/2; - } - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; - scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); -} -void AM_addMark(void) -{ - markpoints[markpointnum].x = m_x + m_w/2; - markpoints[markpointnum].y = m_y + m_h/2; - markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; -} -void AM_findMinMaxBoundaries(void) -{ - int i; - fixed_t a; - fixed_t b; - min_x = min_y = MAXINT; - max_x = max_y = -MAXINT; - for (i=0;i<numvertexes;i++) - { - if (vertexes[i].x < min_x) - min_x = vertexes[i].x; - else if (vertexes[i].x > max_x) - max_x = vertexes[i].x; - if (vertexes[i].y < min_y) - min_y = vertexes[i].y; - else if (vertexes[i].y > max_y) - max_y = vertexes[i].y; - } - max_w = max_x - min_x; - max_h = max_y - min_y; - min_w = 2*PLAYERRADIUS; - min_h = 2*PLAYERRADIUS; - a = FixedDiv(f_w<<FRACBITS, max_w); - b = FixedDiv(f_h<<FRACBITS, max_h); - min_scale_mtof = a < b ? a : b; - max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS); -} -void AM_changeWindowLoc(void) -{ - if (m_paninc.x || m_paninc.y) - { - followplayer = 0; - f_oldloc.x = MAXINT; - } - m_x += m_paninc.x; - m_y += m_paninc.y; - if (m_x + m_w/2 > max_x) - m_x = max_x - m_w/2; - else if (m_x + m_w/2 < min_x) - m_x = min_x - m_w/2; - if (m_y + m_h/2 > max_y) - m_y = max_y - m_h/2; - else if (m_y + m_h/2 < min_y) - m_y = min_y - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; -} -void AM_initVariables(void) -{ - int pnum; - static event_t st_notify = { ev_keyup, AM_MSGENTERED }; - automapactive = true; - fb = screens[0]; - f_oldloc.x = MAXINT; - amclock = 0; - lightlev = 0; - m_paninc.x = m_paninc.y = 0; - ftom_zoommul = FRACUNIT; - mtof_zoommul = FRACUNIT; - m_w = FTOM(f_w); - m_h = FTOM(f_h); - if (!playeringame[pnum = consoleplayer]) - for (pnum=0;pnum<MAXPLAYERS;pnum++) - if (playeringame[pnum]) - break; - plr = &players[pnum]; - m_x = plr->mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; - AM_changeWindowLoc(); - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; - ST_Responder(&st_notify); -} -void AM_loadPics(void) -{ - int i; - char namebuf[9]; - for (i=0;i<10;i++) - { - sprintf(namebuf, "AMMNUM%d", i); - marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); - } -} -void AM_unloadPics(void) -{ - int i; - for (i=0;i<10;i++) - Z_ChangeTag(marknums[i], PU_CACHE); + AM_changeWindowLoc(); + old_m_x = m_x; + old_m_y = m_y; + old_m_w = m_w; + old_m_h = m_h; + ST_Responder(&st_notify); } -void AM_clearMarks(void) + +void +AM_loadPics() +{ + int i; + char namebuf[9]; + + for (i = 0; i < 10; ++i) { + sprintf(namebuf, "AMMNUM%d", i); + marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); + } +} + +void +AM_unloadPics() { - int i; - for (i=0;i<AM_NUMMARKPOINTS;i++) - markpoints[i].x = -1; - markpointnum = 0; + int i; + + for (i=0;i<10;i++) + Z_ChangeTag(marknums[i], PU_CACHE); + } -void AM_LevelInit(void) + +void AM_clearMarks() { - leveljuststarted = 0; - f_x = f_y = 0; - f_w = finit_width; - f_h = finit_height; - AM_clearMarks(); - AM_findMinMaxBoundaries(); - scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); - if (scale_mtof > max_scale_mtof) - scale_mtof = min_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + int i; + + for (i=0;i<AM_NUMMARKPOINTS;i++) + markpoints[i].x = -1; + markpointnum = 0; +} + +void +AM_LevelInit() +{ + leveljuststarted = 0; + f_x = f_y = 0; + f_w = finit_width; + f_h = finit_height; + AM_clearMarks(); + AM_findMinMaxBoundaries(); + scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); + if (scale_mtof > max_scale_mtof) scale_mtof = min_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } -void AM_Stop (void) + +void +AM_Stop() { - static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; - AM_unloadPics(); - automapactive = false; - ST_Responder(&st_notify); - stopped = true; + static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; + + AM_unloadPics(); + automapactive = false; + ST_Responder(&st_notify); + stopped = true; } -void AM_Start (void) + +void +AM_Start() { - static int lastlevel = -1, lastepisode = -1; - if (!stopped) AM_Stop(); - stopped = false; - if (lastlevel != gamemap || lastepisode != gameepisode) - { - AM_LevelInit(); - lastlevel = gamemap; - lastepisode = gameepisode; - } - AM_initVariables(); - AM_loadPics(); + static int lastlevel = -1, lastepisode = -1; + + if (!stopped) + AM_Stop(); + stopped = false; + if (lastlevel != gamemap || lastepisode != gameepisode) { + AM_LevelInit(); + lastlevel = gamemap; + lastepisode = gameepisode; + } + AM_initVariables(); + AM_loadPics(); } -void AM_minOutWindowScale(void) + +void +AM_minOutWindowScale() { - scale_mtof = min_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + scale_mtof = min_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + AM_activateNewScale(); } -void AM_maxOutWindowScale(void) + +void +AM_maxOutWindowScale() { - scale_mtof = max_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + scale_mtof = max_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + AM_activateNewScale(); } + boolean -AM_Responder -( event_t* ev ) -{ - int rc; - static int bigstate=0; - static char buffer[20]; - rc = false; - if (!automapactive) - { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) - { - AM_Start (); - viewactive = false; - rc = true; +AM_Responder(event_t* ev) +{ + static int bigstate=0; + static char buffer[20]; + int rc; + + rc = false; + if (!automapactive) { + if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) { + AM_Start(); + viewactive = false; + rc = true; + } } - } - else if (ev->type == ev_keydown) - { - rc = true; - switch(ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = -FTOM(F_PANINC); - else rc = false; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = -FTOM(F_PANINC); - else rc = false; - break; - case AM_ZOOMOUTKEY: - mtof_zoommul = M_ZOOMOUT; - ftom_zoommul = M_ZOOMIN; - break; - case AM_ZOOMINKEY: - mtof_zoommul = M_ZOOMIN; - ftom_zoommul = M_ZOOMOUT; - break; - case AM_ENDKEY: - bigstate = 0; - viewactive = true; - AM_Stop (); - break; - case AM_GOBIGKEY: - bigstate = !bigstate; - if (bigstate) - { - AM_saveScaleAndLoc(); - AM_minOutWindowScale(); - } - else AM_restoreScaleAndLoc(); - break; - case AM_FOLLOWKEY: - followplayer = !followplayer; - f_oldloc.x = MAXINT; - plr->message = followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF; - break; - case AM_GRIDKEY: - grid = !grid; - plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; - break; - case AM_MARKKEY: - sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); - plr->message = buffer; - AM_addMark(); - break; - case AM_CLEARMARKKEY: - AM_clearMarks(); - plr->message = AMSTR_MARKSCLEARED; - break; - default: - rc = false; + else if (ev->type == ev_keydown) { + rc = true; + switch (ev->data1) { + case AM_PANRIGHTKEY: + if (!followplayer) m_paninc.x = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANLEFTKEY: + if (!followplayer) m_paninc.x = -FTOM(F_PANINC); + else rc = false; + break; + case AM_PANUPKEY: + if (!followplayer) m_paninc.y = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANDOWNKEY: + if (!followplayer) m_paninc.y = -FTOM(F_PANINC); + else rc = false; + break; + case AM_ZOOMOUTKEY: + mtof_zoommul = M_ZOOMOUT; + ftom_zoommul = M_ZOOMIN; + break; + case AM_ZOOMINKEY: + mtof_zoommul = M_ZOOMIN; + ftom_zoommul = M_ZOOMOUT; + break; + case AM_ENDKEY: + bigstate = 0; + viewactive = true; + AM_Stop(); + break; + case AM_GOBIGKEY: + bigstate = !bigstate; + if (bigstate) { + AM_saveScaleAndLoc(); + AM_minOutWindowScale(); + } + else AM_restoreScaleAndLoc(); + break; + case AM_FOLLOWKEY: + followplayer = !followplayer; + f_oldloc.x = INT_MAX; + plr->message = followplayer ? lang[AMSTR_FOLLOWON] : lang[AMSTR_FOLLOWOFF]; + break; + case AM_GRIDKEY: + grid = !grid; + plr->message = grid ? lang[AMSTR_GRIDON] : lang[AMSTR_GRIDOFF]; + break; + case AM_MARKKEY: + sprintf(buffer, "%s %d", lang[AMSTR_MARKEDSPOT], markpointnum); + plr->message = buffer; + AM_addMark(); + break; + case AM_CLEARMARKKEY: + AM_clearMarks(); + plr->message = lang[AMSTR_MARKSCLEARED]; + break; + default: + rc = false; + } + if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) { + rc = false; + cheating = (cheating+1) % 3; + } } - if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) - { - rc = false; - cheating = (cheating+1) % 3; + else if (ev->type == ev_keyup) { + rc = false; + switch (ev->data1) { + case AM_PANRIGHTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANLEFTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANUPKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_PANDOWNKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_ZOOMOUTKEY: + case AM_ZOOMINKEY: + mtof_zoommul = FRACUNIT; + ftom_zoommul = FRACUNIT; + break; + } } - } - else if (ev->type == ev_keyup) - { - rc = false; - switch (ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_ZOOMOUTKEY: - case AM_ZOOMINKEY: - mtof_zoommul = FRACUNIT; - ftom_zoommul = FRACUNIT; - break; + return rc; +} + +void +AM_changeWindowScale() +{ + scale_mtof = FixedMul(scale_mtof, mtof_zoommul); + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); + if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); + else AM_activateNewScale(); +} + +void +AM_doFollowPlayer() +{ + if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { + m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; + m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; + f_oldloc.x = plr->mo->x; + f_oldloc.y = plr->mo->y; } - } - return rc; -} -void AM_changeWindowScale(void) -{ - scale_mtof = FixedMul(scale_mtof, mtof_zoommul); - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - if (scale_mtof < min_scale_mtof) - AM_minOutWindowScale(); - else if (scale_mtof > max_scale_mtof) - AM_maxOutWindowScale(); - else - AM_activateNewScale(); } -void AM_doFollowPlayer(void) + +void +AM_updateLightLev() { - if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) - { - m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; - m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; - f_oldloc.x = plr->mo->x; - f_oldloc.y = plr->mo->y; - } + static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; + static int nexttic = 0; + static int litelevelscnt = 0; + + if (amclock>nexttic) { + lightlev = litelevels[litelevelscnt++]; + if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; + nexttic = amclock + 6 - (amclock % 6); + } } -void AM_Ticker (void) +void +AM_Ticker() { - if (!automapactive) - return; - amclock++; - if (followplayer) - AM_doFollowPlayer(); - if (ftom_zoommul != FRACUNIT) + if (!automapactive) + return; + amclock++; + if (followplayer) AM_doFollowPlayer(); + if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); - if (m_paninc.x || m_paninc.y) + if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); } -void AM_clearFB(int color) + +void +AM_clearFB(int color) { - memset(fb, color, f_w*f_h); + memset(fb, color, f_w * f_h); } + boolean -AM_clipMline -( mline_t* ml, - fline_t* fl ) -{ - enum - { - LEFT =1, - RIGHT =2, - BOTTOM =4, - TOP =8 - }; - int outside; - int outcode1 = 0; - int outcode2 = 0; - fpoint_t tmp; - int dx; - int dy; -#define DOOUTCODE(oc, mx, my) \ - (oc) = 0; \ - if ((my) < 0) (oc) |= TOP; \ - else if ((my) >= f_h) (oc) |= BOTTOM; \ - if ((mx) < 0) (oc) |= LEFT; \ - else if ((mx) >= f_w) (oc) |= RIGHT; - if (ml->a.y > m_y2) - outcode1 = TOP; - else if (ml->a.y < m_y) - outcode1 = BOTTOM; - if (ml->b.y > m_y2) - outcode2 = TOP; - else if (ml->b.y < m_y) - outcode2 = BOTTOM; - if (outcode1 & outcode2) - return false; - if (ml->a.x < m_x) - outcode1 |= LEFT; - else if (ml->a.x > m_x2) - outcode1 |= RIGHT; - if (ml->b.x < m_x) - outcode2 |= LEFT; - else if (ml->b.x > m_x2) - outcode2 |= RIGHT; - if (outcode1 & outcode2) - return false; - fl->a.x = CXMTOF(ml->a.x); - fl->a.y = CYMTOF(ml->a.y); - fl->b.x = CXMTOF(ml->b.x); - fl->b.y = CYMTOF(ml->b.y); - DOOUTCODE(outcode1, fl->a.x, fl->a.y); - DOOUTCODE(outcode2, fl->b.x, fl->b.y); - if (outcode1 & outcode2) - return false; - while (outcode1 | outcode2) - { - if (outcode1) - outside = outcode1; - else - outside = outcode2; - if (outside & TOP) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y))/dy; - tmp.y = 0; - } - else if (outside & BOTTOM) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy; - tmp.y = f_h-1; - } - else if (outside & RIGHT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx; - tmp.x = f_w-1; - } - else if (outside & LEFT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; - tmp.x = 0; +AM_clipMline(mline_t* ml, fline_t* fl) +{ + enum { + LEFT =1, + RIGHT =2, + BOTTOM =4, + TOP =8 + }; + + int outcode1, outcode2, outside, dx, dy; + fpoint_t tmp; + + outcode1 = outcode2 = 0; + if (ml->a.y > m_y2) outcode1 = TOP; + if (ml->a.y < m_y) outcode1 = BOTTOM; + if (ml->b.y > m_y2) outcode2 = TOP; + if (ml->b.y < m_y) outcode2 = BOTTOM; + if (outcode1 & outcode2) return false; + if (ml->a.x < m_x) outcode1 |= LEFT; + if (ml->a.x > m_x2) outcode1 |= RIGHT; + if (ml->b.x < m_x) outcode2 |= LEFT; + if (ml->b.x > m_x2) outcode2 |= RIGHT; + if (outcode1 & outcode2) return false; + fl->a.x = CXMTOF(ml->a.x); + fl->a.y = CYMTOF(ml->a.y); + fl->b.x = CXMTOF(ml->b.x); + fl->b.y = CYMTOF(ml->b.y); + DOOUTCODE(outcode1, fl->a.x, fl->a.y); + DOOUTCODE(outcode2, fl->b.x, fl->b.y); + if (outcode1 & outcode2) return false; + + while (outcode1 | outcode2) { + if (outcode1) outside = outcode1; + else outside = outcode2; + if (outside & TOP) { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx*(fl->a.y))/dy; + tmp.y = 0; + } + if (outside & BOTTOM) { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy; + tmp.y = f_h-1; + } + if (outside & RIGHT) { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx; + tmp.x = f_w-1; + } + if (outside & LEFT) { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; + tmp.x = 0; + } + if (outside == outcode1) { + fl->a = tmp; + DOOUTCODE(outcode1, fl->a.x, fl->a.y); + } else { + fl->b = tmp; + DOOUTCODE(outcode2, fl->b.x, fl->b.y); + } + if (outcode1 & outcode2) return false; } - if (outside == outcode1) - { - fl->a = tmp; - DOOUTCODE(outcode1, fl->a.x, fl->a.y); + return true; +} +#undef DOOUTCODE + +void +AM_drawFline(fline_t* fl, int color) +{ + static int fuck = 0; + int x, y, dx, dy, sx, sy, ax, ay, d; + if (fl->a.x < 0 || fl->a.x >= f_w || fl->a.y < 0 || fl->a.y >= f_h || fl->b.x < 0 || fl->b.x >= f_w || fl->b.y < 0 || fl->b.y >= f_h) { + fprintf(stderr, "fuck %d \r", fuck++); + return; } - else - { - fl->b = tmp; - DOOUTCODE(outcode2, fl->b.x, fl->b.y); + dx = fl->b.x - fl->a.x; + ax = 2 * (dx<0 ? -dx : dx); + sx = dx<0 ? -1 : 1; + dy = fl->b.y - fl->a.y; + ay = 2 * (dy<0 ? -dy : dy); + sy = dy<0 ? -1 : 1; + x = fl->a.x; + y = fl->a.y; + if (ax > ay) { + d = ay - ax/2; + for (;;) { + PUTDOT(x,y,color); + if (x == fl->b.x) return; + if (d>=0) { + y += sy; + d -= ax; + } + x += sx; + d += ay; + } + } else { + d = ax - ay/2; + for (;;) { + PUTDOT(x, y, color); + if (y == fl->b.y) return; + if (d >= 0) { + x += sx; + d -= ay; + } + y += sy; + d += ax; + } } - if (outcode1 & outcode2) - return false; - } - return true; } -#undef DOOUTCODE + void -AM_drawFline -( fline_t* fl, - int color ) -{ - register int x; - register int y; - register int dx; - register int dy; - register int sx; - register int sy; - register int ax; - register int ay; - register int d; - static int fuck = 0; - if ( fl->a.x < 0 || fl->a.x >= f_w - || fl->a.y < 0 || fl->a.y >= f_h - || fl->b.x < 0 || fl->b.x >= f_w - || fl->b.y < 0 || fl->b.y >= f_h) - { - fprintf(stderr, "fuck %d \r", fuck++); - return; - } -#define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) - dx = fl->b.x - fl->a.x; - ax = 2 * (dx<0 ? -dx : dx); - sx = dx<0 ? -1 : 1; - dy = fl->b.y - fl->a.y; - ay = 2 * (dy<0 ? -dy : dy); - sy = dy<0 ? -1 : 1; - x = fl->a.x; - y = fl->a.y; - if (ax > ay) - { - d = ay - ax/2; - while (1) - { - PUTDOT(x,y,color); - if (x == fl->b.x) return; - if (d>=0) - { - y += sy; - d -= ax; - } - x += sx; - d += ay; +AM_drawMline(mline_t* ml, int color) +{ + static fline_t fl; + + if (AM_clipMline(ml, &fl)) AM_drawFline(&fl, color); +} + +void +AM_drawGrid(int color) +{ + fixed_t x, y, start, end; + mline_t ml; + + start = m_x; + if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); + end = m_x + m_w; + ml.a.y = m_y; + ml.b.y = m_y+m_h; + for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) { + ml.a.x = x; + ml.b.x = x; + AM_drawMline(&ml, color); } - } - else - { - d = ax - ay/2; - while (1) - { - PUTDOT(x, y, color); - if (y == fl->b.y) return; - if (d >= 0) - { - x += sx; - d -= ay; - } - y += sy; - d += ax; + start = m_y; + if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); + end = m_y + m_h; + ml.a.x = m_x; + ml.b.x = m_x + m_w; + for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) { + ml.a.y = y; + ml.b.y = y; + AM_drawMline(&ml, color); } - } } + void -AM_drawMline -( mline_t* ml, - int color ) -{ - static fline_t fl; - if (AM_clipMline(ml, &fl)) - AM_drawFline(&fl, color); -} -void AM_drawGrid(int color) -{ - fixed_t x, y; - fixed_t start, end; - mline_t ml; - start = m_x; - if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) - start += (MAPBLOCKUNITS<<FRACBITS) - - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); - end = m_x + m_w; - ml.a.y = m_y; - ml.b.y = m_y+m_h; - for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) - { - ml.a.x = x; - ml.b.x = x; - AM_drawMline(&ml, color); - } - start = m_y; - if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) - start += (MAPBLOCKUNITS<<FRACBITS) - - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); - end = m_y + m_h; - ml.a.x = m_x; - ml.b.x = m_x + m_w; - for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) - { - ml.a.y = y; - ml.b.y = y; - AM_drawMline(&ml, color); - } -} -void AM_drawWalls(void) -{ - int i; - static mline_t l; - for (i=0;i<numlines;i++) - { - l.a.x = lines[i].v1->x; - l.a.y = lines[i].v1->y; - l.b.x = lines[i].v2->x; - l.b.y = lines[i].v2->y; - if (cheating || (lines[i].flags & ML_MAPPED)) - { - if ((lines[i].flags & LINE_NEVERSEE) && !cheating) - continue; - if (!lines[i].backsector) - { - AM_drawMline(&l, WALLCOLORS+lightlev); - } - else - { - if (lines[i].special == 39) - { - AM_drawMline(&l, WALLCOLORS+WALLRANGE/2); - } - else if (lines[i].flags & ML_SECRET) - { - if (cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev); - else AM_drawMline(&l, WALLCOLORS+lightlev); - } - else if (lines[i].backsector->floorheight - != lines[i].frontsector->floorheight) { - AM_drawMline(&l, FDWALLCOLORS + lightlev); - } - else if (lines[i].backsector->ceilingheight - != lines[i].frontsector->ceilingheight) { - AM_drawMline(&l, CDWALLCOLORS+lightlev); - } - else if (cheating) { - AM_drawMline(&l, TSWALLCOLORS+lightlev); +AM_drawWalls() +{ + static mline_t l; + int i; + + for (i=0;i<numlines;i++) { + l.a.x = lines[i].v1->x; + l.a.y = lines[i].v1->y; + l.b.x = lines[i].v2->x; + l.b.y = lines[i].v2->y; + if (cheating || (lines[i].flags & ML_MAPPED)) { + if ((lines[i].flags & LINE_NEVERSEE) && !cheating) continue; + if (!lines[i].backsector) AM_drawMline(&l, WALLCOLORS+lightlev); + else { + if (lines[i].special == 39) AM_drawMline(&l, WALLCOLORS+WALLRANGE/2); + if (lines[i].flags & ML_SECRET) { + if (cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev); + else AM_drawMline(&l, WALLCOLORS+lightlev); + } + if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) AM_drawMline(&l, FDWALLCOLORS + lightlev); + if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) AM_drawMline(&l, CDWALLCOLORS+lightlev); + if (cheating) AM_drawMline(&l, TSWALLCOLORS+lightlev); + } } - } - } - else if (plr->powers[pw_allmap]) - { - if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); + if (plr->powers[pw_allmap]) + if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); } - } } + void -AM_rotate -( fixed_t* x, - fixed_t* y, - angle_t a ) -{ - fixed_t tmpx; - tmpx = - FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); - *y = - FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) - + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); - *x = tmpx; +AM_rotate(fixed_t* x, fixed_t* y, angle_t a) +{ + fixed_t tmpx; + + tmpx = FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); + *y = FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); + *x = tmpx; } + void -AM_drawLineCharacter -( mline_t* lineguy, - int lineguylines, - fixed_t scale, - angle_t angle, - int color, - fixed_t x, - fixed_t y ) -{ - int i; - mline_t l; - for (i=0;i<lineguylines;i++) - { - l.a.x = lineguy[i].a.x; - l.a.y = lineguy[i].a.y; - if (scale) - { - l.a.x = FixedMul(scale, l.a.x); - l.a.y = FixedMul(scale, l.a.y); - } - if (angle) - AM_rotate(&l.a.x, &l.a.y, angle); - l.a.x += x; - l.a.y += y; - l.b.x = lineguy[i].b.x; - l.b.y = lineguy[i].b.y; - if (scale) - { - l.b.x = FixedMul(scale, l.b.x); - l.b.y = FixedMul(scale, l.b.y); +AM_drawLineCharacter(mline_t* lineguy, int lineguylines, fixed_t scale, angle_t angle, int color, fixed_t x, fixed_t y) +{ + mline_t l; + int i; + + for (i = 0; i < lineguylines; ++i) { + l.a.x = lineguy[i].a.x; + l.a.y = lineguy[i].a.y; + if (scale) { + l.a.x = FixedMul(scale, l.a.x); + l.a.y = FixedMul(scale, l.a.y); + } + if (angle) AM_rotate(&l.a.x, &l.a.y, angle); + l.a.x += x; + l.a.y += y; + l.b.x = lineguy[i].b.x; + l.b.y = lineguy[i].b.y; + if (scale) { + l.b.x = FixedMul(scale, l.b.x); + l.b.y = FixedMul(scale, l.b.y); + } + if (angle) AM_rotate(&l.b.x, &l.b.y, angle); + l.b.x += x; + l.b.y += y; + AM_drawMline(&l, color); } - if (angle) - AM_rotate(&l.b.x, &l.b.y, angle); - l.b.x += x; - l.b.y += y; - AM_drawMline(&l, color); - } -} -void AM_drawPlayers(void) -{ - int i; - player_t* p; - static int their_colors[] = { GREENS, GRAYS, BROWNS, REDS }; - int their_color = -1; - int color; - if (!netgame) - { - if (cheating) - AM_drawLineCharacter - (cheat_player_arrow, NUMCHEATPLYRLINES, 0, - plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); - else - AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, plr->mo->angle, - WHITE, plr->mo->x, plr->mo->y); - return; - } - for (i=0;i<MAXPLAYERS;i++) - { - their_color++; - p = &players[i]; - if ( (deathmatch && !singledemo) && p != plr) - continue; - if (!playeringame[i]) - continue; - if (p->powers[pw_invisibility]) - color = 246; - else - color = their_colors[their_color]; - AM_drawLineCharacter - (player_arrow, NUMPLYRLINES, 0, p->mo->angle, - color, p->mo->x, p->mo->y); - } } + void -AM_drawThings -( int colors, - int colorrange) -{ - int i; - mobj_t* t; - for (i=0;i<numsectors;i++) - { - t = sectors[i].thinglist; - while (t) - { - AM_drawLineCharacter - (thintriangle_guy, NUMTHINTRIANGLEGUYLINES, - 16<<FRACBITS, t->angle, colors+lightlev, t->x, t->y); - t = t->snext; +AM_drawPlayers() +{ + static int their_colors[] = { GREENS, GRAYS, BROWNS, REDS }; + player_t* p; + int i, color, their_color; + + their_color = -1; + if (!netgame) { + if (cheating) AM_drawLineCharacter(cheat_player_arrow, NUMCHEATPLYRLINES, 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); + else AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); + return; } - } -} -void AM_drawMarks(void) -{ - int i, fx, fy, w, h; - for (i=0;i<AM_NUMMARKPOINTS;i++) - { - if (markpoints[i].x != -1) - { - w = 5; - h = 6; - fx = CXMTOF(markpoints[i].x); - fy = CYMTOF(markpoints[i].y); - if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) - V_DrawPatch(fx, fy, FB, marknums[i]); + for (i = 0; i < MAXPLAYERS; ++i) { + ++their_color; + p = &players[i]; + if ((deathmatch && !singledemo) && p != plr) continue; + if (!playeringame[i]) continue; + if (p->powers[pw_invisibility]) color = 246; + else color = their_colors[their_color]; + AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y); } - } } -void AM_drawCrosshair(int color) + +void +AM_drawThings(int colors, int colorrange) { - fb[(f_w*(f_h+1))/2] = color; + mobj_t* t; + int i; + + for (i = 0; i < numsectors; ++i) + for (t = sectors[i].thinglist; t; t = t->snext) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors+lightlev, t->x, t->y); } -void AM_Drawer (void) + +void +AM_drawMarks() { - if (!automapactive) return; - AM_clearFB(BACKGROUND); - if (grid) - AM_drawGrid(GRIDCOLORS); - AM_drawWalls(); - AM_drawPlayers(); - if (cheating==2) - AM_drawThings(THINGCOLORS, THINGRANGE); - AM_drawCrosshair(XHAIRCOLORS); - AM_drawMarks(); - V_MarkRect(f_x, f_y, f_w, f_h); + int i, fx, fy, w, h; + + for (i = 0; i < AM_NUMMARKPOINTS; ++i) { + if (markpoints[i].x != -1) { + w = 5; + h = 6; + fx = CXMTOF(markpoints[i].x); + fy = CYMTOF(markpoints[i].y); + if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) V_DrawPatch(fx, fy, FB, marknums[i]); + } + } +} + +void +AM_drawCrosshair(int color) +{ + fb[(f_w*(f_h+1))/2] = color; +} + +void +AM_Drawer() +{ + if (!automapactive) + return; + AM_clearFB(BACKGROUND); + if (grid) AM_drawGrid(GRIDCOLORS); + AM_drawWalls(); + AM_drawPlayers(); + if (cheating==2) AM_drawThings(THINGCOLORS, THINGRANGE); + AM_drawCrosshair(XHAIRCOLORS); + AM_drawMarks(); + V_MarkRect(f_x, f_y, f_w, f_h); } diff --git a/src/am_map.h b/src/am_map.h @@ -1,10 +1,13 @@ #ifndef __AMMAP_H__ #define __AMMAP_H__ + #define AM_MSGHEADER (('a'<<24)+('m'<<16)) #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) -boolean AM_Responder (event_t* ev); -void AM_Ticker (void); -void AM_Drawer (void); -void AM_Stop (void); + +boolean AM_Responder(event_t* ev); +void AM_Ticker(); +void AM_Drawer(); +void AM_Stop(); + #endif diff --git a/src/d_englsh.h b/src/d_englsh.h @@ -1,522 +0,0 @@ -#ifndef __D_ENGLSH__ -#define __D_ENGLSH__ -#define D_DEVSTR "Development mode ON.\n" -#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n" -#define PRESSKEY "press a key." -#define PRESSYN "press y or n." -#define QUITMSG "are you sure you want to\nquit this great game?" -#define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY -#define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY -#define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY -#define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY -#define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN -#define QLPROMPT "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN -#define NEWGAME \ -"you can't start a new game\n"\ -"while in a network game.\n\n"PRESSKEY -#define NIGHTMARE \ -"are you sure? this skill level\n"\ -"isn't even remotely fair.\n\n"PRESSYN -#define SWSTRING \ -"this is the shareware version of doom.\n\n"\ -"you need to order the entire trilogy.\n\n"PRESSKEY -#define MSGOFF "Messages OFF" -#define MSGON "Messages ON" -#define NETEND "you can't end a netgame!\n\n"PRESSKEY -#define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN -#define DOSY "(press y to quit)" -#define DETAILHI "High detail" -#define DETAILLO "Low detail" -#define GAMMALVL0 "Gamma correction OFF" -#define GAMMALVL1 "Gamma correction level 1" -#define GAMMALVL2 "Gamma correction level 2" -#define GAMMALVL3 "Gamma correction level 3" -#define GAMMALVL4 "Gamma correction level 4" -#define EMPTYSTRING "empty slot" -#define GOTARMOR "Picked up the armor." -#define GOTMEGA "Picked up the MegaArmor!" -#define GOTHTHBONUS "Picked up a health bonus." -#define GOTARMBONUS "Picked up an armor bonus." -#define GOTSTIM "Picked up a stimpack." -#define GOTMEDINEED "Picked up a medikit that you REALLY need!" -#define GOTMEDIKIT "Picked up a medikit." -#define GOTSUPER "Supercharge!" -#define GOTBLUECARD "Picked up a blue keycard." -#define GOTYELWCARD "Picked up a yellow keycard." -#define GOTREDCARD "Picked up a red keycard." -#define GOTBLUESKUL "Picked up a blue skull key." -#define GOTYELWSKUL "Picked up a yellow skull key." -#define GOTREDSKULL "Picked up a red skull key." -#define GOTINVUL "Invulnerability!" -#define GOTBERSERK "Berserk!" -#define GOTINVIS "Partial Invisibility" -#define GOTSUIT "Radiation Shielding Suit" -#define GOTMAP "Computer Area Map" -#define GOTVISOR "Light Amplification Visor" -#define GOTMSPHERE "MegaSphere!" -#define GOTCLIP "Picked up a clip." -#define GOTCLIPBOX "Picked up a box of bullets." -#define GOTROCKET "Picked up a rocket." -#define GOTROCKBOX "Picked up a box of rockets." -#define GOTCELL "Picked up an energy cell." -#define GOTCELLBOX "Picked up an energy cell pack." -#define GOTSHELLS "Picked up 4 shotgun shells." -#define GOTSHELLBOX "Picked up a box of shotgun shells." -#define GOTBACKPACK "Picked up a backpack full of ammo!" -#define GOTBFG9000 "You got the BFG9000! Oh, yes." -#define GOTCHAINGUN "You got the chaingun!" -#define GOTCHAINSAW "A chainsaw! Find some meat!" -#define GOTLAUNCHER "You got the rocket launcher!" -#define GOTPLASMA "You got the plasma gun!" -#define GOTSHOTGUN "You got the shotgun!" -#define GOTSHOTGUN2 "You got the super shotgun!" -#define PD_BLUEO "You need a blue key to activate this object" -#define PD_REDO "You need a red key to activate this object" -#define PD_YELLOWO "You need a yellow key to activate this object" -#define PD_BLUEK "You need a blue key to open this door" -#define PD_REDK "You need a red key to open this door" -#define PD_YELLOWK "You need a yellow key to open this door" -#define GGSAVED "game saved." -#define HUSTR_MSGU "[Message unsent]" -#define HUSTR_E1M1 "E1M1: Hangar" -#define HUSTR_E1M2 "E1M2: Nuclear Plant" -#define HUSTR_E1M3 "E1M3: Toxin Refinery" -#define HUSTR_E1M4 "E1M4: Command Control" -#define HUSTR_E1M5 "E1M5: Phobos Lab" -#define HUSTR_E1M6 "E1M6: Central Processing" -#define HUSTR_E1M7 "E1M7: Computer Station" -#define HUSTR_E1M8 "E1M8: Phobos Anomaly" -#define HUSTR_E1M9 "E1M9: Military Base" -#define HUSTR_E2M1 "E2M1: Deimos Anomaly" -#define HUSTR_E2M2 "E2M2: Containment Area" -#define HUSTR_E2M3 "E2M3: Refinery" -#define HUSTR_E2M4 "E2M4: Deimos Lab" -#define HUSTR_E2M5 "E2M5: Command Center" -#define HUSTR_E2M6 "E2M6: Halls of the Damned" -#define HUSTR_E2M7 "E2M7: Spawning Vats" -#define HUSTR_E2M8 "E2M8: Tower of Babel" -#define HUSTR_E2M9 "E2M9: Fortress of Mystery" -#define HUSTR_E3M1 "E3M1: Hell Keep" -#define HUSTR_E3M2 "E3M2: Slough of Despair" -#define HUSTR_E3M3 "E3M3: Pandemonium" -#define HUSTR_E3M4 "E3M4: House of Pain" -#define HUSTR_E3M5 "E3M5: Unholy Cathedral" -#define HUSTR_E3M6 "E3M6: Mt. Erebus" -#define HUSTR_E3M7 "E3M7: Limbo" -#define HUSTR_E3M8 "E3M8: Dis" -#define HUSTR_E3M9 "E3M9: Warrens" -#define HUSTR_E4M1 "E4M1: Hell Beneath" -#define HUSTR_E4M2 "E4M2: Perfect Hatred" -#define HUSTR_E4M3 "E4M3: Sever The Wicked" -#define HUSTR_E4M4 "E4M4: Unruly Evil" -#define HUSTR_E4M5 "E4M5: They Will Repent" -#define HUSTR_E4M6 "E4M6: Against Thee Wickedly" -#define HUSTR_E4M7 "E4M7: And Hell Followed" -#define HUSTR_E4M8 "E4M8: Unto The Cruel" -#define HUSTR_E4M9 "E4M9: Fear" -#define HUSTR_1 "level 1: entryway" -#define HUSTR_2 "level 2: underhalls" -#define HUSTR_3 "level 3: the gantlet" -#define HUSTR_4 "level 4: the focus" -#define HUSTR_5 "level 5: the waste tunnels" -#define HUSTR_6 "level 6: the crusher" -#define HUSTR_7 "level 7: dead simple" -#define HUSTR_8 "level 8: tricks and traps" -#define HUSTR_9 "level 9: the pit" -#define HUSTR_10 "level 10: refueling base" -#define HUSTR_11 "level 11: 'o' of destruction!" -#define HUSTR_12 "level 12: the factory" -#define HUSTR_13 "level 13: downtown" -#define HUSTR_14 "level 14: the inmost dens" -#define HUSTR_15 "level 15: industrial zone" -#define HUSTR_16 "level 16: suburbs" -#define HUSTR_17 "level 17: tenements" -#define HUSTR_18 "level 18: the courtyard" -#define HUSTR_19 "level 19: the citadel" -#define HUSTR_20 "level 20: gotcha!" -#define HUSTR_21 "level 21: nirvana" -#define HUSTR_22 "level 22: the catacombs" -#define HUSTR_23 "level 23: barrels o' fun" -#define HUSTR_24 "level 24: the chasm" -#define HUSTR_25 "level 25: bloodfalls" -#define HUSTR_26 "level 26: the abandoned mines" -#define HUSTR_27 "level 27: monster condo" -#define HUSTR_28 "level 28: the spirit world" -#define HUSTR_29 "level 29: the living end" -#define HUSTR_30 "level 30: icon of sin" -#define HUSTR_31 "level 31: wolfenstein" -#define HUSTR_32 "level 32: grosse" -#define PHUSTR_1 "level 1: congo" -#define PHUSTR_2 "level 2: well of souls" -#define PHUSTR_3 "level 3: aztec" -#define PHUSTR_4 "level 4: caged" -#define PHUSTR_5 "level 5: ghost town" -#define PHUSTR_6 "level 6: baron's lair" -#define PHUSTR_7 "level 7: caughtyard" -#define PHUSTR_8 "level 8: realm" -#define PHUSTR_9 "level 9: abattoire" -#define PHUSTR_10 "level 10: onslaught" -#define PHUSTR_11 "level 11: hunted" -#define PHUSTR_12 "level 12: speed" -#define PHUSTR_13 "level 13: the crypt" -#define PHUSTR_14 "level 14: genesis" -#define PHUSTR_15 "level 15: the twilight" -#define PHUSTR_16 "level 16: the omen" -#define PHUSTR_17 "level 17: compound" -#define PHUSTR_18 "level 18: neurosphere" -#define PHUSTR_19 "level 19: nme" -#define PHUSTR_20 "level 20: the death domain" -#define PHUSTR_21 "level 21: slayer" -#define PHUSTR_22 "level 22: impossible mission" -#define PHUSTR_23 "level 23: tombstone" -#define PHUSTR_24 "level 24: the final frontier" -#define PHUSTR_25 "level 25: the temple of darkness" -#define PHUSTR_26 "level 26: bunker" -#define PHUSTR_27 "level 27: anti-christ" -#define PHUSTR_28 "level 28: the sewers" -#define PHUSTR_29 "level 29: odyssey of noises" -#define PHUSTR_30 "level 30: the gateway of hell" -#define PHUSTR_31 "level 31: cyberden" -#define PHUSTR_32 "level 32: go 2 it" -#define THUSTR_1 "level 1: system control" -#define THUSTR_2 "level 2: human bbq" -#define THUSTR_3 "level 3: power control" -#define THUSTR_4 "level 4: wormhole" -#define THUSTR_5 "level 5: hanger" -#define THUSTR_6 "level 6: open season" -#define THUSTR_7 "level 7: prison" -#define THUSTR_8 "level 8: metal" -#define THUSTR_9 "level 9: stronghold" -#define THUSTR_10 "level 10: redemption" -#define THUSTR_11 "level 11: storage facility" -#define THUSTR_12 "level 12: crater" -#define THUSTR_13 "level 13: nukage processing" -#define THUSTR_14 "level 14: steel works" -#define THUSTR_15 "level 15: dead zone" -#define THUSTR_16 "level 16: deepest reaches" -#define THUSTR_17 "level 17: processing area" -#define THUSTR_18 "level 18: mill" -#define THUSTR_19 "level 19: shipping/respawning" -#define THUSTR_20 "level 20: central processing" -#define THUSTR_21 "level 21: administration center" -#define THUSTR_22 "level 22: habitat" -#define THUSTR_23 "level 23: lunar mining project" -#define THUSTR_24 "level 24: quarry" -#define THUSTR_25 "level 25: baron's den" -#define THUSTR_26 "level 26: ballistyx" -#define THUSTR_27 "level 27: mount pain" -#define THUSTR_28 "level 28: heck" -#define THUSTR_29 "level 29: river styx" -#define THUSTR_30 "level 30: last call" -#define THUSTR_31 "level 31: pharaoh" -#define THUSTR_32 "level 32: caribbean" -#define HUSTR_CHATMACRO1 "I'm ready to kick butt!" -#define HUSTR_CHATMACRO2 "I'm OK." -#define HUSTR_CHATMACRO3 "I'm not looking too good!" -#define HUSTR_CHATMACRO4 "Help!" -#define HUSTR_CHATMACRO5 "You suck!" -#define HUSTR_CHATMACRO6 "Next time, scumbag..." -#define HUSTR_CHATMACRO7 "Come here!" -#define HUSTR_CHATMACRO8 "I'll take care of it." -#define HUSTR_CHATMACRO9 "Yes" -#define HUSTR_CHATMACRO0 "No" -#define HUSTR_TALKTOSELF1 "You mumble to yourself" -#define HUSTR_TALKTOSELF2 "Who's there?" -#define HUSTR_TALKTOSELF3 "You scare yourself" -#define HUSTR_TALKTOSELF4 "You start to rave" -#define HUSTR_TALKTOSELF5 "You've lost it..." -#define HUSTR_MESSAGESENT "[Message Sent]" -#define HUSTR_PLRGREEN "Green: " -#define HUSTR_PLRINDIGO "Indigo: " -#define HUSTR_PLRBROWN "Brown: " -#define HUSTR_PLRRED "Red: " -#define HUSTR_KEYGREEN 'g' -#define HUSTR_KEYINDIGO 'i' -#define HUSTR_KEYBROWN 'b' -#define HUSTR_KEYRED 'r' -#define AMSTR_FOLLOWON "Follow Mode ON" -#define AMSTR_FOLLOWOFF "Follow Mode OFF" -#define AMSTR_GRIDON "Grid ON" -#define AMSTR_GRIDOFF "Grid OFF" -#define AMSTR_MARKEDSPOT "Marked Spot" -#define AMSTR_MARKSCLEARED "All Marks Cleared" -#define STSTR_MUS "Music Change" -#define STSTR_NOMUS "IMPOSSIBLE SELECTION" -#define STSTR_DQDON "Degreelessness Mode On" -#define STSTR_DQDOFF "Degreelessness Mode Off" -#define STSTR_KFAADDED "Very Happy Ammo Added" -#define STSTR_FAADDED "Ammo (no keys) Added" -#define STSTR_NCON "No Clipping Mode ON" -#define STSTR_NCOFF "No Clipping Mode OFF" -#define STSTR_BEHOLD "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp" -#define STSTR_BEHOLDX "Power-up Toggled" -#define STSTR_CHOPPERS "... doesn't suck - GM" -#define STSTR_CLEV "Changing Level..." -#define E1TEXT \ -"Once you beat the big badasses and\n"\ -"clean out the moon base you're supposed\n"\ -"to win, aren't you? Aren't you? Where's\n"\ -"your fat reward and ticket home? What\n"\ -"the hell is this? It's not supposed to\n"\ -"end this way!\n"\ -"\n" \ -"It stinks like rotten meat, but looks\n"\ -"like the lost Deimos base. Looks like\n"\ -"you're stuck on The Shores of Hell.\n"\ -"The only way out is through.\n"\ -"\n"\ -"To continue the DOOM experience, play\n"\ -"The Shores of Hell and its amazing\n"\ -"sequel, Inferno!\n" -#define E2TEXT \ -"You've done it! The hideous cyber-\n"\ -"demon lord that ruled the lost Deimos\n"\ -"moon base has been slain and you\n"\ -"are triumphant! But ... where are\n"\ -"you? You clamber to the edge of the\n"\ -"moon and look down to see the awful\n"\ -"truth.\n" \ -"\n"\ -"Deimos floats above Hell itself!\n"\ -"You've never heard of anyone escaping\n"\ -"from Hell, but you'll make the bastards\n"\ -"sorry they ever heard of you! Quickly,\n"\ -"you rappel down to the surface of\n"\ -"Hell.\n"\ -"\n" \ -"Now, it's on to the final chapter of\n"\ -"DOOM! -- Inferno." -#define E3TEXT \ -"The loathsome spiderdemon that\n"\ -"masterminded the invasion of the moon\n"\ -"bases and caused so much death has had\n"\ -"its ass kicked for all time.\n"\ -"\n"\ -"A hidden doorway opens and you enter.\n"\ -"You've proven too tough for Hell to\n"\ -"contain, and now Hell at last plays\n"\ -"fair -- for you emerge from the door\n"\ -"to see the green fields of Earth!\n"\ -"Home at last.\n" \ -"\n"\ -"You wonder what's been happening on\n"\ -"Earth while you were battling evil\n"\ -"unleashed. It's good that no Hell-\n"\ -"spawn could have come through that\n"\ -"door with you ..." -#define E4TEXT \ -"the spider mastermind must have sent forth\n"\ -"its legions of hellspawn before your\n"\ -"final confrontation with that terrible\n"\ -"beast from hell. but you stepped forward\n"\ -"and brought forth eternal damnation and\n"\ -"suffering upon the horde as a true hero\n"\ -"would in the face of something so evil.\n"\ -"\n"\ -"besides, someone was gonna pay for what\n"\ -"happened to daisy, your pet rabbit.\n"\ -"\n"\ -"but now, you see spread before you more\n"\ -"potential pain and gibbitude as a nation\n"\ -"of demons run amok among our cities.\n"\ -"\n"\ -"next stop, hell on earth!" -#define C1TEXT \ -"YOU HAVE ENTERED DEEPLY INTO THE INFESTED\n" \ -"STARPORT. BUT SOMETHING IS WRONG. THE\n" \ -"MONSTERS HAVE BROUGHT THEIR OWN REALITY\n" \ -"WITH THEM, AND THE STARPORT'S TECHNOLOGY\n" \ -"IS BEING SUBVERTED BY THEIR PRESENCE.\n" \ -"\n"\ -"AHEAD, YOU SEE AN OUTPOST OF HELL, A\n" \ -"FORTIFIED ZONE. IF YOU CAN GET PAST IT,\n" \ -"YOU CAN PENETRATE INTO THE HAUNTED HEART\n" \ -"OF THE STARBASE AND FIND THE CONTROLLING\n" \ -"SWITCH WHICH HOLDS EARTH'S POPULATION\n" \ -"HOSTAGE." -#define C2TEXT \ -"YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" \ -"HUMANKIND TO EVACUATE EARTH AND ESCAPE\n"\ -"THE NIGHTMARE. NOW YOU ARE THE ONLY\n"\ -"HUMAN LEFT ON THE FACE OF THE PLANET.\n"\ -"CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n"\ -"AND EVIL SPIRITS ARE YOUR ONLY NEIGHBORS.\n"\ -"YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n"\ -"THAT YOU HAVE SAVED YOUR SPECIES.\n"\ -"\n"\ -"BUT THEN, EARTH CONTROL BEAMS DOWN A\n"\ -"MESSAGE FROM SPACE: \"SENSORS HAVE LOCATED\n"\ -"THE SOURCE OF THE ALIEN INVASION. IF YOU\n"\ -"GO THERE, YOU MAY BE ABLE TO BLOCK THEIR\n"\ -"ENTRY. THE ALIEN BASE IS IN THE HEART OF\n"\ -"YOUR OWN HOME CITY, NOT FAR FROM THE\n"\ -"STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n"\ -"UP AND RETURN TO THE FRAY." -#define C3TEXT \ -"YOU ARE AT THE CORRUPT HEART OF THE CITY,\n"\ -"SURROUNDED BY THE CORPSES OF YOUR ENEMIES.\n"\ -"YOU SEE NO WAY TO DESTROY THE CREATURES'\n"\ -"ENTRYWAY ON THIS SIDE, SO YOU CLENCH YOUR\n"\ -"TEETH AND PLUNGE THROUGH IT.\n"\ -"\n"\ -"THERE MUST BE A WAY TO CLOSE IT ON THE\n"\ -"OTHER SIDE. WHAT DO YOU CARE IF YOU'VE\n"\ -"GOT TO GO THROUGH HELL TO GET TO IT?" -#define C4TEXT \ -"THE HORRENDOUS VISAGE OF THE BIGGEST\n"\ -"DEMON YOU'VE EVER SEEN CRUMBLES BEFORE\n"\ -"YOU, AFTER YOU PUMP YOUR ROCKETS INTO\n"\ -"HIS EXPOSED BRAIN. THE MONSTER SHRIVELS\n"\ -"UP AND DIES, ITS THRASHING LIMBS\n"\ -"DEVASTATING UNTOLD MILES OF HELL'S\n"\ -"SURFACE.\n"\ -"\n"\ -"YOU'VE DONE IT. THE INVASION IS OVER.\n"\ -"EARTH IS SAVED. HELL IS A WRECK. YOU\n"\ -"WONDER WHERE BAD FOLKS WILL GO WHEN THEY\n"\ -"DIE, NOW. WIPING THE SWEAT FROM YOUR\n"\ -"FOREHEAD YOU BEGIN THE LONG TREK BACK\n"\ -"HOME. REBUILDING EARTH OUGHT TO BE A\n"\ -"LOT MORE FUN THAN RUINING IT WAS.\n" -#define C5TEXT \ -"CONGRATULATIONS, YOU'VE FOUND THE SECRET\n"\ -"LEVEL! LOOKS LIKE IT'S BEEN BUILT BY\n"\ -"HUMANS, RATHER THAN DEMONS. YOU WONDER\n"\ -"WHO THE INMATES OF THIS CORNER OF HELL\n"\ -"WILL BE." -#define C6TEXT \ -"CONGRATULATIONS, YOU'VE FOUND THE\n"\ -"SUPER SECRET LEVEL! YOU'D BETTER\n"\ -"BLAZE THROUGH THIS ONE!\n" -#define P1TEXT \ -"You gloat over the steaming carcass of the\n"\ -"Guardian. With its death, you've wrested\n"\ -"the Accelerator from the stinking claws\n"\ -"of Hell. You relax and glance around the\n"\ -"room. Damn! There was supposed to be at\n"\ -"least one working prototype, but you can't\n"\ -"see it. The demons must have taken it.\n"\ -"\n"\ -"You must find the prototype, or all your\n"\ -"struggles will have been wasted. Keep\n"\ -"moving, keep fighting, keep killing.\n"\ -"Oh yes, keep living, too." -#define P2TEXT \ -"Even the deadly Arch-Vile labyrinth could\n"\ -"not stop you, and you've gotten to the\n"\ -"prototype Accelerator which is soon\n"\ -"efficiently and permanently deactivated.\n"\ -"\n"\ -"You're good at that kind of thing." -#define P3TEXT \ -"You've bashed and battered your way into\n"\ -"the heart of the devil-hive. Time for a\n"\ -"Search-and-Destroy mission, aimed at the\n"\ -"Gatekeeper, whose foul offspring is\n"\ -"cascading to Earth. Yeah, he's bad. But\n"\ -"you know who's worse!\n"\ -"\n"\ -"Grinning evilly, you check your gear, and\n"\ -"get ready to give the bastard a little Hell\n"\ -"of your own making!" -#define P4TEXT \ -"The Gatekeeper's evil face is splattered\n"\ -"all over the place. As its tattered corpse\n"\ -"collapses, an inverted Gate forms and\n"\ -"sucks down the shards of the last\n"\ -"prototype Accelerator, not to mention the\n"\ -"few remaining demons. You're done. Hell\n"\ -"has gone back to pounding bad dead folks \n"\ -"instead of good live ones. Remember to\n"\ -"tell your grandkids to put a rocket\n"\ -"launcher in your coffin. If you go to Hell\n"\ -"when you die, you'll need it for some\n"\ -"final cleaning-up ..." -#define P5TEXT \ -"You've found the second-hardest level we\n"\ -"got. Hope you have a saved game a level or\n"\ -"two previous. If not, be prepared to die\n"\ -"aplenty. For master marines only." -#define P6TEXT \ -"Betcha wondered just what WAS the hardest\n"\ -"level we had ready for ya? Now you know.\n"\ -"No one gets out alive." -#define T1TEXT \ -"You've fought your way out of the infested\n"\ -"experimental labs. It seems that UAC has\n"\ -"once again gulped it down. With their\n"\ -"high turnover, it must be hard for poor\n"\ -"old UAC to buy corporate health insurance\n"\ -"nowadays..\n"\ -"\n"\ -"Ahead lies the military complex, now\n"\ -"swarming with diseased horrors hot to get\n"\ -"their teeth into you. With luck, the\n"\ -"complex still has some warlike ordnance\n"\ -"laying around." -#define T2TEXT \ -"You hear the grinding of heavy machinery\n"\ -"ahead. You sure hope they're not stamping\n"\ -"out new hellspawn, but you're ready to\n"\ -"ream out a whole herd if you have to.\n"\ -"They might be planning a blood feast, but\n"\ -"you feel about as mean as two thousand\n"\ -"maniacs packed into one mad killer.\n"\ -"\n"\ -"You don't plan to go down easy." -#define T3TEXT \ -"The vista opening ahead looks real damn\n"\ -"familiar. Smells familiar, too -- like\n"\ -"fried excrement. You didn't like this\n"\ -"place before, and you sure as hell ain't\n"\ -"planning to like it now. The more you\n"\ -"brood on it, the madder you get.\n"\ -"Hefting your gun, an evil grin trickles\n"\ -"onto your face. Time to take some names." -#define T4TEXT \ -"Suddenly, all is silent, from one horizon\n"\ -"to the other. The agonizing echo of Hell\n"\ -"fades away, the nightmare sky turns to\n"\ -"blue, the heaps of monster corpses start \n"\ -"to evaporate along with the evil stench \n"\ -"that filled the air. Jeeze, maybe you've\n"\ -"done it. Have you really won?\n"\ -"\n"\ -"Something rumbles in the distance.\n"\ -"A blue light begins to glow inside the\n"\ -"ruined skull of the demon-spitter." -#define T5TEXT \ -"What now? Looks totally different. Kind\n"\ -"of like King Tut's condo. Well,\n"\ -"whatever's here can't be any worse\n"\ -"than usual. Can it? Or maybe it's best\n"\ -"to let sleeping gods lie.." -#define T6TEXT \ -"Time for a vacation. You've burst the\n"\ -"bowels of hell and by golly you're ready\n"\ -"for a break. You mutter to yourself,\n"\ -"Maybe someone else can kick Hell's ass\n"\ -"next time around. Ahead lies a quiet town,\n"\ -"with peaceful flowing water, quaint\n"\ -"buildings, and presumably no Hellspawn.\n"\ -"\n"\ -"As you step off the transport, you hear\n"\ -"the stomp of a cyberdemon's iron shoe." -#define CC_ZOMBIE "ZOMBIEMAN" -#define CC_SHOTGUN "SHOTGUN GUY" -#define CC_HEAVY "HEAVY WEAPON DUDE" -#define CC_IMP "IMP" -#define CC_DEMON "DEMON" -#define CC_LOST "LOST SOUL" -#define CC_CACO "CACODEMON" -#define CC_HELL "HELL KNIGHT" -#define CC_BARON "BARON OF HELL" -#define CC_ARACH "ARACHNOTRON" -#define CC_PAIN "PAIN ELEMENTAL" -#define CC_REVEN "REVENANT" -#define CC_MANCU "MANCUBUS" -#define CC_ARCH "ARCH-VILE" -#define CC_SPIDER "THE SPIDER MASTERMIND" -#define CC_CYBER "THE CYBERDEMON" -#define CC_HERO "OUR HERO" -#endif diff --git a/src/d_event.h b/src/d_event.h @@ -1,50 +1,55 @@ #ifndef __D_EVENT__ #define __D_EVENT__ -#include "doomtype.h" -typedef enum -{ - ev_keydown, - ev_keyup, - ev_mouse, - ev_joystick -} evtype_t; -typedef struct -{ - evtype_t type; - int data1; - int data2; - int data3; -} event_t; -typedef enum -{ - ga_nothing, - ga_loadlevel, - ga_newgame, - ga_loadgame, - ga_savegame, - ga_playdemo, - ga_completed, - ga_victory, - ga_worlddone, - ga_screenshot + +#include "doomdef.h" + +typedef enum { + ev_keydown, + ev_keyup, + ev_mouse, + ev_joystick +}evtype_t; + + +typedef struct { + evtype_t type; + int data1; + int data2; + int data3; +}event_t; + + +typedef enum { + ga_nothing, + ga_loadlevel, + ga_newgame, + ga_loadgame, + ga_savegame, + ga_playdemo, + ga_completed, + ga_victory, + ga_worlddone } gameaction_t; -typedef enum -{ - BT_ATTACK = 1, - BT_USE = 2, - BT_SPECIAL = 128, - BT_SPECIALMASK = 3, - BT_CHANGE = 4, - BT_WEAPONMASK = (8+16+32), - BT_WEAPONSHIFT = 3, - BTS_PAUSE = 1, - BTS_SAVEGAME = 2, - BTS_SAVEMASK = (4+8+16), - BTS_SAVESHIFT = 2 -} buttoncode_t; + +typedef enum { + BT_ATTACK = 1, + BT_USE = 2, + BT_SPECIAL = 128, + BT_SPECIALMASK = 3, + BT_CHANGE = 4, + BT_WEAPONMASK = (8+16+32), + BT_WEAPONSHIFT = 3, + BTS_PAUSE = 1, + BTS_SAVEGAME = 2, + BTS_SAVEMASK = (4+8+16), + BTS_SAVESHIFT = 2 +}buttoncode_t; + #define MAXEVENTS 64 -extern event_t events[MAXEVENTS]; -extern int eventhead; -extern int eventtail; -extern gameaction_t gameaction; + +extern event_t events[MAXEVENTS]; +extern int eventhead; +extern int eventtail; +extern gameaction_t gameaction; + #endif diff --git a/src/d_french.h b/src/d_french.h @@ -1,5 +1,6 @@ #ifndef __D_FRENCH__ #define __D_FRENCH__ + #define D_DEVSTR "MODE DEVELOPPEMENT ON.\n" #define D_CDROM "VERSION CD-ROM: DEFAULT.CFG DANS C:\\DOOMDATA\n" #define PRESSKEY "APPUYEZ SUR UNE TOUCHE." @@ -8,21 +9,15 @@ #define LOADNET "VOUS NE POUVEZ PAS CHARGER\nUN JEU EN RESEAU!\n\n"PRESSKEY #define QLOADNET "CHARGEMENT RAPIDE INTERDIT EN RESEAU!\n\n"PRESSKEY #define QSAVESPOT "VOUS N'AVEZ PAS CHOISI UN EMPLACEMENT!\n\n"PRESSKEY -#define SAVEDEAD "VOUS NE POUVEZ PAS SAUVER SI VOUS NE JOUEZ "\ -"PAS!\n\n"PRESSKEY +#define SAVEDEAD "VOUS NE POUVEZ PAS SAUVER SI VOUS NE JOUEZ PAS!\n\n"PRESSKEY #define QSPROMPT "SAUVEGARDE RAPIDE DANS LE FICHIER \n\n'%s'?\n\n"PRESSYN -#define QLPROMPT "VOULEZ-VOUS CHARGER LA SAUVEGARDE"\ -"\n\n'%s'?\n\n"PRESSYN -#define NEWGAME "VOUS NE POUVEZ PAS LANCER\n"\ -"UN NOUVEAU JEU SUR RESEAU.\n\n"PRESSKEY -#define NIGHTMARE "VOUS CONFIRMEZ? CE NIVEAU EST\n"\ -"VRAIMENT IMPITOYABLE!n"PRESSYN -#define SWSTRING "CECI EST UNE VERSION SHAREWARE DE DOOM.\n\n"\ -"VOUS DEVRIEZ COMMANDER LA TRILOGIE COMPLETE.\n\n"PRESSKEY +#define QLPROMPT "VOULEZ-VOUS CHARGER LA SAUVEGARDE\n\n'%s'?\n\n"PRESSYN +#define NEWGAME "VOUS NE POUVEZ PAS LANCER\nUN NOUVEAU JEU SUR RESEAU.\n\n"PRESSKEY +#define NIGHTMARE "VOUS CONFIRMEZ? CE NIVEAU EST\nVRAIMENT IMPITOYABLE!n"PRESSYN +#define SWSTRING "CECI EST UNE VERSION SHAREWARE DE DOOM.\n\nVOUS DEVRIEZ COMMANDER LA TRILOGIE COMPLETE.\n\n"PRESSKEY #define MSGOFF "MESSAGES OFF" #define MSGON "MESSAGES ON" -#define NETEND "VOUS NE POUVEZ PAS METTRE FIN A UN JEU SUR "\ -"RESEAU!\n\n"PRESSKEY +#define NETEND "VOUS NE POUVEZ PAS METTRE FIN A UN JEU SUR RESEAU!\n\n"PRESSKEY #define ENDGAME "VOUS VOULEZ VRAIMENT METTRE FIN AU JEU?\n\n"PRESSYN #define DOSY "(APPUYEZ SUR Y POUR REVENIR AU OS.)" #define DETAILHI "GRAPHISMES MAXIMUM " @@ -179,116 +174,15 @@ #define STSTR_BEHOLDX "AMELIORATION ACTIVEE" #define STSTR_CHOPPERS "... DOESN'T SUCK - GM" #define STSTR_CLEV "CHANGEMENT DE NIVEAU..." -#define E1TEXT "APRES AVOIR VAINCU LES GROS MECHANTS\n"\ -"ET NETTOYE LA BASE LUNAIRE, VOUS AVEZ\n"\ -"GAGNE, NON? PAS VRAI? OU EST DONC VOTRE\n"\ -" RECOMPENSE ET VOTRE BILLET DE\n"\ -"RETOUR? QU'EST-QUE CA VEUT DIRE?CE"\ -"N'EST PAS LA FIN ESPEREE!\n"\ -"\n" \ -"CA SENT LA VIANDE PUTREFIEE, MAIS\n"\ -"ON DIRAIT LA BASE DEIMOS. VOUS ETES\n"\ -"APPAREMMENT BLOQUE AUX PORTES DE L'ENFER.\n"\ -"LA SEULE ISSUE EST DE L'AUTRE COTE.\n"\ -"\n"\ -"POUR VIVRE LA SUITE DE DOOM, JOUEZ\n"\ -"A 'AUX PORTES DE L'ENFER' ET A\n"\ -"L'EPISODE SUIVANT, 'L'ENFER'!\n" -#define E2TEXT "VOUS AVEZ REUSSI. L'INFAME DEMON\n"\ -"QUI CONTROLAIT LA BASE LUNAIRE DE\n"\ -"DEIMOS EST MORT, ET VOUS AVEZ\n"\ -"TRIOMPHE! MAIS... OU ETES-VOUS?\n"\ -"VOUS GRIMPEZ JUSQU'AU BORD DE LA\n"\ -"LUNE ET VOUS DECOUVREZ L'ATROCE\n"\ -"VERITE.\n" \ -"\n"\ -"DEIMOS EST AU-DESSUS DE L'ENFER!\n"\ -"VOUS SAVEZ QUE PERSONNE NE S'EN\n"\ -"EST JAMAIS ECHAPPE, MAIS CES FUMIERS\n"\ -"VONT REGRETTER DE VOUS AVOIR CONNU!\n"\ -"VOUS REDESCENDEZ RAPIDEMENT VERS\n"\ -"LA SURFACE DE L'ENFER.\n"\ -"\n" \ -"VOICI MAINTENANT LE CHAPITRE FINAL DE\n"\ -"DOOM! -- L'ENFER." -#define E3TEXT "LE DEMON ARACHNEEN ET REPUGNANT\n"\ -"QUI A DIRIGE L'INVASION DES BASES\n"\ -"LUNAIRES ET SEME LA MORT VIENT DE SE\n"\ -"FAIRE PULVERISER UNE FOIS POUR TOUTES.\n"\ -"\n"\ -"UNE PORTE SECRETE S'OUVRE. VOUS ENTREZ.\n"\ -"VOUS AVEZ PROUVE QUE VOUS POUVIEZ\n"\ -"RESISTER AUX HORREURS DE L'ENFER.\n"\ -"IL SAIT ETRE BEAU JOUEUR, ET LORSQUE\n"\ -"VOUS SORTEZ, VOUS REVOYEZ LES VERTES\n"\ -"PRAIRIES DE LA TERRE, VOTRE PLANETE.\n"\ -"\n"\ -"VOUS VOUS DEMANDEZ CE QUI S'EST PASSE\n"\ -"SUR TERRE PENDANT QUE VOUS AVEZ\n"\ -"COMBATTU LE DEMON. HEUREUSEMENT,\n"\ -"AUCUN GERME DU MAL N'A FRANCHI\n"\ -"CETTE PORTE AVEC VOUS..." -#define C1TEXT "VOUS ETES AU PLUS PROFOND DE L'ASTROPORT\n" \ -"INFESTE DE MONSTRES, MAIS QUELQUE CHOSE\n" \ -"NE VA PAS. ILS ONT APPORTE LEUR PROPRE\n" \ -"REALITE, ET LA TECHNOLOGIE DE L'ASTROPORT\n" \ -"EST AFFECTEE PAR LEUR PRESENCE.\n" \ -"\n"\ -"DEVANT VOUS, VOUS VOYEZ UN POSTE AVANCE\n" \ -"DE L'ENFER, UNE ZONE FORTIFIEE. SI VOUS\n" \ -"POUVEZ PASSER, VOUS POURREZ PENETRER AU\n" \ -"COEUR DE LA BASE HANTEE ET TROUVER \n" \ -"L'INTERRUPTEUR DE CONTROLE QUI GARDE LA \n" \ -"POPULATION DE LA TERRE EN OTAGE." -#define C2TEXT "VOUS AVEZ GAGNE! VOTRE VICTOIRE A PERMIS\n" \ -"A L'HUMANITE D'EVACUER LA TERRE ET \n"\ -"D'ECHAPPER AU CAUCHEMAR. VOUS ETES \n"\ -"MAINTENANT LE DERNIER HUMAIN A LA SURFACE \n"\ -"DE LA PLANETE. VOUS ETES ENTOURE DE \n"\ -"MUTANTS CANNIBALES, D'EXTRATERRESTRES \n"\ -"CARNIVORES ET D'ESPRITS DU MAL. VOUS \n"\ -"ATTENDEZ CALMEMENT LA MORT, HEUREUX \n"\ -"D'AVOIR PU SAUVER VOTRE RACE.\n"\ -"MAIS UN MESSAGE VOUS PARVIENT SOUDAIN\n"\ -"DE L'ESPACE: \"NOS CAPTEURS ONT LOCALISE\n"\ -"LA SOURCE DE L'INVASION EXTRATERRESTRE.\n"\ -"SI VOUS Y ALLEZ, VOUS POURREZ PEUT-ETRE\n"\ -"LES ARRETER. LEUR BASE EST SITUEE AU COEUR\n"\ -"DE VOTRE VILLE NATALE, PRES DE L'ASTROPORT.\n"\ -"VOUS VOUS RELEVEZ LENTEMENT ET PENIBLEMENT\n"\ -"ET VOUS REPARTEZ POUR LE FRONT." -#define C3TEXT "VOUS ETES AU COEUR DE LA CITE CORROMPUE,\n"\ -"ENTOURE PAR LES CADAVRES DE VOS ENNEMIS.\n"\ -"VOUS NE VOYEZ PAS COMMENT DETRUIRE LA PORTE\n"\ -"DES CREATURES DE CE COTE. VOUS SERREZ\n"\ -"LES DENTS ET PLONGEZ DANS L'OUVERTURE.\n"\ -"\n"\ -"IL DOIT Y AVOIR UN MOYEN DE LA FERMER\n"\ -"DE L'AUTRE COTE. VOUS ACCEPTEZ DE\n"\ -"TRAVERSER L'ENFER POUR LE FAIRE?" -#define C4TEXT "LE VISAGE HORRIBLE D'UN DEMON D'UNE\n"\ -"TAILLE INCROYABLE S'EFFONDRE DEVANT\n"\ -"VOUS LORSQUE VOUS TIREZ UNE SALVE DE\n"\ -"ROQUETTES DANS SON CERVEAU. LE MONSTRE\n"\ -"SE RATATINE, SES MEMBRES DECHIQUETES\n"\ -"SE REPANDANT SUR DES CENTAINES DE\n"\ -"KILOMETRES A LA SURFACE DE L'ENFER.\n"\ -"\n"\ -"VOUS AVEZ REUSSI. L'INVASION N'AURA.\n"\ -"PAS LIEU. LA TERRE EST SAUVEE. L'ENFER\n"\ -"EST ANEANTI. EN VOUS DEMANDANT OU IRONT\n"\ -"MAINTENANT LES DAMNES, VOUS ESSUYEZ\n"\ -"VOTRE FRONT COUVERT DE SUEUR ET REPARTEZ\n"\ -"VERS LA TERRE. SA RECONSTRUCTION SERA\n"\ -"BEAUCOUP PLUS DROLE QUE SA DESTRUCTION.\n" -#define C5TEXT "FELICITATIONS! VOUS AVEZ TROUVE LE\n"\ -"NIVEAU SECRET! IL SEMBLE AVOIR ETE\n"\ -"CONSTRUIT PAR LES HUMAINS. VOUS VOUS\n"\ -"DEMANDEZ QUELS PEUVENT ETRE LES\n"\ -"HABITANTS DE CE COIN PERDU DE L'ENFER." -#define C6TEXT "FELICITATIONS! VOUS AVEZ DECOUVERT\n"\ -"LE NIVEAU SUPER SECRET! VOUS FERIEZ\n"\ -"MIEUX DE FONCER DANS CELUI-LA!\n" +#define E1TEXT "APRES AVOIR VAINCU LES GROS MECHANTS\nET NETTOYE LA BASE LUNAIRE, VOUS AVEZ\nGAGNE, NON? PAS VRAI? OU EST DONC VOTRE\n RECOMPENSE ET VOTRE BILLET DE\nRETOUR? QU'EST-QUE CA VEUT DIRE?CEN'EST PAS LA FIN ESPEREE!\n\nCA SENT LA VIANDE PUTREFIEE, MAIS\nON DIRAIT LA BASE DEIMOS. VOUS ETES\nAPPAREMMENT BLOQUE AUX PORTES DE L'ENFER.\nLA SEULE ISSUE EST DE L'AUTRE COTE.\n\nPOUR VIVRE LA SUITE DE DOOM, JOUEZ\nA 'AUX PORTES DE L'ENFER' ET A\nL'EPISODE SUIVANT, 'L'ENFER'!\n" +#define E2TEXT "VOUS AVEZ REUSSI. L'INFAME DEMON\nQUI CONTROLAIT LA BASE LUNAIRE DE\nDEIMOS EST MORT, ET VOUS AVEZ\nTRIOMPHE! MAIS... OU ETES-VOUS?\nVOUS GRIMPEZ JUSQU'AU BORD DE LA\nLUNE ET VOUS DECOUVREZ L'ATROCE\nVERITE.\n\nDEIMOS EST AU-DESSUS DE L'ENFER!\nVOUS SAVEZ QUE PERSONNE NE S'EN\nEST JAMAIS ECHAPPE, MAIS CES FUMIERS\nVONT REGRETTER DE VOUS AVOIR CONNU!\nVOUS REDESCENDEZ RAPIDEMENT VERS\nLA SURFACE DE L'ENFER.\n\nVOICI MAINTENANT LE CHAPITRE FINAL DE\nDOOM! -- L'ENFER." +#define E3TEXT "LE DEMON ARACHNEEN ET REPUGNANT\nQUI A DIRIGE L'INVASION DES BASES\nLUNAIRES ET SEME LA MORT VIENT DE SE\nFAIRE PULVERISER UNE FOIS POUR TOUTES.\n\nUNE PORTE SECRETE S'OUVRE. VOUS ENTREZ.\nVOUS AVEZ PROUVE QUE VOUS POUVIEZ\nRESISTER AUX HORREURS DE L'ENFER.\nIL SAIT ETRE BEAU JOUEUR, ET LORSQUE\nVOUS SORTEZ, VOUS REVOYEZ LES VERTES\nPRAIRIES DE LA TERRE, VOTRE PLANETE.\n\nVOUS VOUS DEMANDEZ CE QUI S'EST PASSE\nSUR TERRE PENDANT QUE VOUS AVEZ\nCOMBATTU LE DEMON. HEUREUSEMENT,\nAUCUN GERME DU MAL N'A FRANCHI\nCETTE PORTE AVEC VOUS..." +#define C1TEXT "VOUS ETES AU PLUS PROFOND DE L'ASTROPORT\nINFESTE DE MONSTRES, MAIS QUELQUE CHOSE\nNE VA PAS. ILS ONT APPORTE LEUR PROPRE\nREALITE, ET LA TECHNOLOGIE DE L'ASTROPORT\nEST AFFECTEE PAR LEUR PRESENCE.\n\nDEVANT VOUS, VOUS VOYEZ UN POSTE AVANCE\nDE L'ENFER, UNE ZONE FORTIFIEE. SI VOUS\nPOUVEZ PASSER, VOUS POURREZ PENETRER AU\nCOEUR DE LA BASE HANTEE ET TROUVER \nL'INTERRUPTEUR DE CONTROLE QUI GARDE LA \nPOPULATION DE LA TERRE EN OTAGE." +#define C2TEXT "VOUS AVEZ GAGNE! VOTRE VICTOIRE A PERMIS\nA L'HUMANITE D'EVACUER LA TERRE ET \nD'ECHAPPER AU CAUCHEMAR. VOUS ETES \nMAINTENANT LE DERNIER HUMAIN A LA SURFACE \nDE LA PLANETE. VOUS ETES ENTOURE DE \nMUTANTS CANNIBALES, D'EXTRATERRESTRES \nCARNIVORES ET D'ESPRITS DU MAL. VOUS \nATTENDEZ CALMEMENT LA MORT, HEUREUX \nD'AVOIR PU SAUVER VOTRE RACE.\nMAIS UN MESSAGE VOUS PARVIENT SOUDAIN\nDE L'ESPACE: \"NOS CAPTEURS ONT LOCALISE\nLA SOURCE DE L'INVASION EXTRATERRESTRE.\nSI VOUS Y ALLEZ, VOUS POURREZ PEUT-ETRE\nLES ARRETER. LEUR BASE EST SITUEE AU COEUR\nDE VOTRE VILLE NATALE, PRES DE L'ASTROPORT.\nVOUS VOUS RELEVEZ LENTEMENT ET PENIBLEMENT\nET VOUS REPARTEZ POUR LE FRONT." +#define C3TEXT "VOUS ETES AU COEUR DE LA CITE CORROMPUE,\nENTOURE PAR LES CADAVRES DE VOS ENNEMIS.\nVOUS NE VOYEZ PAS COMMENT DETRUIRE LA PORTE\nDES CREATURES DE CE COTE. VOUS SERREZ\nLES DENTS ET PLONGEZ DANS L'OUVERTURE.\n\nIL DOIT Y AVOIR UN MOYEN DE LA FERMER\nDE L'AUTRE COTE. VOUS ACCEPTEZ DE\nTRAVERSER L'ENFER POUR LE FAIRE?" +#define C4TEXT "LE VISAGE HORRIBLE D'UN DEMON D'UNE\nTAILLE INCROYABLE S'EFFONDRE DEVANT\nVOUS LORSQUE VOUS TIREZ UNE SALVE DE\nROQUETTES DANS SON CERVEAU. LE MONSTRE\nSE RATATINE, SES MEMBRES DECHIQUETES\nSE REPANDANT SUR DES CENTAINES DE\nKILOMETRES A LA SURFACE DE L'ENFER.\n\nVOUS AVEZ REUSSI. L'INVASION N'AURA.\nPAS LIEU. LA TERRE EST SAUVEE. L'ENFER\nEST ANEANTI. EN VOUS DEMANDANT OU IRONT\nMAINTENANT LES DAMNES, VOUS ESSUYEZ\nVOTRE FRONT COUVERT DE SUEUR ET REPARTEZ\nVERS LA TERRE. SA RECONSTRUCTION SERA\nBEAUCOUP PLUS DROLE QUE SA DESTRUCTION.\n" +#define C5TEXT "FELICITATIONS! VOUS AVEZ TROUVE LE\nNIVEAU SECRET! IL SEMBLE AVOIR ETE\nCONSTRUIT PAR LES HUMAINS. VOUS VOUS\nDEMANDEZ QUELS PEUVENT ETRE LES\nHABITANTS DE CE COIN PERDU DE L'ENFER." +#define C6TEXT "FELICITATIONS! VOUS AVEZ DECOUVERT\nLE NIVEAU SUPER SECRET! VOUS FERIEZ\nMIEUX DE FONCER DANS CELUI-LA!\n" #define CC_ZOMBIE "ZOMBIE" #define CC_SHOTGUN "TYPE AU FUSIL" #define CC_HEAVY "MEC SUPER-ARME" @@ -306,4 +200,5 @@ #define CC_SPIDER "L'ARAIGNEE CERVEAU" #define CC_CYBER "LE CYBERDEMON" #define CC_HERO "NOTRE HEROS" + #endif diff --git a/src/d_items.c b/src/d_items.c @@ -1,80 +1,15 @@ #include "info.h" -#ifdef __GNUG__ -#pragma implementation "d_items.h" -#endif + #include "d_items.h" -weaponinfo_t weaponinfo[NUMWEAPONS] = -{ - { - am_noammo, - S_PUNCHUP, - S_PUNCHDOWN, - S_PUNCH, - S_PUNCH1, - S_NULL - }, - { - am_clip, - S_PISTOLUP, - S_PISTOLDOWN, - S_PISTOL, - S_PISTOL1, - S_PISTOLFLASH - }, - { - am_shell, - S_SGUNUP, - S_SGUNDOWN, - S_SGUN, - S_SGUN1, - S_SGUNFLASH1 - }, - { - am_clip, - S_CHAINUP, - S_CHAINDOWN, - S_CHAIN, - S_CHAIN1, - S_CHAINFLASH1 - }, - { - am_misl, - S_MISSILEUP, - S_MISSILEDOWN, - S_MISSILE, - S_MISSILE1, - S_MISSILEFLASH1 - }, - { - am_cell, - S_PLASMAUP, - S_PLASMADOWN, - S_PLASMA, - S_PLASMA1, - S_PLASMAFLASH1 - }, - { - am_cell, - S_BFGUP, - S_BFGDOWN, - S_BFG, - S_BFG1, - S_BFGFLASH1 - }, - { - am_noammo, - S_SAWUP, - S_SAWDOWN, - S_SAW, - S_SAW1, - S_NULL - }, - { - am_shell, - S_DSGUNUP, - S_DSGUNDOWN, - S_DSGUN, - S_DSGUN1, - S_DSGUNFLASH1 - }, -}; + +weaponinfo_t weaponinfo[NUMWEAPONS] = { + { am_noammo, S_PUNCHUP, S_PUNCHDOWN, S_PUNCH, S_PUNCH1, S_NULL }, + { am_clip, S_PISTOLUP, S_PISTOLDOWN, S_PISTOL, S_PISTOL1, S_PISTOLFLASH }, + { am_shell, S_SGUNUP, S_SGUNDOWN, S_SGUN, S_SGUN1, S_SGUNFLASH1}, + { am_clip, S_CHAINUP, S_CHAINDOWN, S_CHAIN, S_CHAIN1, S_CHAINFLASH1 }, + { am_misl, S_MISSILEUP, S_MISSILEDOWN, S_MISSILE, S_MISSILE1, S_MISSILEFLASH1 }, + { am_cell, S_PLASMAUP, S_PLASMADOWN, S_PLASMA, S_PLASMA1, S_PLASMAFLASH1 }, + { am_cell, S_BFGUP, S_BFGDOWN, S_BFG, S_BFG1, S_BFGFLASH1 }, + { am_noammo, S_SAWUP, S_SAWDOWN, S_SAW, S_SAW1, S_NULL }, + { am_shell, S_DSGUNUP, S_DSGUNDOWN, S_DSGUN, S_DSGUN1, S_DSGUNFLASH1 }, +}; +\ No newline at end of file diff --git a/src/d_items.h b/src/d_items.h @@ -1,9 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_ITEMS__ #define __D_ITEMS__ + #include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + typedef struct { ammotype_t ammo; @@ -12,6 +39,14 @@ typedef struct int readystate; int atkstate; int flashstate; + } weaponinfo_t; + extern weaponinfo_t weaponinfo[NUMWEAPONS]; + #endif + + + + + diff --git a/src/d_main.c b/src/d_main.c @@ -1,11 +1,13 @@ #define BGCOLOR 7 #define FGCOLOR 8 + #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> + #include "doomdef.h" #include "doomstat.h" #include "dstrings.h" @@ -30,770 +32,282 @@ #include "p_setup.h" #include "r_local.h" #include "d_main.h" -void D_DoomLoop (void); -char* wadfiles[MAXWADFILES]; -boolean devparm; -boolean nomonsters; -boolean respawnparm; -boolean fastparm; -boolean drone; -boolean singletics = false; -extern boolean inhelpscreens; -skill_t startskill; -int startepisode; -int startmap; -boolean autostart; -FILE* debugfile; -boolean advancedemo; -char wadfile[1024]; -char mapdir[1024]; -char basedefault[1024]; -void D_CheckNetGame (void); -void D_ProcessEvents (void); -void G_BuildTiccmd (ticcmd_t* cmd); -void D_DoAdvanceDemo (void); -event_t events[MAXEVENTS]; -int eventhead; -int eventtail; + +void D_CheckNetGame(); +void D_ProcessEvents(); +void G_BuildTiccmd(ticcmd_t* cmd); +void D_DoAdvanceDemo(); + +extern boolean setsizeneeded; +extern int showMessages; +extern boolean inhelpscreens; +skill_t startskill; +FILE* debugfile; +char* wadfiles[MAXWADFILES]; +int startepisode; +int startmap; +boolean devparm; +boolean nomonsters; +boolean respawnparm; +boolean fastparm; +boolean drone; +boolean singletics = false; +boolean autostart; +boolean advancedemo; +char wadfile[1024]; +char mapdir[1024]; +char basedefault[1024]; +event_t events[MAXEVENTS]; +int eventhead; +int eventtail; +gamestate_t wipegamestate = GS_DEMOSCREEN; +void R_ExecuteSetViewSize(); void D_PostEvent(event_t* ev) { - events[eventhead] = *ev; - eventhead = (eventhead + 1)&(MAXEVENTS-1); -} -void D_ProcessEvents (void) -{ - event_t* ev; - if ( ( gamemode == commercial ) - && (W_CheckNumForName("map01")<0) ) - return; - for ( ; eventtail != eventhead ; eventtail = (eventtail + 1)&(MAXEVENTS-1) ) - { - ev = &events[eventtail]; - if (M_Responder (ev)) - continue; - G_Responder (ev); - } + events[eventhead] = *ev; + eventhead =(eventhead + 1)&(MAXEVENTS-1); } -gamestate_t wipegamestate = GS_DEMOSCREEN; -extern boolean setsizeneeded; -extern int showMessages; -void R_ExecuteSetViewSize (void); -void D_Display (void) + +void +D_ProcessEvents() { - static boolean viewactivestate = false; - static boolean menuactivestate = false; - static boolean inhelpscreensstate = false; - static boolean fullscreen = false; - static gamestate_t oldgamestate = -1; - static int borderdrawcount; - int nowtime; - int tics; - int wipestart; - int y; - boolean done; - boolean wipe; - boolean redrawsbar; - if (nodrawers) - return; - redrawsbar = false; - if (setsizeneeded) - { - R_ExecuteSetViewSize (); - oldgamestate = -1; - borderdrawcount = 3; - } - if (gamestate != wipegamestate) - { - wipe = true; - wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - wipe = false; - if (gamestate == GS_LEVEL && gametic) - HU_Erase(); - switch (gamestate) - { - case GS_LEVEL: - if (!gametic) - break; - if (automapactive) - AM_Drawer (); - if (wipe || (viewheight != 200 && fullscreen) ) - redrawsbar = true; - if (inhelpscreensstate && !inhelpscreens) - redrawsbar = true; - ST_Drawer (viewheight == 200, redrawsbar ); - fullscreen = viewheight == 200; - break; - case GS_INTERMISSION: - WI_Drawer (); - break; - case GS_FINALE: - F_Drawer (); - break; - case GS_DEMOSCREEN: - D_PageDrawer (); - break; - } - I_UpdateNoBlit (); - if (gamestate == GS_LEVEL && !automapactive && gametic) - R_RenderPlayerView (&players[displayplayer]); - if (gamestate == GS_LEVEL && gametic) - HU_Drawer (); - if (gamestate != oldgamestate && gamestate != GS_LEVEL) - I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); - if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) - { - viewactivestate = false; - R_FillBackScreen (); - } - if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320) - { - if (menuactive || menuactivestate || !viewactivestate) - borderdrawcount = 3; - if (borderdrawcount) - { - R_DrawViewBorder (); - borderdrawcount--; + event_t* ev; + + for (; eventtail != eventhead; eventtail =(eventtail + 1)&(MAXEVENTS-1)) { + ev = &events[eventtail]; + if (M_Responder(ev)) continue; + G_Responder(ev); } - } - menuactivestate = menuactive; - viewactivestate = viewactive; - inhelpscreensstate = inhelpscreens; - oldgamestate = wipegamestate = gamestate; - if (paused) - { - if (automapactive) - y = 4; - else - y = viewwindowy+4; - V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2, - y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE)); - } - M_Drawer (); - NetUpdate (); - if (!wipe) - { - I_FinishUpdate (); - return; - } - wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); - wipestart = I_GetTime () - 1; - do - { - do - { - nowtime = I_GetTime (); - tics = nowtime - wipestart; - } while (!tics); - wipestart = nowtime; - done = wipe_ScreenWipe(wipe_Melt - , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics); - I_UpdateNoBlit (); - M_Drawer (); - I_FinishUpdate (); - } while (!done); } -extern boolean demorecording; -void D_DoomLoop (void) + +void +D_Display() { - if (demorecording) - G_BeginRecording (); - if (M_CheckParm ("-debugfile")) - { - char filename[20]; - sprintf (filename,"debug%i.txt",consoleplayer); - printf ("debug output to: %s\n",filename); - debugfile = fopen (filename,"w"); - } - I_InitGraphics (); - while (1) - { - if (singletics) - { - I_StartTic (); - D_ProcessEvents (); - G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); - if (advancedemo) - D_DoAdvanceDemo (); - M_Ticker (); - G_Ticker (); - gametic++; - maketic++; + static boolean viewactivestate = false; + static boolean menuactivestate = false; + static boolean inhelpscreensstate = false; + static boolean fullscreen = false; + static gamestate_t oldgamestate = -1; + static int borderdrawcount; + int nowtime, tics, wipestart, y; + boolean done, wipe, redrawsbar; + + if (nodrawers) + return; + redrawsbar = false; + if (setsizeneeded) { + R_ExecuteSetViewSize(); + oldgamestate = -1; + borderdrawcount = 3; + } + if (gamestate != wipegamestate) { + wipe = true; + wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } else - { - TryRunTics (); + wipe = false; + if (gamestate == GS_LEVEL && gametic) + HU_Erase(); + switch (gamestate) { + case GS_LEVEL: + if (!gametic) + break; + if (automapactive) + AM_Drawer(); + if (wipe ||(viewheight != 200 && fullscreen)) + redrawsbar = true; + if (inhelpscreensstate && !inhelpscreens) + redrawsbar = true; + ST_Drawer(viewheight == 200, redrawsbar); + fullscreen = viewheight == 200; + break; + case GS_INTERMISSION: + WI_Drawer(); + break; + case GS_FINALE: + F_Drawer(); + break; + case GS_DEMOSCREEN: + D_PageDrawer(); + break; + } + I_UpdateNoBlit(); + if (gamestate == GS_LEVEL && gametic && !automapactive) + R_RenderPlayerView(&players[displayplayer]); + if (gamestate == GS_LEVEL && gametic) + HU_Drawer(); + if (gamestate != oldgamestate && gamestate != GS_LEVEL) + I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); + if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) { + viewactivestate = false; + R_FillBackScreen(); + } + if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320) { + if (menuactive || menuactivestate || !viewactivestate) borderdrawcount = 3; + if (borderdrawcount) { + R_DrawViewBorder(); + borderdrawcount--; + } + } + menuactivestate = menuactive; + viewactivestate = viewactive; + inhelpscreensstate = inhelpscreens; + oldgamestate = wipegamestate = gamestate; + if (paused) { + if (automapactive) y = 4; + else y = viewwindowy + 4; + V_DrawPatch(viewwindowx+(scaledviewwidth-68)/2, y, 0, W_CacheLumpName("M_PAUSE", PU_CACHE)); + } + M_Drawer(); + NetUpdate(); + if (!wipe) { + I_FinishUpdate(); + return; } - S_UpdateSounds (players[consoleplayer].mo); - D_Display (); -#ifndef SNDSERV - I_UpdateSound(); -#endif -#ifndef SNDINTR - I_SubmitSound(); -#endif - } + wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); + wipestart = I_GetTime() - 1; + do { + do { + nowtime = I_GetTime(); + tics = nowtime - wipestart; + } while(!tics); + wipestart = nowtime; + done = wipe_ScreenWipe(wipe_Melt, 0, 0, SCREENWIDTH, SCREENHEIGHT, tics); + I_UpdateNoBlit(); + M_Drawer(); + I_FinishUpdate(); + } while(!done); } -int demosequence; -int pagetic; -char *pagename; -void D_PageTicker (void) + +int demosequence; +int pagetic; +char* pagename; + +void +D_PageTicker() { - if (--pagetic < 0) - D_AdvanceDemo (); + if (--pagetic < 0) + D_AdvanceDemo(); } -void D_PageDrawer (void) + +void +D_PageDrawer() { - V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE)); + V_DrawPatch(0, 0, 0, W_CacheLumpName(pagename, PU_CACHE)); } -void D_AdvanceDemo (void) + +void +D_AdvanceDemo() { - advancedemo = true; + advancedemo = true; } - void D_DoAdvanceDemo (void) + +void +D_DoAdvanceDemo() { - players[consoleplayer].playerstate = PST_LIVE; - advancedemo = false; - usergame = false; - paused = false; - gameaction = ga_nothing; - if ( gamemode == retail ) - demosequence = (demosequence+1)%7; - else - demosequence = (demosequence+1)%6; - switch (demosequence) - { - case 0: - if ( gamemode == commercial ) - pagetic = 35 * 11; - else - pagetic = 170; - gamestate = GS_DEMOSCREEN; - pagename = "TITLEPIC"; - if ( gamemode == commercial ) - S_StartMusic(mus_dm2ttl); - else - S_StartMusic (mus_intro); - break; - case 1: - G_DeferedPlayDemo ("demo1"); - break; - case 2: - pagetic = 200; - gamestate = GS_DEMOSCREEN; - pagename = "CREDIT"; - break; - case 3: - G_DeferedPlayDemo ("demo2"); - break; - case 4: - gamestate = GS_DEMOSCREEN; - if ( gamemode == commercial) - { - pagetic = 35 * 11; - pagename = "TITLEPIC"; - S_StartMusic(mus_dm2ttl); - } - else - { - pagetic = 200; - if ( gamemode == retail ) - pagename = "CREDIT"; - else - pagename = "HELP2"; + players[consoleplayer].playerstate = PST_LIVE; + advancedemo = false; + usergame = false; + paused = false; + gameaction = ga_nothing; + demosequence =(demosequence+1)%6; + switch (demosequence) { + case 0: + pagetic = 170; + gamestate = GS_DEMOSCREEN; + pagename = "TITLEPIC"; + S_StartMusic(mus_intro); + break; + case 1: + G_DeferedPlayDemo("DEMO1"); + break; + case 2: + pagetic = 200; + gamestate = GS_DEMOSCREEN; + pagename = "CREDIT"; + break; + case 3: + G_DeferedPlayDemo("DEMO2"); + break; + case 4: + gamestate = GS_DEMOSCREEN; + pagetic = 200; + pagename = "HELP2"; + break; + case 5: + G_DeferedPlayDemo("DEMO3"); + break; + case 6: + G_DeferedPlayDemo("DEMO4"); + break; } - break; - case 5: - G_DeferedPlayDemo ("demo3"); - break; - case 6: - G_DeferedPlayDemo ("demo4"); - break; - } -} -void D_StartTitle (void) -{ - gameaction = ga_nothing; - demosequence = -1; - D_AdvanceDemo (); } -char title[128]; -void D_AddFile (char *file) + +void +D_StartTitle() { - int numwadfiles; - char *newfile; - for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++); - newfile = malloc(strlen(file)+1); - strcpy (newfile, file); - wadfiles[numwadfiles] = newfile; + gameaction = ga_nothing; + demosequence = -1; + D_AdvanceDemo(); } -void IdentifyVersion (void) + +void +D_AddFile(char* file) { - char* doom1wad; - char* doomwad; - char* doomuwad; - char* doom2wad; - char* doom2fwad; - char* plutoniawad; - char* tntwad; - char *home; - char *doomwaddir; + char* newfile; + int numwadfiles; - doomwaddir = getenv("DOOMWADDIR"); - if (!doomwaddir) - doomwaddir = "."; - doom2wad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(doom2wad, "%s/doom2.wad", doomwaddir); - doomuwad = malloc(strlen(doomwaddir)+1+8+1); - sprintf(doomuwad, "%s/doomu.wad", doomwaddir); - doomwad = malloc(strlen(doomwaddir)+1+8+1); - sprintf(doomwad, "%s/doom.wad", doomwaddir); - doom1wad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(doom1wad, "%s/doom1.wad", doomwaddir); - plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1); - sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir); - tntwad = malloc(strlen(doomwaddir)+1+9+1); - sprintf(tntwad, "%s/tnt.wad", doomwaddir); - doom2fwad = malloc(strlen(doomwaddir)+1+10+1); - sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - home = getenv("HOME"); - if (!home) - I_Error("Please set $HOME to your home directory"); - sprintf(basedefault, "%s/.doomrc", home); - if (M_CheckParm ("-shdev")) - { - gamemode = shareware; - devparm = true; - D_AddFile (DEVDATA"doom1.wad"); - D_AddFile (DEVMAPS"data_se/texture1.lmp"); - D_AddFile (DEVMAPS"data_se/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if (M_CheckParm ("-regdev")) - { - gamemode = registered; - devparm = true; - D_AddFile (DEVDATA"doom.wad"); - D_AddFile (DEVMAPS"data_se/texture1.lmp"); - D_AddFile (DEVMAPS"data_se/texture2.lmp"); - D_AddFile (DEVMAPS"data_se/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if (M_CheckParm ("-comdev")) - { - gamemode = commercial; - devparm = true; - /* I don't bother - if(plutonia) - D_AddFile (DEVDATA"plutonia.wad"); - else if(tnt) - D_AddFile (DEVDATA"tnt.wad"); - else*/ - D_AddFile (DEVDATA"doom2.wad"); - D_AddFile (DEVMAPS"cdata/texture1.lmp"); - D_AddFile (DEVMAPS"cdata/pnames.lmp"); - strcpy (basedefault,DEVDATA"default.cfg"); - return; - } - if ( !access (doom2fwad,R_OK) ) - { - gamemode = commercial; - language = french; - printf("French version\n"); - D_AddFile (doom2fwad); - return; - } - if ( !access (doom2wad,R_OK) ) - { - gamemode = commercial; - D_AddFile (doom2wad); - return; - } - if ( !access (plutoniawad, R_OK ) ) - { - gamemode = commercial; - D_AddFile (plutoniawad); - return; - } - if ( !access ( tntwad, R_OK ) ) - { - gamemode = commercial; - D_AddFile (tntwad); - return; - } - if ( !access (doomuwad,R_OK) ) - { - gamemode = retail; - D_AddFile (doomuwad); - return; - } - if ( !access (doomwad,R_OK) ) - { - gamemode = registered; - D_AddFile (doomwad); - return; - } - if ( !access (doom1wad,R_OK) ) - { - gamemode = shareware; - D_AddFile (doom1wad); - return; - } - printf("Game mode indeterminate.\n"); - gamemode = indetermined; + if (access("doom1.wad", R_OK)) + I_Error("D_AddFile: no wad mmmbud"); + for (numwadfiles = 0; wadfiles[numwadfiles]; ++numwadfiles); + newfile = malloc(strlen(file)+1); + strcpy(newfile, file); + wadfiles[numwadfiles] = newfile; } -void FindResponseFile (void) + +void +init() { - int i; -#define MAXARGVS 100 - for (i = 1;i < myargc;i++) - if (myargv[i][0] == '@') - { - FILE * handle; - int size; - int k; - int index; - int indexinfile; - char *infile; - char *file; - char *moreargs[20]; - char *firstargv; - handle = fopen (&myargv[i][1],"rb"); - if (!handle) - { - printf ("\nNo such response file!"); - exit(1); - } - printf("Found response file %s!\n",&myargv[i][1]); - fseek (handle,0,SEEK_END); - size = ftell(handle); - fseek (handle,0,SEEK_SET); - file = malloc (size); - fread (file,size,1,handle); - fclose (handle); - for (index = 0,k = i+1; k < myargc; k++) - moreargs[index++] = myargv[k]; - firstargv = myargv[0]; - myargv = malloc(sizeof(char *)*MAXARGVS); - memset(myargv,0,sizeof(char *)*MAXARGVS); - myargv[0] = firstargv; - infile = file; - indexinfile = k = 0; - indexinfile++; - do - { - myargv[indexinfile++] = infile+k; - while(k < size && - ((*(infile+k)>= ' '+1) && (*(infile+k)<='z'))) - k++; - *(infile+k) = 0; - while(k < size && - ((*(infile+k)<= ' ') || (*(infile+k)>'z'))) - k++; - } while(k < size); - for (k = 0;k < index;k++) - myargv[indexinfile++] = moreargs[k]; - myargc = indexinfile; - printf("%d command-line args:\n",myargc); - for (k=1;k<myargc;k++) - printf("%s\n",myargv[k]); - break; - } } -void D_DoomMain (void) + +void +D_DoomMain() { - int p; - char file[256]; - FindResponseFile (); - IdentifyVersion (); - setbuf (stdout, NULL); - modifiedgame = false; - nomonsters = M_CheckParm ("-nomonsters"); - respawnparm = M_CheckParm ("-respawn"); - fastparm = M_CheckParm ("-fast"); - devparm = M_CheckParm ("-devparm"); - if (M_CheckParm ("-altdeath")) - deathmatch = 2; - else if (M_CheckParm ("-deathmatch")) - deathmatch = 1; - switch ( gamemode ) - { - case retail: - sprintf (title, - " " - "The Ultimate DOOM Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case shareware: - sprintf (title, - " " - "DOOM Shareware Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case registered: - sprintf (title, - " " - "DOOM Registered Startup v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case commercial: - sprintf (title, - " " - "DOOM 2: Hell on Earth v%i.%i" - " ", - VERSION/100,VERSION%100); - break; -/*FIXME - case pack_plut: - sprintf (title, - " " - "DOOM 2: Plutonia Experiment v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - case pack_tnt: - sprintf (title, - " " - "DOOM 2: TNT - Evilution v%i.%i" - " ", - VERSION/100,VERSION%100); - break; -*/ - default: - sprintf (title, - " " - "Public DOOM - v%i.%i" - " ", - VERSION/100,VERSION%100); - break; - } - printf ("%s\n",title); - if (devparm) - printf(D_DEVSTR); - if (M_CheckParm("-cdrom")) - { - printf(D_CDROM); - mkdir("c:\\doomdata",0); - strcpy (basedefault,"c:/doomdata/default.cfg"); - } - if ( (p=M_CheckParm ("-turbo")) ) - { - int scale = 200; - extern int forwardmove[2]; - extern int sidemove[2]; - if (p<myargc-1) - scale = atoi (myargv[p+1]); - if (scale < 10) - scale = 10; - if (scale > 400) - scale = 400; - printf ("turbo scale: %i%%\n",scale); - forwardmove[0] = forwardmove[0]*scale/100; - forwardmove[1] = forwardmove[1]*scale/100; - sidemove[0] = sidemove[0]*scale/100; - sidemove[1] = sidemove[1]*scale/100; - } - p = M_CheckParm ("-wart"); - if (p) - { - myargv[p][4] = 'p'; - switch (gamemode ) - { - case shareware: - case retail: - case registered: - sprintf (file,"~"DEVMAPS"E%cM%c.wad", - myargv[p+1][0], myargv[p+2][0]); - printf("Warping to Episode %s, Map %s.\n", - myargv[p+1],myargv[p+2]); - break; - case commercial: - default: - p = atoi (myargv[p+1]); - if (p<10) - sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p); - else - sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p); - break; - } - D_AddFile (file); - } - p = M_CheckParm ("-file"); - if (p) - { - modifiedgame = true; - while (++p != myargc && myargv[p][0] != '-') - D_AddFile (myargv[p]); - } - p = M_CheckParm ("-playdemo"); - if (!p) - p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) - { - sprintf (file,"%s.lmp", myargv[p+1]); - D_AddFile (file); - printf("Playing demo %s.lmp.\n",myargv[p+1]); - } - startskill = sk_medium; - startepisode = 1; - startmap = 1; - autostart = false; - p = M_CheckParm ("-skill"); - if (p && p < myargc-1) - { - startskill = myargv[p+1][0]-'1'; - autostart = true; - } - p = M_CheckParm ("-episode"); - if (p && p < myargc-1) - { - startepisode = myargv[p+1][0]-'0'; + D_AddFile("doom1.wad"); + setbuf(stdout, NULL); + modifiedgame = false; + startskill = sk_medium; + startepisode = 1; startmap = 1; - autostart = true; - } - p = M_CheckParm ("-timer"); - if (p && p < myargc-1 && deathmatch) - { - int time; - time = atoi(myargv[p+1]); - printf("Levels will end after %d minute",time); - if (time>1) - printf("s"); - printf(".\n"); - } - p = M_CheckParm ("-avg"); - if (p && p < myargc-1 && deathmatch) - printf("Austin Virtual Gaming: Levels will end after 20 minutes\n"); - p = M_CheckParm ("-warp"); - if (p && p < myargc-1) - { - if (gamemode == commercial) - startmap = atoi (myargv[p+1]); - else - { - startepisode = myargv[p+1][0]-'0'; - startmap = myargv[p+2][0]-'0'; + autostart = false; + /*everything should be one big init function...*/ + V_Init(); + M_LoadDefaults(); + Z_Init(); + W_InitMultipleFiles(wadfiles); + M_Init(); + R_Init(); + P_Init(); + I_Init(); + D_CheckNetGame(); + S_Init(snd_SfxVolume, snd_MusicVolume); + HU_Init(); + ST_Init(); + if (gameaction != ga_loadgame) { + if (autostart || netgame) + G_InitNew(startskill, startepisode, startmap); + else + D_StartTitle(); + } + I_InitGraphics(); + /*...everything*/ + for (;;) { + TryRunTics(); + S_UpdateSounds(players[consoleplayer].mo); + D_Display(); + I_UpdateSound(); + I_SubmitSound(); } - autostart = true; - } - printf ("V_Init: allocate screens.\n"); - V_Init (); - printf ("M_LoadDefaults: Load system defaults.\n"); - M_LoadDefaults (); - printf ("Z_Init: Init zone memory allocation daemon. \n"); - Z_Init (); - printf ("W_Init: Init WADfiles.\n"); - W_InitMultipleFiles (wadfiles); - if (modifiedgame) - { - char name[23][8]= - { - "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9", - "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9", - "dphoof","bfgga0","heada1","cybra1","spida1d1" - }; - int i; - if ( gamemode == shareware) - I_Error("\nYou cannot -file with the shareware " - "version. Register!"); - if (gamemode == registered) - for (i = 0;i < 23; i++) - if (W_CheckNumForName(name[i])<0) - I_Error("\nThis is not the registered version."); - } - if (modifiedgame) - { - /*m*/printf ( - "===========================================================================\n" - "ATTENTION: This version of DOOM has been modified. If you would like to\n" - "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n" - " You will not receive technical support for modified games.\n" - " press enter to continue\n" - "===========================================================================\n" - ); - getchar (); - } - switch ( gamemode ) - { - case shareware: - case indetermined: - printf ( - "===========================================================================\n" - " Shareware!\n" - "===========================================================================\n" - ); - break; - case registered: - case retail: - case commercial: - printf ( - "===========================================================================\n" - " Commercial product - do not distribute!\n" - " Please report software piracy to the SPA: 1-800-388-PIR8\n" - "===========================================================================\n" - ); - break; - default: - break; - } - printf ("M_Init: Init miscellaneous info.\n"); - M_Init (); - printf ("R_Init: Init DOOM refresh daemon - "); - R_Init (); - printf ("\nP_Init: Init Playloop state.\n"); - P_Init (); - printf ("I_Init: Setting up machine state.\n"); - I_Init (); - printf ("D_CheckNetGame: Checking network game status.\n"); - D_CheckNetGame (); - printf ("S_Init: Setting up sound.\n"); - S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); - printf ("HU_Init: Setting up heads up display.\n"); - HU_Init (); - printf ("ST_Init: Init status bar.\n"); - ST_Init (); - p = M_CheckParm ("-record"); - if (p && p < myargc-1) - { - G_RecordDemo (myargv[p+1]); - autostart = true; - } - p = M_CheckParm ("-playdemo"); - if (p && p < myargc-1) - { - singledemo = true; - G_DeferedPlayDemo (myargv[p+1]); - D_DoomLoop (); - } - p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) - { - G_TimeDemo (myargv[p+1]); - D_DoomLoop (); - } - p = M_CheckParm ("-loadgame"); - if (p && p < myargc-1) - { - if (M_CheckParm("-cdrom")) - sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]); - else - sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]); - G_LoadGame (file); - } - if ( gameaction != ga_loadgame ) - { - if (autostart || netgame) - G_InitNew (startskill, startepisode, startmap); - else - D_StartTitle (); - } - D_DoomLoop (); } diff --git a/src/d_main.h b/src/d_main.h @@ -1,16 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_MAIN__ #define __D_MAIN__ + #include "d_event.h" + #ifdef __GNUG__ #pragma interface #endif + + + #define MAXWADFILES 20 extern char* wadfiles[MAXWADFILES]; + void D_AddFile (char *file); + + + + + + + + + void D_DoomMain (void); + + void D_PostEvent (event_t* ev); + + + + + + void D_PageTicker (void); void D_PageDrawer (void); void D_AdvanceDemo (void); void D_StartTitle (void); + #endif diff --git a/src/d_net.c b/src/d_net.c @@ -1,3 +1,5 @@ +#include <limits.h> + #include "m_menu.h" #include "i_system.h" #include "i_video.h" @@ -5,521 +7,470 @@ #include "g_game.h" #include "doomdef.h" #include "doomstat.h" + #define NCMD_EXIT 0x80000000 #define NCMD_RETRANSMIT 0x40000000 #define NCMD_SETUP 0x20000000 -#define NCMD_KILL 0x10000000 +#define NCMD_KILL 0x10000000 #define NCMD_CHECKSUM 0x0fffffff -doomcom_t* doomcom; -doomdata_t* netbuffer; #define RESENDCOUNT 10 -#define PL_DRONE 0x80 +#define PL_DRONE 0x80 + +doomcom_t* doomcom; +doomdata_t* netbuffer; ticcmd_t localcmds[BACKUPTICS]; -ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; -int nettics[MAXNETNODES]; -boolean nodeingame[MAXNETNODES]; -boolean remoteresend[MAXNETNODES]; -int resendto[MAXNETNODES]; +ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; +int nettics[MAXNETNODES]; +boolean nodeingame[MAXNETNODES]; +boolean remoteresend[MAXNETNODES]; +int resendto[MAXNETNODES]; int resendcount[MAXNETNODES]; int nodeforplayer[MAXPLAYERS]; -int maketic; +int maketic; int lastnettic; int skiptics; -int ticdup; -int maxsend; -void D_ProcessEvents (void); -void G_BuildTiccmd (ticcmd_t *cmd); -void D_DoAdvanceDemo (void); +int ticdup; +int maxsend; + +void D_ProcessEvents (); +void G_BuildTiccmd (ticcmd_t *cmd); +void D_DoAdvanceDemo (); + boolean reboundpacket; doomdata_t reboundstore; -int +long NetbufferSize() { - return (long)&(((doomdata_t *)0)->cmds[netbuffer->numtics]); + return (long)&(((doomdata_t*)0)->cmds[netbuffer->numtics]); } -unsigned +uint NetbufferChecksum() { - return 0; + long i, l; + uint c; + + c = 0x1234567; + return 0; /*Linux, fixme. Endianess?*/ + l = (NetbufferSize() - (long)&(((doomdata_t *)0)->retransmitfrom))/4; + for (i = 0; i < l; ++i) + c += ((unsigned *)&netbuffer->retransmitfrom)[i] * (i+1); + return c & NCMD_CHECKSUM; } -int ExpandTics (int low) +int +ExpandTics(int low) { - int delta; - delta = low - (maketic&0xff); - if (delta >= -64 && delta <= 64) - return (maketic&~0xff) + low; - if (delta > 64) - return (maketic&~0xff) - 256 + low; - if (delta < -64) - return (maketic&~0xff) + 256 + low; - I_Error ("ExpandTics: strange value %i at maketic %i",low,maketic); - return 0; + int delta; + + delta = low - (maketic & 0xff); + if (delta >= -64 && delta <= 64) + return (maketic&~0xff) + low; + if (delta > 64) + return (maketic&~0xff) - 256 + low; + if (delta < -64) + return (maketic&~0xff) + 256 + low; + I_Error("ExpandTics: strange value %i at maketic %i",low,maketic); + return 0; } + void -HSendPacket - (int node, - int flags ) +HSendPacket(int node, int flags) { - netbuffer->checksum = NetbufferChecksum () | flags; - if (!node) - { - reboundstore = *netbuffer; - reboundpacket = true; - return; - } - if (demoplayback) - return; - if (!netgame) - I_Error ("Tried to transmit to another node"); - doomcom->command = CMD_SEND; - doomcom->remotenode = node; - doomcom->datalength = NetbufferSize (); - if (debugfile) - { - int i; - int realretrans; - if (netbuffer->checksum & NCMD_RETRANSMIT) - realretrans = ExpandTics (netbuffer->retransmitfrom); - else - realretrans = -1; - fprintf (debugfile,"send (%i + %i, R %i) [%i] ", - ExpandTics(netbuffer->starttic), - netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); - } - I_NetCmd (); -} -boolean HGetPacket (void) -{ - if (reboundpacket) - { - *netbuffer = reboundstore; - doomcom->remotenode = 0; - reboundpacket = false; - return true; - } - if (!netgame) - return false; - if (demoplayback) - return false; - doomcom->command = CMD_GET; - I_NetCmd (); - if (doomcom->remotenode == -1) - return false; - if (doomcom->datalength != NetbufferSize ()) - { - if (debugfile) - fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); - return false; - } - if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) ) - { - if (debugfile) - fprintf (debugfile,"bad packet checksum\n"); - return false; - } - if (debugfile) - { - int realretrans; - int i; - if (netbuffer->checksum & NCMD_SETUP) - fprintf (debugfile,"setup packet\n"); - else - { - if (netbuffer->checksum & NCMD_RETRANSMIT) - realretrans = ExpandTics (netbuffer->retransmitfrom); - else - realretrans = -1; - fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ", - doomcom->remotenode, - ExpandTics(netbuffer->starttic), - netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); + int i, realretrans; + + netbuffer->checksum = NetbufferChecksum() | flags; + if (!node) { + reboundstore = *netbuffer; + reboundpacket = true; + return; } - } - return true; + if (demoplayback) + return; + if (!netgame) + I_Error("Tried to transmit to another node"); + doomcom->command = CMD_SEND; + doomcom->remotenode = node; + doomcom->datalength = NetbufferSize (); + if (debugfile) { + if (netbuffer->checksum & NCMD_RETRANSMIT) + realretrans = ExpandTics(netbuffer->retransmitfrom); + else + realretrans = -1; + fprintf (debugfile,"send (%i + %i, R %i) [%i] ", ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); + for (i = 0; i < doomcom->datalength; ++i) + fprintf(debugfile,"%i ",((byte *)netbuffer)[i]); + fprintf(debugfile,"\n"); + } + I_NetCmd(); } -char exitmsg[80]; -void GetPackets (void) + +boolean +HGetPacket() { - int netconsole; - int netnode; - ticcmd_t *src, *dest; - int realend; - int realstart; - while ( HGetPacket() ) - { - if (netbuffer->checksum & NCMD_SETUP) - continue; - netconsole = netbuffer->player & ~PL_DRONE; - netnode = doomcom->remotenode; - realstart = ExpandTics (netbuffer->starttic); - realend = (realstart+netbuffer->numtics); - if (netbuffer->checksum & NCMD_EXIT) - { - if (!nodeingame[netnode]) - continue; - nodeingame[netnode] = false; - playeringame[netconsole] = false; - strcpy (exitmsg, "Player 1 left the game"); - exitmsg[7] += netconsole; - players[consoleplayer].message = exitmsg; - if (demorecording) - G_CheckDemoStatus (); - continue; + int i, realretrans; + + if (reboundpacket) { + *netbuffer = reboundstore; + doomcom->remotenode = 0; + reboundpacket = false; + return true; } - if (netbuffer->checksum & NCMD_KILL) - I_Error ("Killed by network driver"); - nodeforplayer[netconsole] = netnode; - if ( resendcount[netnode] <= 0 - && (netbuffer->checksum & NCMD_RETRANSMIT) ) - { - resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); - if (debugfile) - fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); - resendcount[netnode] = RESENDCOUNT; + if (!netgame) + return false; + if (demoplayback) + return false; + doomcom->command = CMD_GET; + I_NetCmd(); + if (doomcom->remotenode == -1) + return false; + if (doomcom->datalength != NetbufferSize ()) { + if (debugfile) + fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); + return false; } - else - resendcount[netnode]--; - if (realend == nettics[netnode]) - continue; - if (realend < nettics[netnode]) - { - if (debugfile) - fprintf (debugfile, - "out of order packet (%i + %i)\n" , - realstart,netbuffer->numtics); - continue; + if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM)) { + if (debugfile) + fprintf (debugfile,"bad packet checksum\n"); + return false; } - if (realstart > nettics[netnode]) - { - if (debugfile) - fprintf (debugfile, - "missed tics from %i (%i - %i)\n", - netnode, realstart, nettics[netnode]); - remoteresend[netnode] = true; - continue; + if (debugfile) { + if (netbuffer->checksum & NCMD_SETUP) + fprintf (debugfile,"setup packet\n"); + else { + if (netbuffer->checksum & NCMD_RETRANSMIT) + realretrans = ExpandTics (netbuffer->retransmitfrom); + else + realretrans = -1; + fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ", doomcom->remotenode, ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); + for (i = 0; i < doomcom->datalength; ++i) + fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); + fprintf (debugfile,"\n"); + } } - { - int start; - remoteresend[netnode] = false; - start = nettics[netnode] - realstart; - src = &netbuffer->cmds[start]; - while (nettics[netnode] < realend) - { - dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; - nettics[netnode]++; - *dest = *src; - src++; - } + return true; +} + +char exitmsg[80]; + +void +GetPackets() +{ + ticcmd_t *src, *dest; + int realend, realstart, netconsole, netnode, start; + + while (HGetPacket()) { + if (netbuffer->checksum & NCMD_SETUP) + continue; + netconsole = netbuffer->player & ~PL_DRONE; + netnode = doomcom->remotenode; + realstart = ExpandTics (netbuffer->starttic); + realend = (realstart+netbuffer->numtics); + if (netbuffer->checksum & NCMD_EXIT) { + if (!nodeingame[netnode]) + continue; + nodeingame[netnode] = false; + playeringame[netconsole] = false; + strcpy(exitmsg, "Player 1 left the game"); + exitmsg[7] += netconsole; + players[consoleplayer].message = exitmsg; + if (demorecording) + G_CheckDemoStatus(); + continue; + } + if (netbuffer->checksum & NCMD_KILL) + I_Error("Killed by network driver"); + nodeforplayer[netconsole] = netnode; + if (resendcount[netnode] <= 0 && (netbuffer->checksum & NCMD_RETRANSMIT)) { + resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); + if (debugfile) + fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); + resendcount[netnode] = RESENDCOUNT; + } else + --resendcount[netnode]; + if (realend == nettics[netnode]) + continue; + if (realend < nettics[netnode]) { + if (debugfile) + fprintf (debugfile, "out of order packet (%i + %i)\n", realstart, netbuffer->numtics); + continue; + } + if (realstart > nettics[netnode]) { + if (debugfile) + fprintf (debugfile, "missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); + remoteresend[netnode] = true; + continue; + } + + remoteresend[netnode] = false; + start = nettics[netnode] - realstart; + src = &netbuffer->cmds[start]; + while (nettics[netnode] < realend) { + dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; + ++nettics[netnode]; + *dest = *src; + ++src; + } } - } } -int gametime; -void NetUpdate (void) + +int gametime; + +void +NetUpdate() { - int nowtime; - int newtics; - int i,j; - int realstart; - int gameticdiv; - nowtime = I_GetTime ()/ticdup; - newtics = nowtime - gametime; - gametime = nowtime; - if (newtics <= 0) - goto listen; - if (skiptics <= newtics) - { - newtics -= skiptics; - skiptics = 0; - } - else - { - skiptics -= newtics; - newtics = 0; - } - netbuffer->player = consoleplayer; - gameticdiv = gametic/ticdup; - for (i=0 ; i<newtics ; i++) - { - I_StartTic (); - D_ProcessEvents (); - if (maketic - gameticdiv >= BACKUPTICS/2-1) - break; - G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]); - maketic++; - } - if (singletics) - return; - for (i=0 ; i<doomcom->numnodes ; i++) - if (nodeingame[i]) - { - netbuffer->starttic = realstart = resendto[i]; - netbuffer->numtics = maketic - realstart; - if (netbuffer->numtics > BACKUPTICS) - I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); - resendto[i] = maketic - doomcom->extratics; - for (j=0 ; j< netbuffer->numtics ; j++) - netbuffer->cmds[j] = - localcmds[(realstart+j)%BACKUPTICS]; - if (remoteresend[i]) - { - netbuffer->retransmitfrom = nettics[i]; - HSendPacket (i, NCMD_RETRANSMIT); - } - else - { - netbuffer->retransmitfrom = 0; - HSendPacket (i, 0); - } + int nowtime, newtics, i, j, realstart, gameticdiv; + + nowtime = I_GetTime()/ticdup; + newtics = nowtime - gametime; + gametime = nowtime; + if (newtics <= 0) + goto listen; + if (skiptics <= newtics) { + newtics -= skiptics; + skiptics = 0; + } else { + skiptics -= newtics; + newtics = 0; } - listen: - GetPackets (); + netbuffer->player = consoleplayer; + gameticdiv = gametic/ticdup; + for (i = 0; i < newtics; ++i) { + I_StartTic(); + D_ProcessEvents(); + if (maketic - gameticdiv >= BACKUPTICS/2-1) + break; + G_BuildTiccmd(&localcmds[maketic%BACKUPTICS]); + ++maketic; + } + if (singletics) + return; + for (i = 0; i < doomcom->numnodes; ++i) + if (nodeingame[i]) { + netbuffer->starttic = realstart = resendto[i]; + netbuffer->numtics = maketic - realstart; + if (netbuffer->numtics > BACKUPTICS) + I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); + resendto[i] = maketic - doomcom->extratics; + for (j = 0; j < netbuffer->numtics; ++j) + netbuffer->cmds[j] = localcmds[(realstart+j)%BACKUPTICS]; + if (remoteresend[i]) { + netbuffer->retransmitfrom = nettics[i]; + HSendPacket (i, NCMD_RETRANSMIT); + } else { + netbuffer->retransmitfrom = 0; + HSendPacket (i, 0); + } + } +listen: + GetPackets(); } -void CheckAbort (void) + +void +CheckAbort() { - event_t *ev; - int stoptic; - stoptic = I_GetTime () + 2; - while (I_GetTime() < stoptic) - I_StartTic (); - I_StartTic (); - for ( ; eventtail != eventhead - ; eventtail = (eventtail + 1)&(MAXEVENTS-1) ) - { - ev = &events[eventtail]; - if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) - I_Error ("Network game synchronization aborted."); - } + event_t *ev; + int stoptic; + + stoptic = I_GetTime() + 2; + while (I_GetTime() < stoptic) + I_StartTic(); + I_StartTic(); + for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1)) { + ev = &events[eventtail]; + if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) + I_Error("Network game synchronization aborted."); + } } -void D_ArbitrateNetStart (void) + +void +D_ArbitrateNetStart() { - int i; - boolean gotinfo[MAXNETNODES]; - autostart = true; - memset (gotinfo,0,sizeof(gotinfo)); - if (doomcom->consoleplayer) - { - printf ("listening for network start info...\n"); - while (1) - { - CheckAbort (); - if (!HGetPacket ()) - continue; - if (netbuffer->checksum & NCMD_SETUP) - { - if (netbuffer->player != VERSION) - I_Error ("Different DOOM versions cannot play a net game!"); - startskill = netbuffer->retransmitfrom & 15; - deathmatch = (netbuffer->retransmitfrom & 0xc0) >> 6; - nomonsters = (netbuffer->retransmitfrom & 0x20) > 0; - respawnparm = (netbuffer->retransmitfrom & 0x10) > 0; - startmap = netbuffer->starttic & 0x3f; - startepisode = netbuffer->starttic >> 6; - return; - } + int i; + uchar gotinfo[MAXNETNODES]; + + autostart = true; + memset(gotinfo, 0, sizeof(gotinfo)); + if (doomcom->consoleplayer) { + printf ("listening for network start info...\n"); + for (;;) { + CheckAbort(); + if (!HGetPacket()) + continue; + if (netbuffer->checksum & NCMD_SETUP) { + if (netbuffer->player != VERSION) + I_Error("Different DOOM versions cannot play a net game!"); + startskill = netbuffer->retransmitfrom & 15; + deathmatch = (netbuffer->retransmitfrom & 0xc0) >> 6; + nomonsters = (netbuffer->retransmitfrom & 0x20) > 0; + respawnparm = (netbuffer->retransmitfrom & 0x10) > 0; + startmap = netbuffer->starttic & 0x3f; + startepisode = netbuffer->starttic >> 6; + return; + } + } + } else { + printf("sending network start info...\n"); + do { + CheckAbort(); + for (i = 0; i < doomcom->numnodes; ++i) { + netbuffer->retransmitfrom = startskill; + if (deathmatch) + netbuffer->retransmitfrom |= (deathmatch<<6); + if (nomonsters) + netbuffer->retransmitfrom |= 0x20; + if (respawnparm) + netbuffer->retransmitfrom |= 0x10; + netbuffer->starttic = startepisode * 64 + startmap; + netbuffer->player = VERSION; + netbuffer->numtics = 0; + HSendPacket(i, NCMD_SETUP); + } + for(i = 10; i && HGetPacket(); --i) + if((netbuffer->player&0x7f) < MAXNETNODES) + gotinfo[netbuffer->player&0x7f] = true; + for (i = 1; i < doomcom->numnodes; ++i) + if (!gotinfo[i]) + break; + } while (i < doomcom->numnodes); } - } - else - { - printf ("sending network start info...\n"); - do - { - CheckAbort (); - for (i=0 ; i<doomcom->numnodes ; i++) - { - netbuffer->retransmitfrom = startskill; - if (deathmatch) - netbuffer->retransmitfrom |= (deathmatch<<6); - if (nomonsters) - netbuffer->retransmitfrom |= 0x20; - if (respawnparm) - netbuffer->retransmitfrom |= 0x10; - netbuffer->starttic = startepisode * 64 + startmap; - netbuffer->player = VERSION; - netbuffer->numtics = 0; - HSendPacket (i, NCMD_SETUP); - } -#if 1 - for(i = 10 ; i && HGetPacket(); --i) - { - if((netbuffer->player&0x7f) < MAXNETNODES) - gotinfo[netbuffer->player&0x7f] = true; - } -#else - while (HGetPacket ()) - { - gotinfo[netbuffer->player&0x7f] = true; - } -#endif - for (i=1 ; i<doomcom->numnodes ; i++) - if (!gotinfo[i]) - break; - } while (i < doomcom->numnodes); - } } -extern int viewangleoffset; -void D_CheckNetGame (void) + +extern int viewangleoffset; + +void +D_CheckNetGame() { - int i; - for (i=0 ; i<MAXNETNODES ; i++) - { - nodeingame[i] = false; - nettics[i] = 0; - remoteresend[i] = false; - resendto[i] = 0; - } - I_InitNetwork (); - if (doomcom->id != DOOMCOM_ID) - I_Error ("Doomcom buffer invalid!"); - netbuffer = &doomcom->data; - consoleplayer = displayplayer = doomcom->consoleplayer; - if (netgame) - D_ArbitrateNetStart (); - printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", - startskill, deathmatch, startmap, startepisode); - ticdup = doomcom->ticdup; - maxsend = BACKUPTICS/(2*ticdup)-1; - if (maxsend<1) - maxsend = 1; - for (i=0 ; i<doomcom->numplayers ; i++) - playeringame[i] = true; - for (i=0 ; i<doomcom->numnodes ; i++) - nodeingame[i] = true; - printf ("player %i of %i (%i nodes)\n", - consoleplayer+1, doomcom->numplayers, doomcom->numnodes); + int i; + + for (i = 0; i < MAXNETNODES; ++i) { + nodeingame[i] = false; + nettics[i] = 0; + remoteresend[i] = false; + resendto[i] = 0; + } + I_InitNetwork(); + if (doomcom->id != DOOMCOM_ID) + I_Error ("Doomcom buffer invalid!"); + netbuffer = &doomcom->data; + consoleplayer = displayplayer = doomcom->consoleplayer; + if (netgame) + D_ArbitrateNetStart(); + printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", startskill, deathmatch, startmap, startepisode); + ticdup = doomcom->ticdup; + maxsend = BACKUPTICS/(2 * ticdup) - 1; + if (maxsend < 1) + maxsend = 1; + for (i = 0; i < doomcom->numplayers; ++i) + playeringame[i] = true; + for (i = 0; i < doomcom->numnodes; ++i) + nodeingame[i] = true; + printf("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom->numplayers, doomcom->numnodes); } -void D_QuitNetGame (void) + +void +D_QuitNetGame() { - int i, j; - if (debugfile) - fclose (debugfile); - if (!netgame || !usergame || consoleplayer == -1 || demoplayback) - return; - netbuffer->player = consoleplayer; - netbuffer->numtics = 0; - for (i=0 ; i<4 ; i++) - { - for (j=1 ; j<doomcom->numnodes ; j++) - if (nodeingame[j]) - HSendPacket (j, NCMD_EXIT); - I_WaitVBL (1); - } + int i, j; + + if (debugfile) + fclose(debugfile); + if (!netgame || !usergame || consoleplayer == -1 || demoplayback) + return; + netbuffer->player = consoleplayer; + netbuffer->numtics = 0; + for (i = 0; i < 4; ++i) { + for (j = 1; j < doomcom->numnodes; ++j) + if (nodeingame[j]) + HSendPacket(j, NCMD_EXIT); + I_WaitVBL(1); + } } + int frametics[4]; int frameon; int frameskip[4]; int oldnettics; extern boolean advancedemo; -void TryRunTics (void) + +void +TryRunTics() { - int i; - int lowtic; - int entertic; - static int oldentertics; - int realtics; - int availabletics; - int counts; - int numplaying; - entertic = I_GetTime ()/ticdup; - realtics = entertic - oldentertics; - oldentertics = entertic; - NetUpdate (); - lowtic = MAXINT; - numplaying = 0; - for (i=0 ; i<doomcom->numnodes ; i++) - { - if (nodeingame[i]) - { - numplaying++; - if (nettics[i] < lowtic) - lowtic = nettics[i]; - } - } - availabletics = lowtic - gametic/ticdup; - if (realtics < availabletics-1) - counts = realtics+1; - else if (realtics < availabletics) - counts = realtics; - else - counts = availabletics; - if (counts < 1) - counts = 1; - frameon++; - if (debugfile) - fprintf (debugfile, - "=======real: %i avail: %i game: %i\n", - realtics, availabletics,counts); - if (!demoplayback) - { - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i]) - break; - if (consoleplayer == i) - { + static int oldentertics; + ticcmd_t *cmd; + int i, j, lowtic, entertic, realtics, availabletics, counts, numplaying, buf; + + entertic = I_GetTime() / ticdup; + realtics = entertic - oldentertics; + oldentertics = entertic; + NetUpdate(); + lowtic = INT_MAX; + numplaying = 0; + for (i = 0; i < doomcom->numnodes; ++i) { + if (nodeingame[i]) { + ++numplaying; + if (nettics[i] < lowtic) + lowtic = nettics[i]; + } } + availabletics = lowtic - gametic/ticdup; + if (realtics < availabletics-1) + counts = realtics+1; + else if (realtics < availabletics) + counts = realtics; else - { - if (nettics[0] <= nettics[nodeforplayer[i]]) - { - gametime--; - } - frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]); - oldnettics = nettics[0]; - if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) - { - skiptics = 1; - } + counts = availabletics; + if (counts < 1) + counts = 1; + ++frameon; + if (debugfile) + fprintf (debugfile, "=======real: %i avail: %i game: %i\n", realtics, availabletics,counts); + if (!demoplayback) { + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + break; + if (consoleplayer != i) { + if (nettics[0] <= nettics[nodeforplayer[i]]) + --gametime; + frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]); + oldnettics = nettics[0]; + if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) + skiptics = 1; + } + } + while (lowtic < gametic/ticdup + counts) { + NetUpdate(); + lowtic = INT_MAX; + for (i = 0; i < doomcom->numnodes; ++i) + if (nodeingame[i] && nettics[i] < lowtic) + lowtic = nettics[i]; + if (lowtic < gametic/ticdup) + I_Error("TryRunTics: lowtic < gametic"); + if (I_GetTime ()/ticdup - entertic >= 20) { + M_Ticker(); + return; + } } - } - while (lowtic < gametic/ticdup + counts) - { - NetUpdate (); - lowtic = MAXINT; - for (i=0 ; i<doomcom->numnodes ; i++) - if (nodeingame[i] && nettics[i] < lowtic) - lowtic = nettics[i]; - if (lowtic < gametic/ticdup) - I_Error ("TryRunTics: lowtic < gametic"); - if (I_GetTime ()/ticdup - entertic >= 20) - { - M_Ticker (); - return; - } - } - while (counts--) - { - for (i=0 ; i<ticdup ; i++) - { - if (gametic/ticdup > lowtic) - I_Error ("gametic>lowtic"); - if (advancedemo) - D_DoAdvanceDemo (); - M_Ticker (); - G_Ticker (); - gametic++; - if (i != ticdup-1) - { - ticcmd_t *cmd; - int buf; - int j; - buf = (gametic/ticdup)%BACKUPTICS; - for (j=0 ; j<MAXPLAYERS ; j++) - { - cmd = &netcmds[j][buf]; - cmd->chatchar = 0; - if (cmd->buttons & BT_SPECIAL) - cmd->buttons = 0; + while (--counts) { + for (i = 0; i < ticdup; ++i) { + if (gametic/ticdup > lowtic) + I_Error("gametic>lowtic"); + if (advancedemo) + D_DoAdvanceDemo(); + M_Ticker(); + G_Ticker(); + ++gametic; + if (i != ticdup-1) { + buf = (gametic/ticdup) % BACKUPTICS; + for (j = 0; j < MAXPLAYERS; ++j) { + cmd = &netcmds[j][buf]; + cmd->chatchar = 0; + if (cmd->buttons & BT_SPECIAL) + cmd->buttons = 0; + } + } } - } + NetUpdate(); } - NetUpdate (); - } } diff --git a/src/d_net.h b/src/d_net.h @@ -1,48 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_NET__ #define __D_NET__ + #include "d_player.h" + + #ifdef __GNUG__ #pragma interface #endif + + + + + + + + + + #define DOOMCOM_ID 0x12345678l + + #define MAXNETNODES 8 + + + #define BACKUPTICS 12 + typedef enum { CMD_SEND = 1, CMD_GET = 2 + } command_t; + + + + + typedef struct { + unsigned checksum; + byte retransmitfrom; + byte starttic; byte player; byte numtics; ticcmd_t cmds[BACKUPTICS]; + } doomdata_t; + + + + typedef struct { + long id; + + short intnum; + + short command; + short remotenode; + + short datalength; + + + short numnodes; + short ticdup; + short extratics; + short deathmatch; + short savegame; short episode; short map; short skill; + + short consoleplayer; short numplayers; + + + + + + + short angleoffset; + short drone; + + doomdata_t data; + } doomcom_t; + + + + void NetUpdate (void); + + + void D_QuitNetGame (void); + + void TryRunTics (void); + + #endif + + + + + + + diff --git a/src/d_player.h b/src/d_player.h @@ -1,84 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_PLAYER__ #define __D_PLAYER__ + + + + + + #include "d_items.h" #include "p_pspr.h" + + + #include "p_mobj.h" + + + + #include "d_ticcmd.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + + + typedef enum { + PST_LIVE, + PST_DEAD, + PST_REBORN + } playerstate_t; + + + + + typedef enum { + CF_NOCLIP = 1, + CF_GODMODE = 2, + CF_NOMOMENTUM = 4 + } cheat_t; + + + + + typedef struct player_s { mobj_t* mo; playerstate_t playerstate; ticcmd_t cmd; + + + + fixed_t viewz; + fixed_t viewheight; + fixed_t deltaviewheight; + fixed_t bob; + + + int health; int armorpoints; + int armortype; + + int powers[NUMPOWERS]; boolean cards[NUMCARDS]; boolean backpack; + + int frags[MAXPLAYERS]; weapontype_t readyweapon; + + weapontype_t pendingweapon; + boolean weaponowned[NUMWEAPONS]; int ammo[NUMAMMO]; int maxammo[NUMAMMO]; + + int attackdown; int usedown; + + + int cheats; + + int refire; + + int killcount; int itemcount; int secretcount; + + char* message; + + int damagecount; int bonuscount; + + mobj_t* attacker; + + int extralight; + + + int fixedcolormap; + + + int colormap; + + pspdef_t psprites[NUMPSPRITES]; + + boolean didsecret; + } player_t; + + + + + + typedef struct { boolean in; + + int skills; int sitems; int ssecret; int stime; int frags[4]; int score; + } wbplayerstruct_t; + typedef struct { int epsd; + + boolean didsecret; + + int last; int next; + int maxkills; int maxitems; int maxsecret; int maxfrags; + + int partime; + + int pnum; + wbplayerstruct_t plyr[MAXPLAYERS]; + } wbstartstruct_t; + + #endif + + + + + diff --git a/src/d_textur.h b/src/d_textur.h @@ -1,10 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_TEXTUR__ #define __D_TEXTUR__ -#include "doomtype.h" + +#include "doomdef.h" + + + + + + + + typedef struct { byte width; byte height; byte data; } pic_t; + + + + #endif + + + + + diff --git a/src/d_think.h b/src/d_think.h @@ -1,22 +1,27 @@ #ifndef __D_THINK__ #define __D_THINK__ -#ifdef __GNUG__ -#pragma interface -#endif -typedef void (*actionf_v)(); -typedef void (*actionf_p1)( void* ); -typedef void (*actionf_p2)( void*, void* ); -typedef union -{ - actionf_p1 acp1; - actionf_v acv; - actionf_p2 acp2; + +typedef void (*actionf_v)(); +typedef void (*actionf_p1)(void*); +typedef void (*actionf_p2)(void*, void*); + +typedef union { + actionf_p1 acp1; + actionf_v acv; + actionf_p2 acp2; } actionf_t; + typedef actionf_t think_t; -typedef struct thinker_s -{ + +typedef struct thinker_s { struct thinker_s* prev; struct thinker_s* next; think_t function; } thinker_t; + #endif + + + + + diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h @@ -1,9 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __D_TICCMD__ #define __D_TICCMD__ -#include "doomtype.h" + +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + typedef struct { char forwardmove; @@ -13,4 +42,12 @@ typedef struct byte chatchar; byte buttons; } ticcmd_t; + + + #endif + + + + + diff --git a/src/doom1.wad b/src/doom1.wad Binary files differ. diff --git a/src/doomdata.h b/src/doomdata.h @@ -1,7 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + #ifndef __DOOMDATA__ #define __DOOMDATA__ -#include "doomtype.h" + + #include "doomdef.h" + + +#include "doomdef.h" + + + + + + + + + + + enum { ML_LABEL, @@ -16,11 +54,18 @@ enum ML_REJECT, ML_BLOCKMAP }; + + + typedef struct { short x; short y; } mapvertex_t; + + + + typedef struct { short textureoffset; @@ -28,8 +73,14 @@ typedef struct char toptexture[8]; char bottomtexture[8]; char midtexture[8]; + short sector; } mapsidedef_t; + + + + + typedef struct { short v1; @@ -37,17 +88,56 @@ typedef struct short flags; short special; short tag; + short sidenum[2]; } maplinedef_t; + + + + + + + #define ML_BLOCKING 1 + + #define ML_BLOCKMONSTERS 2 + + + #define ML_TWOSIDED 4 + + + + + + + + + + + #define ML_DONTPEGTOP 8 + + #define ML_DONTPEGBOTTOM 16 + + #define ML_SECRET 32 + + #define ML_SOUNDBLOCK 64 + + #define ML_DONTDRAW 128 + + #define ML_MAPPED 256 + + + + + typedef struct { short floorheight; @@ -58,11 +148,18 @@ typedef struct short special; short tag; } mapsector_t; + + typedef struct { short numsegs; + short firstseg; } mapsubsector_t; + + + + typedef struct { short v1; @@ -72,16 +169,37 @@ typedef struct short side; short offset; } mapseg_t; + + + + + + #define NF_SUBSECTOR 0x8000 + typedef struct { + short x; short y; short dx; short dy; + + + short bbox[2][4]; + + + unsigned short children[2]; + } mapnode_t; + + + + + + typedef struct { short x; @@ -90,4 +208,15 @@ typedef struct short type; short options; } mapthing_t; + + + + + #endif + + + + + + diff --git a/src/doomdef.h b/src/doomdef.h @@ -1,37 +1,38 @@ #ifndef __DOOMDEF__ #define __DOOMDEF__ + #include <stdio.h> #include <string.h> -enum { VERSION = 110 }; - -typedef unsigned char uchar; - -typedef enum -{ - shareware, - registered, - commercial, - retail, - indetermined -} GameMode_t; -typedef enum -{ - doom, - doom2, - pack_tnt, - pack_plut, - none -} GameMission_t; - -typedef enum -{ - english, - french, - german, - unknown -} Language_t; +#include <limits.h> #define RANGECHECK +#define KEY_RIGHTARROW 0xae +#define KEY_LEFTARROW 0xac +#define KEY_UPARROW 0xad +#define KEY_DOWNARROW 0xaf +#define KEY_ESCAPE 27 +#define KEY_ENTER 13 +#define KEY_TAB 9 +#define KEY_F1 (0x80+0x3b) +#define KEY_F2 (0x80+0x3c) +#define KEY_F3 (0x80+0x3d) +#define KEY_F4 (0x80+0x3e) +#define KEY_F5 (0x80+0x3f) +#define KEY_F6 (0x80+0x40) +#define KEY_F7 (0x80+0x41) +#define KEY_F8 (0x80+0x42) +#define KEY_F9 (0x80+0x43) +#define KEY_F10 (0x80+0x44) +#define KEY_F11 (0x80+0x57) +#define KEY_F12 (0x80+0x58) +#define KEY_BACKSPACE 127 +#define KEY_PAUSE 0xff +#define KEY_EQUALS 0x3d +#define KEY_MINUS 0x2d +#define KEY_RSHIFT (0x80+0x36) +#define KEY_RCTRL (0x80+0x1d) +#define KEY_RALT (0x80+0x38) +#define KEY_LALT KEY_RALT #define SNDSERV 1 #define BASE_WIDTH 320 #define SCREEN_MUL 1 @@ -40,30 +41,40 @@ typedef enum #define SCREENHEIGHT 200 #define MAXPLAYERS 4 #define TICRATE 35 +#define MTF_EASY 1 +#define MTF_NORMAL 2 +#define MTF_HARD 4 +#define MTF_AMBUSH 8 +#define LENGTH(a) (sizeof(a)/sizeof(a[0])) +#define SKYFLATNAME "F_SKY1" +#define ANGLETOSKYSHIFT 22 + +typedef unsigned char byte; +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; -typedef enum -{ +typedef enum {false, true} boolean; + +enum { VERSION = 110 }; + +typedef enum { GS_LEVEL, GS_INTERMISSION, GS_FINALE, GS_DEMOSCREEN } gamestate_t; -#define MTF_EASY 1 -#define MTF_NORMAL 2 -#define MTF_HARD 4 -#define MTF_AMBUSH 8 - -typedef enum -{ +typedef enum { sk_baby, sk_easy, sk_medium, sk_hard, sk_nightmare } skill_t; -typedef enum -{ + +typedef enum { it_bluecard, it_yellowcard, it_redcard, @@ -72,8 +83,8 @@ typedef enum it_redskull, NUMCARDS } card_t; -typedef enum -{ + +typedef enum { wp_fist, wp_pistol, wp_shotgun, @@ -86,8 +97,8 @@ typedef enum NUMWEAPONS, wp_nochange } weapontype_t; -typedef enum -{ + +typedef enum { am_clip, am_shell, am_cell, @@ -95,8 +106,8 @@ typedef enum NUMAMMO, am_noammo } ammotype_t; -typedef enum -{ + +typedef enum { pw_invulnerability, pw_strength, pw_invisibility, @@ -105,38 +116,329 @@ typedef enum pw_infrared, NUMPOWERS } powertype_t; -typedef enum -{ - INVULNTICS = (30*TICRATE), - INVISTICS = (60*TICRATE), - INFRATICS = (120*TICRATE), - IRONTICS = (60*TICRATE) + +typedef enum { + INVULNTICS = (30*TICRATE), + INVISTICS = (60*TICRATE), + INFRATICS = (120*TICRATE), + IRONTICS = (60*TICRATE) } powerduration_t; -#define KEY_RIGHTARROW 0xae -#define KEY_LEFTARROW 0xac -#define KEY_UPARROW 0xad -#define KEY_DOWNARROW 0xaf -#define KEY_ESCAPE 27 -#define KEY_ENTER 13 -#define KEY_TAB 9 -#define KEY_F1 (0x80+0x3b) -#define KEY_F2 (0x80+0x3c) -#define KEY_F3 (0x80+0x3d) -#define KEY_F4 (0x80+0x3e) -#define KEY_F5 (0x80+0x3f) -#define KEY_F6 (0x80+0x40) -#define KEY_F7 (0x80+0x41) -#define KEY_F8 (0x80+0x42) -#define KEY_F9 (0x80+0x43) -#define KEY_F10 (0x80+0x44) -#define KEY_F11 (0x80+0x57) -#define KEY_F12 (0x80+0x58) -#define KEY_BACKSPACE 127 -#define KEY_PAUSE 0xff -#define KEY_EQUALS 0x3d -#define KEY_MINUS 0x2d -#define KEY_RSHIFT (0x80+0x36) -#define KEY_RCTRL (0x80+0x1d) -#define KEY_RALT (0x80+0x38) -#define KEY_LALT KEY_RALT -#endif + +enum { + NEWLEVEL, + PRESSKEY, + PRESSYN, + D_DEVSTR, + D_CDROM, + LOADNET, + QLOADNET, + QSAVESPOT, + SAVEDEAD, + QSPROMPT, + QLPROMPT, + NEWGAME, + NIGHTMARE, + SWSTRING, + MSGOFF, + MSGON, + NETEND, + ENDGAME, + DOSY, + DETAILHI, + DETAILLO, + GAMMALVL0, + GAMMALVL1, + GAMMALVL2, + GAMMALVL3, + GAMMALVL4, + EMPTYSTRING, + GOTARMOR, + GOTMEGA, + GOTHTHBONUS, + GOTARMBONUS, + GOTSTIM, + GOTMEDINEED, + GOTMEDIKIT, + GOTSUPER, + GOTBLUECARD, + GOTYELWCARD, + GOTREDCARD, + GOTBLUESKUL, + GOTYELWSKUL, + GOTREDSKULL, + GOTINVUL, + GOTBERSERK, + GOTINVIS, + GOTSUIT, + GOTMAP, + GOTVISOR, + GOTMSPHERE, + GOTCLIP, + GOTCLIPBOX, + GOTROCKET, + GOTROCKBOX, + GOTCELL, + GOTCELLBOX, + GOTSHELLS, + GOTSHELLBOX, + GOTBACKPACK, + GOTBFG9000, + GOTCHAINGUN, + GOTCHAINSAW, + GOTLAUNCHER, + GOTPLASMA, + GOTSHOTGUN, + GOTSHOTGUN2, + PD_BLUEO, + PD_REDO, + PD_YELLOWO, + PD_BLUEK, + PD_REDK, + PD_YELLOWK, + GGSAVED, + HUSTR_MSGU, + HUSTR_E1M1, + HUSTR_E1M2, + HUSTR_E1M3, + HUSTR_E1M4, + HUSTR_E1M5, + HUSTR_E1M6, + HUSTR_E1M7, + HUSTR_E1M8, + HUSTR_E1M9, + HUSTR_E2M1, + HUSTR_E2M2, + HUSTR_E2M3, + HUSTR_E2M4, + HUSTR_E2M5, + HUSTR_E2M6, + HUSTR_E2M7, + HUSTR_E2M8, + HUSTR_E2M9, + HUSTR_E3M1, + HUSTR_E3M2, + HUSTR_E3M3, + HUSTR_E3M4, + HUSTR_E3M5, + HUSTR_E3M6, + HUSTR_E3M7, + HUSTR_E3M8, + HUSTR_E3M9, + HUSTR_E4M1, + HUSTR_E4M2, + HUSTR_E4M3, + HUSTR_E4M4, + HUSTR_E4M5, + HUSTR_E4M6, + HUSTR_E4M7, + HUSTR_E4M8, + HUSTR_E4M9, + HUSTR_1, + HUSTR_2, + HUSTR_3, + HUSTR_4, + HUSTR_5, + HUSTR_6, + HUSTR_7, + HUSTR_8, + HUSTR_9, + HUSTR_10, + HUSTR_11, + HUSTR_12, + HUSTR_13, + HUSTR_14, + HUSTR_15, + HUSTR_16, + HUSTR_17, + HUSTR_18, + HUSTR_19, + HUSTR_20, + HUSTR_21, + HUSTR_22, + HUSTR_23, + HUSTR_24, + HUSTR_25, + HUSTR_26, + HUSTR_27, + HUSTR_28, + HUSTR_29, + HUSTR_30, + HUSTR_31, + HUSTR_32, + PHUSTR_1, + PHUSTR_2, + PHUSTR_3, + PHUSTR_4, + PHUSTR_5, + PHUSTR_6, + PHUSTR_7, + PHUSTR_8, + PHUSTR_9, + PHUSTR_10, + PHUSTR_11, + PHUSTR_12, + PHUSTR_13, + PHUSTR_14, + PHUSTR_15, + PHUSTR_16, + PHUSTR_17, + PHUSTR_18, + PHUSTR_19, + PHUSTR_20, + PHUSTR_21, + PHUSTR_22, + PHUSTR_23, + PHUSTR_24, + PHUSTR_25, + PHUSTR_26, + PHUSTR_27, + PHUSTR_28, + PHUSTR_29, + PHUSTR_30, + PHUSTR_31, + PHUSTR_32, + THUSTR_1, + THUSTR_2, + THUSTR_3, + THUSTR_4, + THUSTR_5, + THUSTR_6, + THUSTR_7, + THUSTR_8, + THUSTR_9, + THUSTR_10, + THUSTR_11, + THUSTR_12, + THUSTR_13, + THUSTR_14, + THUSTR_15, + THUSTR_16, + THUSTR_17, + THUSTR_18, + THUSTR_19, + THUSTR_20, + THUSTR_21, + THUSTR_22, + THUSTR_23, + THUSTR_24, + THUSTR_25, + THUSTR_26, + THUSTR_27, + THUSTR_28, + THUSTR_29, + THUSTR_30, + THUSTR_31, + THUSTR_32, + HUSTR_CHATMACRO1, + HUSTR_CHATMACRO2, + HUSTR_CHATMACRO3, + HUSTR_CHATMACRO4, + HUSTR_CHATMACRO5, + HUSTR_CHATMACRO6, + HUSTR_CHATMACRO7, + HUSTR_CHATMACRO8, + HUSTR_CHATMACRO9, + HUSTR_CHATMACRO0, + HUSTR_TALKTOSELF1, + HUSTR_TALKTOSELF2, + HUSTR_TALKTOSELF3, + HUSTR_TALKTOSELF4, + HUSTR_TALKTOSELF5, + HUSTR_MESSAGESENT, + HUSTR_PLRGREEN, + HUSTR_PLRINDIGO, + HUSTR_PLRBROWN, + HUSTR_PLRRED, + HUSTR_KEYGREEN, + HUSTR_KEYINDIGO, + HUSTR_KEYBROWN, + HUSTR_KEYRED, + AMSTR_FOLLOWON, + AMSTR_FOLLOWOFF, + AMSTR_GRIDON, + AMSTR_GRIDOFF, + AMSTR_MARKEDSPOT, + AMSTR_MARKSCLEARED, + STSTR_MUS, + STSTR_NOMUS, + STSTR_DQDON, + STSTR_DQDOFF, + STSTR_KFAADDED, + STSTR_FAADDED, + STSTR_NCON, + STSTR_NCOFF, + STSTR_BEHOLD, + STSTR_BEHOLDX, + STSTR_CHOPPERS, + STSTR_CLEV, + E1TEXT, + E2TEXT, + E3TEXT, + E4TEXT, + C1TEXT, + C2TEXT, + C3TEXT, + C4TEXT, + C5TEXT, + C6TEXT, + P1TEXT, + P2TEXT, + P3TEXT, + P4TEXT, + P5TEXT, + P6TEXT, + T1TEXT, + T2TEXT, + T3TEXT, + T4TEXT, + T5TEXT, + T6TEXT, + CC_ZOMBIE, + CC_SHOTGUN, + CC_HEAVY, + CC_IMP, + CC_DEMON, + CC_LOST, + CC_CACO, + CC_HELL, + CC_BARON, + CC_ARACH, + CC_PAIN, + CC_REVEN, + CC_MANCU, + CC_ARCH, + CC_SPIDER, + CC_CYBER, + CC_HERO, + SAVEGAMENAME, + DEVMAPS, + DEVDATA, + QUITMSG0, + QUITMSG1, + QUITMSG2, + QUITMSG3, + QUITMSG4, + QUITMSG5, + QUITMSG6, + QUITMSG7, + QUITMSG8, + QUITMSG9, + QUITMSG10, + QUITMSG11, + QUITMSG12, + QUITMSG13, + QUITMSG14, + QUITMSG15, + QUITMSG16, + QUITMSG17, + QUITMSG18, + QUITMSG19, + QUITMSG20, + QUITMSG21 +}; + +extern char** lang; + +char* str_cat(char* p, char* q); + +#endif diff --git a/src/doomstat.c b/src/doomstat.c @@ -1,5 +1,3 @@ #include "doomstat.h" -GameMode_t gamemode = indetermined; -GameMission_t gamemission = doom; -Language_t language = english; -boolean modifiedgame; + +boolean modifiedgame; diff --git a/src/doomstat.h b/src/doomstat.h @@ -1,83 +1,81 @@ #ifndef __D_STATE__ #define __D_STATE__ + #include "doomdata.h" #include "d_net.h" #include "d_player.h" -#ifdef __GNUG__ -#pragma interface -#endif -extern boolean nomonsters; -extern boolean respawnparm; -extern boolean fastparm; -extern boolean devparm; -extern GameMode_t gamemode; -extern GameMission_t gamemission; -extern boolean modifiedgame; -extern Language_t language; -extern skill_t startskill; -extern int startepisode; -extern int startmap; -extern boolean autostart; -extern skill_t gameskill; -extern int gameepisode; -extern int gamemap; -extern boolean respawnmonsters; -extern boolean netgame; -extern boolean deathmatch; -extern int snd_SfxVolume; -extern int snd_MusicVolume; -extern int snd_MusicDevice; -extern int snd_SfxDevice; -extern int snd_DesiredMusicDevice; -extern int snd_DesiredSfxDevice; -extern boolean statusbaractive; -extern boolean automapactive; -extern boolean menuactive; -extern boolean paused; -extern boolean viewactive; -extern boolean nodrawers; -extern boolean noblit; -extern int viewwindowx; -extern int viewwindowy; -extern int viewheight; -extern int viewwidth; -extern int scaledviewwidth; -extern int viewangleoffset; -extern int consoleplayer; -extern int displayplayer; -extern int totalkills; -extern int totalitems; -extern int totalsecret; -extern int levelstarttic; -extern int leveltime; -extern boolean usergame; -extern boolean demoplayback; -extern boolean demorecording; -extern boolean singledemo; -extern gamestate_t gamestate; -extern int gametic; -extern player_t players[MAXPLAYERS]; -extern boolean playeringame[MAXPLAYERS]; -#define MAX_DM_STARTS 10 -extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; -extern mapthing_t* deathmatch_p; -extern mapthing_t playerstarts[MAXPLAYERS]; -extern wbstartstruct_t wminfo; -extern int maxammo[NUMAMMO]; -extern char basedefault[1024]; -extern FILE* debugfile; -extern boolean precache; -extern gamestate_t wipegamestate; -extern int mouseSensitivity; -extern boolean singletics; -extern int bodyqueslot; -extern int skyflatnum; -extern doomcom_t* doomcom; -extern doomdata_t* netbuffer; -extern ticcmd_t localcmds[BACKUPTICS]; -extern int rndindex; -extern int maketic; -extern int nettics[MAXNETNODES]; -extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; -extern int ticdup; + +#define MAX_DM_STARTS 10 + +extern FILE* debugfile; +extern doomcom_t* doomcom; +extern doomdata_t* netbuffer; +extern boolean nomonsters; +extern boolean respawnparm; +extern boolean fastparm; +extern boolean devparm; +extern boolean modifiedgame; +extern boolean autostart; +extern boolean respawnmonsters; +extern boolean netgame; +extern boolean deathmatch; +extern boolean statusbaractive; +extern boolean automapactive; +extern boolean menuactive; +extern boolean paused; +extern boolean viewactive; +extern boolean nodrawers; +extern boolean noblit; +extern boolean usergame; +extern boolean demoplayback; +extern boolean demorecording; +extern boolean singledemo; +extern boolean playeringame[MAXPLAYERS]; +extern boolean precache; +extern boolean singletics; +extern int startepisode; +extern int startmap; +extern int gameepisode; +extern int gamemap; +extern int snd_SfxVolume; +extern int snd_MusicVolume; +extern int snd_MusicDevice; +extern int snd_SfxDevice; +extern int snd_DesiredMusicDevice; +extern int snd_DesiredSfxDevice; +extern int viewwindowx; +extern int viewwindowy; +extern int viewheight; +extern int viewwidth; +extern int scaledviewwidth; +extern int viewangleoffset; +extern int consoleplayer; +extern int displayplayer; +extern int totalkills; +extern int totalitems; +extern int totalsecret; +extern int levelstarttic; +extern int leveltime; +extern int gametic; +extern int maxammo[NUMAMMO]; +extern int mouseSensitivity; +extern int bodyqueslot; +extern int skyflatnum; +extern int rndindex; +extern int maketic; +extern int nettics[MAXNETNODES]; +extern int ticdup; +extern mapthing_t* deathmatch_p; +extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; +extern mapthing_t playerstarts[MAXPLAYERS]; +extern skill_t startskill; +extern skill_t gameskill; +extern ticcmd_t localcmds[BACKUPTICS]; +extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; +extern gamestate_t gamestate; +extern gamestate_t wipegamestate; +extern player_t players[MAXPLAYERS]; +extern wbstartstruct_t wminfo; +extern char basedefault[1024]; + #endif diff --git a/src/doomtype.h b/src/doomtype.h @@ -1,9 +0,0 @@ -#ifndef __DOOMTYPE__ -#define __DOOMTYPE__ -#ifndef __BYTEBOOL__ -#define __BYTEBOOL__ -typedef enum {false, true} boolean; -typedef unsigned char byte; -#endif -#include <values.h> -#endif diff --git a/src/dstrings.c b/src/dstrings.c @@ -1,26 +0,0 @@ -#include "dstrings.h" -char* endmsg[NUM_QUITMESSAGES+1] = { - QUITMSG, - "please don't leave, there's more\ndemons to toast!", - "let's beat it -- this is turning\ninto a bloodbath!", - "i wouldn't leave if i were you.\ndos is much worse.", - "you're trying to say you like dos\nbetter than me, right?", - "don't leave yet -- there's a\ndemon around that corner!", - "ya know, next time you come in here\ni'm gonna toast ya.", - "go ahead and leave. see if i care." - "you want to quit?\nthen, thou hast lost an eighth!", - "don't go now, there's a \ndimensional shambler waiting\nat the dos prompt!", - "get outta here and go back\nto your boring programs.", - "if i were your boss, i'd \n deathmatch ya in a minute!", - "look, bud. you leave now\nand you forfeit your body count!", - "just leave. when you come\nback, i'll be waiting with a bat.", - "you're lucky i don't smack\nyou for thinking about leaving." - "fuck you, pussy!\nget the fuck out!", - "you quit and i'll jizz\nin your cystholes!", - "if you leave, i'll make\nthe lord drink my jizz.", - "hey, ron! can we say\n'fuck' in the game?", - "i'd leave: this is just\nmore monsters and levels.\nwhat a load.", - "suck it down, asshole!\nyou're a fucking wimp!", - "don't quit now! we're \nstill spending your money!", - "THIS IS NO MESSAGE!\nPage intentionally left blank." -}; diff --git a/src/dstrings.h b/src/dstrings.h @@ -1,13 +1,11 @@ #ifndef __DSTRINGS__ #define __DSTRINGS__ -#ifdef FRENCH -#include "d_french.h" -#else -#include "d_englsh.h" -#endif -#define SAVEGAMENAME "doomsav" + +#define SAVEGAMENAME "doomsav" #define DEVMAPS "devmaps" #define DEVDATA "devdata" -#define NUM_QUITMESSAGES 22 +#define NUM_QUITMESSAGES 22 + extern char* endmsg[]; + #endif diff --git a/src/f_finale.c b/src/f_finale.c @@ -1,537 +1,384 @@ #include <ctype.h> + +#include "doomdef.h" #include "i_system.h" -#include "m_swap.h" #include "z_zone.h" #include "v_video.h" #include "w_wad.h" #include "s_sound.h" -#include "dstrings.h" #include "sounds.h" #include "doomstat.h" #include "r_state.h" -int finalestage; -int finalecount; +#include "hu_stuff.h" + #define TEXTSPEED 3 #define TEXTWAIT 250 -char* e1text = E1TEXT; -char* e2text = E2TEXT; -char* e3text = E3TEXT; -char* e4text = E4TEXT; -char* c1text = C1TEXT; -char* c2text = C2TEXT; -char* c3text = C3TEXT; -char* c4text = C4TEXT; -char* c5text = C5TEXT; -char* c6text = C6TEXT; -char* p1text = P1TEXT; -char* p2text = P2TEXT; -char* p3text = P3TEXT; -char* p4text = P4TEXT; -char* p5text = P5TEXT; -char* p6text = P6TEXT; -char* t1text = T1TEXT; -char* t2text = T2TEXT; -char* t3text = T3TEXT; -char* t4text = T4TEXT; -char* t5text = T5TEXT; -char* t6text = T6TEXT; + +typedef struct { + int name; + mobjtype_t type; +} castinfo_t; + +void F_CastTicker (); +boolean F_CastResponder (event_t *ev); +void F_CastDrawer (); +void V_DrawPatchFlipped(int x, int y, int scrn, patch_t *patch); + +extern patch_t *hu_font[HU_FONTSIZE]; +int finalestage; +int finalecount; char* finaletext; char* finaleflat; -void F_StartCast (void); -void F_CastTicker (void); -boolean F_CastResponder (event_t *ev); -void F_CastDrawer (void); -void F_StartFinale (void) +int castnum; +int casttics; +state_t* caststate; +boolean castdeath; +int castframes; +int castonmelee; +boolean castattacking; +extern gamestate_t wipegamestate; + +castinfo_t castorder[] = { + {CC_ZOMBIE, MT_POSSESSED}, + {CC_SHOTGUN, MT_SHOTGUY}, + {CC_HEAVY, MT_CHAINGUY}, + {CC_IMP, MT_TROOP}, + {CC_DEMON, MT_SERGEANT}, + {CC_LOST, MT_SKULL}, + {CC_CACO, MT_HEAD}, + {CC_HELL, MT_KNIGHT}, + {CC_BARON, MT_BRUISER}, + {CC_ARACH, MT_BABY}, + {CC_PAIN, MT_PAIN}, + {CC_REVEN, MT_UNDEAD}, + {CC_MANCU, MT_FATSO}, + {CC_ARCH, MT_VILE}, + {CC_SPIDER, MT_SPIDER}, + {CC_CYBER, MT_CYBORG}, + {CC_HERO, MT_PLAYER}, + {0, 0} +}; + +void +F_StartFinale() { - gameaction = ga_nothing; - gamestate = GS_FINALE; - viewactive = false; - automapactive = false; - switch ( gamemode ) - { - case shareware: - case registered: - case retail: - { + gameaction = ga_nothing; + gamestate = GS_FINALE; + viewactive = false; + automapactive = false; S_ChangeMusic(mus_victor, true); - switch (gameepisode) - { - case 1: - finaleflat = "FLOOR4_8"; - finaletext = e1text; - break; - case 2: - finaleflat = "SFLR6_1"; - finaletext = e2text; - break; - case 3: - finaleflat = "MFLR8_4"; - finaletext = e3text; - break; - case 4: - finaleflat = "MFLR8_3"; - finaletext = e4text; - break; - default: - break; + switch (gameepisode) { + case 1: + finaleflat = "FLOOR4_8"; + finaletext = lang[E1TEXT]; + break; + case 2: + finaleflat = "SFLR6_1"; + finaletext = lang[E2TEXT]; + break; + case 3: + finaleflat = "MFLR8_4"; + finaletext = lang[E3TEXT]; + break; + case 4: + finaleflat = "MFLR8_3"; + finaletext = lang[E4TEXT]; + break; } - break; - } - case commercial: - { - S_ChangeMusic(mus_read_m, true); - switch (gamemap) - { - case 6: - finaleflat = "SLIME16"; - finaletext = c1text; - break; - case 11: - finaleflat = "RROCK14"; - finaletext = c2text; - break; - case 20: - finaleflat = "RROCK07"; - finaletext = c3text; - break; - case 30: - finaleflat = "RROCK17"; - finaletext = c4text; - break; - case 15: - finaleflat = "RROCK13"; - finaletext = c5text; - break; - case 31: - finaleflat = "RROCK19"; - finaletext = c6text; - break; - default: - break; - } - break; - } - default: - S_ChangeMusic(mus_read_m, true); - finaleflat = "F_SKY1"; - finaletext = c1text; - break; - } - finalestage = 0; - finalecount = 0; -} -boolean F_Responder (event_t *event) -{ - if (finalestage == 2) - return F_CastResponder (event); - return false; + finalestage = 0; + finalecount = 0; } -void F_Ticker (void) + +boolean +F_Responder(event_t* event) { - int i; - if ( (gamemode == commercial) - && ( finalecount > 50) ) - { - for (i=0 ; i<MAXPLAYERS ; i++) - if (players[i].cmd.buttons) - break; - if (i < MAXPLAYERS) - { - if (gamemap == 30) - F_StartCast (); - else - gameaction = ga_worlddone; - } - } - finalecount++; - if (finalestage == 2) - { - F_CastTicker (); - return; - } - if ( gamemode == commercial) - return; - if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) - { - finalecount = 0; - finalestage = 1; - wipegamestate = -1; - if (gameepisode == 3) - S_StartMusic (mus_bunny); - } + if (finalestage == 2) return F_CastResponder(event); + return false; } -#include "hu_stuff.h" -extern patch_t *hu_font[HU_FONTSIZE]; -void F_TextWrite (void) + +void +F_Ticker() { - byte* src; - byte* dest; - int x,y,w; - int count; - char* ch; - int c; - int cx; - int cy; - src = W_CacheLumpName ( finaleflat , PU_CACHE); - dest = screens[0]; - for (y=0 ; y<SCREENHEIGHT ; y++) - { - for (x=0 ; x<SCREENWIDTH/64 ; x++) - { - memcpy (dest, src+((y&63)<<6), 64); - dest += 64; - } - if (SCREENWIDTH&63) - { - memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); - dest += (SCREENWIDTH&63); + finalecount++; + if (finalestage == 2) { + F_CastTicker (); + return; } - } - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - cx = 10; - cy = 10; - ch = finaletext; - count = (finalecount - 10)/TEXTSPEED; - if (count < 0) - count = 0; - for ( ; count ; count-- ) - { - c = *ch++; - if (!c) - break; - if (c == '\n') - { - cx = 10; - cy += 11; - continue; + if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) { + finalecount = 0; + finalestage = 1; + wipegamestate = -1; + if (gameepisode == 3) S_StartMusic(mus_bunny); } - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - cx += 4; - continue; - } - w = SHORT (hu_font[c]->width); - if (cx+w > SCREENWIDTH) - break; - V_DrawPatch(cx, cy, 0, hu_font[c]); - cx+=w; - } } -typedef struct -{ - char *name; - mobjtype_t type; -} castinfo_t; -castinfo_t castorder[] = { - {CC_ZOMBIE, MT_POSSESSED}, - {CC_SHOTGUN, MT_SHOTGUY}, - {CC_HEAVY, MT_CHAINGUY}, - {CC_IMP, MT_TROOP}, - {CC_DEMON, MT_SERGEANT}, - {CC_LOST, MT_SKULL}, - {CC_CACO, MT_HEAD}, - {CC_HELL, MT_KNIGHT}, - {CC_BARON, MT_BRUISER}, - {CC_ARACH, MT_BABY}, - {CC_PAIN, MT_PAIN}, - {CC_REVEN, MT_UNDEAD}, - {CC_MANCU, MT_FATSO}, - {CC_ARCH, MT_VILE}, - {CC_SPIDER, MT_SPIDER}, - {CC_CYBER, MT_CYBORG}, - {CC_HERO, MT_PLAYER}, - {NULL,0} -}; -int castnum; -int casttics; -state_t* caststate; -boolean castdeath; -int castframes; -int castonmelee; -boolean castattacking; -extern gamestate_t wipegamestate; -void F_StartCast (void) + +void +F_TextWrite() { - wipegamestate = -1; - castnum = 0; - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; - casttics = caststate->tics; - castdeath = false; - finalestage = 2; - castframes = 0; - castonmelee = 0; - castattacking = false; - S_ChangeMusic(mus_evil, true); + byte* src, *dest; + char* ch; + int x, y, w, count, c, cx, cy; + + src = W_CacheLumpName(finaleflat, PU_CACHE); + dest = screens[0]; + for (y = 0; y < SCREENHEIGHT; ++y) { + for (x = 0; x < SCREENWIDTH/64; ++x) { + memcpy (dest, src+((y&63)<<6), 64); + dest += 64; + } + if (SCREENWIDTH&63) { + memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); + dest += (SCREENWIDTH&63); + } + } + V_MarkRect(0, 0, SCREENWIDTH, SCREENHEIGHT); + cx = cy = 10; + ch = finaletext; + count = (finalecount - 10)/TEXTSPEED; + if (count < 0) count = 0; + for (; count; --count) { + c = *ch++; + if (!c) break; + if (c == '\n') { + cx = 10; + cy += 11; + continue; + } + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c> HU_FONTSIZE) { + cx += 4; + continue; + } + w = hu_font[c]->width; + if (cx+w > SCREENWIDTH) break; + V_DrawPatch(cx, cy, 0, hu_font[c]); + cx+=w; + } } -void F_CastTicker (void) + + +void +F_CastTicker() { - int st; - int sfx; - if (--casttics > 0) - return; - if (caststate->tics == -1 || caststate->nextstate == S_NULL) - { - castnum++; - castdeath = false; - if (castorder[castnum].name == NULL) - castnum = 0; - if (mobjinfo[castorder[castnum].type].seesound) - S_StartSound (NULL, mobjinfo[castorder[castnum].type].seesound); - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; - castframes = 0; - } - else - { - if (caststate == &states[S_PLAY_ATK1]) - goto stopattack; - st = caststate->nextstate; - caststate = &states[st]; - castframes++; - switch (st) - { - case S_PLAY_ATK1: sfx = sfx_dshtgn; break; - case S_POSS_ATK2: sfx = sfx_pistol; break; - case S_SPOS_ATK2: sfx = sfx_shotgn; break; - case S_VILE_ATK2: sfx = sfx_vilatk; break; - case S_SKEL_FIST2: sfx = sfx_skeswg; break; - case S_SKEL_FIST4: sfx = sfx_skepch; break; - case S_SKEL_MISS2: sfx = sfx_skeatk; break; - case S_FATT_ATK8: - case S_FATT_ATK5: - case S_FATT_ATK2: sfx = sfx_firsht; break; - case S_CPOS_ATK2: - case S_CPOS_ATK3: - case S_CPOS_ATK4: sfx = sfx_shotgn; break; - case S_TROO_ATK3: sfx = sfx_claw; break; - case S_SARG_ATK2: sfx = sfx_sgtatk; break; - case S_BOSS_ATK2: - case S_BOS2_ATK2: - case S_HEAD_ATK2: sfx = sfx_firsht; break; - case S_SKULL_ATK2: sfx = sfx_sklatk; break; - case S_SPID_ATK2: - case S_SPID_ATK3: sfx = sfx_shotgn; break; - case S_BSPI_ATK2: sfx = sfx_plasma; break; - case S_CYBER_ATK2: - case S_CYBER_ATK4: - case S_CYBER_ATK6: sfx = sfx_rlaunc; break; - case S_PAIN_ATK3: sfx = sfx_sklatk; break; - default: sfx = 0; break; + int st, sfx; + + if (--casttics > 0) return; + if (caststate->tics == -1 || caststate->nextstate == S_NULL) { + castnum++; + castdeath = false; + if (lang[castorder[castnum].name] == NULL) + castnum = 0; + if (mobjinfo[castorder[castnum].type].seesound) + S_StartSound(NULL, mobjinfo[castorder[castnum].type].seesound); + caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + castframes = 0; + } else { + if (caststate == &states[S_PLAY_ATK1]) goto stopattack; + st = caststate->nextstate; + caststate = &states[st]; + castframes++; + switch (st) { + case S_PLAY_ATK1: sfx = sfx_dshtgn; break; + case S_POSS_ATK2: sfx = sfx_pistol; break; + case S_SPOS_ATK2: sfx = sfx_shotgn; break; + case S_VILE_ATK2: sfx = sfx_vilatk; break; + case S_SKEL_FIST2: sfx = sfx_skeswg; break; + case S_SKEL_FIST4: sfx = sfx_skepch; break; + case S_SKEL_MISS2: sfx = sfx_skeatk; break; + case S_FATT_ATK8: + case S_FATT_ATK5: + case S_FATT_ATK2: sfx = sfx_firsht; break; + case S_CPOS_ATK2: + case S_CPOS_ATK3: + case S_CPOS_ATK4: sfx = sfx_shotgn; break; + case S_TROO_ATK3: sfx = sfx_claw; break; + case S_SARG_ATK2: sfx = sfx_sgtatk; break; + case S_BOSS_ATK2: + case S_BOS2_ATK2: + case S_HEAD_ATK2: sfx = sfx_firsht; break; + case S_SKULL_ATK2: sfx = sfx_sklatk; break; + case S_SPID_ATK2: + case S_SPID_ATK3: sfx = sfx_shotgn; break; + case S_BSPI_ATK2: sfx = sfx_plasma; break; + case S_CYBER_ATK2: + case S_CYBER_ATK4: + case S_CYBER_ATK6: sfx = sfx_rlaunc; break; + case S_PAIN_ATK3: sfx = sfx_sklatk; break; + default: sfx = 0; break; + } + if (sfx) S_StartSound(NULL, sfx); } - if (sfx) - S_StartSound (NULL, sfx); - } - if (castframes == 12) - { - castattacking = true; - if (castonmelee) - caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; - else - caststate=&states[mobjinfo[castorder[castnum].type].missilestate]; - castonmelee ^= 1; - if (caststate == &states[S_NULL]) - { - if (castonmelee) - caststate= - &states[mobjinfo[castorder[castnum].type].meleestate]; - else - caststate= - &states[mobjinfo[castorder[castnum].type].missilestate]; + if (castframes == 12) { + castattacking = true; + if (castonmelee) caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; + else caststate=&states[mobjinfo[castorder[castnum].type].missilestate]; + castonmelee ^= 1; + if (caststate == &states[S_NULL]) { + if (castonmelee) caststate = &states[mobjinfo[castorder[castnum].type].meleestate]; + else caststate = &states[mobjinfo[castorder[castnum].type].missilestate]; + } } - } - if (castattacking) - { - if (castframes == 24 - || caststate == &states[mobjinfo[castorder[castnum].type].seestate] ) - { - stopattack: - castattacking = false; - castframes = 0; - caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + if (castattacking) { + if (castframes == 24 || caststate == &states[mobjinfo[castorder[castnum].type].seestate] ) { + stopattack: + castattacking = false; + castframes = 0; + caststate = &states[mobjinfo[castorder[castnum].type].seestate]; + } } - } - casttics = caststate->tics; - if (casttics == -1) - casttics = 15; + casttics = caststate->tics; + if (casttics == -1) casttics = 15; } -boolean F_CastResponder (event_t* ev) + +boolean +F_CastResponder(event_t* ev) { - if (ev->type != ev_keydown) - return false; - if (castdeath) - return true; - castdeath = true; - caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; - casttics = caststate->tics; - castframes = 0; - castattacking = false; - if (mobjinfo[castorder[castnum].type].deathsound) - S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound); - return true; + if (ev->type != ev_keydown) return false; + if (castdeath) return true; + castdeath = true; + caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; + casttics = caststate->tics; + castframes = 0; + castattacking = false; + if (mobjinfo[castorder[castnum].type].deathsound) S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound); + return true; } -void F_CastPrint (char* text) + +void +F_CastPrint(char* text) { - char* ch; - int c; - int cx; - int w; - int width; - ch = text; - width = 0; - while (ch) - { - c = *ch++; - if (!c) - break; - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - width += 4; - continue; + char* ch; + int c, cx, w, width; + + width = 0; + ch = text; + while (ch) { + c = *ch++; + if (!c) break; + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c> HU_FONTSIZE) { + width += 4; + continue; + } + w = (hu_font[c]->width); + width += w; } - w = SHORT (hu_font[c]->width); - width += w; - } - cx = 160-width/2; - ch = text; - while (ch) - { - c = *ch++; - if (!c) - break; - c = toupper(c) - HU_FONTSTART; - if (c < 0 || c> HU_FONTSIZE) - { - cx += 4; - continue; + cx = 160-width/2; + ch = text; + while (ch) { + c = *ch++; + if (!c) break; + c = toupper(c) - HU_FONTSTART; + if (c < 0 || c > HU_FONTSIZE) { + cx += 4; + continue; + } + w = (hu_font[c]->width); + V_DrawPatch(cx, 180, 0, hu_font[c]); + cx += w; } - w = SHORT (hu_font[c]->width); - V_DrawPatch(cx, 180, 0, hu_font[c]); - cx+=w; - } } -void V_DrawPatchFlipped (int x, int y, int scrn, patch_t *patch); -void F_CastDrawer (void) + + +void +F_CastDrawer() { - spritedef_t* sprdef; - spriteframe_t* sprframe; - int lump; - boolean flip; - patch_t* patch; - V_DrawPatch (0,0,0, W_CacheLumpName ("BOSSBACK", PU_CACHE)); - F_CastPrint (castorder[castnum].name); - sprdef = &sprites[caststate->sprite]; - sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; - lump = sprframe->lump[0]; - flip = (boolean)sprframe->flip[0]; - patch = W_CacheLumpNum (lump+firstspritelump, PU_CACHE); - if (flip) - V_DrawPatchFlipped (160,170,0,patch); - else - V_DrawPatch (160,170,0,patch); + spriteframe_t* sprframe; + spritedef_t* sprdef; + patch_t* patch; + int lump; + boolean flip; + + V_DrawPatch (0, 0, 0, W_CacheLumpName ("BOSSBACK", PU_CACHE)); + F_CastPrint(lang[castorder[castnum].name]); + sprdef = &sprites[caststate->sprite]; + sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; + lump = sprframe->lump[0]; + flip = (boolean)sprframe->flip[0]; + patch = W_CacheLumpNum (lump+firstspritelump, PU_CACHE); + if (flip) V_DrawPatchFlipped(160, 170, 0, patch); + else V_DrawPatch (160, 170, 0, patch); } + void -F_DrawPatchCol -( int x, - patch_t* patch, - int col ) +F_DrawPatchCol(int x, patch_t* patch, int col) { - column_t* column; - byte* source; - byte* dest; - byte* desttop; - int count; - column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - desttop = screens[0]+x; - while (column->topdelta != 0xff ) - { - source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; - count = column->length; - while (count--) - { - *dest = *source++; - dest += SCREENWIDTH; + column_t* column; + byte* source, *dest , *desttop; + int count; + + column = (column_t *)((byte *)patch + patch->columnofs[col]); + desttop = screens[0] + x; + while (column->topdelta != 0xff ) { + source = (byte *)column + 3; + dest = desttop + column->topdelta*SCREENWIDTH; + for (count = column->length; count; --count) { + *dest = *source++; + dest += SCREENWIDTH; + } + column = (column_t*)((byte*)column + column->length + 4); } - column = (column_t *)( (byte *)column + column->length + 4 ); - } } -void F_BunnyScroll (void) + +void +F_BunnyScroll() { - int scrolled; - int x; - patch_t* p1; - patch_t* p2; - char name[10]; - int stage; - static int laststage; - p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); - p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - scrolled = 320 - (finalecount-230)/2; - if (scrolled > 320) - scrolled = 320; - if (scrolled < 0) - scrolled = 0; - for ( x=0 ; x<SCREENWIDTH ; x++) - { - if (x+scrolled < 320) - F_DrawPatchCol (x, p1, x+scrolled); - else - F_DrawPatchCol (x, p2, x+scrolled - 320); - } - if (finalecount < 1130) - return; - if (finalecount < 1180) - { - V_DrawPatch ((SCREENWIDTH-13*8)/2, - (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName ("END0",PU_CACHE)); - laststage = 0; - return; - } - stage = (finalecount-1180) / 5; - if (stage > 6) - stage = 6; - if (stage > laststage) - { - S_StartSound (NULL, sfx_pistol); - laststage = stage; - } - sprintf (name,"END%i",stage); - V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName (name,PU_CACHE)); + static int laststage; + patch_t* p1; + patch_t* p2; + int scrolled; + int x; + int stage; + char name[10]; + + p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); + p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); + V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); + scrolled = 320 - (finalecount-230)/2; + if (scrolled > 320) scrolled = 320; + if (scrolled < 0) scrolled = 0; + for (x = 0; x < SCREENWIDTH; ++x) { + if (x+scrolled < 320) F_DrawPatchCol(x, p1, x+scrolled); + else F_DrawPatchCol(x, p2, x+scrolled - 320); + } + if (finalecount < 1130) return; + if (finalecount < 1180) { + V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2, 0, W_CacheLumpName("END0", PU_CACHE)); + laststage = 0; + return; + } + stage = (finalecount-1180) / 5; + if (stage > 6) stage = 6; + if (stage > laststage) { + S_StartSound (NULL, sfx_pistol); + laststage = stage; + } + sprintf (name, "END%i", stage); + V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2, 0, W_CacheLumpName(name, PU_CACHE)); } -void F_Drawer (void) + +void +F_Drawer() { - if (finalestage == 2) - { - F_CastDrawer (); - return; - } - if (!finalestage) - F_TextWrite (); - else - { - switch (gameepisode) - { - case 1: - if ( gamemode == retail ) - V_DrawPatch (0,0,0, - W_CacheLumpName("CREDIT",PU_CACHE)); - else - V_DrawPatch (0,0,0, - W_CacheLumpName("HELP2",PU_CACHE)); - break; - case 2: - V_DrawPatch(0,0,0, - W_CacheLumpName("VICTORY2",PU_CACHE)); - break; - case 3: - F_BunnyScroll (); - break; - case 4: - V_DrawPatch (0,0,0, - W_CacheLumpName("ENDPIC",PU_CACHE)); - break; + if (finalestage == 2) { + F_CastDrawer (); + return; + } + if (!finalestage) F_TextWrite(); + else { + switch (gameepisode) { + case 1: + V_DrawPatch (0, 0, 0, W_CacheLumpName("HELP2", PU_CACHE)); + break; + case 2: + V_DrawPatch(0, 0, 0, W_CacheLumpName("VICTORY2", PU_CACHE)); + break; + case 3: + F_BunnyScroll(); + break; + case 4: + V_DrawPatch (0, 0, 0, W_CacheLumpName("ENDPIC", PU_CACHE)); + break; + } } - } } diff --git a/src/f_finale.h b/src/f_finale.h @@ -1,9 +1,12 @@ #ifndef __F_FINALE__ #define __F_FINALE__ -#include "doomtype.h" + +#include "doomdef.h" #include "d_event.h" + boolean F_Responder (event_t* ev); void F_Ticker (void); void F_Drawer (void); void F_StartFinale (void); + #endif diff --git a/src/f_wipe.c b/src/f_wipe.c @@ -2,54 +2,58 @@ #include "i_video.h" #include "v_video.h" #include "m_random.h" + #include "doomdef.h" #include "f_wipe.h" + static boolean go = 0; static byte* wipe_scr_start; static byte* wipe_scr_end; static byte* wipe_scr; + void -wipe_shittyColMajorXform -( short* array, - int width, - int height ) +wipe_shittyColMajorXform(short* array, int width, int height) { int x; int y; short* dest; + dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); + for(y=0;y<height;y++) for(x=0;x<width;x++) dest[x*height+y] = array[y*width+x]; + memcpy(array, dest, width*height*2); + Z_Free(dest); + } + int -wipe_initColorXForm -( int width, - int height, - int ticks ) +wipe_initColorXForm(int width, int height, int ticks) { memcpy(wipe_scr, wipe_scr_start, width*height); return 0; } + int -wipe_doColorXForm -( int width, +wipe_doColorXForm( int width, int height, int ticks ) { - boolean changed; byte* w; byte* e; - int newval; + boolean changed; + int newval; + changed = false; w = wipe_scr; e = wipe_scr_end; + while (w!=wipe_scr+width*height) { - if (*w != *e) - { + if (*w != *e) { if (*w > *e) { newval = *w - ticks; @@ -72,8 +76,11 @@ wipe_doColorXForm w++; e++; } + return !changed; + } + int wipe_exitColorXForm ( int width, @@ -82,7 +89,10 @@ wipe_exitColorXForm { return 0; } + + static int* y; + int wipe_initMelt ( int width, @@ -90,9 +100,17 @@ wipe_initMelt int ticks ) { int i, r; + + memcpy(wipe_scr, wipe_scr_start, width*height); + + + wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); + + + y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0); y[0] = -(M_Random()%16); for (i=1;i<width;i++) @@ -102,8 +120,10 @@ wipe_initMelt if (y[i] > 0) y[i] = 0; else if (y[i] == -16) y[i] = -15; } + return 0; } + int wipe_doMelt ( int width, @@ -114,10 +134,13 @@ wipe_doMelt int j; int dy; int idx; + short* s; short* d; boolean done = true; + width/=2; + while (ticks--) { for (i=0;i<width;i++) @@ -151,8 +174,11 @@ wipe_doMelt } } } + return done; + } + int wipe_exitMelt ( int width, @@ -162,6 +188,7 @@ wipe_exitMelt Z_Free(y); return 0; } + int wipe_StartScreen ( int x, @@ -173,6 +200,7 @@ wipe_StartScreen I_ReadScreen(wipe_scr_start); return 0; } + int wipe_EndScreen ( int x, @@ -185,6 +213,7 @@ wipe_EndScreen V_DrawBlock(x, y, 0, width, height, wipe_scr_start); return 0; } + int wipe_ScreenWipe ( int wipeno, @@ -200,19 +229,30 @@ wipe_ScreenWipe wipe_initColorXForm, wipe_doColorXForm, wipe_exitColorXForm, wipe_initMelt, wipe_doMelt, wipe_exitMelt }; + void V_MarkRect(int, int, int, int); + + if (!go) { go = 1; + wipe_scr = screens[0]; (*wipes[wipeno*3])(width, height, ticks); } + + V_MarkRect(0, 0, width, height); rc = (*wipes[wipeno*3+1])(width, height, ticks); + + + if (rc) { go = 0; (*wipes[wipeno*3+2])(width, height, ticks); } + return !go; + } diff --git a/src/f_wipe.h b/src/f_wipe.h @@ -1,23 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __F_WIPE_H__ #define __F_WIPE_H__ + + + + + enum { + wipe_ColorXForm, + + wipe_Melt, + wipe_NUMWIPES }; + int wipe_StartScreen ( int x, int y, int width, int height ); + + int wipe_EndScreen ( int x, int y, int width, int height ); + + int wipe_ScreenWipe ( int wipeno, @@ -26,4 +62,10 @@ wipe_ScreenWipe int width, int height, int ticks ); + #endif + + + + + diff --git a/src/g_game.c b/src/g_game.c @@ -1,6 +1,7 @@ #include <string.h> #include <stdlib.h> -#include "doomdef.h" + +#include "doomdef.h" #include "doomstat.h" #include "z_zone.h" #include "f_finale.h" @@ -19,1169 +20,734 @@ #include "am_map.h" #include "v_video.h" #include "w_wad.h" -#include "p_local.h" +#include "p_local.h" #include "s_sound.h" -#include "dstrings.h" #include "sounds.h" #include "r_data.h" -#include "r_sky.h" #include "g_game.h" + #define SAVEGAMESIZE 0x2c000 #define SAVESTRINGSIZE 24 -boolean G_CheckDemoStatus (void); -void G_ReadDemoTiccmd (ticcmd_t* cmd); -void G_WriteDemoTiccmd (ticcmd_t* cmd); -void G_PlayerReborn (int player); -void G_InitNew (skill_t skill, int episode, int map); -void G_DoReborn (int playernum); -void G_DoLoadLevel (void); -void G_DoNewGame (void); -void G_DoLoadGame (void); -void G_DoPlayDemo (void); -void G_DoCompleted (void); -void G_DoVictory (void); -void G_DoWorldDone (void); -void G_DoSaveGame (void); -gameaction_t gameaction; -gamestate_t gamestate; -skill_t gameskill; +#define MAXPLMOVE (forwardmove[1]) +#define TURBOTHRESHOLD 0x32 +#define SLOWTURNTICS 6 +#define NUMKEYS 256 +#define BODYQUESIZE 32 +#define VERSIONSIZE 16 +#define DEMOMARKER 0x80 + +boolean G_CheckDemoStatus (); +void G_ReadDemoTiccmd (ticcmd_t* cmd); +void G_WriteDemoTiccmd (ticcmd_t* cmd); +void G_PlayerReborn (int player); +void G_InitNew (skill_t skill, int episode, int map); +void G_DoReborn (int playernum); +void G_DoLoadLevel (); +void G_DoNewGame (); +void G_DoLoadGame (); +void G_DoPlayDemo (); +void G_DoCompleted (); +void G_DoVictory (); +void G_DoWorldDone (); +void G_DoSaveGame (); +void R_ExecuteSetViewSize (); + +extern gamestate_t wipegamestate; +extern boolean setsizeneeded; +extern char* pagename; +extern int skytexture; +skill_t d_skill; +int d_episode; +int d_map; +boolean secretexit; +gameaction_t gameaction; +gamestate_t gamestate; +skill_t gameskill; boolean respawnmonsters; -int gameepisode; -int gamemap; -boolean paused; -boolean sendpause; -boolean sendsave; -boolean usergame; -boolean timingdemo; -boolean nodrawers; -boolean noblit; -int starttime; -boolean viewactive; -boolean deathmatch; -boolean netgame; -boolean playeringame[MAXPLAYERS]; -player_t players[MAXPLAYERS]; -int consoleplayer; -int displayplayer; -int gametic; -int levelstarttic; -int totalkills, totalitems, totalsecret; -char demoname[32]; -boolean demorecording; -boolean demoplayback; -boolean netdemo; +int gameepisode; +int gamemap; +boolean paused; +boolean sendpause; +boolean sendsave; +boolean usergame; +boolean timingdemo; +boolean nodrawers; +boolean noblit; +int starttime; +boolean viewactive; +boolean deathmatch; +boolean netgame; +boolean playeringame[MAXPLAYERS]; +player_t players[MAXPLAYERS]; +int consoleplayer; +int displayplayer; +int gametic; +int levelstarttic; +int totalkills, totalitems, totalsecret; +char demoname[32]; +boolean demorecording; +boolean demoplayback; +boolean netdemo; byte* demobuffer; byte* demo_p; -byte* demoend; -boolean singledemo; -boolean precache = true; -wbstartstruct_t wminfo; -short consistancy[MAXPLAYERS][BACKUPTICS]; +byte* demoend; +boolean singledemo; +boolean precache = true; +wbstartstruct_t wminfo; +short consistancy[MAXPLAYERS][BACKUPTICS]; byte* savebuffer; -int key_right; +int key_right; int key_left; int key_up; -int key_down; -int key_strafeleft; -int key_straferight; -int key_fire; +int key_down; +int key_strafeleft; +int key_straferight; +int key_fire; int key_use; int key_strafe; -int key_speed; -int mousebfire; -int mousebstrafe; -int mousebforward; -int joybfire; -int joybstrafe; -int joybuse; -int joybspeed; -#define MAXPLMOVE (forwardmove[1]) -#define TURBOTHRESHOLD 0x32 -fixed_t forwardmove[2] = {0x19, 0x32}; -fixed_t sidemove[2] = {0x18, 0x28}; -fixed_t angleturn[3] = {640, 1280, 320}; -#define SLOWTURNTICS 6 -#define NUMKEYS 256 -boolean gamekeydown[NUMKEYS]; -int turnheld; -boolean mousearray[4]; -boolean* mousebuttons = &mousearray[1]; -int mousex; -int mousey; -int dclicktime; +int key_speed; +int mousebfire; +int mousebstrafe; +int mousebforward; +int joybfire; +int joybstrafe; +int joybuse; +int joybspeed; +fixed_t forwardmove[2] = {0x19, 0x32}; +fixed_t sidemove[2] = {0x18, 0x28}; +fixed_t angleturn[3] = {640, 1280, 320}; +boolean gamekeydown[NUMKEYS]; +int turnheld; +boolean mousearray[4]; +boolean* mousebuttons = &mousearray[1]; +int mousex; +int mousey; +int dclicktime; int dclickstate; -int dclicks; -int dclicktime2; +int dclicks; +int dclicktime2; int dclickstate2; int dclicks2; -int joyxmove; +int joyxmove; int joyymove; -boolean joyarray[5]; -boolean* joybuttons = &joyarray[1]; -int savegameslot; -char savedescription[32]; -#define BODYQUESIZE 32 -mobj_t* bodyque[BODYQUESIZE]; -int bodyqueslot; -void* statcopy; -int G_CmdChecksum (ticcmd_t* cmd) -{ - int i; - int sum = 0; - for (i=0 ; i< sizeof(*cmd)/4 - 1 ; i++) - sum += ((int *)cmd)[i]; - return sum; -} -void G_BuildTiccmd (ticcmd_t* cmd) -{ - int i; - boolean strafe; - boolean bstrafe; - int speed; - int tspeed; - int forward; - int side; - ticcmd_t* base; - base = I_BaseTiccmd (); - memcpy (cmd,base,sizeof(*cmd)); - cmd->consistancy = - consistancy[consoleplayer][maketic%BACKUPTICS]; - strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] - || joybuttons[joybstrafe]; - speed = gamekeydown[key_speed] || joybuttons[joybspeed]; - forward = side = 0; - if (joyxmove < 0 - || joyxmove > 0 - || gamekeydown[key_right] - || gamekeydown[key_left]) - turnheld += ticdup; - else - turnheld = 0; - if (turnheld < SLOWTURNTICS) - tspeed = 2; - else - tspeed = speed; - if (strafe) - { - if (gamekeydown[key_right]) - { - side += sidemove[speed]; +boolean joyarray[5]; +boolean* joybuttons = &joyarray[1]; +int savegameslot; +char savedescription[32]; +mobj_t* bodyque[BODYQUESIZE]; +int bodyqueslot; +void* statcopy; +char* defdemoname; + +int pars[4][10] = { + {0}, + {0,30,75,120,90,165,180,180,30,165}, + {0,90,90,90,120,90,360,240,30,170}, + {0,90,45,90,150,90,90,165,30,135} +}; + +int cpars[32] = { + 30,90,120,120,90,150,120,120,270,90, + 210,150,150,150,210,150,420,150,210,150, + 240,150,180,150,150,300,330,420,300,180, + 120,30 +}; + +int +G_CmdChecksum(ticcmd_t* cmd) +{ + int i, sum; + + for (sum = i = 0; i < sizeof(*cmd)/4 - 1; ++i) sum += ((int*)cmd)[i]; + return sum; +} + +void +G_BuildTiccmd(ticcmd_t* cmd) +{ + static ticcmd_t base; + int i, speed, tspeed, forward, side; + boolean strafe, bstrafe; + + memcpy(cmd, &base, sizeof(*cmd)); + cmd->consistancy = consistancy[consoleplayer][maketic%BACKUPTICS]; + strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; + speed = gamekeydown[key_speed] || joybuttons[joybspeed]; + forward = side = 0; + if (joyxmove < 0 || joyxmove > 0 || gamekeydown[key_right] || gamekeydown[key_left]) turnheld += ticdup; + else turnheld = 0; + if (turnheld < SLOWTURNTICS) tspeed = 2; + else tspeed = speed; + if (strafe) { + if (gamekeydown[key_right]) side += sidemove[speed]; + if (gamekeydown[key_left]) side -= sidemove[speed]; + if (joyxmove > 0) side += sidemove[speed]; + if (joyxmove < 0) side -= sidemove[speed]; } - if (gamekeydown[key_left]) - { - side -= sidemove[speed]; + else { + if (gamekeydown[key_right]) cmd->angleturn -= angleturn[tspeed]; + if (gamekeydown[key_left]) cmd->angleturn += angleturn[tspeed]; + if (joyxmove > 0) cmd->angleturn -= angleturn[tspeed]; + if (joyxmove < 0) cmd->angleturn += angleturn[tspeed]; } - if (joyxmove > 0) - side += sidemove[speed]; - if (joyxmove < 0) - side -= sidemove[speed]; - } - else - { - if (gamekeydown[key_right]) - cmd->angleturn -= angleturn[tspeed]; - if (gamekeydown[key_left]) - cmd->angleturn += angleturn[tspeed]; - if (joyxmove > 0) - cmd->angleturn -= angleturn[tspeed]; - if (joyxmove < 0) - cmd->angleturn += angleturn[tspeed]; - } - if (gamekeydown[key_up]) - { - forward += forwardmove[speed]; - } - if (gamekeydown[key_down]) - { - forward -= forwardmove[speed]; - } - if (joyymove < 0) - forward += forwardmove[speed]; - if (joyymove > 0) - forward -= forwardmove[speed]; - if (gamekeydown[key_straferight]) - side += sidemove[speed]; - if (gamekeydown[key_strafeleft]) - side -= sidemove[speed]; - cmd->chatchar = HU_dequeueChatChar(); - if (gamekeydown[key_fire] || mousebuttons[mousebfire] - || joybuttons[joybfire]) - cmd->buttons |= BT_ATTACK; - if (gamekeydown[key_use] || joybuttons[joybuse] ) - { - cmd->buttons |= BT_USE; - dclicks = 0; - } - for (i=0 ; i<NUMWEAPONS-1 ; i++) - if (gamekeydown['1'+i]) - { - cmd->buttons |= BT_CHANGE; - cmd->buttons |= i<<BT_WEAPONSHIFT; - break; + if (gamekeydown[key_up]) forward += forwardmove[speed]; + if (gamekeydown[key_down]) forward -= forwardmove[speed]; + if (joyymove < 0) forward += forwardmove[speed]; + if (joyymove > 0) forward -= forwardmove[speed]; + if (gamekeydown[key_straferight]) side += sidemove[speed]; + if (gamekeydown[key_strafeleft]) side -= sidemove[speed]; + cmd->chatchar = HU_dequeueChatChar(); + if (gamekeydown[key_fire] || mousebuttons[mousebfire] || joybuttons[joybfire]) + cmd->buttons |= BT_ATTACK; + if (gamekeydown[key_use] || joybuttons[joybuse]) { + cmd->buttons |= BT_USE; + dclicks = 0; } - if (mousebuttons[mousebforward]) - forward += forwardmove[speed]; - if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) - { - dclickstate = mousebuttons[mousebforward]; - if (dclickstate) - dclicks++; - if (dclicks == 2) - { - cmd->buttons |= BT_USE; - dclicks = 0; - } - else - dclicktime = 0; - } - else - { - dclicktime += ticdup; - if (dclicktime > 20) - { - dclicks = 0; - dclickstate = 0; - } - } - bstrafe = - mousebuttons[mousebstrafe] - || joybuttons[joybstrafe]; - if (bstrafe != dclickstate2 && dclicktime2 > 1 ) - { - dclickstate2 = bstrafe; - if (dclickstate2) - dclicks2++; - if (dclicks2 == 2) - { - cmd->buttons |= BT_USE; - dclicks2 = 0; - } - else - dclicktime2 = 0; - } - else - { - dclicktime2 += ticdup; - if (dclicktime2 > 20) - { - dclicks2 = 0; - dclickstate2 = 0; - } - } - forward += mousey; - if (strafe) - side += mousex*2; - else - cmd->angleturn -= mousex*0x8; - mousex = mousey = 0; - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - cmd->forwardmove += forward; - cmd->sidemove += side; - if (sendpause) - { - sendpause = false; - cmd->buttons = BT_SPECIAL | BTS_PAUSE; - } - if (sendsave) - { - sendsave = false; - cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT); - } -} -extern gamestate_t wipegamestate; -void G_DoLoadLevel (void) -{ - int i; - skyflatnum = R_FlatNumForName ( SKYFLATNAME ); - if ( (gamemode == commercial) || (gamemode == retail)) { - skytexture = R_TextureNumForName ("SKY3"); - if (gamemap < 12) - skytexture = R_TextureNumForName ("SKY1"); - else - if (gamemap < 21) - skytexture = R_TextureNumForName ("SKY2"); - } - levelstarttic = gametic; - if (wipegamestate == GS_LEVEL) - wipegamestate = -1; - gamestate = GS_LEVEL; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i] && players[i].playerstate == PST_DEAD) - players[i].playerstate = PST_REBORN; - memset (players[i].frags,0,sizeof(players[i].frags)); - } - P_SetupLevel (gameepisode, gamemap, 0, gameskill); - displayplayer = consoleplayer; - starttime = I_GetTime (); - gameaction = ga_nothing; - Z_CheckHeap (); - memset (gamekeydown, 0, sizeof(gamekeydown)); - joyxmove = joyymove = 0; - mousex = mousey = 0; - sendpause = sendsave = paused = false; - memset(mousebuttons, 0, sizeof(*mousebuttons)); - memset(joybuttons, 0, sizeof(*joybuttons)); -} -boolean G_Responder (event_t* ev) -{ - if (gamestate == GS_LEVEL && ev->type == ev_keydown - && ev->data1 == KEY_F12 && (singledemo || !deathmatch) ) - { - do - { - displayplayer++; - if (displayplayer == MAXPLAYERS) - displayplayer = 0; - } while (!playeringame[displayplayer] && displayplayer != consoleplayer); - return true; - } - if (gameaction == ga_nothing && !singledemo && - (demoplayback || gamestate == GS_DEMOSCREEN) - ) - { - if (ev->type == ev_keydown || - (ev->type == ev_mouse && ev->data1) || - (ev->type == ev_joystick && ev->data1) ) - { - M_StartControlPanel (); - return true; - } - return false; - } - if (gamestate == GS_LEVEL) - { -#if 0 - if (devparm && ev->type == ev_keydown && ev->data1 == ';') - { - G_DeathMatchSpawnPlayer (0); - return true; - } -#endif - if (HU_Responder (ev)) - return true; - if (ST_Responder (ev)) - return true; - if (AM_Responder (ev)) - return true; - } - if (gamestate == GS_FINALE) - { - if (F_Responder (ev)) - return true; - } - switch (ev->type) - { - case ev_keydown: - if (ev->data1 == KEY_PAUSE) - { - sendpause = true; - return true; - } - if (ev->data1 <NUMKEYS) - gamekeydown[ev->data1] = true; - return true; - case ev_keyup: - if (ev->data1 <NUMKEYS) - gamekeydown[ev->data1] = false; - return false; - case ev_mouse: - mousebuttons[0] = ev->data1 & 1; - mousebuttons[1] = ev->data1 & 2; - mousebuttons[2] = ev->data1 & 4; - mousex = ev->data2*(mouseSensitivity+5)/10; - mousey = ev->data3*(mouseSensitivity+5)/10; - return true; - case ev_joystick: - joybuttons[0] = ev->data1 & 1; - joybuttons[1] = ev->data1 & 2; - joybuttons[2] = ev->data1 & 4; - joybuttons[3] = ev->data1 & 8; - joyxmove = ev->data2; - joyymove = ev->data3; - return true; - default: - break; - } - return false; -} -void G_Ticker (void) -{ - int i; - int buf; - ticcmd_t* cmd; - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i] && players[i].playerstate == PST_REBORN) - G_DoReborn (i); - while (gameaction != ga_nothing) - { - switch (gameaction) - { - case ga_loadlevel: - G_DoLoadLevel (); - break; - case ga_newgame: - G_DoNewGame (); - break; - case ga_loadgame: - G_DoLoadGame (); - break; - case ga_savegame: - G_DoSaveGame (); - break; - case ga_playdemo: - G_DoPlayDemo (); - break; - case ga_completed: - G_DoCompleted (); - break; - case ga_victory: - F_StartFinale (); - break; - case ga_worlddone: - G_DoWorldDone (); - break; - case ga_screenshot: - M_ScreenShot (); - gameaction = ga_nothing; - break; - case ga_nothing: - break; - } - } - buf = (gametic/ticdup)%BACKUPTICS; - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - cmd = &players[i].cmd; - memcpy (cmd, &netcmds[i][buf], sizeof(ticcmd_t)); - if (demoplayback) - G_ReadDemoTiccmd (cmd); - if (demorecording) - G_WriteDemoTiccmd (cmd); - if (cmd->forwardmove > TURBOTHRESHOLD - && !(gametic&31) && ((gametic>>5)&3) == i ) - { - static char turbomessage[80]; - extern char *player_names[4]; - sprintf (turbomessage, "%s is turbo!",player_names[i]); - players[consoleplayer].message = turbomessage; - } - if (netgame && !netdemo && !(gametic%ticdup) ) - { - if (gametic > BACKUPTICS - && consistancy[i][buf] != cmd->consistancy) - { - I_Error ("consistency failure (%i should be %i)", - cmd->consistancy, consistancy[i][buf]); - } - if (players[i].mo) - consistancy[i][buf] = players[i].mo->x; - else - consistancy[i][buf] = rndindex; - } + for (i = 0; i < NUMWEAPONS - 1; ++i) + if (gamekeydown['1'+i]) { + cmd->buttons |= BT_CHANGE; + cmd->buttons |= i<<BT_WEAPONSHIFT; + break; + } + if (mousebuttons[mousebforward]) forward += forwardmove[speed]; + if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) { + dclickstate = mousebuttons[mousebforward]; + if (dclickstate) dclicks++; + if (dclicks == 2) { + cmd->buttons |= BT_USE; + dclicks = 0; + } else dclicktime = 0; + } else { + dclicktime += ticdup; + if (dclicktime > 20) { + dclicks = 0; + dclickstate = 0; + } + } + bstrafe = mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; + if (bstrafe != dclickstate2 && dclicktime2 > 1 ) { + dclickstate2 = bstrafe; + if (dclickstate2) dclicks2++; + if (dclicks2 == 2) { + cmd->buttons |= BT_USE; + dclicks2 = 0; + } else dclicktime2 = 0; + } else { + dclicktime2 += ticdup; + if (dclicktime2 > 20) { + dclicks2 = 0; + dclickstate2 = 0; + } + } + forward += mousey; + if (strafe) side += mousex * 2; + else cmd->angleturn -= mousex*0x8; + mousex = mousey = 0; + if (forward > MAXPLMOVE) forward = MAXPLMOVE; + if (forward < -MAXPLMOVE) forward = -MAXPLMOVE; + if (side > MAXPLMOVE) side = MAXPLMOVE; + if (side < -MAXPLMOVE) side = -MAXPLMOVE; + cmd->forwardmove += forward; + cmd->sidemove += side; + if (sendpause) { + sendpause = false; + cmd->buttons = BT_SPECIAL | BTS_PAUSE; } - } - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (playeringame[i]) - { - if (players[i].cmd.buttons & BT_SPECIAL) - { - switch (players[i].cmd.buttons & BT_SPECIALMASK) - { - case BTS_PAUSE: - paused ^= 1; - if (paused) - S_PauseSound (); - else - S_ResumeSound (); - break; - case BTS_SAVEGAME: - if (!savedescription[0]) - strcpy (savedescription, "NET GAME"); - savegameslot = - (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT; - gameaction = ga_savegame; - break; - } - } + if (sendsave) { + sendsave = false; + cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT); } - } - switch (gamestate) - { - case GS_LEVEL: - P_Ticker (); - ST_Ticker (); - AM_Ticker (); - HU_Ticker (); - break; - case GS_INTERMISSION: - WI_Ticker (); - break; - case GS_FINALE: - F_Ticker (); - break; - case GS_DEMOSCREEN: - D_PageTicker (); - break; - } -} -void G_InitPlayer (int player) -{ - G_PlayerReborn (player); -} -void G_PlayerFinishLevel (int player) -{ - player_t* p; - p = &players[player]; - memset (p->powers, 0, sizeof (p->powers)); - memset (p->cards, 0, sizeof (p->cards)); - p->mo->flags &= ~MF_SHADOW; - p->extralight = 0; - p->fixedcolormap = 0; - p->damagecount = 0; - p->bonuscount = 0; -} -void G_PlayerReborn (int player) -{ - player_t* p; - int i; - int frags[MAXPLAYERS]; - int killcount; - int itemcount; - int secretcount; - memcpy (frags,players[player].frags,sizeof(frags)); - killcount = players[player].killcount; - itemcount = players[player].itemcount; - secretcount = players[player].secretcount; - p = &players[player]; - memset (p, 0, sizeof(*p)); - memcpy (players[player].frags, frags, sizeof(players[player].frags)); - players[player].killcount = killcount; - players[player].itemcount = itemcount; - players[player].secretcount = secretcount; - p->usedown = p->attackdown = true; - p->playerstate = PST_LIVE; - p->health = MAXHEALTH; - p->readyweapon = p->pendingweapon = wp_pistol; - p->weaponowned[wp_fist] = true; - p->weaponowned[wp_pistol] = true; - p->ammo[am_clip] = 50; - for (i=0 ; i<NUMAMMO ; i++) - p->maxammo[i] = maxammo[i]; } -void P_SpawnPlayer (mapthing_t* mthing); + +void +G_DoLoadLevel() +{ + int i; + + skyflatnum = R_FlatNumForName(SKYFLATNAME); + levelstarttic = gametic; + if (wipegamestate == GS_LEVEL) wipegamestate = -1; + gamestate = GS_LEVEL; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; + memset(players[i].frags,0,sizeof(players[i].frags)); + } + P_SetupLevel(gameepisode, gamemap, 0, gameskill); + displayplayer = consoleplayer; + starttime = I_GetTime(); + gameaction = ga_nothing; + Z_CheckHeap(); + memset(gamekeydown, 0, sizeof(gamekeydown)); + joyxmove = joyymove = 0; + mousex = mousey = 0; + sendpause = sendsave = paused = false; + memset(mousebuttons, 0, sizeof(*mousebuttons)); + memset(joybuttons, 0, sizeof(*joybuttons)); +} + boolean -G_CheckSpot -( int playernum, - mapthing_t* mthing ) -{ - fixed_t x; - fixed_t y; - subsector_t* ss; - unsigned an; - mobj_t* mo; - int i; - if (!players[playernum].mo) - { - for (i=0 ; i<playernum ; i++) - if (players[i].mo->x == mthing->x << FRACBITS - && players[i].mo->y == mthing->y << FRACBITS) - return false; +G_Responder(event_t* ev) +{ + if (gamestate == GS_LEVEL && ev->type == ev_keydown && ev->data1 == KEY_F12 && (singledemo || !deathmatch)) { + do { + displayplayer++; + if (displayplayer == MAXPLAYERS) displayplayer = 0; + } while (!playeringame[displayplayer] && displayplayer != consoleplayer); + return true; + } + if (gameaction == ga_nothing && !singledemo && (demoplayback || gamestate == GS_DEMOSCREEN)) { + if (ev->type == ev_keydown || (ev->type == ev_mouse && ev->data1) || (ev->type == ev_joystick && ev->data1)) { + M_StartControlPanel(); + return true; + } + return false; + } + if (gamestate == GS_LEVEL) { + if (HU_Responder(ev)) + return true; + if (ST_Responder(ev)) + return true; + if (AM_Responder(ev)) + return true; + } + if (gamestate == GS_FINALE) + if (F_Responder(ev)) return true; + + switch (ev->type) { + case ev_keydown: + if (ev->data1 == KEY_PAUSE) { + sendpause = true; + return true; + } + if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = true; + return true; + case ev_keyup: + if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = false; + return false; + case ev_mouse: + mousebuttons[0] = ev->data1 & 1; + mousebuttons[1] = ev->data1 & 2; + mousebuttons[2] = ev->data1 & 4; + mousex = ev->data2*(mouseSensitivity+5)/10; + mousey = ev->data3*(mouseSensitivity+5)/10; + return true; + case ev_joystick: + joybuttons[0] = ev->data1 & 1; + joybuttons[1] = ev->data1 & 2; + joybuttons[2] = ev->data1 & 4; + joybuttons[3] = ev->data1 & 8; + joyxmove = ev->data2; + joyymove = ev->data3; + return true; + default: + return false; + } +} + +void +G_Ticker() +{ + int i, buf; + ticcmd_t* cmd; + + + for (i = 0; i < MAXPLAYERS; ++i) if(playeringame[i] && players[i].playerstate == PST_REBORN) G_DoReborn (i); + while (gameaction != ga_nothing) { + switch (gameaction) { + case ga_loadlevel: + G_DoLoadLevel(); + break; + case ga_newgame: + G_DoNewGame(); + break; + case ga_loadgame: + G_DoLoadGame(); + break; + case ga_savegame: + G_DoSaveGame(); + break; + case ga_playdemo: + G_DoPlayDemo(); + break; + case ga_completed: + G_DoCompleted(); + break; + case ga_victory: + F_StartFinale(); + break; + case ga_worlddone: + G_DoWorldDone(); + break; + case ga_nothing: + break; + } + } + buf = (gametic/ticdup)%BACKUPTICS; + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + cmd = &players[i].cmd; + memcpy (cmd, &netcmds[i][buf], sizeof(ticcmd_t)); + if (demoplayback) G_ReadDemoTiccmd (cmd); + if (demorecording) G_WriteDemoTiccmd (cmd); + if (cmd->forwardmove > TURBOTHRESHOLD && !(gametic&31) && ((gametic>>5)&3) == i) { + static char turbomessage[80]; + extern char *player_names[4]; + sprintf (turbomessage, "%s is turbo!",player_names[i]); + players[consoleplayer].message = turbomessage; + } + if (netgame && !netdemo && !(gametic%ticdup) ) { + if (gametic > BACKUPTICS && consistancy[i][buf] != cmd->consistancy) I_Error("consistency failure (%i should be %i)", cmd->consistancy, consistancy[i][buf]); + if (players[i].mo) consistancy[i][buf] = players[i].mo->x; + else consistancy[i][buf] = rndindex; + } + } + } + for (i = 0; i < MAXPLAYERS; ++i) { + if (playeringame[i]) { + if (players[i].cmd.buttons & BT_SPECIAL){ + switch (players[i].cmd.buttons & BT_SPECIALMASK) { + case BTS_PAUSE: + paused ^= 1; + if (paused) S_PauseSound (); + else S_ResumeSound (); + break; + case BTS_SAVEGAME: + if (!savedescription[0]) strcpy(savedescription, "NET GAME"); + savegameslot = (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT; + gameaction = ga_savegame; + break; + } + } + } + } + switch (gamestate) { + case GS_LEVEL: + P_Ticker(); + ST_Ticker(); + AM_Ticker(); + HU_Ticker(); + break; + case GS_INTERMISSION: + WI_Ticker(); + break; + case GS_FINALE: + F_Ticker(); + break; + case GS_DEMOSCREEN: + D_PageTicker(); + break; + } +} + +void +G_InitPlayer(int player) +{ + G_PlayerReborn(player); +} + +void +G_PlayerFinishLevel(int player) +{ + player_t* p; + + p = &players[player]; + memset (p->powers, 0, sizeof (p->powers)); + memset (p->cards, 0, sizeof (p->cards)); + p->mo->flags &= ~MF_SHADOW; + p->extralight = 0; + p->fixedcolormap = 0; + p->damagecount = 0; + p->bonuscount = 0; +} + +void +G_PlayerReborn(int player) +{ + player_t* p; + int i, killcount, itemcount, secretcount, frags[MAXPLAYERS]; + + memcpy(frags,players[player].frags,sizeof(frags)); + killcount = players[player].killcount; + itemcount = players[player].itemcount; + secretcount = players[player].secretcount; + p = &players[player]; + memset(p, 0, sizeof(*p)); + memcpy(players[player].frags, frags, sizeof(players[player].frags)); + players[player].killcount = killcount; + players[player].itemcount = itemcount; + players[player].secretcount = secretcount; + p->usedown = p->attackdown = true; + p->playerstate = PST_LIVE; + p->health = MAXHEALTH; + p->readyweapon = p->pendingweapon = wp_pistol; + p->weaponowned[wp_fist] = true; + p->weaponowned[wp_pistol] = true; + p->ammo[am_clip] = 50; + for (i = 0; i < NUMAMMO; ++i) p->maxammo[i] = maxammo[i]; +} + +void P_SpawnPlayer(mapthing_t* mthing); + +boolean +G_CheckSpot(int playernum, mapthing_t* mthing) +{ + subsector_t* ss; + mobj_t* mo; + fixed_t x, y; + unsigned an; + int i; + + if (!players[playernum].mo) { + for (i = 0; i < playernum; ++i) + if (players[i].mo->x == mthing->x << FRACBITS && players[i].mo->y == mthing->y << FRACBITS) + return false; + return true; + } + x = mthing->x << FRACBITS; + y = mthing->y << FRACBITS; + if (!P_CheckPosition (players[playernum].mo, x, y)) return false; + if (bodyqueslot >= BODYQUESIZE) P_RemoveMobj (bodyque[bodyqueslot%BODYQUESIZE]); + bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo; + bodyqueslot++; + ss = R_PointInSubsector(x,y); + an = (ANG45 * (mthing->angle/45)) >> ANGLETOFINESHIFT; + mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an], ss->sector->floorheight, MT_TFOG); + if (players[consoleplayer].viewz != 1) S_StartSound (mo, sfx_telept); return true; - } - x = mthing->x << FRACBITS; - y = mthing->y << FRACBITS; - if (!P_CheckPosition (players[playernum].mo, x, y) ) - return false; - if (bodyqueslot >= BODYQUESIZE) - P_RemoveMobj (bodyque[bodyqueslot%BODYQUESIZE]); - bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo; - bodyqueslot++; - ss = R_PointInSubsector (x,y); - an = ( ANG45 * (mthing->angle/45) ) >> ANGLETOFINESHIFT; - mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an] - , ss->sector->floorheight - , MT_TFOG); - if (players[consoleplayer].viewz != 1) - S_StartSound (mo, sfx_telept); - return true; -} -void G_DeathMatchSpawnPlayer (int playernum) -{ - int i,j; - int selections; - selections = deathmatch_p - deathmatchstarts; - if (selections < 4) - I_Error ("Only %i deathmatch spots, 4 required", selections); - for (j=0 ; j<20 ; j++) - { - i = P_Random() % selections; - if (G_CheckSpot (playernum, &deathmatchstarts[i]) ) - { - deathmatchstarts[i].type = playernum+1; - P_SpawnPlayer (&deathmatchstarts[i]); - return; - } - } - P_SpawnPlayer (&playerstarts[playernum]); -} -void G_DoReborn (int playernum) -{ - int i; - if (!netgame) - { - gameaction = ga_loadlevel; - } - else - { - players[playernum].mo->player = NULL; - if (deathmatch) - { - G_DeathMatchSpawnPlayer (playernum); - return; - } - if (G_CheckSpot (playernum, &playerstarts[playernum]) ) - { - P_SpawnPlayer (&playerstarts[playernum]); - return; +} + +void +G_DeathMatchSpawnPlayer(int playernum) +{ + int i, j, selections; + + selections = deathmatch_p - deathmatchstarts; + if (selections < 4) I_Error ("Only %i deathmatch spots, 4 required", selections); + for (j = 0; j < 20; ++j) { + i = P_Random() % selections; + if (G_CheckSpot (playernum, &deathmatchstarts[i])) { + deathmatchstarts[i].type = playernum+1; + P_SpawnPlayer (&deathmatchstarts[i]); + return; + } } - for (i=0 ; i<MAXPLAYERS ; i++) - { - if (G_CheckSpot (playernum, &playerstarts[i]) ) - { - playerstarts[i].type = playernum+1; - P_SpawnPlayer (&playerstarts[i]); - playerstarts[i].type = i+1; - return; - } + P_SpawnPlayer(&playerstarts[playernum]); +} + +void +G_DoReborn(int playernum) +{ + int i; + + if (!netgame) gameaction = ga_loadlevel; + else { + players[playernum].mo->player = NULL; + if (deathmatch) { + G_DeathMatchSpawnPlayer (playernum); + return; + } + if (G_CheckSpot(playernum, &playerstarts[playernum])) { + P_SpawnPlayer (&playerstarts[playernum]); + return; + } + for (i = 0; i < MAXPLAYERS; ++i) { + if (G_CheckSpot (playernum, &playerstarts[i])) { + playerstarts[i].type = playernum+1; + P_SpawnPlayer (&playerstarts[i]); + playerstarts[i].type = i+1; + return; + } + } + P_SpawnPlayer(&playerstarts[playernum]); } - P_SpawnPlayer (&playerstarts[playernum]); - } -} -void G_ScreenShot (void) -{ - gameaction = ga_screenshot; -} -int pars[4][10] = -{ - {0}, - {0,30,75,120,90,165,180,180,30,165}, - {0,90,90,90,120,90,360,240,30,170}, - {0,90,45,90,150,90,90,165,30,135} -}; -int cpars[32] = +} + +void +G_ExitLevel() { - 30,90,120,120,90,150,120,120,270,90, - 210,150,150,150,210,150,420,150,210,150, - 240,150,180,150,150,300,330,420,300,180, - 120,30 -}; -boolean secretexit; -extern char* pagename; -void G_ExitLevel (void) -{ - secretexit = false; - gameaction = ga_completed; -} -void G_SecretExitLevel (void) -{ - if ( (gamemode == commercial) - && (W_CheckNumForName("map31")<0)) secretexit = false; - else - secretexit = true; - gameaction = ga_completed; -} -void G_DoCompleted (void) -{ - int i; - gameaction = ga_nothing; - for (i=0 ; i<MAXPLAYERS ; i++) - if (playeringame[i]) - G_PlayerFinishLevel (i); - if (automapactive) - AM_Stop (); - if ( gamemode != commercial) - switch(gamemap) - { - case 8: - gameaction = ga_victory; - return; - case 9: - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].didsecret = true; - break; - } - if ( (gamemap == 8) - && (gamemode != commercial) ) - { - gameaction = ga_victory; - return; - } - if ( (gamemap == 9) - && (gamemode != commercial) ) - { - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].didsecret = true; - } - wminfo.didsecret = players[consoleplayer].didsecret; - wminfo.epsd = gameepisode -1; - wminfo.last = gamemap -1; - if ( gamemode == commercial) - { - if (secretexit) - switch(gamemap) - { - case 15: wminfo.next = 30; break; - case 31: wminfo.next = 31; break; - } - else - switch(gamemap) - { - case 31: - case 32: wminfo.next = 15; break; - default: wminfo.next = gamemap; - } - } - else - { - if (secretexit) - wminfo.next = 8; - else if (gamemap == 9) - { - switch (gameepisode) - { - case 1: - wminfo.next = 3; - break; - case 2: - wminfo.next = 5; - break; - case 3: - wminfo.next = 6; - break; - case 4: - wminfo.next = 2; - break; - } - } - else - wminfo.next = gamemap; - } - wminfo.maxkills = totalkills; - wminfo.maxitems = totalitems; - wminfo.maxsecret = totalsecret; - wminfo.maxfrags = 0; - if ( gamemode == commercial ) - wminfo.partime = 35*cpars[gamemap-1]; - else - wminfo.partime = 35*pars[gameepisode][gamemap]; - wminfo.pnum = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) - { - wminfo.plyr[i].in = playeringame[i]; - wminfo.plyr[i].skills = players[i].killcount; - wminfo.plyr[i].sitems = players[i].itemcount; - wminfo.plyr[i].ssecret = players[i].secretcount; - wminfo.plyr[i].stime = leveltime; - memcpy (wminfo.plyr[i].frags, players[i].frags - , sizeof(wminfo.plyr[i].frags)); - } - gamestate = GS_INTERMISSION; - viewactive = false; - automapactive = false; - if (statcopy) - memcpy (statcopy, &wminfo, sizeof(wminfo)); - WI_Start (&wminfo); -} -void G_WorldDone (void) -{ - gameaction = ga_worlddone; - if (secretexit) - players[consoleplayer].didsecret = true; - if ( gamemode == commercial ) - { - switch (gamemap) - { - case 15: - case 31: - if (!secretexit) - break; - case 6: - case 11: - case 20: - case 30: - F_StartFinale (); - break; + gameaction = ga_completed; +} + +void +G_SecretExitLevel() +{ + secretexit = true; + gameaction = ga_completed; +} + +void +G_DoCompleted() +{ + int i; + + gameaction = ga_nothing; + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + G_PlayerFinishLevel (i); + if (automapactive) AM_Stop(); + if (gamemap == 9) + for (i = 0; i < MAXPLAYERS; ++i) players[i].didsecret = true; + wminfo.didsecret = players[consoleplayer].didsecret; + wminfo.epsd = gameepisode -1; + wminfo.last = gamemap -1; + if (secretexit) wminfo.next = 8; + else if (gamemap == 9) { + switch (gameepisode) { + case 1: + wminfo.next = 3; + break; + case 2: + wminfo.next = 5; + break; + case 3: + wminfo.next = 6; + break; + case 4: + wminfo.next = 2; + break; + } + } else wminfo.next = gamemap; + wminfo.maxkills = totalkills; + wminfo.maxitems = totalitems; + wminfo.maxsecret = totalsecret; + wminfo.maxfrags = 0; + wminfo.partime = 35*pars[gameepisode][gamemap]; + wminfo.pnum = consoleplayer; + for (i = 0; i < MAXPLAYERS; ++i) { + wminfo.plyr[i].in = playeringame[i]; + wminfo.plyr[i].skills = players[i].killcount; + wminfo.plyr[i].sitems = players[i].itemcount; + wminfo.plyr[i].ssecret = players[i].secretcount; + wminfo.plyr[i].stime = leveltime; memcpy(wminfo.plyr[i].frags, players[i].frags, sizeof(wminfo.plyr[i].frags)); } - } -} -void G_DoWorldDone (void) -{ - gamestate = GS_LEVEL; - gamemap = wminfo.next+1; - G_DoLoadLevel (); - gameaction = ga_nothing; - viewactive = true; -} -extern boolean setsizeneeded; -void R_ExecuteSetViewSize (void); + gamestate = GS_INTERMISSION; + viewactive = false; + automapactive = false; + if (statcopy) memcpy(statcopy, &wminfo, sizeof(wminfo)); + WI_Start (&wminfo); +} + +void +G_WorldDone() +{ + gameaction = ga_worlddone; + if (secretexit) players[consoleplayer].didsecret = true; +} + +void +G_DoWorldDone() +{ + gamestate = GS_LEVEL; + gamemap = wminfo.next+1; + G_DoLoadLevel(); + gameaction = ga_nothing; + viewactive = true; +} + char savename[256]; -void G_LoadGame (char* name) -{ - strcpy (savename, name); - gameaction = ga_loadgame; -} -#define VERSIONSIZE 16 -void G_DoLoadGame (void) -{ - int i; - int a,b,c; - char vcheck[VERSIONSIZE]; - gameaction = ga_nothing; - save_p = savebuffer + SAVESTRINGSIZE; - memset (vcheck,0,sizeof(vcheck)); - sprintf (vcheck,"version %i",VERSION); - if (strcmp((char*)save_p, vcheck)) - return; - save_p += VERSIONSIZE; - gameskill = *save_p++; - gameepisode = *save_p++; - gamemap = *save_p++; - for (i=0 ; i<MAXPLAYERS ; i++) - playeringame[i] = *save_p++; - G_InitNew (gameskill, gameepisode, gamemap); - a = *save_p++; - b = *save_p++; - c = *save_p++; - leveltime = (a<<16) + (b<<8) + c; - P_UnArchivePlayers (); - P_UnArchiveWorld (); - P_UnArchiveThinkers (); - P_UnArchiveSpecials (); - if (*save_p != 0x1d) - I_Error ("Bad savegame"); - Z_Free (savebuffer); - if (setsizeneeded) - R_ExecuteSetViewSize (); - R_FillBackScreen (); -} + +void G_LoadGame (char* name) +{ + strcpy (savename, name); + gameaction = ga_loadgame; +} + void -G_SaveGame -( int slot, - char* description ) -{ - savegameslot = slot; - strcpy (savedescription, description); - sendsave = true; -} -void G_DoSaveGame (void) -{ - char name[100]; - char name2[VERSIONSIZE]; - char* description; - int length; - int i; - if (M_CheckParm("-cdrom")) - sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot); - else - sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot); - description = savedescription; - save_p = savebuffer = screens[1]+0x4000; - memcpy (save_p, description, SAVESTRINGSIZE); - save_p += SAVESTRINGSIZE; - memset (name2,0,sizeof(name2)); - sprintf (name2,"version %i",VERSION); - memcpy (save_p, name2, VERSIONSIZE); - save_p += VERSIONSIZE; - *save_p++ = gameskill; - *save_p++ = gameepisode; - *save_p++ = gamemap; - for (i=0 ; i<MAXPLAYERS ; i++) - *save_p++ = playeringame[i]; - *save_p++ = leveltime>>16; - *save_p++ = leveltime>>8; - *save_p++ = leveltime; - P_ArchivePlayers (); - P_ArchiveWorld (); - P_ArchiveThinkers (); - P_ArchiveSpecials (); - *save_p++ = 0x1d; - length = save_p - savebuffer; - if (length > SAVEGAMESIZE) - I_Error ("Savegame buffer overrun"); - M_WriteFile (name, savebuffer, length); - gameaction = ga_nothing; - savedescription[0] = 0; - players[consoleplayer].message = GGSAVED; - R_FillBackScreen (); -} -skill_t d_skill; -int d_episode; -int d_map; +G_DoLoadGame() +{ + int i, a, b, c; + char vcheck[VERSIONSIZE]; + + gameaction = ga_nothing; + M_ReadFile(savename, &savebuffer); + save_p = savebuffer + SAVESTRINGSIZE; + memset(vcheck, 0, sizeof(vcheck)); + sprintf (vcheck, "version %i", VERSION); + if (strcmp ((char*)save_p, vcheck)) return; + save_p += VERSIONSIZE; + gameskill = *save_p++; + gameepisode = *save_p++; + gamemap = *save_p++; + for (i = 0; i < MAXPLAYERS; ++i) playeringame[i] = *save_p++; + G_InitNew(gameskill, gameepisode, gamemap); + a = *save_p++; + b = *save_p++; + c = *save_p++; + leveltime = (a<<16) + (b<<8) + c; + P_UnArchivePlayers(); + P_UnArchiveWorld(); + P_UnArchiveThinkers(); + P_UnArchiveSpecials(); + if (*save_p != 0x1d) I_Error("Bad savegame"); + Z_Free(savebuffer); + if (setsizeneeded) R_ExecuteSetViewSize(); + R_FillBackScreen(); +} + void -G_DeferedInitNew -( skill_t skill, - int episode, - int map) -{ - d_skill = skill; - d_episode = episode; - d_map = map; - gameaction = ga_newgame; -} -void G_DoNewGame (void) +G_SaveGame(int slot, char* description) { - demoplayback = false; - netdemo = false; - netgame = false; - deathmatch = false; - playeringame[1] = playeringame[2] = playeringame[3] = 0; - respawnparm = false; - fastparm = false; - nomonsters = false; - consoleplayer = 0; - G_InitNew (d_skill, d_episode, d_map); - gameaction = ga_nothing; -} -extern int skytexture; + savegameslot = slot; + strcpy(savedescription, description); + sendsave = true; +} + void -G_InitNew -( skill_t skill, - int episode, - int map ) -{ - int i; - if (paused) - { - paused = false; - S_ResumeSound (); - } - if (skill > sk_nightmare) - skill = sk_nightmare; - if (episode < 1) - episode = 1; - if ( gamemode == retail ) - { - if (episode > 4) - episode = 4; - } - else if ( gamemode == shareware ) - { - if (episode > 1) - episode = 1; - } - else - { - if (episode > 3) - episode = 3; - } - if (map < 1) - map = 1; - if ( (map > 9) - && ( gamemode != commercial) ) - map = 9; - M_ClearRandom (); - if (skill == sk_nightmare || respawnparm ) - respawnmonsters = true; - else - respawnmonsters = false; - if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare) ) - { - for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) - states[i].tics >>= 1; - mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; - mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; - mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; - } - else if (skill != sk_nightmare && gameskill == sk_nightmare) - { - for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) - states[i].tics <<= 1; - mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; - mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; - mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; - } - for (i=0 ; i<MAXPLAYERS ; i++) - players[i].playerstate = PST_REBORN; - usergame = true; - paused = false; - demoplayback = false; - automapactive = false; - viewactive = true; - gameepisode = episode; - gamemap = map; - gameskill = skill; - viewactive = true; - if ( gamemode == commercial) - { - skytexture = R_TextureNumForName ("SKY3"); - if (gamemap < 12) - skytexture = R_TextureNumForName ("SKY1"); +G_DoSaveGame() +{ + char* description; + char name[100]; + char name2[VERSIONSIZE]; + int i, length; + + if (M_CheckParm("-cdrom")) + sprintf(name, "c:\\doomdata\\%s%d.dsg", lang[SAVEGAMENAME], savegameslot); else - if (gamemap < 21) - skytexture = R_TextureNumForName ("SKY2"); - } - else - switch (episode) - { - case 1: - skytexture = R_TextureNumForName ("SKY1"); - break; - case 2: - skytexture = R_TextureNumForName ("SKY2"); - break; - case 3: - skytexture = R_TextureNumForName ("SKY3"); - break; - case 4: - skytexture = R_TextureNumForName ("SKY4"); - break; - } - G_DoLoadLevel (); -} -#define DEMOMARKER 0x80 -void G_ReadDemoTiccmd (ticcmd_t* cmd) -{ - if (*demo_p == DEMOMARKER) - { - G_CheckDemoStatus (); - return; - } - cmd->forwardmove = ((signed char)*demo_p++); - cmd->sidemove = ((signed char)*demo_p++); - cmd->angleturn = ((unsigned char)*demo_p++)<<8; - cmd->buttons = (unsigned char)*demo_p++; -} -void G_WriteDemoTiccmd (ticcmd_t* cmd) -{ - if (gamekeydown['q']) - G_CheckDemoStatus (); - *demo_p++ = cmd->forwardmove; - *demo_p++ = cmd->sidemove; - *demo_p++ = (cmd->angleturn+128)>>8; - *demo_p++ = cmd->buttons; - demo_p -= 4; - if (demo_p > demoend - 16) - { - G_CheckDemoStatus (); - return; - } - G_ReadDemoTiccmd (cmd); -} -void G_RecordDemo (char* name) -{ - int i; - int maxsize; - usergame = false; - strcpy (demoname, name); - strcat (demoname, ".lmp"); - maxsize = 0x20000; - i = M_CheckParm ("-maxdemo"); - if (i && i<myargc-1) - maxsize = atoi(myargv[i+1])*1024; - demobuffer = Z_Malloc (maxsize,PU_STATIC,NULL); - demoend = demobuffer + maxsize; - demorecording = true; -} -void G_BeginRecording (void) -{ - int i; - demo_p = demobuffer; - *demo_p++ = VERSION; - *demo_p++ = gameskill; - *demo_p++ = gameepisode; - *demo_p++ = gamemap; - *demo_p++ = deathmatch; - *demo_p++ = respawnparm; - *demo_p++ = fastparm; - *demo_p++ = nomonsters; - *demo_p++ = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) - *demo_p++ = playeringame[i]; -} -char* defdemoname; -void G_DeferedPlayDemo (char* name) -{ - defdemoname = name; - gameaction = ga_playdemo; -} -void G_DoPlayDemo (void) -{ - skill_t skill; - int i, episode, map; - gameaction = ga_nothing; - demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC); - if ( *demo_p++ != VERSION) - { - fprintf( stderr, "Demo is from a different game version!\n"); - gameaction = ga_nothing; - return; - } - skill = *demo_p++; - episode = *demo_p++; - map = *demo_p++; - deathmatch = *demo_p++; - respawnparm = *demo_p++; - fastparm = *demo_p++; - nomonsters = *demo_p++; - consoleplayer = *demo_p++; - for (i=0 ; i<MAXPLAYERS ; i++) - playeringame[i] = *demo_p++; - if (playeringame[1]) - { - netgame = true; - netdemo = true; - } - precache = false; - G_InitNew (skill, episode, map); - precache = true; - usergame = false; - demoplayback = true; -} -void G_TimeDemo (char* name) -{ - nodrawers = M_CheckParm ("-nodraw"); - noblit = M_CheckParm ("-noblit"); - timingdemo = true; - singletics = true; - defdemoname = name; - gameaction = ga_playdemo; -} -/* -=================== -= -= G_CheckDemoStatus -= -= Called after a death or level completion to allow demos to be cleaned up -= Returns true if a new demo loop action will take place -=================== -*/ -boolean G_CheckDemoStatus (void) -{ - int endtime; - if (timingdemo) - { - endtime = I_GetTime (); - I_Error ("timed %i gametics in %i realtics",gametic - , endtime-starttime); - } - if (demoplayback) - { - if (singledemo) - I_Quit (); - Z_ChangeTag (demobuffer, PU_CACHE); - demoplayback = false; + sprintf(name, "%s%d.dsg", lang[SAVEGAMENAME], savegameslot); + description = savedescription; + save_p = savebuffer = screens[1]+0x4000; + memcpy (save_p, description, SAVESTRINGSIZE); + save_p += SAVESTRINGSIZE; + memset (name2,0,sizeof(name2)); + sprintf (name2,"version %i",VERSION); + memcpy (save_p, name2, VERSIONSIZE); + save_p += VERSIONSIZE; + *save_p++ = gameskill; + *save_p++ = gameepisode; + *save_p++ = gamemap; + for (i=0 ; i<MAXPLAYERS ; i++) + *save_p++ = playeringame[i]; + *save_p++ = leveltime>>16; + *save_p++ = leveltime>>8; + *save_p++ = leveltime; + P_ArchivePlayers(); + P_ArchiveWorld(); + P_ArchiveThinkers(); + P_ArchiveSpecials(); + *save_p++ = 0x1d; + length = save_p - savebuffer; + if (length > SAVEGAMESIZE) I_Error("Savegame buffer overrun"); + M_WriteFile(name, savebuffer, length); + gameaction = ga_nothing; + savedescription[0] = 0; + players[consoleplayer].message = lang[GGSAVED]; + R_FillBackScreen(); +} + +void +G_DeferedInitNew(skill_t skill, int episode, int map) +{ + d_skill = skill; + d_episode = episode; + d_map = map; + gameaction = ga_newgame; +} + +void +G_DoNewGame() +{ + demoplayback = false; netdemo = false; netgame = false; deathmatch = false; @@ -1190,16 +756,186 @@ boolean G_CheckDemoStatus (void) fastparm = false; nomonsters = false; consoleplayer = 0; - D_AdvanceDemo (); - return true; - } - if (demorecording) - { - *demo_p++ = DEMOMARKER; - M_WriteFile (demoname, demobuffer, demo_p - demobuffer); - Z_Free (demobuffer); - demorecording = false; - I_Error ("Demo %s recorded",demoname); - } - return false; -} + G_InitNew (d_skill, d_episode, d_map); + gameaction = ga_nothing; +} + +void +G_InitNew(skill_t skill, int episode, int map) +{ + int i; + + if (paused) { + paused = false; + S_ResumeSound(); + } + if (skill > sk_nightmare) + skill = sk_nightmare; + episode = 1; + if (map < 1) map = 1; + if (map > 9) map = 9; + M_ClearRandom(); + if (skill == sk_nightmare || respawnparm) + respawnmonsters = true; + else respawnmonsters = false; + if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare)) { + for (i = S_SARG_RUN1; i <= S_SARG_PAIN2; ++i) states[i].tics >>= 1; + mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; + mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; + mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; + } + if (skill != sk_nightmare && gameskill == sk_nightmare) { + for (i = S_SARG_RUN1; i <= S_SARG_PAIN2; ++i) states[i].tics <<= 1; + mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; + mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; + mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; + } + for (i = 0; i < MAXPLAYERS; ++i) players[i].playerstate = PST_REBORN; + usergame = true; + paused = false; + demoplayback = false; + automapactive = false; + viewactive = true; + gameepisode = episode; + gamemap = map; + gameskill = skill; + viewactive = true; + switch(episode) { + case 1: + skytexture = R_TextureNumForName("SKY1"); + break; + case 2: + skytexture = R_TextureNumForName("SKY2"); + break; + case 3: + skytexture = R_TextureNumForName("SKY3"); + break; + case 4: + skytexture = R_TextureNumForName("SKY4"); + break; + } + G_DoLoadLevel(); +} + +void +G_ReadDemoTiccmd(ticcmd_t* cmd) +{ + if (*demo_p == DEMOMARKER) { + G_CheckDemoStatus(); + return; + } + cmd->forwardmove = ((signed char)*demo_p++); + cmd->sidemove = ((signed char)*demo_p++); + cmd->angleturn = ((unsigned char)*demo_p++)<<8; + cmd->buttons = (unsigned char)*demo_p++; +} + +void +G_WriteDemoTiccmd(ticcmd_t* cmd) +{ + if (gamekeydown['q']) G_CheckDemoStatus(); + *demo_p++ = cmd->forwardmove; + *demo_p++ = cmd->sidemove; + *demo_p++ = (cmd->angleturn+128)>>8; + *demo_p++ = cmd->buttons; + demo_p -= 4; + if (demo_p > demoend - 16) { + G_CheckDemoStatus(); + return; + } + G_ReadDemoTiccmd(cmd); +} + +void +G_BeginRecording() +{ + int i; + + demo_p = demobuffer; + *demo_p++ = VERSION; + *demo_p++ = gameskill; + *demo_p++ = gameepisode; + *demo_p++ = gamemap; + *demo_p++ = deathmatch; + *demo_p++ = respawnparm; + *demo_p++ = fastparm; + *demo_p++ = nomonsters; + *demo_p++ = consoleplayer; + for (i = 0; i < MAXPLAYERS; ++i) + *demo_p++ = playeringame[i]; +} + +void +G_DeferedPlayDemo(char* name) +{ + defdemoname = name; + gameaction = ga_playdemo; +} + +void +G_DoPlayDemo() +{ + skill_t skill; + int i, episode, map; + + gameaction = ga_nothing; + demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC); + if (*demo_p++ != VERSION) { + fprintf( stderr, "Demo is from a different game version!\n"); + gameaction = ga_nothing; + return; + } + + skill = *demo_p++; + episode = *demo_p++; + map = *demo_p++; + deathmatch = *demo_p++; + respawnparm = *demo_p++; + fastparm = *demo_p++; + nomonsters = *demo_p++; + consoleplayer = *demo_p++; + for (i = 0; i < MAXPLAYERS; ++i) playeringame[i] = *demo_p++; + if (playeringame[1]) { + netgame = true; + netdemo = true; + } + precache = false; + G_InitNew(skill, episode, map); + precache = true; + usergame = false; + demoplayback = true; +} + +boolean +G_CheckDemoStatus() +{ + int endtime; + + if (timingdemo) { + endtime = I_GetTime(); + I_Error("timed %i gametics in %i realtics", gametic , endtime-starttime); + } + if (demoplayback) { + if (singledemo) I_Quit (); + Z_ChangeTag(demobuffer, PU_CACHE); + demoplayback = false; + netdemo = false; + netgame = false; + deathmatch = false; + playeringame[1] = playeringame[2] = playeringame[3] = 0; + respawnparm = false; + fastparm = false; + nomonsters = false; + consoleplayer = 0; + D_AdvanceDemo(); + return true; + } + if (demorecording) { + *demo_p++ = DEMOMARKER; + M_WriteFile(demoname, demobuffer, demo_p - demobuffer); + Z_Free(demobuffer); + demorecording = false; + I_Error("Demo %s recorded",demoname); + } + return false; +} diff --git a/src/g_game.h b/src/g_game.h @@ -1,23 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __G_GAME__ #define __G_GAME__ + #include "doomdef.h" #include "d_event.h" + + + + + + void G_DeathMatchSpawnPlayer (int playernum); + void G_InitNew (skill_t skill, int episode, int map); + + + + void G_DeferedInitNew (skill_t skill, int episode, int map); + void G_DeferedPlayDemo (char* demo); + + + void G_LoadGame (char* name); + void G_DoLoadGame (void); + + void G_SaveGame (int slot, char* description); + + void G_RecordDemo (char* name); + void G_BeginRecording (void); + void G_PlayDemo (char* name); void G_TimeDemo (char* name); boolean G_CheckDemoStatus (void); + void G_ExitLevel (void); void G_SecretExitLevel (void); + void G_WorldDone (void); + void G_Ticker (void); boolean G_Responder (event_t* ev); + void G_ScreenShot (void); + + #endif + + + + + diff --git a/src/hu_lib.c b/src/hu_lib.c @@ -1,21 +1,28 @@ #include <ctype.h> + #include "doomdef.h" + #include "v_video.h" -#include "m_swap.h" #include "hu_lib.h" #include "r_local.h" #include "r_draw.h" + + #define noterased viewwindowx + extern boolean automapactive; + void HUlib_init(void) { } + void HUlib_clearTextLine(hu_textline_t* t) { t->len = 0; t->l[0] = 0; t->needsupdate = true; } + void HUlib_initTextLine ( hu_textline_t* t, @@ -30,11 +37,13 @@ HUlib_initTextLine t->sc = sc; HUlib_clearTextLine(t); } + boolean HUlib_addCharToTextLine ( hu_textline_t* t, char ch ) { + if (t->len == HU_MAXLINELENGTH) return false; else @@ -44,9 +53,12 @@ HUlib_addCharToTextLine t->needsupdate = 4; return true; } + } + boolean HUlib_delCharFromTextLine(hu_textline_t* t) { + if (!t->len) return false; else { @@ -54,16 +66,21 @@ boolean HUlib_delCharFromTextLine(hu_textline_t* t) t->needsupdate = 4; return true; } + } + void HUlib_drawTextLine ( hu_textline_t* l, boolean drawcursor ) { + int i; int w; int x; unsigned char c; + + x = l->x; for (i=0;i<l->len;i++) { @@ -72,10 +89,10 @@ HUlib_drawTextLine && c >= l->sc && c <= '_') { - w = SHORT(l->f[c - l->sc]->width); + w = l->f[c - l->sc]->width; if (x+w > SCREENWIDTH) break; - V_DrawPatchDirect(x, l->y, FG, l->f[c - l->sc]); + V_DrawPatch(x, l->y, FG, l->f[c - l->sc]); x += w; } else @@ -85,21 +102,31 @@ HUlib_drawTextLine break; } } + + if (drawcursor - && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) + && x + l->f['_' - l->sc]->width <= SCREENWIDTH) { - V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]); + V_DrawPatch(x, l->y, FG, l->f['_' - l->sc]); } } + + + void HUlib_eraseTextLine(hu_textline_t* l) { int lh; int y; int yoffset; + + + + + if (!automapactive && viewwindowx && l->needsupdate) { - lh = SHORT(l->f[0]->height) + 1; + lh = l->f[0]->height + 1; for (y=l->y,yoffset=y*SCREENWIDTH ; y<l->y+lh ; y++,yoffset+=SCREENWIDTH) { if (y < viewwindowy || y >= viewwindowy + viewheight) @@ -108,11 +135,15 @@ void HUlib_eraseTextLine(hu_textline_t* l) { R_VideoErase(yoffset, viewwindowx); R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); + } } } + if (l->needsupdate) l->needsupdate--; + } + void HUlib_initSText ( hu_stext_t* s, @@ -123,25 +154,34 @@ HUlib_initSText int startchar, boolean* on ) { + int i; + s->h = h; s->on = on; s->laston = true; s->cl = 0; for (i=0;i<h;i++) - HUlib_initTextLine(&s->l[i], - x, y - i*(SHORT(font[0]->height)+1), - font, startchar); + HUlib_initTextLine(&s->l[i], x, y - i*(font[0]->height+1), font, startchar); + } + void HUlib_addLineToSText(hu_stext_t* s) { + int i; + + if (++s->cl == s->h) s->cl = 0; HUlib_clearTextLine(&s->l[s->cl]); + + for (i=0 ; i<s->h ; i++) s->l[i].needsupdate = 4; + } + void HUlib_addMessageToSText ( hu_stext_t* s, @@ -152,27 +192,39 @@ HUlib_addMessageToSText if (prefix) while (*prefix) HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++)); + while (*msg) HUlib_addCharToTextLine(&s->l[s->cl], *(msg++)); } + void HUlib_drawSText(hu_stext_t* s) { int i, idx; hu_textline_t *l; + if (!*s->on) return; + + for (i=0 ; i<s->h ; i++) { idx = s->cl - i; if (idx < 0) idx += s->h; + l = &s->l[idx]; + + HUlib_drawTextLine(l, false); } + } + void HUlib_eraseSText(hu_stext_t* s) { + int i; + for (i=0 ; i<s->h ; i++) { if (s->laston && !*s->on) @@ -180,36 +232,39 @@ void HUlib_eraseSText(hu_stext_t* s) HUlib_eraseTextLine(&s->l[i]); } s->laston = *s->on; + } + void -HUlib_initIText -( hu_itext_t* it, - int x, - int y, - patch_t** font, - int startchar, - boolean* on ) +HUlib_initIText(hu_itext_t* it, int x, int y, patch_t** font, int startchar, boolean* on) { it->lm = 0; it->on = on; it->laston = true; HUlib_initTextLine(&it->l, x, y, font, startchar); } + + + void HUlib_delCharFromIText(hu_itext_t* it) { if (it->l.len != it->lm) HUlib_delCharFromTextLine(&it->l); } + void HUlib_eraseLineFromIText(hu_itext_t* it) { while (it->lm != it->l.len) HUlib_delCharFromTextLine(&it->l); } + + void HUlib_resetIText(hu_itext_t* it) { it->lm = 0; HUlib_clearTextLine(&it->l); } + void HUlib_addPrefixToIText ( hu_itext_t* it, @@ -219,11 +274,15 @@ HUlib_addPrefixToIText HUlib_addCharToTextLine(&it->l, *(str++)); it->lm = it->l.len; } + + + boolean HUlib_keyInIText ( hu_itext_t* it, unsigned char ch ) { + if (ch >= ' ' && ch <= '_') HUlib_addCharToTextLine(&it->l, (char) ch); else @@ -232,15 +291,22 @@ HUlib_keyInIText else if (ch != KEY_ENTER) return false; + return true; + } + void HUlib_drawIText(hu_itext_t* it) { + hu_textline_t *l = &it->l; + if (!*it->on) return; HUlib_drawTextLine(l, true); + } + void HUlib_eraseIText(hu_itext_t* it) { if (it->laston && !*it->on) @@ -248,3 +314,4 @@ void HUlib_eraseIText(hu_itext_t* it) HUlib_eraseTextLine(&it->l); it->laston = *it->on; } + diff --git a/src/hu_lib.h b/src/hu_lib.h @@ -1,79 +1,58 @@ #ifndef __HULIB__ #define __HULIB__ + #include "r_defs.h" + #define BG 1 #define FG 0 #define HU_CHARERASE KEY_BACKSPACE #define HU_MAXLINES 4 #define HU_MAXLINELENGTH 80 -typedef struct -{ - int x; - int y; - patch_t** f; - int sc; - char l[HU_MAXLINELENGTH+1]; - int len; + +typedef struct { + int x; + int y; + patch_t** f; + int sc; + char l[HU_MAXLINELENGTH+1]; + int len; int needsupdate; } hu_textline_t; -typedef struct -{ - hu_textline_t l[HU_MAXLINES]; - int h; - int cl; - boolean* on; - boolean laston; + +typedef struct { + hu_textline_t l[HU_MAXLINES]; + int h; + int cl; + boolean* on; + boolean laston; } hu_stext_t; -typedef struct -{ - hu_textline_t l; - int lm; - boolean* on; - boolean laston; + +typedef struct { + hu_textline_t l; + int lm; + boolean* on; + boolean laston; } hu_itext_t; + void HUlib_init(void); -void HUlib_clearTextLine(hu_textline_t *t); -void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); +void HUlib_clearTextLine(hu_textline_t *t); +void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); boolean HUlib_delCharFromTextLine(hu_textline_t *t); -void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); -void HUlib_eraseTextLine(hu_textline_t *l); -void -HUlib_initSText -( hu_stext_t* s, - int x, - int y, - int h, - patch_t** font, - int startchar, - boolean* on ); +void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); +void HUlib_eraseTextLine(hu_textline_t *l); +void HUlib_initSText(hu_stext_t* s, int x, int y, int h, patch_t** font, int startchar, boolean* on); void HUlib_addLineToSText(hu_stext_t* s); -void -HUlib_addMessageToSText -( hu_stext_t* s, - char* prefix, - char* msg ); +void HUlib_addMessageToSText(hu_stext_t* s, char* prefix, char* msg); void HUlib_drawSText(hu_stext_t* s); void HUlib_eraseSText(hu_stext_t* s); -void -HUlib_initIText -( hu_itext_t* it, - int x, - int y, - patch_t** font, - int startchar, - boolean* on ); +void HUlib_initIText(hu_itext_t* it, int x, int y, patch_t** font, int startchar, boolean* on); void HUlib_delCharFromIText(hu_itext_t* it); void HUlib_eraseLineFromIText(hu_itext_t* it); void HUlib_resetIText(hu_itext_t* it); -void -HUlib_addPrefixToIText -( hu_itext_t* it, - char* str ); -boolean -HUlib_keyInIText -( hu_itext_t* it, - unsigned char ch ); +void HUlib_addPrefixToIText(hu_itext_t* it, char* str); +boolean HUlib_keyInIText(hu_itext_t* it, unsigned char ch); void HUlib_drawIText(hu_itext_t* it); void HUlib_eraseIText(hu_itext_t* it); + #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c @@ -1,7 +1,7 @@ #include <ctype.h> + #include "doomdef.h" #include "z_zone.h" -#include "m_swap.h" #include "hu_stuff.h" #include "hu_lib.h" #include "w_wad.h" @@ -9,39 +9,42 @@ #include "doomstat.h" #include "dstrings.h" #include "sounds.h" -#define HU_TITLE (mapnames[(gameepisode-1)*9+gamemap-1]) -#define HU_TITLE2 (mapnames2[gamemap-1]) -#define HU_TITLEP (mapnamesp[gamemap-1]) -#define HU_TITLET (mapnamest[gamemap-1]) + +#define HU_TITLE (lang[mapnames[(gameepisode-1)*9+gamemap-1]]) +#define HU_TITLE2 (lang[mapnames2[gamemap-1]]) +#define HU_TITLEP (lang[mapnamesp[gamemap-1]]) +#define HU_TITLET (lang[mapnamest[gamemap-1]]) #define HU_TITLEHEIGHT 1 #define HU_TITLEX 0 -#define HU_TITLEY (167 - SHORT(hu_font[0]->height)) +#define HU_TITLEY (167 - hu_font[0]->height) #define HU_INPUTTOGGLE 't' -#define HU_INPUTX HU_MSGX -#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(hu_font[0]->height) +1)) +#define HU_INPUTX HU_MSGX +#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(hu_font[0]->height) +1) #define HU_INPUTWIDTH 64 #define HU_INPUTHEIGHT 1 -char* chat_macros[] = -{ - HUSTR_CHATMACRO0, - HUSTR_CHATMACRO1, - HUSTR_CHATMACRO2, - HUSTR_CHATMACRO3, - HUSTR_CHATMACRO4, - HUSTR_CHATMACRO5, - HUSTR_CHATMACRO6, - HUSTR_CHATMACRO7, - HUSTR_CHATMACRO8, - HUSTR_CHATMACRO9 +#define QUEUESIZE 128 + +int chat_macros[] = { + HUSTR_CHATMACRO0, + HUSTR_CHATMACRO1, + HUSTR_CHATMACRO2, + HUSTR_CHATMACRO3, + HUSTR_CHATMACRO4, + HUSTR_CHATMACRO5, + HUSTR_CHATMACRO6, + HUSTR_CHATMACRO7, + HUSTR_CHATMACRO8, + HUSTR_CHATMACRO9 }; -char* player_names[] = -{ - HUSTR_PLRGREEN, - HUSTR_PLRINDIGO, - HUSTR_PLRBROWN, - HUSTR_PLRRED + +int player_names[] = { + HUSTR_PLRGREEN, + HUSTR_PLRINDIGO, + HUSTR_PLRBROWN, + HUSTR_PLRRED }; -char chat_char; + +char chat_char; static player_t* plr; patch_t* hu_font[HU_FONTSIZE]; static hu_textline_t w_title; @@ -58,552 +61,487 @@ static int message_counter; extern int showMessages; extern boolean automapactive; static boolean headsupactive = false; -char* mapnames[] = -{ - HUSTR_E1M1, - HUSTR_E1M2, - HUSTR_E1M3, - HUSTR_E1M4, - HUSTR_E1M5, - HUSTR_E1M6, - HUSTR_E1M7, - HUSTR_E1M8, - HUSTR_E1M9, - HUSTR_E2M1, - HUSTR_E2M2, - HUSTR_E2M3, - HUSTR_E2M4, - HUSTR_E2M5, - HUSTR_E2M6, - HUSTR_E2M7, - HUSTR_E2M8, - HUSTR_E2M9, - HUSTR_E3M1, - HUSTR_E3M2, - HUSTR_E3M3, - HUSTR_E3M4, - HUSTR_E3M5, - HUSTR_E3M6, - HUSTR_E3M7, - HUSTR_E3M8, - HUSTR_E3M9, - HUSTR_E4M1, - HUSTR_E4M2, - HUSTR_E4M3, - HUSTR_E4M4, - HUSTR_E4M5, - HUSTR_E4M6, - HUSTR_E4M7, - HUSTR_E4M8, - HUSTR_E4M9, - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL", - "NEWLEVEL" +static char chatchars[QUEUESIZE]; +static int head = 0; +static int tail = 0; + + +int mapnames[] = { + HUSTR_E1M1, + HUSTR_E1M2, + HUSTR_E1M3, + HUSTR_E1M4, + HUSTR_E1M5, + HUSTR_E1M6, + HUSTR_E1M7, + HUSTR_E1M8, + HUSTR_E1M9, + HUSTR_E2M1, + HUSTR_E2M2, + HUSTR_E2M3, + HUSTR_E2M4, + HUSTR_E2M5, + HUSTR_E2M6, + HUSTR_E2M7, + HUSTR_E2M8, + HUSTR_E2M9, + HUSTR_E3M1, + HUSTR_E3M2, + HUSTR_E3M3, + HUSTR_E3M4, + HUSTR_E3M5, + HUSTR_E3M6, + HUSTR_E3M7, + HUSTR_E3M8, + HUSTR_E3M9, + HUSTR_E4M1, + HUSTR_E4M2, + HUSTR_E4M3, + HUSTR_E4M4, + HUSTR_E4M5, + HUSTR_E4M6, + HUSTR_E4M7, + HUSTR_E4M8, + HUSTR_E4M9, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL, + NEWLEVEL }; -char* mapnames2[] = -{ - HUSTR_1, - HUSTR_2, - HUSTR_3, - HUSTR_4, - HUSTR_5, - HUSTR_6, - HUSTR_7, - HUSTR_8, - HUSTR_9, - HUSTR_10, - HUSTR_11, - HUSTR_12, - HUSTR_13, - HUSTR_14, - HUSTR_15, - HUSTR_16, - HUSTR_17, - HUSTR_18, - HUSTR_19, - HUSTR_20, - HUSTR_21, - HUSTR_22, - HUSTR_23, - HUSTR_24, - HUSTR_25, - HUSTR_26, - HUSTR_27, - HUSTR_28, - HUSTR_29, - HUSTR_30, - HUSTR_31, - HUSTR_32 + +int mapnames2[] = { + HUSTR_1, + HUSTR_2, + HUSTR_3, + HUSTR_4, + HUSTR_5, + HUSTR_6, + HUSTR_7, + HUSTR_8, + HUSTR_9, + HUSTR_10, + HUSTR_11, + HUSTR_12, + HUSTR_13, + HUSTR_14, + HUSTR_15, + HUSTR_16, + HUSTR_17, + HUSTR_18, + HUSTR_19, + HUSTR_20, + HUSTR_21, + HUSTR_22, + HUSTR_23, + HUSTR_24, + HUSTR_25, + HUSTR_26, + HUSTR_27, + HUSTR_28, + HUSTR_29, + HUSTR_30, + HUSTR_31, + HUSTR_32 }; -char* mapnamesp[] = -{ - PHUSTR_1, - PHUSTR_2, - PHUSTR_3, - PHUSTR_4, - PHUSTR_5, - PHUSTR_6, - PHUSTR_7, - PHUSTR_8, - PHUSTR_9, - PHUSTR_10, - PHUSTR_11, - PHUSTR_12, - PHUSTR_13, - PHUSTR_14, - PHUSTR_15, - PHUSTR_16, - PHUSTR_17, - PHUSTR_18, - PHUSTR_19, - PHUSTR_20, - PHUSTR_21, - PHUSTR_22, - PHUSTR_23, - PHUSTR_24, - PHUSTR_25, - PHUSTR_26, - PHUSTR_27, - PHUSTR_28, - PHUSTR_29, - PHUSTR_30, - PHUSTR_31, - PHUSTR_32 + +int mapnamesp[] = { + PHUSTR_1, + PHUSTR_2, + PHUSTR_3, + PHUSTR_4, + PHUSTR_5, + PHUSTR_6, + PHUSTR_7, + PHUSTR_8, + PHUSTR_9, + PHUSTR_10, + PHUSTR_11, + PHUSTR_12, + PHUSTR_13, + PHUSTR_14, + PHUSTR_15, + PHUSTR_16, + PHUSTR_17, + PHUSTR_18, + PHUSTR_19, + PHUSTR_20, + PHUSTR_21, + PHUSTR_22, + PHUSTR_23, + PHUSTR_24, + PHUSTR_25, + PHUSTR_26, + PHUSTR_27, + PHUSTR_28, + PHUSTR_29, + PHUSTR_30, + PHUSTR_31, + PHUSTR_32 }; -char *mapnamest[] = -{ - THUSTR_1, - THUSTR_2, - THUSTR_3, - THUSTR_4, - THUSTR_5, - THUSTR_6, - THUSTR_7, - THUSTR_8, - THUSTR_9, - THUSTR_10, - THUSTR_11, - THUSTR_12, - THUSTR_13, - THUSTR_14, - THUSTR_15, - THUSTR_16, - THUSTR_17, - THUSTR_18, - THUSTR_19, - THUSTR_20, - THUSTR_21, - THUSTR_22, - THUSTR_23, - THUSTR_24, - THUSTR_25, - THUSTR_26, - THUSTR_27, - THUSTR_28, - THUSTR_29, - THUSTR_30, - THUSTR_31, - THUSTR_32 + +int mapnamest[] = { + THUSTR_1, + THUSTR_2, + THUSTR_3, + THUSTR_4, + THUSTR_5, + THUSTR_6, + THUSTR_7, + THUSTR_8, + THUSTR_9, + THUSTR_10, + THUSTR_11, + THUSTR_12, + THUSTR_13, + THUSTR_14, + THUSTR_15, + THUSTR_16, + THUSTR_17, + THUSTR_18, + THUSTR_19, + THUSTR_20, + THUSTR_21, + THUSTR_22, + THUSTR_23, + THUSTR_24, + THUSTR_25, + THUSTR_26, + THUSTR_27, + THUSTR_28, + THUSTR_29, + THUSTR_30, + THUSTR_31, + THUSTR_32 }; + const char* shiftxform; -const char french_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', '"', '#', '$', '%', '&', - '"', - '(', ')', '*', '+', - '?', - '_', - '>', - '?', - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '/', - '.', - '<', - '+', - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', - '!', - ']', - '"', '_', - '\'', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 +const char french_shiftxform[] = { + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', '"', '#', '$', '%', '&', + '"', + '(', ')', '*', '+', + '?', + '_', + '>', + '?', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '/', + '.', + '<', + '+', + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', + '!', + ']', + '"', '_', + '\'', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 + }; -const char english_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', '"', '#', '$', '%', '&', - '"', - '(', ')', '*', '+', - '<', - '_', - '>', - '?', - ')', - '!', - '@', - '#', - '$', - '%', - '^', - '&', - '*', - '(', - ':', - ':', - '<', - '+', - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', - '!', - ']', - '"', '_', - '\'', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 + +const char english_shiftxform[] = { + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', '"', '#', '$', '%', '&', + '"', + '(', ')', '*', '+', + '<', + '_', + '>', + '?', + ')', + '!', + '@', + '#', + '$', + '%', + '^', + '&', + '*', + '(', + ':', + ':', + '<', + '+', + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', + '!', + ']', + '"', '_', + '\'', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 }; -char frenchKeyMap[128]= -{ - 0, - 1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30, - 31, - ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!', - '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?', - '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', - 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_', - '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', - 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127 + +char frenchKeyMap[128] = { + 0, + 1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30, + 31, + ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!', + '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?', + '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', + 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_', + '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', + 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127 }; + char ForeignTranslation(unsigned char ch) { - return ch < 128 ? frenchKeyMap[ch] : ch; + return ch < 128 ? frenchKeyMap[ch] : ch; } -void HU_Init(void) + +void +HU_Init() { - int i; - int j; - char buffer[9]; - if (french) - shiftxform = french_shiftxform; - else + + int i, j; + char buffer[9]; + shiftxform = english_shiftxform; - j = HU_FONTSTART; - for (i=0;i<HU_FONTSIZE;i++) - { - sprintf(buffer, "STCFN%.3d", j++); - hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC); - } + j = HU_FONTSTART; + for (i = 0; i < HU_FONTSIZE; ++i) { + sprintf(buffer, "STCFN%.3d", j++); + hu_font[i] = (patch_t*)W_CacheLumpName(buffer, PU_STATIC); + } } -void HU_Stop(void) + +void +HU_Stop() { - headsupactive = false; + headsupactive = false; } -void HU_Start(void) + +void +HU_Start() { - int i; - char* s; - if (headsupactive) - HU_Stop(); - plr = &players[consoleplayer]; - message_on = false; - message_dontfuckwithme = false; - message_nottobefuckedwith = false; - chat_on = false; - HUlib_initSText(&w_message, - HU_MSGX, HU_MSGY, HU_MSGHEIGHT, - hu_font, - HU_FONTSTART, &message_on); - HUlib_initTextLine(&w_title, - HU_TITLEX, HU_TITLEY, - hu_font, - HU_FONTSTART); - switch ( gamemode ) - { - case shareware: - case registered: - case retail: + char* s; + int i; + + if (headsupactive) + HU_Stop(); + plr = &players[consoleplayer]; + message_on = false; + message_dontfuckwithme = false; + message_nottobefuckedwith = false; + chat_on = false; + HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, hu_font, HU_FONTSTART, &message_on); + HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, hu_font, HU_FONTSTART); s = HU_TITLE; - break; -/* FIXME - case pack_plut: - s = HU_TITLEP; - break; - case pack_tnt: - s = HU_TITLET; - break; -*/ - case commercial: - default: - s = HU_TITLE2; - break; - } - while (*s) - HUlib_addCharToTextLine(&w_title, *(s++)); - HUlib_initIText(&w_chat, - HU_INPUTX, HU_INPUTY, - hu_font, - HU_FONTSTART, &chat_on); - for (i=0 ; i<MAXPLAYERS ; i++) - HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, &always_off); - headsupactive = true; + while (*s) + HUlib_addCharToTextLine(&w_title, *(s++)); + HUlib_initIText(&w_chat, HU_INPUTX, HU_INPUTY, hu_font, HU_FONTSTART, &chat_on); + for (i = 0; i < MAXPLAYERS; ++i) + HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, &always_off); + headsupactive = true; } -void HU_Drawer(void) + +void +HU_Drawer() { - HUlib_drawSText(&w_message); - HUlib_drawIText(&w_chat); - if (automapactive) - HUlib_drawTextLine(&w_title, false); + HUlib_drawSText(&w_message); + HUlib_drawIText(&w_chat); + if (automapactive) + HUlib_drawTextLine(&w_title, false); } -void HU_Erase(void) + +void +HU_Erase() { - HUlib_eraseSText(&w_message); - HUlib_eraseIText(&w_chat); - HUlib_eraseTextLine(&w_title); + HUlib_eraseSText(&w_message); + HUlib_eraseIText(&w_chat); + HUlib_eraseTextLine(&w_title); } -void HU_Ticker(void) + +void +HU_Ticker() { - int i, rc; - char c; - if (message_counter && !--message_counter) - { - message_on = false; - message_nottobefuckedwith = false; - } - if (showMessages || message_dontfuckwithme) - { - if ((plr->message && !message_nottobefuckedwith) - || (plr->message && message_dontfuckwithme)) - { - HUlib_addMessageToSText(&w_message, 0, plr->message); - plr->message = 0; - message_on = true; - message_counter = HU_MSGTIMEOUT; - message_nottobefuckedwith = message_dontfuckwithme; - message_dontfuckwithme = 0; + int i, rc; + char c; + + if (message_counter && !--message_counter) { + message_on = false; + message_nottobefuckedwith = false; } - } - if (netgame) - { - for (i=0 ; i<MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - if (i != consoleplayer - && (c = players[i].cmd.chatchar)) - { - if (c <= HU_BROADCAST) - chat_dest[i] = c; - else - { - if (c >= 'a' && c <= 'z') - c = (char) shiftxform[(unsigned char) c]; - rc = HUlib_keyInIText(&w_inputbuffer[i], c); - if (rc && c == KEY_ENTER) - { - if (w_inputbuffer[i].l.len - && (chat_dest[i] == consoleplayer+1 - || chat_dest[i] == HU_BROADCAST)) - { - HUlib_addMessageToSText(&w_message, - player_names[i], - w_inputbuffer[i].l.l); - message_nottobefuckedwith = true; - message_on = true; - message_counter = HU_MSGTIMEOUT; - if ( gamemode == commercial ) - S_StartSound(0, sfx_radio); - else - S_StartSound(0, sfx_tink); + if (showMessages || message_dontfuckwithme) { + if ((plr->message && !message_nottobefuckedwith) || (plr->message && message_dontfuckwithme)) { + HUlib_addMessageToSText(&w_message, 0, plr->message); + plr->message = 0; + message_on = true; + message_counter = HU_MSGTIMEOUT; + message_nottobefuckedwith = message_dontfuckwithme; + message_dontfuckwithme = 0; + } + } + if (netgame) { + for (i = 0 ; i < MAXPLAYERS; ++i) { + if (!playeringame[i]) continue; + if (i != consoleplayer && (c = players[i].cmd.chatchar)) { + if (c <= HU_BROADCAST) + chat_dest[i] = c; + else { + if (c >= 'a' && c <= 'z') + c = (char) shiftxform[(unsigned char) c]; + rc = HUlib_keyInIText(&w_inputbuffer[i], c); + if (rc && c == KEY_ENTER) { + if (w_inputbuffer[i].l.len && (chat_dest[i] == consoleplayer+1 || chat_dest[i] == HU_BROADCAST)) { + HUlib_addMessageToSText(&w_message, lang[player_names[i]], w_inputbuffer[i].l.l); + message_nottobefuckedwith = true; + message_on = true; + message_counter = HU_MSGTIMEOUT; + S_StartSound(0, sfx_tink); + } + HUlib_resetIText(&w_inputbuffer[i]); + } + } + players[i].cmd.chatchar = 0; } - HUlib_resetIText(&w_inputbuffer[i]); - } } - players[i].cmd.chatchar = 0; - } } - } } -#define QUEUESIZE 128 -static char chatchars[QUEUESIZE]; -static int head = 0; -static int tail = 0; -void HU_queueChatChar(char c) + + +void +HU_queueChatChar(char c) { - if (((head + 1) & (QUEUESIZE-1)) == tail) - { - plr->message = HUSTR_MSGU; - } - else - { - chatchars[head] = c; - head = (head + 1) & (QUEUESIZE-1); - } + if (((head + 1) & (QUEUESIZE-1)) == tail) + plr->message = lang[HUSTR_MSGU]; + else { + chatchars[head] = c; + head = (head + 1) & (QUEUESIZE-1); + } } -char HU_dequeueChatChar(void) + +char +HU_dequeueChatChar() { - char c; - if (head != tail) - { - c = chatchars[tail]; - tail = (tail + 1) & (QUEUESIZE-1); - } - else - { - c = 0; - } - return c; + char c; + + if (head != tail) { + c = chatchars[tail]; + tail = (tail + 1) & (QUEUESIZE-1); + } else c = 0; + return c; } -boolean HU_Responder(event_t *ev) + +boolean +HU_Responder(event_t *ev) { - static char lastmessage[HU_MAXLINELENGTH+1]; - char* macromessage; - boolean eatkey = false; - static boolean shiftdown = false; - static boolean altdown = false; - unsigned char c; - int i; - int numplayers; - static char destination_keys[MAXPLAYERS] = - { - HUSTR_KEYGREEN, - HUSTR_KEYINDIGO, - HUSTR_KEYBROWN, - HUSTR_KEYRED - }; - static int num_nobrainers = 0; - numplayers = 0; - for (i=0 ; i<MAXPLAYERS ; i++) - numplayers += playeringame[i]; - if (ev->data1 == KEY_RSHIFT) - { - shiftdown = ev->type == ev_keydown; - return false; - } - else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) - { - altdown = ev->type == ev_keydown; - return false; - } - if (ev->type != ev_keydown) - return false; - if (!chat_on) - { - if (ev->data1 == HU_MSGREFRESH) - { - message_on = true; - message_counter = HU_MSGTIMEOUT; - eatkey = true; + static char lastmessage[HU_MAXLINELENGTH+1]; + static boolean shiftdown = false; + static boolean altdown = false; + static int num_nobrainers = 0; + static char destination_keys[MAXPLAYERS] = { 'g', 'i', 'b', 'r' } ; + char* macromessage; + boolean eatkey; + unsigned char c; + int i, numplayers; + + eatkey = false; + numplayers = 0; + for (i = 0; i < MAXPLAYERS; ++i) + numplayers += playeringame[i]; + if (ev->data1 == KEY_RSHIFT) { + shiftdown = ev->type == ev_keydown; + return false; } - else if (netgame && ev->data1 == HU_INPUTTOGGLE) - { - eatkey = chat_on = true; - HUlib_resetIText(&w_chat); - HU_queueChatChar(HU_BROADCAST); + if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) { + altdown = ev->type == ev_keydown; + return false; } - else if (netgame && numplayers > 2) - { - for (i=0; i<MAXPLAYERS ; i++) - { - if (ev->data1 == destination_keys[i]) - { - if (playeringame[i] && i!=consoleplayer) - { + if (ev->type != ev_keydown) + return false; + if (!chat_on) { + if (ev->data1 == HU_MSGREFRESH) { + message_on = true; + message_counter = HU_MSGTIMEOUT; + eatkey = true; + } + if (netgame && ev->data1 == HU_INPUTTOGGLE) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); - HU_queueChatChar(i+1); - break; - } - else if (i == consoleplayer) - { - num_nobrainers++; - if (num_nobrainers < 3) - plr->message = HUSTR_TALKTOSELF1; - else if (num_nobrainers < 6) - plr->message = HUSTR_TALKTOSELF2; - else if (num_nobrainers < 9) - plr->message = HUSTR_TALKTOSELF3; - else if (num_nobrainers < 32) - plr->message = HUSTR_TALKTOSELF4; - else - plr->message = HUSTR_TALKTOSELF5; - } + HU_queueChatChar(HU_BROADCAST); } - } - } - } - else - { - c = ev->data1; - if (altdown) - { - c = c - '0'; - if (c > 9) - return false; - macromessage = chat_macros[c]; - HU_queueChatChar(KEY_ENTER); - while (*macromessage) - HU_queueChatChar(*macromessage++); - HU_queueChatChar(KEY_ENTER); - chat_on = false; - strcpy(lastmessage, chat_macros[c]); - plr->message = lastmessage; - eatkey = true; - } - else - { - if (french) - c = ForeignTranslation(c); - if (shiftdown || (c >= 'a' && c <= 'z')) - c = shiftxform[c]; - eatkey = HUlib_keyInIText(&w_chat, c); - if (eatkey) - { - HU_queueChatChar(c); - } - if (c == KEY_ENTER) - { - chat_on = false; - if (w_chat.l.len) - { - strcpy(lastmessage, w_chat.l.l); - plr->message = lastmessage; + if (netgame && numplayers > 2) { + for (i = 0; i < MAXPLAYERS; ++i) { + if (ev->data1 == destination_keys[i]) { + if (playeringame[i] && i!=consoleplayer) { + eatkey = chat_on = true; + HUlib_resetIText(&w_chat); + HU_queueChatChar(i+1); + break; + } + if (i == consoleplayer) { + ++num_nobrainers; + if (num_nobrainers < 3) plr->message = lang[HUSTR_TALKTOSELF1]; + else if (num_nobrainers < 6) plr->message = lang[HUSTR_TALKTOSELF2]; + else if (num_nobrainers < 9) plr->message = lang[HUSTR_TALKTOSELF3]; + else if (num_nobrainers < 32) plr->message = lang[HUSTR_TALKTOSELF4]; + else plr->message = lang[HUSTR_TALKTOSELF5]; + } + } + } + } + } else { + c = ev->data1; + if (altdown) { + c = c - '0'; + if (c > 9) + return false; + macromessage = lang[chat_macros[c]]; + HU_queueChatChar(KEY_ENTER); + while (*macromessage) + HU_queueChatChar(*macromessage++); + HU_queueChatChar(KEY_ENTER); + chat_on = false; + strcpy(lastmessage, lang[chat_macros[c]]); + plr->message = lastmessage; + eatkey = true; + } else { + if (shiftdown || (c >= 'a' && c <= 'z')) + c = shiftxform[c]; + eatkey = HUlib_keyInIText(&w_chat, c); + if (eatkey) + HU_queueChatChar(c); + if (c == KEY_ENTER) { + chat_on = false; + if (w_chat.l.len) { + strcpy(lastmessage, w_chat.l.l); + plr->message = lastmessage; + } + } + if (c == KEY_ESCAPE) + chat_on = false; } - } - else if (c == KEY_ESCAPE) - chat_on = false; } - } - return eatkey; + return eatkey; } diff --git a/src/hu_stuff.h b/src/hu_stuff.h @@ -1,7 +1,9 @@ #ifndef __HU_STUFF_H__ #define __HU_STUFF_H__ + #include "d_event.h" -#define HU_FONTSTART '!' + +#define HU_FONTSTART '!' #define HU_FONTEND '_' #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) #define HU_BROADCAST 5 @@ -11,6 +13,7 @@ #define HU_MSGWIDTH 64 #define HU_MSGHEIGHT 1 #define HU_MSGTIMEOUT (4*TICRATE) + void HU_Init(void); void HU_Start(void); boolean HU_Responder(event_t* ev); @@ -18,4 +21,5 @@ void HU_Ticker(void); void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); + #endif diff --git a/src/i_main.c b/src/i_main.c @@ -1,13 +1,13 @@ #include "doomdef.h" + #include "m_argv.h" #include "d_main.h" + int -main -( int argc, - char** argv ) +main(int argc, char** argv) { myargc = argc; myargv = argv; - D_DoomMain (); + D_DoomMain(); return 0; } diff --git a/src/i_net.c b/src/i_net.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> + #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -8,41 +9,68 @@ #include <unistd.h> #include <netdb.h> #include <sys/ioctl.h> + #include "i_system.h" #include "d_event.h" #include "d_net.h" #include "m_argv.h" + #include "doomstat.h" -#ifdef __GNUG__ -#pragma implementation "i_net.h" -#endif + #include "i_net.h" + +/* #define ntohl(x) \ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ (((unsigned long int)(x) & 0xff000000U) >> 24))) + #define ntohs(x) \ ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ - (((unsigned short int)(x) & 0xff00) >> 8))) + (((unsigned short int)(x) & 0xff00) >> 8))) \ + #define htonl(x) ntohl(x) #define htons(x) ntohs(x) +*/ + void NetSend (void); boolean NetListen (void); + + + + + + int DOOMPORT = (IPPORT_USERRESERVED +0x1d ); + int sendsocket; int insocket; + struct sockaddr_in sendaddress[MAXNETNODES]; + void (*netget) (void); void (*netsend) (void); + + + + + int UDPsocket (void) { int s; + + s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (s<0) I_Error ("can't create socket: %s",strerror(errno)); + return s; } + + + + void BindToLocalPort ( int s, @@ -50,18 +78,27 @@ BindToLocalPort { int v; struct sockaddr_in address; + memset (&address, 0, sizeof(address)); address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = port; + v = bind (s, (void *)&address, sizeof(address)); if (v == -1) I_Error ("BindToPort: bind: %s", strerror(errno)); } + + + + + void PacketSend (void) { int c; doomdata_t sw; + + sw.checksum = htonl(netbuffer->checksum); sw.player = netbuffer->player; sw.retransmitfrom = netbuffer->retransmitfrom; @@ -76,20 +113,30 @@ void PacketSend (void) sw.cmds[c].chatchar = netbuffer->cmds[c].chatchar; sw.cmds[c].buttons = netbuffer->cmds[c].buttons; } + + c = sendto (sendsocket , &sw, doomcom->datalength ,0,(void *)&sendaddress[doomcom->remotenode] ,sizeof(sendaddress[doomcom->remotenode])); + + + } + + + + + void PacketGet (void) { int i; int c; struct sockaddr_in fromaddress; - socklen_t fromlen; + unsigned int fromlen; doomdata_t sw; - + fromlen = sizeof(fromaddress); - c = recvfrom(insocket, &sw, sizeof(sw), 0 , (struct sockaddr *)&fromaddress, &fromlen ); + c = recvfrom (insocket, &sw, sizeof(sw), 0, (struct sockaddr *)&fromaddress, &fromlen ); if (c == -1 ) { if (errno != EWOULDBLOCK) @@ -97,27 +144,36 @@ void PacketGet (void) doomcom->remotenode = -1; return; } + { static int first=1; if (first) printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1)); first = 0; } + + for (i=0 ; i<doomcom->numnodes ; i++) if ( fromaddress.sin_addr.s_addr == sendaddress[i].sin_addr.s_addr ) break; + if (i == doomcom->numnodes) { + doomcom->remotenode = -1; - return; + return; } + doomcom->remotenode = i; doomcom->datalength = c; + + netbuffer->checksum = ntohl(sw.checksum); netbuffer->player = sw.player; netbuffer->retransmitfrom = sw.retransmitfrom; netbuffer->starttic = sw.starttic; netbuffer->numtics = sw.numtics; + for (c=0 ; c< netbuffer->numtics ; c++) { netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove; @@ -128,27 +184,42 @@ void PacketGet (void) netbuffer->cmds[c].buttons = sw.cmds[c].buttons; } } + + + int GetLocalAddress (void) { char hostname[1024]; struct hostent* hostentry; int v; + + v = gethostname (hostname, sizeof(hostname)); if (v == -1) I_Error ("GetLocalAddress : gethostname: errno %d",errno); + hostentry = gethostbyname (hostname); if (!hostentry) I_Error ("GetLocalAddress : gethostbyname: couldn't get local host"); + return *(int *)hostentry->h_addr_list[0]; } + + + + + void I_InitNetwork (void) { boolean trueval = true; int i; int p; struct hostent* hostentry; + doomcom = malloc (sizeof (*doomcom) ); memset (doomcom, 0, sizeof(*doomcom) ); + + i = M_CheckParm ("-dup"); if (i && i< myargc-1) { @@ -160,19 +231,25 @@ void I_InitNetwork (void) } else doomcom-> ticdup = 1; + if (M_CheckParm ("-extratic")) doomcom-> extratics = 1; else doomcom-> extratics = 0; + p = M_CheckParm ("-port"); if (p && p<myargc-1) { DOOMPORT = atoi (myargv[p+1]); printf ("using alternate port %i\n",DOOMPORT); } + + + i = M_CheckParm ("-net"); if (!i) { + netgame = false; doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes = 1; @@ -180,11 +257,16 @@ void I_InitNetwork (void) doomcom->consoleplayer = 0; return; } + netsend = PacketSend; netget = PacketGet; netgame = true; + + doomcom->consoleplayer = myargv[i+1][0]-'1'; + doomcom->numnodes = 1; + i++; while (++i < myargc && myargv[i][0] != '-') { @@ -205,13 +287,19 @@ void I_InitNetwork (void) } doomcom->numnodes++; } + doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes; + + insocket = UDPsocket (); BindToLocalPort (insocket,htons(DOOMPORT)); ioctl (insocket, FIONBIO, &trueval); + sendsocket = UDPsocket (); } + + void I_NetCmd (void) { if (doomcom->command == CMD_SEND) @@ -225,3 +313,4 @@ void I_NetCmd (void) else I_Error ("Bad net cmd: %i\n",doomcom->command); } + diff --git a/src/i_net.h b/src/i_net.h @@ -1,8 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_NET__ #define __I_NET__ + + #ifdef __GNUG__ #pragma interface #endif + + + + + + void I_InitNetwork (void); void I_NetCmd (void); + + #endif + + + + + diff --git a/src/i_sound.c b/src/i_sound.c @@ -1,53 +1,132 @@ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -#include <errno.h> + #include <math.h> +#include <errno.h> + #include <sys/time.h> #include <sys/types.h> + #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> + + #include <linux/soundcard.h> + + #include <time.h> #include <signal.h> + #include "z_zone.h" + #include "i_system.h" #include "i_sound.h" #include "m_argv.h" #include "m_misc.h" #include "w_wad.h" + #include "doomdef.h" + + #ifdef SNDSERV + FILE* sndserver=0; char* sndserver_filename = "./sndserver "; #elif SNDINTR + + + + #define SOUND_INTERVAL 500 + + int I_SoundSetTimer( int duration_of_tick ); void I_SoundDelTimer( void ); #else + #endif + + + + + static int flag = 0; + + + + + + + + #define SAMPLECOUNT 512 #define NUM_CHANNELS 8 + #define BUFMUL 4 #define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) + #define SAMPLERATE 11025 #define SAMPLESIZE 2 + + int lengths[NUMSFX]; + + int audio_fd; + + + + + signed short mixbuffer[MIXBUFFERSIZE]; + + + unsigned int channelstep[NUM_CHANNELS]; + unsigned int channelstepremainder[NUM_CHANNELS]; + + + unsigned char* channels[NUM_CHANNELS]; unsigned char* channelsend[NUM_CHANNELS]; + + + + + + + int channelstart[NUM_CHANNELS]; + + + + + int channelhandles[NUM_CHANNELS]; + + + int channelids[NUM_CHANNELS]; + + int steptable[256]; + + int vol_lookup[128*256]; + + int* channelleftvol_lookup[NUM_CHANNELS]; int* channelrightvol_lookup[NUM_CHANNELS]; + + + + + + + void myioctl ( int fd, @@ -55,6 +134,7 @@ myioctl int* arg ) { int rc; + rc = ioctl(fd, command, arg); if (rc < 0) { @@ -63,6 +143,15 @@ myioctl exit(-1); } } + + + + + + + + + void* getsfx ( char* sfxname, @@ -75,22 +164,73 @@ getsfx int paddedsize; char name[20]; int sfxlump; - sprintf(name, "ds%s", sfxname); + + + + + sprintf(name, "DS%s", sfxname); + + + + + + + + + + + if ( W_CheckNumForName(name) == -1 ) - sfxlump = W_GetNumForName("dspistol"); + sfxlump = W_GetNumForName("DSPISTOL"); else sfxlump = W_GetNumForName(name); + size = W_LumpLength( sfxlump ); + + + + + + + sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC ); + + + paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT; + + paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 ); + + + + + memcpy( paddedsfx, sfx, size ); for (i=size ; i<paddedsize+8 ; i++) paddedsfx[i] = 128; + + Z_Free( sfx ); + + *len = paddedsize; + + return (void *) (paddedsfx + 8); } + + + + + + + + + + + + int addsfx ( int sfxid, @@ -99,13 +239,19 @@ addsfx int seperation ) { static unsigned short handlenums = 0; + int i; int rc = -1; + int oldest = gametic; int oldestnum = 0; int slot; + int rightvol; int leftvol; + + + if ( sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful @@ -113,16 +259,23 @@ addsfx || sfxid == sfx_stnmov || sfxid == sfx_pistol ) { + for (i=0 ; i<NUM_CHANNELS ; i++) { + if ( (channels[i]) && (channelids[i] == sfxid) ) { + channels[i] = 0; + + break; } } } + + for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++) { if (channelstart[i] < oldest) @@ -131,62 +284,159 @@ addsfx oldest = channelstart[i]; } } + + + + + if (i == NUM_CHANNELS) slot = oldestnum; else slot = i; + + + + channels[slot] = (unsigned char *) S_sfx[sfxid].data; + channelsend[slot] = channels[slot] + lengths[sfxid]; + + if (!handlenums) handlenums = 100; + + + channelhandles[slot] = rc = handlenums++; + + + channelstep[slot] = step; + channelstepremainder[slot] = 0; + channelstart[slot] = gametic; + + + seperation += 1; + + + + leftvol = volume - ((volume*seperation*seperation) >> 16); seperation = seperation - 257; rightvol = volume - ((volume*seperation*seperation) >> 16); + + if (rightvol < 0 || rightvol > 127) I_Error("rightvol out of bounds"); + if (leftvol < 0 || leftvol > 127) I_Error("leftvol out of bounds"); + + + channelleftvol_lookup[slot] = &vol_lookup[leftvol*256]; channelrightvol_lookup[slot] = &vol_lookup[rightvol*256]; + + + channelids[slot] = sfxid; + + return rc; } + + + + + + + + + + + + + + void I_SetChannels() { + + + int i; int j; + int* steptablemid = steptable + 128; + + /*for (i=0; i<NUM_CHANNELS; i++) { channels[i] = 0; }*/ + + + for (i=-128 ; i<128 ; i++) steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0); + + + + + for (i=0 ; i<128 ; i++) for (j=0 ; j<256 ; j++) vol_lookup[i*256+j] = (i*(j-128)*256)/127; } + + void I_SetSfxVolume(int volume) { + + + + + snd_SfxVolume = volume; } + + void I_SetMusicVolume(int volume) { + snd_MusicVolume = volume; + + } + + + + + + int I_GetSfxLumpNum(sfxinfo_t* sfx) { char namebuf[9]; - sprintf(namebuf, "ds%s", sfx->name); + sprintf(namebuf, "DS%s", sfx->name); return W_GetNumForName(namebuf); } + + + + + + + + + + + + + int I_StartSound ( int id, @@ -195,96 +445,201 @@ I_StartSound int pitch, int priority ) { + + priority = 0; + #ifdef SNDSERV if (sndserver) { fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep); fflush(sndserver); } + return id; #else + + + + id = addsfx( id, vol, steptable[pitch], sep ); + + + return id; #endif } + + + void I_StopSound (int handle) { + + + + + + handle = 0; } + + int I_SoundIsPlaying(int handle) { + return gametic < handle; } + + + + + + + + + + + + + + + + + void I_UpdateSound( void ) { #ifdef SNDINTR static int misses = 0; #endif + + + + register unsigned int sample; register int dl; register int dr; + + signed short* leftout; signed short* rightout; signed short* leftend; + int step; + + int chan; + + + leftout = mixbuffer; rightout = mixbuffer+1; step = 2; + + + leftend = mixbuffer + SAMPLECOUNT*step; + + + + while (leftout != leftend) { + dl = 0; dr = 0; + + + + for ( chan = 0; chan < NUM_CHANNELS; chan++ ) { + if (channels[ chan ]) { + sample = *channels[ chan ]; + + + + dl += channelleftvol_lookup[ chan ][sample]; dr += channelrightvol_lookup[ chan ][sample]; + channelstepremainder[ chan ] += channelstep[ chan ]; + channels[ chan ] += channelstepremainder[ chan ] >> 16; + channelstepremainder[ chan ] &= 65536-1; + + if (channels[ chan ] >= channelsend[ chan ]) channels[ chan ] = 0; } } + + + + + + + if (dl > 0x7fff) *leftout = 0x7fff; else if (dl < -0x8000) *leftout = -0x8000; else *leftout = dl; + + if (dr > 0x7fff) *rightout = 0x7fff; else if (dr < -0x8000) *rightout = -0x8000; else *rightout = dr; + + leftout += step; rightout += step; } + #ifdef SNDINTR + if ( flag ) { misses += flag; flag = 0; } + if ( misses > 10 ) { fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n"); misses = 0; } + + flag++; #endif } + + + + + + + + + + void I_SubmitSound(void) { + write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); } + + + void I_UpdateSoundParams ( int handle, @@ -292,44 +647,76 @@ I_UpdateSoundParams int sep, int pitch) { + + + + + + handle = vol = sep = pitch = 0; } + + + + void I_ShutdownSound(void) { #ifdef SNDSERV if (sndserver) { + fprintf(sndserver, "q\n"); fflush(sndserver); } #else + int done = 0; int i; + + + fprintf( stderr, "I_ShutdownSound: NOT finishing pending sounds\n"); fflush( stderr ); + while ( !done ) { for( i=0 ; i<8 && !channels[i] ; i++); + + + done=1; } #ifdef SNDINTR I_SoundDelTimer(); #endif + + close ( audio_fd ); #endif + + return; } + + + + + + void I_InitSound() { #ifdef SNDSERV char buffer[256]; + if (getenv("DOOMWADDIR")) sprintf(buffer, "%s/%s", getenv("DOOMWADDIR"), sndserver_filename); else sprintf(buffer, "%s", sndserver_filename); + + if ( !access(buffer, X_OK) ) { strcat(buffer, " -quiet"); @@ -338,126 +725,230 @@ I_InitSound() else fprintf(stderr, "Could not start sound server [%s]\n", buffer); #else + int i; + #ifdef SNDINTR fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL ); I_SoundSetTimer( SOUND_INTERVAL ); #endif + + fprintf( stderr, "I_InitSound: "); + audio_fd = open("/dev/dsp", O_WRONLY); if (audio_fd<0) fprintf(stderr, "Could not open /dev/dsp\n"); + + i = 11 | (2<<16); myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); myioctl(audio_fd, SNDCTL_DSP_RESET, 0); + i=SAMPLERATE; + myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); + i=1; myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); + myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); + if (i&=AFMT_S16_LE) myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); else fprintf(stderr, "Could not play signed 16 data\n"); + fprintf(stderr, " configured audio device\n" ); + + + fprintf( stderr, "I_InitSound: "); + for (i=1 ; i<NUMSFX ; i++) { + if (!S_sfx[i].link) { + S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] ); } else { + S_sfx[i].data = S_sfx[i].link->data; lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)]; } } + fprintf( stderr, " pre-cached all sound data\n"); + + for ( i = 0; i< MIXBUFFERSIZE; i++ ) mixbuffer[i] = 0; + + fprintf(stderr, "I_InitSound: sound module ready\n"); + #endif } + + + + + + + + + void I_InitMusic(void) { } void I_ShutdownMusic(void) { } + static int looping=0; static int musicdies=-1; + void I_PlaySong(int handle, int looping) { + handle = looping = 0; musicdies = gametic + TICRATE*30; } + void I_PauseSong (int handle) { + handle = 0; } + void I_ResumeSong (int handle) { + handle = 0; } + void I_StopSong(int handle) { + handle = 0; + looping = 0; musicdies = 0; } + void I_UnRegisterSong(int handle) { + handle = 0; } + int I_RegisterSong(void* data) { + data = NULL; + return 1; } + + int I_QrySongPlaying(int handle) { + handle = 0; return looping || musicdies > gametic; } + + + + + + + + + + + #ifdef sun typedef sigset_t tSigSet; #else typedef int tSigSet; #endif + + + + + + static int /*__itimer_which*/ itimer = ITIMER_REAL; + static int sig = SIGALRM; + + void I_HandleSoundTimer( int ignore ) { + + + + if ( flag ) { + + write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); + + flag = 0; } else return; + + ignore = 0; return; } + + int I_SoundSetTimer( int duration_of_tick ) { + struct itimerval value; struct itimerval ovalue; struct sigaction act; struct sigaction oact; + int res; + + + + + act.sa_handler = I_HandleSoundTimer; #ifndef sun + #endif act.sa_flags = SA_RESTART; + sigaction( sig, &act, &oact ); + value.it_interval.tv_sec = 0; value.it_interval.tv_usec = duration_of_tick; value.it_value.tv_sec = 0; value.it_value.tv_usec = duration_of_tick; + + res = setitimer( itimer, &value, &ovalue ); + + if ( res == -1 ) fprintf( stderr, "I_SoundSetTimer: interrupt n.a.\n"); + return res; } + + + void I_SoundDelTimer() { + if ( I_SoundSetTimer( 0 ) == -1) fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n"); } diff --git a/src/i_sound.h b/src/i_sound.h @@ -1,19 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_SOUND__ #define __I_SOUND__ + #include "doomdef.h" + + #ifdef SNDSERV #include <stdio.h> extern FILE* sndserver; extern char* sndserver_filename; #endif + #include "doomstat.h" #include "sounds.h" + + + + void I_InitSound(); + + void I_UpdateSound(void); void I_SubmitSound(void); + + void I_ShutdownSound(void); + + + + + + + void I_SetChannels(); + + int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ); + + + int I_StartSound ( int id, @@ -21,24 +67,56 @@ I_StartSound int sep, int pitch, int priority ); + + + void I_StopSound(int handle); + + + + int I_SoundIsPlaying(int handle); + + + void I_UpdateSoundParams ( int handle, int vol, int sep, int pitch ); + + + + + void I_InitMusic(void); void I_ShutdownMusic(void); + void I_SetMusicVolume(int volume); + void I_PauseSong(int handle); void I_ResumeSong(int handle); + int I_RegisterSong(void *data); + + + + void I_PlaySong ( int handle, int looping ); + void I_StopSong(int handle); + void I_UnRegisterSong(int handle); + + + #endif + + + + + diff --git a/src/i_system.c b/src/i_system.c @@ -4,102 +4,69 @@ #include <stdarg.h> #include <sys/time.h> #include <unistd.h> + #include "doomdef.h" #include "m_misc.h" #include "i_video.h" #include "i_sound.h" #include "d_net.h" #include "g_game.h" -#ifdef __GNUG__ -#pragma implementation "i_system.h" -#endif #include "i_system.h" -int mb_used = 6; -void -I_Tactile -( int on, - int off, - int total ) -{ - on = off = total = 0; -} -ticcmd_t emptycmd; -ticcmd_t* I_BaseTiccmd(void) -{ - return &emptycmd; -} -int I_GetHeapSize (void) + +int +I_GetTime() { - return mb_used*1024*1024; -} -byte* I_ZoneBase (int* size) -{ - *size = mb_used*1024*1024; - return (byte *) malloc (*size); -} -int I_GetTime (void) -{ - struct timeval tp; - struct timezone tzp; - int newtics; - static int basetime=0; - gettimeofday(&tp, &tzp); + struct timeval tp; + static int basetime = 0; + int newtics; + + gettimeofday(&tp, NULL); if (!basetime) - basetime = tp.tv_sec; - newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000; + basetime = tp.tv_sec; + newtics = (tp.tv_sec-basetime) * TICRATE + tp.tv_usec * TICRATE / 1000000; return newtics; } -void I_Init (void) + +void +I_Init() { I_InitSound(); } -void I_Quit (void) + +void +I_Quit() { D_QuitNetGame (); I_ShutdownSound(); I_ShutdownMusic(); - M_SaveDefaults (); I_ShutdownGraphics(); exit(0); } -void I_WaitVBL(int count) + +void +I_WaitVBL(int count) { -#ifdef SGI - sginap(1); -#else -#ifdef SUN - sleep(0); -#else usleep (count * (1000000/70) ); -#endif -#endif -} -void I_BeginRead(void) -{ -} -void I_EndRead(void) -{ -} -byte* I_AllocLow(int length) -{ - byte* mem; - mem = (byte *)malloc (length); - memset (mem,0,length); - return mem; } + extern boolean demorecording; -void I_Error (char *error, ...) + +void +I_Error(char *error, ...) { va_list argptr; - va_start (argptr,error); - fprintf (stderr, "Error: "); - vfprintf (stderr,error,argptr); - fprintf (stderr, "\n"); - va_end (argptr); - fflush( stderr ); + int i; + + va_start(argptr,error); + fprintf(stderr, "Error: "); + vfprintf(stderr,error,argptr); + fprintf(stderr, "\n"); + va_end(argptr); + fflush(stderr); if (demorecording) - G_CheckDemoStatus(); - D_QuitNetGame (); + G_CheckDemoStatus(); + D_QuitNetGame(); I_ShutdownGraphics(); - exit(-1); + i = *(int*)0; + exit(i); } diff --git a/src/i_system.h b/src/i_system.h @@ -1,18 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_SYSTEM__ #define __I_SYSTEM__ + #include "d_ticcmd.h" #include "d_event.h" + #ifdef __GNUG__ #pragma interface #endif + + + void I_Init (void); + + + + byte* I_ZoneBase (int *size); + + + + int I_GetTime (void); + + + + + + + + + + void I_StartFrame (void); + + + + + + + void I_StartTic (void); + + + + + + + + + ticcmd_t* I_BaseTiccmd (void); + + + + void I_Quit (void); + + + + byte* I_AllocLow (int length); + void I_Tactile (int on, int off, int total); + + void I_Error (char *error, ...); + + #endif + + + + + diff --git a/src/i_video.h b/src/i_video.h @@ -1,16 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + #ifndef __I_VIDEO__ #define __I_VIDEO__ -#include "doomtype.h" + + +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif + + + + + void I_InitGraphics (void); + + void I_ShutdownGraphics(void); + + void I_SetPalette (byte* palette); + void I_UpdateNoBlit (void); void I_FinishUpdate (void); + + void I_WaitVBL(int count); + void I_ReadScreen (byte* scr); + void I_BeginRead (void); void I_EndRead (void); + + + #endif + + + + + diff --git a/src/info.c b/src/info.c @@ -1,11 +1,9 @@ #include "sounds.h" #include "m_fixed.h" -#ifdef __GNUG__ -#pragma implementation "info.h" -#endif #include "info.h" #include "p_mobj.h" -char *sprnames[NUMSPRITES] = { + +char* sprnames[NUMSPRITES] = { "TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG", "MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2", "PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS", @@ -21,7 +19,8 @@ char *sprnames[NUMSPRITES] = { "COL5","TBLU","TGRN","TRED","SMBT","SMGT","SMRT","HDB1","HDB2","HDB3", "HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2" }; -void A_Light0(); + +void A_Light0(); void A_WeaponReady(); void A_Lower(); void A_Raise(); @@ -95,6 +94,7 @@ void A_BrainSpit(); void A_SpawnSound(); void A_SpawnFly(); void A_BrainExplode(); + state_t states[NUMSTATES] = { {SPR_TROO,0,-1,{NULL},S_NULL,0,0}, {SPR_SHTG,4,0,{A_Light0},S_NULL,0,0}, @@ -1064,3430 +1064,3568 @@ state_t states[NUMSTATES] = { {SPR_TLP2,32770,4,{NULL},S_TECH2LAMP4,0,0}, {SPR_TLP2,32771,4,{NULL},S_TECH2LAMP,0,0} }; + + mobjinfo_t mobjinfo[NUMMOBJTYPES] = { { - -1, - S_PLAY, - 100, - S_PLAY_RUN1, - sfx_None, - 0, - sfx_None, - S_PLAY_PAIN, - 255, - sfx_plpain, - S_NULL, - S_PLAY_ATK1, - S_PLAY_DIE1, - S_PLAY_XDIE1, - sfx_pldeth, - 0, - 16*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_None, - MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, - S_NULL - }, - { - 3004, - S_POSS_STND, - 20, - S_POSS_RUN1, - sfx_posit1, - 8, - sfx_pistol, - S_POSS_PAIN, - 200, - sfx_popain, - 0, - S_POSS_ATK1, - S_POSS_DIE1, - S_POSS_XDIE1, - sfx_podth1, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_POSS_RAISE1 - }, - { - 9, - S_SPOS_STND, - 30, - S_SPOS_RUN1, - sfx_posit2, - 8, - 0, - S_SPOS_PAIN, - 170, - sfx_popain, - 0, - S_SPOS_ATK1, - S_SPOS_DIE1, - S_SPOS_XDIE1, - sfx_podth2, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SPOS_RAISE1 - }, - { - 64, - S_VILE_STND, - 700, - S_VILE_RUN1, - sfx_vilsit, - 8, - 0, - S_VILE_PAIN, - 10, - sfx_vipain, - 0, - S_VILE_ATK1, - S_VILE_DIE1, - S_NULL, - sfx_vildth, - 15, - 20*FRACUNIT, - 56*FRACUNIT, - 500, - 0, - sfx_vilact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - -1, - S_FIRE1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 66, - S_SKEL_STND, - 300, - S_SKEL_RUN1, - sfx_skesit, - 8, - 0, - S_SKEL_PAIN, - 100, - sfx_popain, - S_SKEL_FIST1, - S_SKEL_MISS1, - S_SKEL_DIE1, - S_NULL, - sfx_skedth, - 10, - 20*FRACUNIT, - 56*FRACUNIT, - 500, - 0, - sfx_skeact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SKEL_RAISE1 - }, - { - -1, - S_TRACER, - 1000, - S_NULL, - sfx_skeatk, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_TRACEEXP1, - S_NULL, - sfx_barexp, - 10*FRACUNIT, - 11*FRACUNIT, - 8*FRACUNIT, - 100, - 10, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - -1, - S_SMOKE1, - 1000, - S_NULL, - sfx_None, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_NULL, - S_NULL, - sfx_None, - 0, - 20*FRACUNIT, - 16*FRACUNIT, - 100, - 0, - sfx_None, - MF_NOBLOCKMAP|MF_NOGRAVITY, - S_NULL - }, - { - 67, - S_FATT_STND, - 600, - S_FATT_RUN1, - sfx_mansit, - 8, - 0, - S_FATT_PAIN, - 80, - sfx_mnpain, - 0, - S_FATT_ATK1, - S_FATT_DIE1, - S_NULL, - sfx_mandth, - 8, - 48*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_FATT_RAISE1 - }, - { - -1, - S_FATSHOT1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_FATSHOTX1, - S_NULL, - sfx_firxpl, - 20*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 8, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - 65, - S_CPOS_STND, - 70, - S_CPOS_RUN1, - sfx_posit2, - 8, - 0, - S_CPOS_PAIN, - 170, - sfx_popain, - 0, - S_CPOS_ATK1, - S_CPOS_DIE1, - S_CPOS_XDIE1, - sfx_podth2, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_CPOS_RAISE1 - }, - { - 3001, - S_TROO_STND, - 60, - S_TROO_RUN1, - sfx_bgsit1, - 8, - 0, - S_TROO_PAIN, - 200, - sfx_popain, - S_TROO_ATK1, - S_TROO_ATK1, - S_TROO_DIE1, - S_TROO_XDIE1, - sfx_bgdth1, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_bgact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_TROO_RAISE1 - }, - { - 3002, - S_SARG_STND, - 150, - S_SARG_RUN1, - sfx_sgtsit, - 8, - sfx_sgtatk, - S_SARG_PAIN, - 180, - sfx_dmpain, - S_SARG_ATK1, - 0, - S_SARG_DIE1, - S_NULL, - sfx_sgtdth, - 10, - 30*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SARG_RAISE1 - }, - { - 58, - S_SARG_STND, - 150, - S_SARG_RUN1, - sfx_sgtsit, - 8, - sfx_sgtatk, - S_SARG_PAIN, - 180, - sfx_dmpain, - S_SARG_ATK1, - 0, - S_SARG_DIE1, - S_NULL, - sfx_sgtdth, - 10, - 30*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_SHADOW|MF_COUNTKILL, - S_SARG_RAISE1 - }, - { - 3005, - S_HEAD_STND, - 400, - S_HEAD_RUN1, - sfx_cacsit, - 8, - 0, - S_HEAD_PAIN, - 128, - sfx_dmpain, - 0, - S_HEAD_ATK1, - S_HEAD_DIE1, - S_NULL, - sfx_cacdth, - 8, - 31*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, - S_HEAD_RAISE1 - }, - { - 3003, - S_BOSS_STND, - 1000, - S_BOSS_RUN1, - sfx_brssit, - 8, - 0, - S_BOSS_PAIN, - 50, - sfx_dmpain, - S_BOSS_ATK1, - S_BOSS_ATK1, - S_BOSS_DIE1, - S_NULL, - sfx_brsdth, - 8, - 24*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BOSS_RAISE1 - }, - { - -1, - S_BRBALL1, - 1000, - S_NULL, - sfx_firsht, - 8, - sfx_None, - S_NULL, - 0, - sfx_None, - S_NULL, - S_NULL, - S_BRBALLX1, - S_NULL, - sfx_firxpl, - 15*FRACUNIT, - 6*FRACUNIT, - 8*FRACUNIT, - 100, - 8, - sfx_None, - MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, - S_NULL - }, - { - 69, - S_BOS2_STND, - 500, - S_BOS2_RUN1, - sfx_kntsit, - 8, - 0, - S_BOS2_PAIN, - 50, - sfx_dmpain, - S_BOS2_ATK1, - S_BOS2_ATK1, - S_BOS2_DIE1, - S_NULL, - sfx_kntdth, - 8, - 24*FRACUNIT, - 64*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BOS2_RAISE1 - }, - { - 3006, - S_SKULL_STND, - 100, - S_SKULL_RUN1, - 0, - 8, - sfx_sklatk, - S_SKULL_PAIN, - 256, - sfx_dmpain, - 0, - S_SKULL_ATK1, - S_SKULL_DIE1, - S_NULL, - sfx_firxpl, - 8, - 16*FRACUNIT, - 56*FRACUNIT, - 50, - 3, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY, - S_NULL - }, - { - 7, - S_SPID_STND, - 3000, - S_SPID_RUN1, - sfx_spisit, - 8, - sfx_shotgn, - S_SPID_PAIN, - 40, - sfx_dmpain, - 0, - S_SPID_ATK1, - S_SPID_DIE1, - S_NULL, - sfx_spidth, - 12, - 128*FRACUNIT, - 100*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 68, - S_BSPI_STND, - 500, - S_BSPI_SIGHT, - sfx_bspsit, - 8, - 0, - S_BSPI_PAIN, - 128, - sfx_dmpain, - 0, - S_BSPI_ATK1, - S_BSPI_DIE1, - S_NULL, - sfx_bspdth, - 12, - 64*FRACUNIT, - 64*FRACUNIT, - 600, - 0, - sfx_bspact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_BSPI_RAISE1 - }, - { - 16, - S_CYBER_STND, - 4000, - S_CYBER_RUN1, - sfx_cybsit, - 8, - 0, - S_CYBER_PAIN, - 20, - sfx_dmpain, - 0, - S_CYBER_ATK1, - S_CYBER_DIE1, - S_NULL, - sfx_cybdth, - 16, - 40*FRACUNIT, - 110*FRACUNIT, - 1000, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 71, - S_PAIN_STND, - 400, - S_PAIN_RUN1, - sfx_pesit, - 8, - 0, - S_PAIN_PAIN, - 128, - sfx_pepain, - 0, - S_PAIN_ATK1, - S_PAIN_DIE1, - S_NULL, - sfx_pedth, - 8, - 31*FRACUNIT, - 56*FRACUNIT, - 400, - 0, - sfx_dmact, - MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, - S_PAIN_RAISE1 - }, - { - 84, - S_SSWV_STND, - 50, - S_SSWV_RUN1, - sfx_sssit, - 8, - 0, - S_SSWV_PAIN, - 170, - sfx_popain, - 0, - S_SSWV_ATK1, - S_SSWV_DIE1, - S_SSWV_XDIE1, - sfx_ssdth, - 8, - 20*FRACUNIT, - 56*FRACUNIT, - 100, - 0, - sfx_posact, - MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, - S_SSWV_RAISE1 - }, - { - 72, - S_KEENSTND, - 100, - S_NULL, - sfx_None, - 8, - sfx_None, - S_KEENPAIN, - 256, - sfx_keenpn, - S_NULL, - S_NULL, - S_COMMKEEN, - S_NULL, - sfx_keendt, - 0, - 16*FRACUNIT, - 72*FRACUNIT, - 10000000, - 0, - sfx_None, - MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY|MF_SHOOTABLE|MF_COUNTKILL, - S_NULL - }, - { - 88, - S_BRAIN, - 250, - S_NULL, - sfx_None, - 8, - sfx_None, - S_BRAIN_PAIN, - 255, - sfx_bospn, - S_NULL, - S_NULL, - S_BRAIN_DIE1, - S_NULL, - sfx_bosdth, - 0, - 16*FRACUNIT, - 16*FRACUNIT, - 10000000, - 0, - sfx_None, - MF_SOLID|MF_SHOOTABLE, - S_NULL - }, - { - 89, - S_BRAINEYE, - 1000, - S_BRAINEYESEE, - sfx_None, - 8, - sfx_None, - S_NULL,