├── Hexen Source ├── MAKE.BAT ├── W.BAT ├── CT_CHAT.H ├── DRCOORD.H ├── VGAVIEW.H ├── I_CDMUS.H ├── DEFS.INC ├── M.BAT ├── ST_START.H ├── TEMPLATE.C ├── HEX.LNK ├── SOUNDST.H ├── I_SOUND.H ├── I_IBM_A.ASM ├── I_HEADER.H ├── MAKEFILE ├── T.BAT ├── AM_DATA.H ├── P_TICK.C ├── AM_MAP.H ├── P_SWITCH.C ├── P_TELEPT.C ├── XDDEFS.H ├── WADLINK.WL ├── TEXTDEFS.H ├── P_PLATS.C ├── SOUNDS.H ├── I_CYBER.C ├── LINEAR.ASM ├── DSTRINGS.H ├── P_CEILNG.C ├── P_DOORS.C ├── P_LIGHTS.C ├── I_SOUND.C ├── F_FINALE.C ├── ST_START.C ├── P_SIGHT.C ├── Z_ZONE.C ├── V_VIDEO.C ├── P_ANIM.C └── CT_CHAT.C └── README.txt /Hexen Source/MAKE.BAT: -------------------------------------------------------------------------------- 1 | wmake 2 | -------------------------------------------------------------------------------- /Hexen Source/W.BAT: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Making HEXEN.WAD 3 | echo Preprocessing: wadlink.txt to wadlink.wl 4 | wcc386 /dNOMAPS /dREGISTERED /p /fo=wadlink.wl \data\wadlink.txt 5 | echo wadlinking ... 6 | \tools\exe\wadlink 7 | -------------------------------------------------------------------------------- /Hexen Source/CT_CHAT.H: -------------------------------------------------------------------------------- 1 | // 2 | // Chat mode stuff 3 | // 4 | 5 | #define CT_PLR_GREEN 1 6 | #define CT_PLR_YELLOW 2 7 | #define CT_PLR_RED 3 8 | #define CT_PLR_BLUE 4 9 | #define CT_PLR_ALL 5 10 | 11 | #define CT_KEY_GREEN 'g' 12 | #define CT_KEY_YELLOW 'y' 13 | #define CT_KEY_RED 'r' 14 | #define CT_KEY_BLUE 'b' 15 | #define CT_KEY_ALL 't' 16 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Activision and Raven are releasing this code for people to learn from and play with. 2 | This code is copyright Activision 1996-1998 3 | [edit 2 Sep 2008] The code is release under GNU GPLv2 (see LICENSE) 4 | 5 | Issues: 6 | The DMX sound library is not included with the source due to license issues, 7 | so you won't be able to link until those sound calls are replaced or removed. 8 | -------------------------------------------------------------------------------- /Hexen Source/DRCOORD.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** DRCoord.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: DRCoord.h,v $ 7 | //** $Revision: 1.1 $ 8 | //** $Date: 95/05/11 00:19:30 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #import 14 | 15 | @interface DRCoord:Object 16 | { 17 | id players_i; 18 | id console_i; 19 | id skill_i; 20 | id episode_i; 21 | id map_i; 22 | } 23 | 24 | - newGame: sender; 25 | - scale1: sender; 26 | - scale2: sender; 27 | - scale4: sender; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Hexen Source/VGAVIEW.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** VGAView.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: VGAView.h,v $ 7 | //** $Revision: 1.1 $ 8 | //** $Date: 95/05/11 00:19:48 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #import 14 | #import "h2def.h" 15 | 16 | // a few globals 17 | extern byte *bytebuffer; 18 | 19 | 20 | @interface VGAView:View 21 | { 22 | id game; 23 | int nextpalette[256]; // color lookup table 24 | int *nextimage; // palette expanded and scaled 25 | unsigned scale; 26 | NXWindowDepth depth; 27 | } 28 | 29 | - updateView; 30 | - (unsigned)scale; 31 | - setPalette:(byte *)pal; 32 | - setScale:(int)newscale; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Hexen Source/I_CDMUS.H: -------------------------------------------------------------------------------- 1 | 2 | // i_cdmus.h 3 | 4 | #ifndef __ICDMUS__ 5 | #define __ICDMUS__ 6 | 7 | #define CDERR_NOTINSTALLED 10 // MSCDEX not installed 8 | #define CDERR_NOAUDIOSUPPORT 11 // CD-ROM Doesn't support audio 9 | #define CDERR_NOAUDIOTRACKS 12 // Current CD has no audio tracks 10 | #define CDERR_BADDRIVE 20 // Bad drive number 11 | #define CDERR_BADTRACK 21 // Bad track number 12 | #define CDERR_IOCTLBUFFMEM 22 // Not enough low memory for IOCTL 13 | #define CDERR_DEVREQBASE 100 // DevReq errors 14 | 15 | extern int cd_Error; 16 | 17 | int I_CDMusInit(void); 18 | int I_CDMusPlay(int track); 19 | int I_CDMusStop(void); 20 | int I_CDMusResume(void); 21 | int I_CDMusSetVolume(int volume); 22 | int I_CDMusFirstTrack(void); 23 | int I_CDMusLastTrack(void); 24 | int I_CDMusTrackLength(int track); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Hexen Source/DEFS.INC: -------------------------------------------------------------------------------- 1 | SKIPPRIMITIVES = 0 ; set to 1 to skip unwound drawing 2 | 3 | 4 | SCREEN = 0a0000h 5 | SCREENWIDTH = 320 6 | SCREENHEIGHT = 200 7 | PLANEWIDTH = 80 8 | PLANESIZE = 80*200 9 | 10 | PEL_WRITE_ADR = 03c8h 11 | PEL_DATA = 03c9h 12 | 13 | SC_INDEX = 03C4h 14 | SC_MAPMASK = 2 15 | 16 | OP_RET = 0c3h 17 | OP_MOVAL = 08ah 18 | OP_MOVDEST = 088h 19 | 20 | 21 | .DATA 22 | 23 | EXTRN _dc_colormap:DWORD 24 | EXTRN _tinttable:DWORD 25 | EXTRN _dc_x:DWORD 26 | EXTRN _dc_yl:DWORD 27 | EXTRN _dc_yh:DWORD 28 | EXTRN _dc_iscale:DWORD 29 | EXTRN _dc_texturemid:DWORD 30 | EXTRN _dc_source:DWORD 31 | 32 | EXTRN _ylookup:DWORD 33 | EXTRN _columnofs:DWORD 34 | 35 | 36 | EXTRN _ds_y:DWORD 37 | EXTRN _ds_x1:DWORD 38 | EXTRN _ds_x2:DWORD 39 | EXTRN _ds_colormap:DWORD 40 | EXTRN _ds_xfrac:DWORD 41 | EXTRN _ds_yfrac:DWORD 42 | EXTRN _ds_xstep:DWORD 43 | EXTRN _ds_ystep:DWORD 44 | EXTRN _ds_source:DWORD 45 | 46 | PUSHR MACRO 47 | pushad 48 | ENDM 49 | 50 | POPR MACRO 51 | popad 52 | ENDM 53 | -------------------------------------------------------------------------------- /Hexen Source/M.BAT: -------------------------------------------------------------------------------- 1 | @REM Hexen make batch 2 | @echo off 3 | 4 | if "%1"=="/?" goto usage 5 | if "%1"=="f" goto final 6 | if "%1"=="F" goto final 7 | if "%1"=="d" goto debug 8 | if "%1"=="D" goto debug 9 | goto normal 10 | 11 | :usage 12 | echo. 13 | echo Hexen make batch 14 | echo Usage: M [/?] [build-type] 15 | echo. 16 | echo build-type f = Final build (no RANGECHECK) 17 | echo build-type d = Debug build (include debugging info) 18 | echo. 19 | goto end 20 | 21 | :final 22 | echo. 23 | echo. 24 | echo *** Building Hexen FINAL executable 25 | echo. 26 | echo. 27 | shift 28 | wmake hex.exe EXTERNOPT=/dNORANGECHECKING %1 %2 %3 %4 %5 %6 %7 %8 %9 29 | goto end 30 | 31 | :debug 32 | echo. 33 | echo. 34 | echo *** Building Hexen DEBUG executable 35 | echo. 36 | echo. 37 | shift 38 | wmake hex.exe EXTERNOPT=/d2 %1 %2 %3 %4 %5 %6 %7 %8 %9 39 | goto end 40 | 41 | :normal 42 | echo. 43 | echo. 44 | echo *** Building Hexen DEVELOPMENT executable 45 | echo. 46 | echo. 47 | wmake hex.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 48 | goto end 49 | 50 | :end 51 | -------------------------------------------------------------------------------- /Hexen Source/ST_START.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** template.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: st_start.h,v $ 7 | //** $Revision: 1.5 $ 8 | //** $Date: 95/10/11 23:35:33 $ 9 | //** $Author: paul $ 10 | //** 11 | //************************************************************************** 12 | 13 | // HEADER FILES ------------------------------------------------------------ 14 | 15 | // MACROS ------------------------------------------------------------------ 16 | 17 | // TYPES ------------------------------------------------------------------- 18 | 19 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 20 | extern void ST_Init(void); 21 | extern void ST_Done(void); 22 | extern void ST_Message(char *message, ...); 23 | extern void ST_RealMessage(char *message, ...); 24 | extern void ST_Progress(void); 25 | extern void ST_NetProgress(void); 26 | extern void ST_NetDone(void); 27 | 28 | // PUBLIC DATA DECLARATIONS ------------------------------------------------ 29 | -------------------------------------------------------------------------------- /Hexen Source/TEMPLATE.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** TEMPLATE.C 5 | //** 6 | //************************************************************************** 7 | 8 | // HEADER FILES ------------------------------------------------------------ 9 | 10 | // MACROS ------------------------------------------------------------------ 11 | 12 | // TYPES ------------------------------------------------------------------- 13 | 14 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 15 | 16 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 17 | 18 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 19 | 20 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 21 | 22 | // PUBLIC DATA DEFINITIONS ------------------------------------------------- 23 | 24 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 25 | 26 | // CODE -------------------------------------------------------------------- 27 | 28 | //========================================================================== 29 | // 30 | // 31 | // 32 | //========================================================================== 33 | -------------------------------------------------------------------------------- /Hexen Source/HEX.LNK: -------------------------------------------------------------------------------- 1 | 2 | # HEX.EXE Linker directive file 3 | 4 | option quiet 5 | option map 6 | option statics 7 | option stack=65536 8 | option stub=wstub 9 | debug all 10 | libpath %WATCOM%\lib386 11 | libpath %WATCOM%\lib386\dos 12 | lib noemu387.lib 13 | lib dmx 14 | format os2 le 15 | name hex 16 | 17 | file i_cyber.obj 18 | file i_ibm.obj 19 | file i_ibm_a.obj 20 | file i_sound.obj 21 | file i_cdmus.obj 22 | file linear.obj 23 | 24 | file am_map.obj 25 | file a_action.obj 26 | file ct_chat.obj 27 | file d_net.obj 28 | file f_finale.obj 29 | file g_game.obj 30 | file h2_main.obj 31 | file info.obj 32 | file in_lude.obj 33 | file mn_menu.obj 34 | file m_misc.obj 35 | file p_acs.obj 36 | file p_anim.obj 37 | file p_ceilng.obj 38 | file p_doors.obj 39 | file p_enemy.obj 40 | file p_floor.obj 41 | file p_inter.obj 42 | file p_lights.obj 43 | file p_map.obj 44 | file p_maputl.obj 45 | file p_mobj.obj 46 | file p_plats.obj 47 | file p_pspr.obj 48 | file p_setup.obj 49 | file p_sight.obj 50 | file p_spec.obj 51 | file p_switch.obj 52 | file p_telept.obj 53 | file p_tick.obj 54 | file p_things.obj 55 | file p_user.obj 56 | file po_man.obj 57 | file r_bsp.obj 58 | file r_data.obj 59 | file r_draw.obj 60 | file r_main.obj 61 | file r_plane.obj 62 | file r_segs.obj 63 | file r_things.obj 64 | file sb_bar.obj 65 | file sc_man.obj 66 | file sn_sonix.obj 67 | file st_start.obj 68 | file sv_save.obj 69 | file sounds.obj 70 | file tables.obj 71 | file v_video.obj 72 | file w_wad.obj 73 | file z_zone.obj 74 | -------------------------------------------------------------------------------- /Hexen Source/SOUNDST.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** soundst.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: soundst.h,v $ 7 | //** $Revision: 1.13 $ 8 | //** $Date: 95/10/12 18:01:27 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #ifndef __SOUNDSTH__ 14 | #define __SOUNDSTH__ 15 | 16 | typedef struct 17 | { 18 | char name[8]; 19 | int p1; 20 | } musicinfo_t; 21 | 22 | typedef struct sfxinfo_s 23 | { 24 | char tagName[32]; 25 | char lumpname[12]; // Only need 9 bytes, but padded out to be dword aligned 26 | //struct sfxinfo_s *link; // Make alias for another sound 27 | int priority; // Higher priority takes precendence 28 | int usefulness; // Determines when a sound should be cached out 29 | void *snd_ptr; 30 | int lumpnum; 31 | int numchannels; // total number of channels a sound type may occupy 32 | boolean changePitch; 33 | } sfxinfo_t; 34 | 35 | typedef struct 36 | { 37 | mobj_t *mo; 38 | int sound_id; 39 | int handle; 40 | int volume; 41 | int pitch; 42 | int priority; 43 | } channel_t; 44 | 45 | typedef struct 46 | { 47 | long id; 48 | unsigned short priority; 49 | char *name; 50 | mobj_t *mo; 51 | int distance; 52 | } ChanInfo_t; 53 | 54 | typedef struct 55 | { 56 | int channelCount; 57 | int musicVolume; 58 | int soundVolume; 59 | ChanInfo_t chan[8]; 60 | } SoundInfo_t; 61 | 62 | extern int snd_MaxVolume; 63 | extern int snd_MusicVolume; 64 | 65 | void S_Start(void); 66 | void S_StartSound(mobj_t *origin, int sound_id); 67 | int S_GetSoundID(char *name); 68 | void S_StartSoundAtVolume(mobj_t *origin, int sound_id, int volume); 69 | void S_StopSound(mobj_t *origin); 70 | void S_StopAllSound(void); 71 | void S_PauseSound(void); 72 | void S_ResumeSound(void); 73 | void S_UpdateSounds(mobj_t *listener); 74 | void S_StartSong(int song, boolean loop); 75 | void S_StartSongName(char *songLump, boolean loop); 76 | void S_Init(void); 77 | void S_GetChannelInfo(SoundInfo_t *s); 78 | void S_SetMusicVolume(void); 79 | boolean S_GetSoundPlayingInfo(mobj_t *mobj, int sound_id); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Hexen Source/I_SOUND.H: -------------------------------------------------------------------------------- 1 | #ifndef __SOUND__ 2 | #define __SOUND__ 3 | 4 | #define SND_TICRATE 140 // tic rate for updating sound 5 | #define SND_MAXSONGS 40 // max number of songs in game 6 | #define SND_SAMPLERATE 11025 // sample rate of sound effects 7 | 8 | typedef enum 9 | { 10 | snd_none, 11 | snd_PC, 12 | snd_Adlib, 13 | snd_SB, 14 | snd_PAS, 15 | snd_GUS, 16 | snd_MPU, 17 | snd_MPU2, 18 | snd_MPU3, 19 | snd_AWE, 20 | snd_CDMUSIC, 21 | NUM_SCARDS 22 | } cardenum_t; 23 | 24 | void I_PauseSong(int handle); 25 | void I_ResumeSong(int handle); 26 | void I_SetMusicVolume(int volume); 27 | void I_SetSfxVolume(int volume); 28 | int I_RegisterSong(void *data); 29 | void I_UnRegisterSong(int handle); 30 | int I_QrySongPlaying(int handle); 31 | void I_StopSong(int handle); 32 | void I_PlaySong(int handle, int looping); 33 | int I_GetSfxLumpNum(sfxinfo_t *sound); 34 | int I_StartSound (int id, void *data, int vol, int sep, int pitch, int priority); 35 | void I_StopSound(int handle); 36 | int I_SoundIsPlaying(int handle); 37 | void I_UpdateSoundParams(int handle, int vol, int sep, int pitch); 38 | void I_sndArbitrateCards(void); 39 | void I_StartupSound (void); 40 | void I_ShutdownSound (void); 41 | void I_SetChannels(int channels); 42 | 43 | #endif 44 | 45 | #ifndef __ICDMUS__ 46 | #define __ICDMUS__ 47 | 48 | #define CDERR_NOTINSTALLED 10 // MSCDEX not installed 49 | #define CDERR_NOAUDIOSUPPORT 11 // CD-ROM Doesn't support audio 50 | #define CDERR_NOAUDIOTRACKS 12 // Current CD has no audio tracks 51 | #define CDERR_BADDRIVE 20 // Bad drive number 52 | #define CDERR_BADTRACK 21 // Bad track number 53 | #define CDERR_IOCTLBUFFMEM 22 // Not enough low memory for IOCTL 54 | #define CDERR_DEVREQBASE 100 // DevReq errors 55 | 56 | extern int cd_Error; 57 | 58 | int I_CDMusInit(void); 59 | int I_CDMusPlay(int track); 60 | int I_CDMusStop(void); 61 | int I_CDMusResume(void); 62 | int I_CDMusSetVolume(int volume); 63 | int I_CDMusFirstTrack(void); 64 | int I_CDMusLastTrack(void); 65 | int I_CDMusTrackLength(int track); 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /Hexen Source/I_IBM_A.ASM: -------------------------------------------------------------------------------- 1 | .386 2 | .MODEL small 3 | 4 | .DATA 5 | 6 | 7 | 8 | .CODE 9 | 10 | IF 0 11 | #define PEL_WRITE_ADR 0x3c8 12 | #define PEL_READ_ADR 0x3c7 13 | #define PEL_DATA 0x3c9 14 | ENDIF 15 | 16 | ;================ 17 | ; 18 | ; I_DivException 19 | ; 20 | ;================ 21 | 22 | PROC I_DivException_ 23 | PUBLIC I_DivException_ 24 | mov edx,03c9h 25 | mov al,63 26 | out dx,al 27 | 28 | mov ebx,0ffffffh 29 | mov eax,[ebx] 30 | retf 31 | ENDP 32 | 33 | ;================ 34 | ; 35 | ; I_SetDivException 36 | ; 37 | ;================ 38 | 39 | PROC I_SetDivException_ 40 | PUBLIC I_SetDivException_ 41 | pusha 42 | 43 | mov eax,0212h 44 | mov ebx,0 45 | mov ecx,cs 46 | mov edx,OFFSET I_DivException_ 47 | int 31h 48 | jnc good 49 | 50 | popa 51 | mov eax,0 52 | ret 53 | 54 | good: 55 | popa 56 | mov eax,1 57 | ret 58 | 59 | ENDP 60 | 61 | 62 | ;================ 63 | ; 64 | ; I_ReadJoystick 65 | ; 66 | ; Read the absolute joystick values 67 | ; returns false if not connected 68 | ;================ 69 | 70 | .data 71 | 72 | _joystickx dd 0 73 | _joysticky dd 0 74 | PUBLIC _joystickx, _joysticky 75 | 76 | .code 77 | 78 | PROC I_ReadJoystick_ 79 | PUBLIC I_ReadJoystick_ 80 | pushad 81 | pushf ; state of interrupt flag 82 | cli 83 | 84 | mov dx,0201h 85 | in al,dx 86 | out dx,al ; Clear the resistors 87 | 88 | mov ah,1 ; Get masks into registers 89 | mov ch,2 90 | 91 | xor esi,esi ; Clear count registers 92 | xor edi,edi 93 | xor ebx,ebx ; Clear high byte of bx for later 94 | 95 | mov ebp,10000 ; joystick is disconnected if value is this big 96 | 97 | jloop: 98 | in al,dx ; Get bits indicating whether all are finished 99 | 100 | dec ebp ; Check bounding register 101 | jz bad ; We have a silly value - abort 102 | 103 | mov bl,al ; Duplicate the bits 104 | and bl,ah ; Mask off useless bits (in [xb]) 105 | add esi,ebx ; Possibly increment count register 106 | mov cl,bl ; Save for testing later 107 | 108 | mov bl,al 109 | and bl,ch ; [yb] 110 | add edi,ebx 111 | 112 | add cl,bl 113 | jnz jloop ; If both bits were 0, drop out 114 | 115 | done: 116 | mov [_joystickx],esi 117 | shr edi,1 ; because 2s were added 118 | mov [_joysticky],edi 119 | 120 | popf ; restore interrupt flag 121 | popad 122 | mov eax,1 ; read was ok 123 | ret 124 | 125 | bad: 126 | popf ; restore interrupt flag 127 | popad 128 | xor eax, eax ; read was bad 129 | ret 130 | 131 | ENDP 132 | 133 | 134 | END 135 | 136 | -------------------------------------------------------------------------------- /Hexen Source/I_HEADER.H: -------------------------------------------------------------------------------- 1 | #ifndef __I_HEADER_H__ 2 | #define __I_HEADER_H__ 3 | 4 | #include "h2def.h" 5 | 6 | //-------- 7 | //SOUND IO 8 | //-------- 9 | #define FREQ_LOW 0x40 10 | #define FREQ_NORM 0x80 11 | #define FREQ_HIGH 0xff 12 | 13 | void I_SetMasterVolume(int volume); 14 | 15 | void I_TurnOffSfx(void); 16 | void I_TurnOnSfx(void); 17 | void I_TurnOffMusic(void); 18 | void I_TurnOnMusic(void); 19 | 20 | // MUSIC I/O 21 | // 22 | 23 | int I_RegisterSong(void *songdata); 24 | // called by anything that wants to register a song lump with the sound lib 25 | // calls Paul's function of the similar name to register music only. 26 | // note that the song data is the same for any sound card and is paul's 27 | // MUS format. Returns a handle which will be passed to all other music 28 | // functions. 29 | 30 | void I_UnregisterSong(int handle); 31 | // called by anything which is finished with a song and no longer needs 32 | // the sound library to be aware of it. All songs should be stopped 33 | // before calling this, but it will double check and stop it if necessary. 34 | 35 | void I_LoopSong(int handle); 36 | // called by anything that wishes to start music. 37 | // plays a song, and when the song is done, starts playing it again in 38 | // an endless loop. the start is faded in over three seconds. 39 | 40 | void I_FadeOutSong(int handle, int fotime); 41 | // called by anything that wishes to stop music. 42 | // fades out the song over milliseconds. 43 | 44 | void I_StopSong(int handle); 45 | // called by anything that wishes to stop music. 46 | // stops a song abruptly. 47 | 48 | // SFX I/O 49 | // 50 | 51 | void *I_GetSoundEffect (char *soundname); 52 | // called by routines which wish to play a sound effect at some later 53 | // time. Pass it the lump name of a sound effect WITHOUT the sfx 54 | // prefix. This means the maximum name length is 7 letters/digits. 55 | // The prefixes for different sound cards are 'S','M','A', and 'P'. 56 | // They refer to the card type. The routine will cache in the 57 | // appropriate sound effect when it is played. 58 | 59 | void I_UngetSoundEffect (void *soundset); 60 | // called by routines which wish to no longer use the sounds at all 61 | // frees up the associated structure. It stops any currently playing 62 | // sound effects. 63 | 64 | void I_StartSound (channel_t *c, int vol, int sep, int pitch, int priority); 65 | // Starts a sound in a particular sound channel 66 | 67 | void I_UpdateSoundParams(channel_t *c, int vol, int sep, int pitch); 68 | // Updates the volume, separation, and pitch of a sound channel 69 | 70 | void I_StopSound(channel_t *c); 71 | // Stops a sound channel 72 | 73 | int I_SoundIsPlaying(channel_t *c); 74 | // called by S_*()'s to see if a channel is still playing. Returns 0 75 | // if no longer playing, 1 if playing. 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /Hexen Source/MAKEFILE: -------------------------------------------------------------------------------- 1 | 2 | # -------------------------------------------------------------------------- 3 | # 4 | # WCC386 Options: 5 | # 6 | # 4r use 80486 timings and register argument passing 7 | # c compile only 8 | # d1 include line number debugging information 9 | # d2 include full sybolic debugging information 10 | # ei force enums to be of type int 11 | # j change char default from unsigned to signed 12 | # oa relax aliasing checking 13 | # od do not optimize 14 | # oe[=#] expand functions inline, # = quads (default 20) 15 | # oi use the inline library functions 16 | # om generate inline 80x87 code for math functions 17 | # ot optimize for time 18 | # ox maximum optimization 19 | # s remove stack overflow checks 20 | # zp1 align structures on bytes 21 | # zq use quiet mode 22 | # /i=dir add include directories 23 | # 24 | # -------------------------------------------------------------------------- 25 | 26 | LOCOBJS = & 27 | i_cdmus.obj & 28 | i_cyber.obj & 29 | i_ibm.obj & 30 | i_ibm_a.obj & 31 | i_sound.obj & 32 | linear.obj 33 | 34 | GLOBOBJS = & 35 | am_map.obj & 36 | a_action.obj & 37 | ct_chat.obj & 38 | d_net.obj & 39 | f_finale.obj & 40 | g_game.obj & 41 | h2_main.obj & 42 | info.obj & 43 | in_lude.obj & 44 | mn_menu.obj & 45 | m_misc.obj & 46 | p_acs.obj & 47 | p_anim.obj & 48 | p_ceilng.obj & 49 | p_doors.obj & 50 | p_enemy.obj & 51 | p_floor.obj & 52 | p_inter.obj & 53 | p_lights.obj & 54 | p_map.obj & 55 | p_maputl.obj & 56 | p_mobj.obj & 57 | p_plats.obj & 58 | p_pspr.obj & 59 | p_setup.obj & 60 | p_sight.obj & 61 | p_spec.obj & 62 | p_switch.obj & 63 | p_telept.obj & 64 | p_tick.obj & 65 | p_things.obj & 66 | p_user.obj & 67 | po_man.obj & 68 | r_bsp.obj & 69 | r_data.obj & 70 | r_draw.obj & 71 | r_main.obj & 72 | r_plane.obj & 73 | r_segs.obj & 74 | r_things.obj & 75 | sb_bar.obj & 76 | sc_man.obj & 77 | sn_sonix.obj & 78 | st_start.obj & 79 | sv_save.obj & 80 | sounds.obj & 81 | tables.obj & 82 | v_video.obj & 83 | w_wad.obj & 84 | z_zone.obj 85 | 86 | default: .SYMBOLIC 87 | @echo. 88 | @echo You must use M.BAT to build Hexen. 89 | @echo Type "M /?" for help. 90 | @echo. 91 | 92 | # 93 | # DEBUG Build: 94 | # 95 | # The EXTERNOPT macro should be set to /d2 96 | # 97 | # FINAL Build: 98 | # 99 | # The EXTERNOPT macro should be set to /dNORANGECHECKING 100 | # 101 | 102 | VERSION_ID = BCP 103 | 104 | VERSIONOPT = /dVER_ID="$(VERSION_ID)" 105 | 106 | CCOPTS = $(EXTERNOPT) $(VERSIONOPT) /omaxet /zp1 /4r /ei /j /zq /i=dmx 107 | 108 | hex.exe : $(LOCOBJS) $(GLOBOBJS) 109 | wlink @hex.lnk 110 | ncopy hex.exe striphex.exe 111 | wstrip striphex.exe 112 | 4gwbind 4gwpro.exe striphex.exe hexen.exe -V 113 | ncopy hex.map v_$(VERSION_ID).map 114 | prsucc 115 | 116 | .c.obj : 117 | wcc386 $(CCOPTS) $[* 118 | 119 | .asm.obj : 120 | tasm /mx $[* 121 | -------------------------------------------------------------------------------- /Hexen Source/T.BAT: -------------------------------------------------------------------------------- 1 | @REM Hexen startup batch file 2 | @echo off 3 | 4 | echo : 5 | call castoff 6 | echo : 7 | 8 | if "%1x"=="x" goto badargs 9 | 10 | set hticargs=-devmaps dev.txt -warp %1 11 | set hticwads=-file 12 | set hticnplay= 13 | 14 | :parseloop 15 | if "%2x"=="x" goto doneparse 16 | if "%2"=="m" goto nomonsters 17 | if "%2"=="M" goto nomonsters 18 | if "%2"=="s1" goto skill1 19 | if "%2"=="S1" goto skill1 20 | if "%2"=="s2" goto skill2 21 | if "%2"=="S2" goto skill2 22 | if "%2"=="s3" goto skill3 23 | if "%2"=="S3" goto skill3 24 | if "%2"=="s4" goto skill4 25 | if "%2"=="S4" goto skill4 26 | if "%2"=="s5" goto skill5 27 | if "%2"=="S5" goto skill5 28 | if "%2"=="n1" goto nplay1 29 | if "%2"=="N1" goto nplay1 30 | if "%2"=="n2" goto nplay2 31 | if "%2"=="N2" goto nplay2 32 | if "%2"=="n3" goto nplay3 33 | if "%2"=="N3" goto nplay3 34 | if "%2"=="n4" goto nplay4 35 | if "%2"=="N4" goto nplay4 36 | if "%2"=="p" goto altport 37 | if "%2"=="P" goto altport 38 | if "%2"=="c0" goto class0 39 | if "%2"=="C0" goto class0 40 | if "%2"=="c1" goto class1 41 | if "%2"=="C1" goto class1 42 | if "%2"=="c2" goto class2 43 | if "%2"=="C2" goto class2 44 | if "%2"=="r" goto randclass 45 | if "%2"=="R" goto randclass 46 | goto addwad 47 | 48 | :nomonsters 49 | set hticargs=%hticargs% -nomonsters 50 | shift 51 | goto parseloop 52 | 53 | :skill1 54 | set hticargs=%hticargs% -skill 1 55 | shift 56 | goto parseloop 57 | 58 | :skill2 59 | set hticargs=%hticargs% -skill 2 60 | shift 61 | goto parseloop 62 | 63 | :skill3 64 | set hticargs=%hticargs% -skill 3 65 | shift 66 | goto parseloop 67 | 68 | :skill4 69 | set hticargs=%hticargs% -skill 4 70 | shift 71 | goto parseloop 72 | 73 | :skill5 74 | set hticargs=%hticargs% -skill 5 75 | shift 76 | goto parseloop 77 | 78 | :nplay1 79 | set hticnplay=1 80 | shift 81 | goto parseloop 82 | 83 | :nplay2 84 | set hticnplay=2 85 | shift 86 | goto parseloop 87 | 88 | :nplay3 89 | set hticnplay=3 90 | shift 91 | goto parseloop 92 | 93 | :nplay4 94 | set hticnplay=4 95 | shift 96 | goto parseloop 97 | 98 | :altport 99 | set hticargs=%hticargs% -port 2 100 | shift 101 | goto parseloop 102 | 103 | :class0 104 | set hticargs=%hticargs% -class 0 105 | shift 106 | goto parseloop 107 | 108 | :class1 109 | set hticargs=%hticargs% -class 1 110 | shift 111 | goto parseloop 112 | 113 | :class2 114 | set hticargs=%hticargs% -class 2 115 | shift 116 | goto parseloop 117 | 118 | :randclass 119 | set hticargs=%hticargs% -randclass 120 | shift 121 | goto parseloop 122 | 123 | :addwad 124 | set hticwads=%hticwads% %3.wad 125 | shift 126 | goto parseloop 127 | 128 | :badargs 129 | echo HEXEN STARTUP 130 | echo Usage: H map [s?] [m] [n?] [p] [wadfile [wadfile ...] ] 131 | echo. 132 | echo [s?] = skill (1-5) 133 | echo [m] = no monsters 134 | echo [n?] = net play (1-4) 135 | echo [p] = use alternate port setting 136 | echo [r] = random player class 137 | echo [wadfile] = add external wadfile (.WAD is implicit) 138 | echo. 139 | goto end 140 | 141 | :doneparse 142 | if "%hticwads%" == "-file" goto startgame 143 | set hticargs=%hticargs% %hticwads% 144 | :startgame 145 | if "%hticnplay%x" == "x" goto normalplay 146 | echo -nodes %hticnplay% -deathmatch %hticargs% 147 | hexipx -nodes %hticnplay% -deathmatch %hticargs% 148 | goto end 149 | 150 | :normalplay 151 | echo %hticargs% 152 | hexen %hticargs% 153 | goto end 154 | 155 | :end 156 | set hticargs= 157 | set hticwads= 158 | set hticnplay= 159 | 160 | echo : 161 | @call caston 162 | echo : 163 | -------------------------------------------------------------------------------- /Hexen Source/AM_DATA.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** am_data.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: am_data.h,v $ 7 | //** $Revision: 1.2 $ 8 | //** $Date: 96/01/06 18:37:22 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #ifndef __AMDATA_H__ 14 | #define __AMDATA_H__ 15 | 16 | #pragma once 17 | 18 | // a line drawing of the player pointing right, starting from the middle. 19 | 20 | #define R ((8*PLAYERRADIUS)/7) 21 | 22 | mline_t player_arrow[] = { 23 | { { -R+R/4, 0 }, { 0, 0} }, // center line. 24 | { { -R+R/4, R/8 }, { R, 0} }, // blade 25 | { { -R+R/4, -R/8 }, { R, 0 } }, 26 | { { -R+R/4, -R/4 }, { -R+R/4, R/4 } }, // crosspiece 27 | { { -R+R/8, -R/4 }, { -R+R/8, R/4 } }, 28 | { { -R+R/8, -R/4 }, { -R+R/4, -R/4} }, //crosspiece connectors 29 | { { -R+R/8, R/4 }, { -R+R/4, R/4} }, 30 | { { -R-R/4, R/8 }, { -R-R/4, -R/8 } }, //pommel 31 | { { -R-R/4, R/8 }, { -R+R/8, R/8 } }, 32 | { { -R-R/4, -R/8}, { -R+R/8, -R/8 } } 33 | }; 34 | 35 | /* 36 | mline_t keysquare[] = { 37 | { { 0, 0 }, { R/4, -R/2 } }, 38 | { { R/4, -R/2 }, { R/2, -R/2 } }, 39 | { { R/2, -R/2 }, { R/2, R/2 } }, 40 | { { R/2, R/2 }, { R/4, R/2 } }, 41 | { { R/4, R/2 }, { 0, 0 } }, // handle part type thing 42 | { { 0, 0 }, { -R, 0 } }, // stem 43 | { { -R, 0 }, { -R, -R/2 } }, // end lockpick part 44 | { { -3*R/4, 0 }, { -3*R/4, -R/4 } } 45 | }; 46 | */ 47 | 48 | /*mline_t player_arrow[] = { 49 | { { -R+R/8, 0 }, { R, 0 } }, // ----- 50 | { { R, 0 }, { R-R/2, R/4 } }, // -----> 51 | { { R, 0 }, { R-R/2, -R/4 } }, 52 | { { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >----> 53 | { { -R+R/8, 0 }, { -R-R/8, -R/4 } }, 54 | { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>---> 55 | { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } 56 | }; 57 | */ 58 | #undef R 59 | #define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) 60 | #define NUMKEYSQUARELINES (sizeof(keysquare)/sizeof(mline_t)) 61 | 62 | /* 63 | #define R ((8*PLAYERRADIUS)/7) 64 | mline_t cheat_player_arrow[] = { 65 | { { -R+R/8, 0 }, { R, 0 } }, // ----- 66 | { { R, 0 }, { R-R/2, R/6 } }, // -----> 67 | { { R, 0 }, { R-R/2, -R/6 } }, 68 | { { -R+R/8, 0 }, { -R-R/8, R/6 } }, // >-----> 69 | { { -R+R/8, 0 }, { -R-R/8, -R/6 } }, 70 | { { -R+3*R/8, 0 }, { -R+R/8, R/6 } }, // >>-----> 71 | { { -R+3*R/8, 0 }, { -R+R/8, -R/6 } }, 72 | { { -R/2, 0 }, { -R/2, -R/6 } }, // >>-d---> 73 | { { -R/2, -R/6 }, { -R/2+R/6, -R/6 } }, 74 | { { -R/2+R/6, -R/6 }, { -R/2+R/6, R/4 } }, 75 | { { -R/6, 0 }, { -R/6, -R/6 } }, // >>-dd--> 76 | { { -R/6, -R/6 }, { 0, -R/6 } }, 77 | { { 0, -R/6 }, { 0, R/4 } }, 78 | { { R/6, R/4 }, { R/6, -R/7 } }, // >>-ddt-> 79 | { { R/6, -R/7 }, { R/6+R/32, -R/7-R/32 } }, 80 | { { R/6+R/32, -R/7-R/32 }, { R/6+R/10, -R/7 } } 81 | }; 82 | #undef R 83 | #define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) 84 | */ 85 | 86 | 87 | /* 88 | #define R (FRACUNIT) 89 | mline_t triangle_guy[] = { 90 | { { -.867*R, -.5*R }, { .867*R, -.5*R } }, 91 | { { .867*R, -.5*R } , { 0, R } }, 92 | { { 0, R }, { -.867*R, -.5*R } } 93 | }; 94 | #undef R 95 | #define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) 96 | */ 97 | 98 | #define R (FRACUNIT) 99 | mline_t thintriangle_guy[] = { 100 | { { -.5*R, -.7*R }, { R, 0 } }, 101 | { { R, 0 }, { -.5*R, .7*R } }, 102 | { { -.5*R, .7*R }, { -.5*R, -.7*R } } 103 | }; 104 | #undef R 105 | #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /Hexen Source/P_TICK.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_tick.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_tick.c,v $ 7 | //** $Revision: 1.5 $ 8 | //** $Date: 95/10/08 21:53:00 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | // HEADER FILES ------------------------------------------------------------ 14 | 15 | #include "h2def.h" 16 | #include "p_local.h" 17 | 18 | // MACROS ------------------------------------------------------------------ 19 | 20 | // TYPES ------------------------------------------------------------------- 21 | 22 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 23 | 24 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 25 | 26 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 27 | 28 | static void RunThinkers(void); 29 | 30 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 31 | 32 | // PUBLIC DATA DEFINITIONS ------------------------------------------------- 33 | 34 | int leveltime; 35 | int TimerGame; 36 | thinker_t thinkercap; // The head and tail of the thinker list 37 | 38 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 39 | 40 | // CODE -------------------------------------------------------------------- 41 | 42 | //========================================================================== 43 | // 44 | // P_Ticker 45 | // 46 | //========================================================================== 47 | 48 | void P_Ticker(void) 49 | { 50 | int i; 51 | 52 | if(paused) 53 | { 54 | return; 55 | } 56 | for(i = 0; i < MAXPLAYERS; i++) 57 | { 58 | if(playeringame[i]) 59 | { 60 | P_PlayerThink(&players[i]); 61 | } 62 | } 63 | if(TimerGame) 64 | { 65 | if(!--TimerGame) 66 | { 67 | G_Completed(P_TranslateMap(P_GetMapNextMap(gamemap)), 0); 68 | } 69 | } 70 | RunThinkers(); 71 | P_UpdateSpecials(); 72 | P_AnimateSurfaces(); 73 | leveltime++; 74 | } 75 | 76 | //========================================================================== 77 | // 78 | // RunThinkers 79 | // 80 | //========================================================================== 81 | 82 | static void RunThinkers(void) 83 | { 84 | thinker_t *currentthinker; 85 | 86 | currentthinker = thinkercap.next; 87 | while(currentthinker != &thinkercap) 88 | { 89 | if(currentthinker->function == (think_t)-1) 90 | { // Time to remove it 91 | currentthinker->next->prev = currentthinker->prev; 92 | currentthinker->prev->next = currentthinker->next; 93 | Z_Free(currentthinker); 94 | } 95 | else if(currentthinker->function) 96 | { 97 | currentthinker->function(currentthinker); 98 | } 99 | currentthinker = currentthinker->next; 100 | } 101 | } 102 | 103 | //========================================================================== 104 | // 105 | // P_InitThinkers 106 | // 107 | //========================================================================== 108 | 109 | void P_InitThinkers(void) 110 | { 111 | thinkercap.prev = thinkercap.next = &thinkercap; 112 | } 113 | 114 | //========================================================================== 115 | // 116 | // P_AddThinker 117 | // 118 | // Adds a new thinker at the end of the list. 119 | // 120 | //========================================================================== 121 | 122 | void P_AddThinker(thinker_t *thinker) 123 | { 124 | thinkercap.prev->next = thinker; 125 | thinker->next = &thinkercap; 126 | thinker->prev = thinkercap.prev; 127 | thinkercap.prev = thinker; 128 | } 129 | 130 | //========================================================================== 131 | // 132 | // P_RemoveThinker 133 | // 134 | // Deallocation is lazy -- it will not actually be freed until its 135 | // thinking turn comes up. 136 | // 137 | //========================================================================== 138 | 139 | void P_RemoveThinker(thinker_t *thinker) 140 | { 141 | thinker->function = (think_t)-1; 142 | } 143 | -------------------------------------------------------------------------------- /Hexen Source/AM_MAP.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** am_map.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: am_map.h,v $ 7 | //** $Revision: 1.3 $ 8 | //** $Date: 95/12/31 19:47:21 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #ifndef __AMMAP_H__ 14 | #define __AMMAP_H__ 15 | 16 | #pragma once 17 | 18 | // For use if I do walls with outsides/insides 19 | #define REDS 12*8 20 | #define REDRANGE 1//16 21 | #define BLUES (256-4*16+8) 22 | #define BLUERANGE 1//8 23 | #define GREENS (33*8) 24 | #define GREENRANGE 1//16 25 | #define GRAYS (5*8) 26 | #define GRAYSRANGE 1//16 27 | #define BROWNS (14*8) 28 | #define BROWNRANGE 1//16 29 | #define YELLOWS 10*8 30 | #define YELLOWRANGE 1 31 | #define BLACK 0 32 | #define WHITE 4*8 33 | #define PARCH 13*8-1 34 | #define BLOODRED 177 35 | #define BLUEKEY 157 36 | #define YELLOWKEY 137 37 | #define GREENKEY 198 38 | 39 | // Automap colors 40 | 41 | #define AM_PLR1_COLOR 157 // Blue 42 | #define AM_PLR2_COLOR 177 // Red 43 | #define AM_PLR3_COLOR 137 // Yellow 44 | #define AM_PLR4_COLOR 198 // Green 45 | #define AM_PLR5_COLOR 215 // Jade 46 | #define AM_PLR6_COLOR 32 // White 47 | #define AM_PLR7_COLOR 106 // Hazel 48 | #define AM_PLR8_COLOR 234 // Purple 49 | 50 | #define BACKGROUND PARCH 51 | #define YOURCOLORS WHITE 52 | #define YOURRANGE 0 53 | #define WALLCOLORS REDS 54 | #define WALLRANGE REDRANGE 55 | #define TSWALLCOLORS GRAYS 56 | #define TSWALLRANGE GRAYSRANGE 57 | #define FDWALLCOLORS BROWNS 58 | #define FDWALLRANGE BROWNRANGE 59 | #define CDWALLCOLORS YELLOWS 60 | #define CDWALLRANGE YELLOWRANGE 61 | #define THINGCOLORS GREENS 62 | #define THINGRANGE GREENRANGE 63 | #define SECRETWALLCOLORS WALLCOLORS 64 | #define SECRETWALLRANGE WALLRANGE 65 | #define GRIDCOLORS (GRAYS + GRAYSRANGE/2) 66 | #define GRIDRANGE 0 67 | #define XHAIRCOLORS GRAYS 68 | 69 | // drawing stuff 70 | #define FB 0 71 | 72 | #define KEY_TAB 9 73 | #define AM_PANDOWNKEY KEY_DOWNARROW 74 | #define AM_PANUPKEY KEY_UPARROW 75 | #define AM_PANRIGHTKEY KEY_RIGHTARROW 76 | #define AM_PANLEFTKEY KEY_LEFTARROW 77 | //#define AM_PANDOWNKEY SC_DOWNARROW 78 | //#define AM_PANUPKEY SC_UPARROW 79 | //#define AM_PANRIGHTKEY SC_RIGHTARROW 80 | //#define AM_PANLEFTKEY SC_LEFTARROW 81 | 82 | #define AM_ZOOMINKEY '=' 83 | //#define AM_ZOOMINKEY 13 84 | //#define AM_ZOOMOUTKEY 12 85 | #define AM_ZOOMOUTKEY '-' 86 | #define AM_STARTKEY KEY_TAB 87 | #define AM_ENDKEY KEY_TAB 88 | #define AM_GOBIGKEY '0' 89 | //#define AM_GOBIGKEY 11 90 | //#define AM_FOLLOWKEY 33 91 | //#define AM_GRIDKEY 34 92 | #define AM_FOLLOWKEY 'f' 93 | #define AM_GRIDKEY 'g' 94 | 95 | #define AM_NUMMARKPOINTS 10 96 | 97 | #define AM_MSGHEADER (('a'<<24)+('m'<<16)) 98 | #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) 99 | #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) 100 | 101 | #define INITSCALEMTOF (.2*FRACUNIT) // scale on entry 102 | // how much the automap moves window per tic in frame-buffer coordinates 103 | #define F_PANINC 4 // moves 140 pixels in 1 second 104 | // how much zoom-in per tic 105 | #define M_ZOOMIN ((int) (1.02*FRACUNIT)) // goes to 2x in 1 second 106 | // how much zoom-out per tic 107 | #define M_ZOOMOUT ((int) (FRACUNIT/1.02)) // pulls out to 0.5x in 1 second 108 | 109 | // translates between frame-buffer and map distances 110 | #define FTOM(x) FixedMul(((x)<<16),scale_ftom) 111 | #define MTOF(x) (FixedMul((x),scale_mtof)>>16) 112 | // translates between frame-buffer and map coordinates 113 | #define CXMTOF(x) (f_x + MTOF((x)-m_x)) 114 | #define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) 115 | 116 | // the following is crap 117 | #define LINE_NEVERSEE ML_DONTDRAW 118 | 119 | typedef struct 120 | { 121 | int x, y; 122 | } fpoint_t; 123 | 124 | typedef struct 125 | { 126 | fpoint_t a, b; 127 | } fline_t; 128 | 129 | typedef vertex_t mpoint_t; 130 | 131 | typedef struct 132 | { 133 | mpoint_t a, b; 134 | } mline_t; 135 | 136 | typedef struct 137 | { 138 | fixed_t slp, islp; 139 | } islope_t; 140 | 141 | // extern int f_x, f_y, f_w, f_h; 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /Hexen Source/P_SWITCH.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_switch.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_switch.c,v $ 7 | //** $Revision: 1.8 $ 8 | //** $Date: 95/09/05 13:58:59 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | #include "soundst.h" 16 | 17 | //================================================================== 18 | // 19 | // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE 20 | // 21 | //================================================================== 22 | switchlist_t alphSwitchList[] = 23 | { 24 | { "SW_1_UP", "SW_1_DN", SFX_SWITCH1 }, 25 | { "SW_2_UP", "SW_2_DN", SFX_SWITCH1 }, 26 | { "VALVE1", "VALVE2", SFX_VALVE_TURN }, 27 | { "SW51_OFF", "SW51_ON", SFX_SWITCH2 }, 28 | { "SW52_OFF", "SW52_ON", SFX_SWITCH2 }, 29 | { "SW53_UP", "SW53_DN", SFX_ROPE_PULL }, 30 | { "PUZZLE5", "PUZZLE9", SFX_SWITCH1 }, 31 | { "PUZZLE6", "PUZZLE10", SFX_SWITCH1 }, 32 | { "PUZZLE7", "PUZZLE11", SFX_SWITCH1 }, 33 | { "PUZZLE8", "PUZZLE12", SFX_SWITCH1 }, 34 | {"\0", "\0", 0} 35 | }; 36 | 37 | int switchlist[MAXSWITCHES * 2]; 38 | int numswitches; 39 | button_t buttonlist[MAXBUTTONS]; 40 | 41 | /* 42 | =============== 43 | = 44 | = P_InitSwitchList 45 | = 46 | = Only called at game initialization 47 | = 48 | =============== 49 | */ 50 | 51 | void P_InitSwitchList(void) 52 | { 53 | int i; 54 | int index; 55 | 56 | for (index = 0, i = 0; i < MAXSWITCHES; i++) 57 | { 58 | if(!alphSwitchList[i].soundID) 59 | { 60 | numswitches = index/2; 61 | switchlist[index] = -1; 62 | break; 63 | } 64 | switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); 65 | switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2); 66 | } 67 | } 68 | 69 | //================================================================== 70 | // 71 | // Start a button counting down till it turns off. 72 | // 73 | //================================================================== 74 | void P_StartButton(line_t *line,bwhere_e w,int texture,int time) 75 | { 76 | int i; 77 | 78 | for (i = 0;i < MAXBUTTONS;i++) 79 | { 80 | if (!buttonlist[i].btimer) 81 | { 82 | buttonlist[i].line = line; 83 | buttonlist[i].where = w; 84 | buttonlist[i].btexture = texture; 85 | buttonlist[i].btimer = time; 86 | buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; 87 | return; 88 | } 89 | } 90 | I_Error("P_StartButton: no button slots left!"); 91 | } 92 | 93 | //================================================================== 94 | // 95 | // Function that changes wall texture. 96 | // Tell it if switch is ok to use again (1=yes, it's a button). 97 | // 98 | //================================================================== 99 | void P_ChangeSwitchTexture(line_t *line, int useAgain) 100 | { 101 | int texTop; 102 | int texMid; 103 | int texBot; 104 | int i; 105 | 106 | texTop = sides[line->sidenum[0]].toptexture; 107 | texMid = sides[line->sidenum[0]].midtexture; 108 | texBot = sides[line->sidenum[0]].bottomtexture; 109 | 110 | for (i = 0; i < numswitches*2; i++) 111 | { 112 | if (switchlist[i] == texTop) 113 | { 114 | S_StartSound((mobj_t *)&line->frontsector->soundorg, 115 | alphSwitchList[i/2].soundID); 116 | sides[line->sidenum[0]].toptexture = switchlist[i^1]; 117 | if(useAgain) 118 | { 119 | P_StartButton(line, SWTCH_TOP, switchlist[i], BUTTONTIME); 120 | } 121 | return; 122 | } 123 | else if (switchlist[i] == texMid) 124 | { 125 | S_StartSound((mobj_t *)&line->frontsector->soundorg, 126 | alphSwitchList[i/2].soundID); 127 | sides[line->sidenum[0]].midtexture = switchlist[i^1]; 128 | if(useAgain) 129 | { 130 | P_StartButton(line, SWTCH_MIDDLE, switchlist[i], BUTTONTIME); 131 | } 132 | return; 133 | } 134 | else if (switchlist[i] == texBot) 135 | { 136 | S_StartSound((mobj_t *)&line->frontsector->soundorg, 137 | alphSwitchList[i/2].soundID); 138 | sides[line->sidenum[0]].bottomtexture = switchlist[i^1]; 139 | if(useAgain) 140 | { 141 | P_StartButton(line, SWTCH_BOTTOM, switchlist[i], BUTTONTIME); 142 | } 143 | return; 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Hexen Source/P_TELEPT.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_telept.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_telept.c,v $ 7 | //** $Revision: 1.13 $ 8 | //** $Date: 95/10/08 04:23:24 $ 9 | //** $Author: paul $ 10 | //** 11 | //************************************************************************** 12 | 13 | // HEADER FILES ------------------------------------------------------------ 14 | 15 | #include "h2def.h" 16 | #include "p_local.h" 17 | #include "soundst.h" 18 | 19 | // MACROS ------------------------------------------------------------------ 20 | 21 | // TYPES ------------------------------------------------------------------- 22 | 23 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 24 | 25 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 26 | 27 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 28 | 29 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 30 | 31 | // PUBLIC DATA DEFINITIONS ------------------------------------------------- 32 | 33 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 34 | 35 | // CODE -------------------------------------------------------------------- 36 | 37 | //========================================================================== 38 | // 39 | // P_Teleport 40 | // 41 | //========================================================================== 42 | 43 | boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle, 44 | boolean useFog) 45 | { 46 | fixed_t oldx; 47 | fixed_t oldy; 48 | fixed_t oldz; 49 | fixed_t aboveFloor; 50 | fixed_t fogDelta; 51 | player_t *player; 52 | unsigned an; 53 | mobj_t *fog; 54 | 55 | oldx = thing->x; 56 | oldy = thing->y; 57 | oldz = thing->z; 58 | aboveFloor = thing->z-thing->floorz; 59 | if(!P_TeleportMove(thing, x, y)) 60 | { 61 | return false; 62 | } 63 | if(thing->player) 64 | { 65 | player = thing->player; 66 | if(player->powers[pw_flight] && aboveFloor) 67 | { 68 | thing->z = thing->floorz+aboveFloor; 69 | if(thing->z+thing->height > thing->ceilingz) 70 | { 71 | thing->z = thing->ceilingz-thing->height; 72 | } 73 | player->viewz = thing->z+player->viewheight; 74 | } 75 | else 76 | { 77 | thing->z = thing->floorz; 78 | player->viewz = thing->z+player->viewheight; 79 | if(useFog) 80 | { 81 | player->lookdir = 0; 82 | } 83 | } 84 | } 85 | else if(thing->flags&MF_MISSILE) 86 | { 87 | thing->z = thing->floorz+aboveFloor; 88 | if(thing->z+thing->height > thing->ceilingz) 89 | { 90 | thing->z = thing->ceilingz-thing->height; 91 | } 92 | } 93 | else 94 | { 95 | thing->z = thing->floorz; 96 | } 97 | // Spawn teleport fog at source and destination 98 | if(useFog) 99 | { 100 | fogDelta = thing->flags&MF_MISSILE ? 0 : TELEFOGHEIGHT; 101 | fog = P_SpawnMobj(oldx, oldy, oldz+fogDelta, MT_TFOG); 102 | S_StartSound(fog, SFX_TELEPORT); 103 | an = angle>>ANGLETOFINESHIFT; 104 | fog = P_SpawnMobj(x+20*finecosine[an], 105 | y+20*finesine[an], thing->z+fogDelta, MT_TFOG); 106 | S_StartSound(fog, SFX_TELEPORT); 107 | if(thing->player && !thing->player->powers[pw_speed]) 108 | { // Freeze player for about .5 sec 109 | thing->reactiontime = 18; 110 | } 111 | thing->angle = angle; 112 | } 113 | if(thing->flags2&MF2_FLOORCLIP) 114 | { 115 | if(thing->z == thing->subsector->sector->floorheight 116 | && P_GetThingFloorType(thing) > FLOOR_SOLID) 117 | { 118 | thing->floorclip = 10*FRACUNIT; 119 | } 120 | else 121 | { 122 | thing->floorclip = 0; 123 | } 124 | } 125 | if(thing->flags&MF_MISSILE) 126 | { 127 | angle >>= ANGLETOFINESHIFT; 128 | thing->momx = FixedMul(thing->info->speed, finecosine[angle]); 129 | thing->momy = FixedMul(thing->info->speed, finesine[angle]); 130 | } 131 | else if(useFog) // no fog doesn't alter the player's momentums 132 | { 133 | thing->momx = thing->momy = thing->momz = 0; 134 | } 135 | return true; 136 | } 137 | 138 | //========================================================================== 139 | // 140 | // EV_Teleport 141 | // 142 | //========================================================================== 143 | 144 | boolean EV_Teleport(int tid, mobj_t *thing, boolean fog) 145 | { 146 | int i; 147 | int count; 148 | mobj_t *mo; 149 | int searcher; 150 | 151 | if(!thing) 152 | { // Teleport function called with an invalid mobj 153 | return false; 154 | } 155 | if(thing->flags2&MF2_NOTELEPORT) 156 | { 157 | return false; 158 | } 159 | count = 0; 160 | searcher = -1; 161 | while(P_FindMobjFromTID(tid, &searcher) != NULL) 162 | { 163 | count++; 164 | } 165 | if(count == 0) 166 | { 167 | return false; 168 | } 169 | count = 1+(P_Random()%count); 170 | searcher = -1; 171 | for(i = 0; i < count; i++) 172 | { 173 | mo = P_FindMobjFromTID(tid, &searcher); 174 | } 175 | if (!mo) I_Error("Can't find teleport mapspot\n"); 176 | return P_Teleport(thing, mo->x, mo->y, mo->angle, fog); 177 | } 178 | -------------------------------------------------------------------------------- /Hexen Source/XDDEFS.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** xddefs.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: xddefs.h,v $ 7 | //** $Revision: 1.4 $ 8 | //** $Date: 95/08/11 10:22:08 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #ifndef __XDDEFS__ 14 | #define __XDDEFS__ 15 | 16 | #ifndef __BYTEBOOL__ 17 | #define __BYTEBOOL__ 18 | typedef enum {false, true} boolean; 19 | typedef unsigned char byte; 20 | #endif 21 | 22 | //-------------------------------------------------------------------------- 23 | // 24 | // Map level types 25 | // 26 | //-------------------------------------------------------------------------- 27 | 28 | // lump order in a map wad 29 | enum 30 | { 31 | ML_LABEL, 32 | ML_THINGS, 33 | ML_LINEDEFS, 34 | ML_SIDEDEFS, 35 | ML_VERTEXES, 36 | ML_SEGS, 37 | ML_SSECTORS, 38 | ML_NODES, 39 | ML_SECTORS, 40 | ML_REJECT, 41 | ML_BLOCKMAP, 42 | ML_BEHAVIOR 43 | }; 44 | 45 | typedef struct 46 | { 47 | short x; 48 | short y; 49 | } mapvertex_t; 50 | 51 | typedef struct 52 | { 53 | short textureoffset; 54 | short rowoffset; 55 | char toptexture[8]; 56 | char bottomtexture[8]; 57 | char midtexture[8]; 58 | short sector; // on viewer's side 59 | } mapsidedef_t; 60 | 61 | typedef struct 62 | { 63 | short v1; 64 | short v2; 65 | short flags; 66 | byte special; 67 | byte arg1; 68 | byte arg2; 69 | byte arg3; 70 | byte arg4; 71 | byte arg5; 72 | short sidenum[2]; // sidenum[1] will be -1 if one sided 73 | } maplinedef_t; 74 | 75 | #define ML_BLOCKING 0x0001 76 | #define ML_BLOCKMONSTERS 0x0002 77 | #define ML_TWOSIDED 0x0004 78 | #define ML_DONTPEGTOP 0x0008 79 | #define ML_DONTPEGBOTTOM 0x0010 80 | #define ML_SECRET 0x0020 // don't map as two sided: IT'S A SECRET! 81 | #define ML_SOUNDBLOCK 0x0040 // don't let sound cross two of these 82 | #define ML_DONTDRAW 0x0080 // don't draw on the automap 83 | #define ML_MAPPED 0x0100 // set if already drawn in automap 84 | #define ML_REPEAT_SPECIAL 0x0200 // special is repeatable 85 | #define ML_SPAC_SHIFT 10 86 | #define ML_SPAC_MASK 0x1c00 87 | #define GET_SPAC(flags) ((flags&ML_SPAC_MASK)>>ML_SPAC_SHIFT) 88 | 89 | // Special activation types 90 | #define SPAC_CROSS 0 // when player crosses line 91 | #define SPAC_USE 1 // when player uses line 92 | #define SPAC_MCROSS 2 // when monster crosses line 93 | #define SPAC_IMPACT 3 // when projectile hits line 94 | #define SPAC_PUSH 4 // when player/monster pushes line 95 | #define SPAC_PCROSS 5 // when projectile crosses line 96 | 97 | typedef struct 98 | { 99 | short floorheight; 100 | short ceilingheight; 101 | char floorpic[8]; 102 | char ceilingpic[8]; 103 | short lightlevel; 104 | short special; 105 | short tag; 106 | } mapsector_t; 107 | 108 | typedef struct 109 | { 110 | short numsegs; 111 | short firstseg; // segs are stored sequentially 112 | } mapsubsector_t; 113 | 114 | typedef struct 115 | { 116 | short v1; 117 | short v2; 118 | short angle; 119 | short linedef; 120 | short side; 121 | short offset; 122 | } mapseg_t; 123 | 124 | enum 125 | { // bbox coordinates 126 | BOXTOP, 127 | BOXBOTTOM, 128 | BOXLEFT, 129 | BOXRIGHT 130 | }; 131 | 132 | #define NF_SUBSECTOR 0x8000 133 | typedef struct 134 | { 135 | short x,y,dx,dy; // partition line 136 | short bbox[2][4]; // bounding box for each child 137 | unsigned short children[2]; // if NF_SUBSECTOR its a subsector 138 | } mapnode_t; 139 | 140 | typedef struct 141 | { 142 | short tid; 143 | short x; 144 | short y; 145 | short height; 146 | short angle; 147 | short type; 148 | short options; 149 | byte special; 150 | byte arg1; 151 | byte arg2; 152 | byte arg3; 153 | byte arg4; 154 | byte arg5; 155 | } mapthing_t; 156 | 157 | #define MTF_EASY 1 158 | #define MTF_NORMAL 2 159 | #define MTF_HARD 4 160 | #define MTF_AMBUSH 8 161 | #define MTF_DORMANT 16 162 | #define MTF_FIGHTER 32 163 | #define MTF_CLERIC 64 164 | #define MTF_MAGE 128 165 | #define MTF_GSINGLE 256 166 | #define MTF_GCOOP 512 167 | #define MTF_GDEATHMATCH 1024 168 | 169 | //-------------------------------------------------------------------------- 170 | // 171 | // Texture definition 172 | // 173 | //-------------------------------------------------------------------------- 174 | 175 | typedef struct 176 | { 177 | short originx; 178 | short originy; 179 | short patch; 180 | short stepdir; 181 | short colormap; 182 | } mappatch_t; 183 | 184 | typedef struct 185 | { 186 | char name[8]; 187 | boolean masked; 188 | short width; 189 | short height; 190 | void **columndirectory; // OBSOLETE 191 | short patchcount; 192 | mappatch_t patches[1]; 193 | } maptexture_t; 194 | 195 | //-------------------------------------------------------------------------- 196 | // 197 | // Graphics 198 | // 199 | //-------------------------------------------------------------------------- 200 | 201 | // posts are runs of non masked source pixels 202 | typedef struct 203 | { 204 | byte topdelta; // -1 is the last post in a column 205 | byte length; 206 | // length data bytes follows 207 | } post_t; 208 | 209 | // column_t is a list of 0 or more post_t, (byte)-1 terminated 210 | typedef post_t column_t; 211 | 212 | // a patch holds one or more columns 213 | // patches are used for sprites and all masked pictures 214 | typedef struct 215 | { 216 | short width; // bounding box size 217 | short height; 218 | short leftoffset; // pixels to the left of origin 219 | short topoffset; // pixels below the origin 220 | int columnofs[8]; // only [width] used 221 | // the [0] is &columnofs[width] 222 | } patch_t; 223 | 224 | // a pic is an unmasked block of pixels 225 | typedef struct 226 | { 227 | byte width,height; 228 | byte data; 229 | } pic_t; 230 | 231 | #endif // __XDDEFS__ 232 | -------------------------------------------------------------------------------- /Hexen Source/WADLINK.WL: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ; WAD NAME 10 | 11 | $WADNAME HEXEN 12 | 13 | ; VERSION ID 14 | 15 | \data\xxtic.lmp 16 | 17 | ; STARTUP SCREEN 18 | 19 | \art\startup\startup.lmp 20 | 21 | ; PALETTES AND COLOR MAPS 22 | 23 | \art\palette\playpal.lmp 24 | \art\palette\colormap.lmp 25 | \art\palette\fogmap.lmp 26 | \art\palette\tinttab.lmp 27 | 28 | ; TRANSLATION TABLES 29 | 30 | $shootwad \art\palette\trans-8.wad 31 | 32 | ; DEMOS 33 | 34 | \data\demos\demo1.lmp 35 | \data\demos\demo2.lmp 36 | \data\demos\demo3.lmp 37 | 38 | ; SCREENS 39 | 40 | $shootwad \art\screens\screens.wad 41 | ; \data\txtscrn2\endtext.bin 42 | 43 | ; LEVEL MAPS 44 | 45 | 46 | 47 | ; CLUSTER CONCLUSION MESSAGES 48 | 49 | \data\text\clus1msg.txt 50 | \data\text\clus2msg.txt 51 | \data\text\clus3msg.txt 52 | \data\text\clus4msg.txt 53 | 54 | ; WIN GAME MESSAGES 55 | 56 | \data\text\win1msg.txt 57 | \data\text\win2msg.txt 58 | \data\text\win3msg.txt 59 | 60 | ; TEXTURE INFO AND PATCH NAMES 61 | 62 | \maps\pnames.lmp 63 | \maps\texture1.lmp 64 | 65 | \maps\texture2.lmp 66 | 67 | 68 | ; SCRIPTS 69 | 70 | \data\scripts\animdefs.txt 71 | \data\scripts\mapinfo.txt 72 | \data\scripts\sndinfo.txt 73 | \data\scripts\sndseq.txt 74 | 75 | ; AUTOMAP 76 | 77 | $shootwad \art\automap\automap 78 | 79 | ; STATUS BAR 80 | 81 | 82 | $shootwad \art\statbar\statbar 83 | 84 | 85 | ; MENU 86 | 87 | $shootwad \art\menu\menu 88 | 89 | ; FONTS 90 | 91 | $label fonta_s 92 | $shootwad \art\fonts\fonta 93 | $label fonta_e 94 | $label fontay_s 95 | $shootwad \art\fonts\fonta_y 96 | $label fontay_e 97 | $label fontb_s 98 | $shootwad \art\fonts\fontb 99 | $label fontb_e 100 | 101 | ; START SPRITES 102 | 103 | $label s_start 104 | 105 | ; Fighter weapons 106 | $shootwad \art\weapons\fighter\punch\punch.wad 107 | $shootwad \art\weapons\fighter\axe\axe.wad 108 | $shootwad \art\weapons\fighter\hammer\hammer.wad 109 | $shootwad \art\weapons\fighter\sword\sword.wad 110 | 111 | ; Cleric weapons 112 | $shootwad \art\weapons\cleric\mace\mace.wad 113 | $shootwad \art\weapons\cleric\sstaff\sstaff.wad 114 | $shootwad \art\weapons\cleric\flame\flame.wad 115 | $shootwad \art\weapons\cleric\holy\holy.wad 116 | 117 | ; Mage weapons 118 | $shootwad \art\weapons\mage\wand\wand.wad 119 | $shootwad \art\weapons\mage\cone\cone.wad 120 | $shootwad \art\weapons\mage\lightng\lightng.wad 121 | $shootwad \art\weapons\mage\staff\mstaff.wad 122 | 123 | ; Morphed player weapons 124 | ; $shootwad \art\weapons\beak\beak.wad 125 | $shootwad \art\weapons\snout\snout.wad 126 | 127 | 128 | ; PLAYER 129 | 130 | $shootwad \art\player\fighter\fighter 131 | $shootwad \art\player\fighter\fighter2 132 | 133 | $shootwad \art\player\mage\mage 134 | $shootwad \art\player\mage\mage2 135 | $shootwad \art\player\mage\mage3 136 | 137 | $shootwad \art\player\cleric\cleric 138 | $shootwad \art\player\cleric\cleric2 139 | $shootwad \art\player\cleric\cleric3 140 | 141 | 142 | ; MONSTERS 143 | 144 | ; Sea Serpent 145 | $shootwad \art\monsters\serpent\serpent 146 | 147 | ; Centaur 148 | $shootwad \art\monsters\centaur\centaur 149 | $shootwad \art\monsters\centaur\centaur2 150 | $shootwad \art\monsters\centaur\centaur3 151 | $shootwad \art\monsters\centaur\centfx 152 | 153 | ; Demon 154 | $shootwad \art\monsters\demon\demon 155 | 156 | ; Demon2 157 | $shootwad \art\monsters\demon2\demon2 158 | 159 | ; Wraith 160 | $shootwad \art\monsters\wraith\wraith 161 | 162 | ; Dragon Lich 163 | $shootwad \art\monsters\dragon\dragon 164 | 165 | ; Bishop 166 | $shootwad \art\monsters\bishop\bishop 167 | 168 | ; Ettin 169 | $shootwad \art\monsters\ettin\ettin 170 | 171 | ; Fire Demon 172 | $shootwad \art\monsters\firedemn\fired 173 | 174 | ; Ice Guy 175 | $shootwad \art\monsters\ice\iceguy 176 | 177 | ; Sorcerer Boss Guy 178 | $shootwad \art\monsters\boss1\sorc 179 | 180 | ; Korax 181 | $shootwad \art\monsters\korax\korax 182 | 183 | ; Chicken 184 | ; $shootwad \art\monsters\chicken\chicken 185 | 186 | ; Pig 187 | $shootwad \art\monsters\pig\pig 188 | 189 | ; Maulotaur 190 | $shootwad \art\monsters\minotaur\walk 191 | $shootwad \art\monsters\minotaur\pain 192 | ;$shootwad \art\monsters\minotaur\death 193 | $shootwad \art\monsters\minotaur\attack 194 | $shootwad \art\monsters\minotaur\fx 195 | 196 | 197 | ; STATIC SPRITES 198 | 199 | $shootwad \art\sprites\e1spr 200 | $shootwad \art\sprites\s\sprite_s 201 | 202 | ; World projectile sprites 203 | $shootwad \art\sprites\prjtile\prjtile 204 | 205 | $shootwad \art\sprites\r\sprite_r 206 | 207 | $shootwad \art\sprites\fogpatch\fogpatch.wad 208 | 209 | 210 | $shootwad \art\weapons\images\images 211 | $shootwad \art\artifcts\artifcts 212 | $shootwad \art\items\items 213 | ; $shootwad \art\ammo\ammo 214 | 215 | 216 | ; Mana 217 | $shootwad \art\mana\mana 218 | 219 | ; END SPRITES 220 | 221 | $label s_end 222 | 223 | ;--------------------------------------------------------------------------- 224 | ; WALL PATCHES 225 | 226 | $label p_start 227 | ; Shareware wall patches 228 | $label p1_start 229 | $shootwad \art\walls\s\walls_s 230 | $shootwad \art\backdrop\sky_s 231 | $label p1_end 232 | 233 | ; Registered wall patches 234 | $label p2_start 235 | $shootwad \art\walls\r\walls_r 236 | $shootwad \art\backdrop\sky_r 237 | $label p2_end 238 | 239 | $label p_end 240 | 241 | ;--------------------------------------------------------------------------- 242 | ; FLATS 243 | 244 | $label f_start 245 | ; Shareware flats 246 | $label f1_start 247 | $shootwad \art\flats\s\flats_s 248 | $label f1_end 249 | 250 | ; Registered flats 251 | $label f2_start 252 | $shootwad \art\flats\r\flats_r 253 | $label f2_end 254 | 255 | $label f_end 256 | 257 | ; SOUND 258 | 259 | \sound\misc\genmidi.op2 260 | \sound\misc\dmxgus.lmp 261 | \sound\misc\sndcurve.lmp 262 | 263 | 264 | $shootwad \sound\archive\sndwad_r 265 | 266 | -------------------------------------------------------------------------------- /Hexen Source/TEXTDEFS.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** textdefs.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: textdefs.h,v $ 7 | //** $Revision: 1.34 $ 8 | //** $Date: 96/01/05 23:33:22 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | // MN_menu.c --------------------------------------------------------------- 14 | 15 | #define PRESSKEY "press a key." 16 | #define PRESSYN "press y or n." 17 | #define TXT_PAUSED "PAUSED" 18 | #define QUITMSG "are you sure you want to\nquit this great game?" 19 | #define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY 20 | #define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY 21 | #define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY 22 | #define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY 23 | #define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN 24 | #define QLPROMPT "do you want to quickload the game named"\ 25 | "\n\n'%s'?\n\n"PRESSYN 26 | #define NEWGAME "you can't start a new game\n"\ 27 | "while in a network game.\n\n"PRESSKEY 28 | #define MSGOFF "Messages OFF" 29 | #define MSGON "Messages ON" 30 | #define NETEND "you can't end a netgame!\n\n"PRESSKEY 31 | #define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN 32 | #define DOSY "(press y to quit to dos.)" 33 | #define TXT_GAMMA_LEVEL_OFF "GAMMA CORRECTION OFF" 34 | #define TXT_GAMMA_LEVEL_1 "GAMMA CORRECTION LEVEL 1" 35 | #define TXT_GAMMA_LEVEL_2 "GAMMA CORRECTION LEVEL 2" 36 | #define TXT_GAMMA_LEVEL_3 "GAMMA CORRECTION LEVEL 3" 37 | #define TXT_GAMMA_LEVEL_4 "GAMMA CORRECTION LEVEL 4" 38 | #define EMPTYSTRING "empty slot" 39 | 40 | // P_inter.c --------------------------------------------------------------- 41 | 42 | // Mana 43 | 44 | #define TXT_MANA_1 "BLUE MANA" 45 | #define TXT_MANA_2 "GREEN MANA" 46 | #define TXT_MANA_BOTH "COMBINED MANA" 47 | 48 | // Keys 49 | 50 | #define TXT_KEY_STEEL "STEEL KEY" 51 | #define TXT_KEY_CAVE "CAVE KEY" 52 | #define TXT_KEY_AXE "AXE KEY" 53 | #define TXT_KEY_FIRE "FIRE KEY" 54 | #define TXT_KEY_EMERALD "EMERALD KEY" 55 | #define TXT_KEY_DUNGEON "DUNGEON KEY" 56 | #define TXT_KEY_SILVER "SILVER KEY" 57 | #define TXT_KEY_RUSTED "RUSTED KEY" 58 | #define TXT_KEY_HORN "HORN KEY" 59 | #define TXT_KEY_SWAMP "SWAMP KEY" 60 | #define TXT_KEY_CASTLE "CASTLE KEY" 61 | 62 | // Artifacts 63 | 64 | #define TXT_ARTIINVULNERABILITY "ICON OF THE DEFENDER" 65 | #define TXT_ARTIHEALTH "QUARTZ FLASK" 66 | #define TXT_ARTISUPERHEALTH "MYSTIC URN" 67 | #define TXT_ARTISUMMON "DARK SERVANT" 68 | #define TXT_ARTITORCH "TORCH" 69 | #define TXT_ARTIEGG "PORKALATOR" 70 | #define TXT_ARTIFLY "WINGS OF WRATH" 71 | #define TXT_ARTITELEPORT "CHAOS DEVICE" 72 | #define TXT_ARTIPOISONBAG "FLECHETTE" 73 | #define TXT_ARTITELEPORTOTHER "BANISHMENT DEVICE" 74 | #define TXT_ARTISPEED "BOOTS OF SPEED" 75 | #define TXT_ARTIBOOSTMANA "KRATER OF MIGHT" 76 | #define TXT_ARTIBOOSTARMOR "DRAGONSKIN BRACERS" 77 | #define TXT_ARTIBLASTRADIUS "DISC OF REPULSION" 78 | #define TXT_ARTIHEALINGRADIUS "MYSTIC AMBIT INCANT" 79 | 80 | // Puzzle artifacts 81 | 82 | #define TXT_ARTIPUZZSKULL "YORICK'S SKULL" 83 | #define TXT_ARTIPUZZGEMBIG "HEART OF D'SPARIL" 84 | #define TXT_ARTIPUZZGEMRED "RUBY PLANET" 85 | #define TXT_ARTIPUZZGEMGREEN1 "EMERALD PLANET" 86 | #define TXT_ARTIPUZZGEMGREEN2 "EMERALD PLANET" 87 | #define TXT_ARTIPUZZGEMBLUE1 "SAPPHIRE PLANET" 88 | #define TXT_ARTIPUZZGEMBLUE2 "SAPPHIRE PLANET" 89 | #define TXT_ARTIPUZZBOOK1 "DAEMON CODEX" 90 | #define TXT_ARTIPUZZBOOK2 "LIBER OSCURA" 91 | #define TXT_ARTIPUZZSKULL2 "FLAME MASK" 92 | #define TXT_ARTIPUZZFWEAPON "GLAIVE SEAL" 93 | #define TXT_ARTIPUZZCWEAPON "HOLY RELIC" 94 | #define TXT_ARTIPUZZMWEAPON "SIGIL OF THE MAGUS" 95 | #define TXT_ARTIPUZZGEAR "CLOCK GEAR" 96 | #define TXT_USEPUZZLEFAILED "YOU CANNOT USE THIS HERE" 97 | 98 | // Items 99 | 100 | #define TXT_ITEMHEALTH "CRYSTAL VIAL" 101 | #define TXT_ITEMBAGOFHOLDING "BAG OF HOLDING" 102 | #define TXT_ITEMSHIELD1 "SILVER SHIELD" 103 | #define TXT_ITEMSHIELD2 "ENCHANTED SHIELD" 104 | #define TXT_ITEMSUPERMAP "MAP SCROLL" 105 | #define TXT_ARMOR1 "MESH ARMOR" 106 | #define TXT_ARMOR2 "FALCON SHIELD" 107 | #define TXT_ARMOR3 "PLATINUM HELMET" 108 | #define TXT_ARMOR4 "AMULET OF WARDING" 109 | 110 | // Weapons 111 | 112 | #define TXT_WEAPON_F2 "TIMON'S AXE" 113 | #define TXT_WEAPON_F3 "HAMMER OF RETRIBUTION" 114 | #define TXT_WEAPON_F4 "QUIETUS ASSEMBLED" 115 | #define TXT_WEAPON_C2 "SERPENT STAFF" 116 | #define TXT_WEAPON_C3 "FIRESTORM" 117 | #define TXT_WEAPON_C4 "WRAITHVERGE ASSEMBLED" 118 | #define TXT_WEAPON_M2 "FROST SHARDS" 119 | #define TXT_WEAPON_M3 "ARC OF DEATH" 120 | #define TXT_WEAPON_M4 "BLOODSCOURGE ASSEMBLED" 121 | #define TXT_QUIETUS_PIECE "SEGMENT OF QUIETUS" 122 | #define TXT_WRAITHVERGE_PIECE "SEGMENT OF WRAITHVERGE" 123 | #define TXT_BLOODSCOURGE_PIECE "SEGMENT OF BLOODSCOURGE" 124 | 125 | // SB_bar.c ---------------------------------------------------------------- 126 | 127 | #define TXT_CHEATGODON "GOD MODE ON" 128 | #define TXT_CHEATGODOFF "GOD MODE OFF" 129 | #define TXT_CHEATNOCLIPON "NO CLIPPING ON" 130 | #define TXT_CHEATNOCLIPOFF "NO CLIPPING OFF" 131 | #define TXT_CHEATWEAPONS "ALL WEAPONS" 132 | #define TXT_CHEATHEALTH "FULL HEALTH" 133 | #define TXT_CHEATKEYS "ALL KEYS" 134 | #define TXT_CHEATSOUNDON "SOUND DEBUG ON" 135 | #define TXT_CHEATSOUNDOFF "SOUND DEBUG OFF" 136 | #define TXT_CHEATTICKERON "TICKER ON" 137 | #define TXT_CHEATTICKEROFF "TICKER OFF" 138 | #define TXT_CHEATARTIFACTS3 "ALL ARTIFACTS" 139 | #define TXT_CHEATARTIFACTSFAIL "BAD INPUT" 140 | #define TXT_CHEATWARP "LEVEL WARP" 141 | #define TXT_CHEATSCREENSHOT "SCREENSHOT" 142 | #define TXT_CHEATIDDQD "TRYING TO CHEAT, EH? NOW YOU DIE!" 143 | #define TXT_CHEATIDKFA "CHEATER - YOU DON'T DESERVE WEAPONS" 144 | #define TXT_CHEATBADINPUT "BAD INPUT" 145 | #define TXT_CHEATNOMAP "CAN'T FIND MAP" 146 | 147 | // G_game.c ---------------------------------------------------------------- 148 | 149 | #define TXT_GAMESAVED "GAME SAVED" 150 | 151 | // M_misc.c ---------------------------------------------------------------- 152 | 153 | #define HUSTR_CHATMACRO1 "I'm ready to kick butt!" 154 | #define HUSTR_CHATMACRO2 "I'm OK." 155 | #define HUSTR_CHATMACRO3 "I'm not looking too good!" 156 | #define HUSTR_CHATMACRO4 "Help!" 157 | #define HUSTR_CHATMACRO5 "You suck!" 158 | #define HUSTR_CHATMACRO6 "Next time, scumbag..." 159 | #define HUSTR_CHATMACRO7 "Come here!" 160 | #define HUSTR_CHATMACRO8 "I'll take care of it." 161 | #define HUSTR_CHATMACRO9 "Yes" 162 | #define HUSTR_CHATMACRO0 "No" 163 | 164 | // AM_map.c ---------------------------------------------------------------- 165 | 166 | #define AMSTR_FOLLOWON "FOLLOW MODE ON" 167 | #define AMSTR_FOLLOWOFF "FOLLOW MODE OFF" 168 | -------------------------------------------------------------------------------- /Hexen Source/P_PLATS.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_plats.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_plats.c,v $ 7 | //** $Revision: 1.11 $ 8 | //** $Date: 95/09/11 22:06:30 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | #include "soundst.h" 16 | 17 | plat_t *activeplats[MAXPLATS]; 18 | 19 | //================================================================== 20 | // 21 | // Move a plat up and down 22 | // 23 | //================================================================== 24 | void T_PlatRaise(plat_t *plat) 25 | { 26 | result_e res; 27 | 28 | switch(plat->status) 29 | { 30 | case PLAT_UP: 31 | res = T_MovePlane(plat->sector, plat->speed, 32 | plat->high, plat->crush, 0, 1); 33 | if (res == RES_CRUSHED && (!plat->crush)) 34 | { 35 | plat->count = plat->wait; 36 | plat->status = PLAT_DOWN; 37 | SN_StartSequence((mobj_t *)&plat->sector->soundorg, 38 | SEQ_PLATFORM+plat->sector->seqType); 39 | } 40 | else 41 | if (res == RES_PASTDEST) 42 | { 43 | plat->count = plat->wait; 44 | plat->status = PLAT_WAITING; 45 | SN_StopSequence((mobj_t *)&plat->sector->soundorg); 46 | switch(plat->type) 47 | { 48 | case PLAT_DOWNWAITUPSTAY: 49 | case PLAT_DOWNBYVALUEWAITUPSTAY: 50 | P_RemoveActivePlat(plat); 51 | break; 52 | default: 53 | break; 54 | } 55 | } 56 | break; 57 | case PLAT_DOWN: 58 | res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); 59 | if (res == RES_PASTDEST) 60 | { 61 | plat->count = plat->wait; 62 | plat->status = PLAT_WAITING; 63 | switch(plat->type) 64 | { 65 | case PLAT_UPWAITDOWNSTAY: 66 | case PLAT_UPBYVALUEWAITDOWNSTAY: 67 | P_RemoveActivePlat(plat); 68 | break; 69 | default: 70 | break; 71 | } 72 | SN_StopSequence((mobj_t *)&plat->sector->soundorg); 73 | } 74 | break; 75 | case PLAT_WAITING: 76 | if (!--plat->count) 77 | { 78 | if (plat->sector->floorheight == plat->low) 79 | plat->status = PLAT_UP; 80 | else 81 | plat->status = PLAT_DOWN; 82 | SN_StartSequence((mobj_t *)&plat->sector->soundorg, 83 | SEQ_PLATFORM+plat->sector->seqType); 84 | } 85 | // case PLAT_IN_STASIS: 86 | // break; 87 | } 88 | } 89 | 90 | //================================================================== 91 | // 92 | // Do Platforms 93 | // "amount" is only used for SOME platforms. 94 | // 95 | //================================================================== 96 | int EV_DoPlat(line_t *line, byte *args, plattype_e type, int amount) 97 | { 98 | plat_t *plat; 99 | int secnum; 100 | int rtn; 101 | sector_t *sec; 102 | 103 | secnum = -1; 104 | rtn = 0; 105 | 106 | /* 107 | // 108 | // Activate all plats that are in_stasis 109 | // 110 | switch(type) 111 | { 112 | case PLAT_PERPETUALRAISE: 113 | P_ActivateInStasis(args[0]); 114 | break; 115 | default: 116 | break; 117 | } 118 | */ 119 | 120 | while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) 121 | { 122 | sec = §ors[secnum]; 123 | if (sec->specialdata) 124 | continue; 125 | 126 | // 127 | // Find lowest & highest floors around sector 128 | // 129 | rtn = 1; 130 | plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); 131 | P_AddThinker(&plat->thinker); 132 | 133 | plat->type = type; 134 | plat->sector = sec; 135 | plat->sector->specialdata = plat; 136 | plat->thinker.function = T_PlatRaise; 137 | plat->crush = false; 138 | plat->tag = args[0]; 139 | plat->speed = args[1]*(FRACUNIT/8); 140 | switch(type) 141 | { 142 | case PLAT_DOWNWAITUPSTAY: 143 | plat->low = P_FindLowestFloorSurrounding(sec)+8*FRACUNIT; 144 | if (plat->low > sec->floorheight) 145 | plat->low = sec->floorheight; 146 | plat->high = sec->floorheight; 147 | plat->wait = args[2]; 148 | plat->status = PLAT_DOWN; 149 | break; 150 | case PLAT_DOWNBYVALUEWAITUPSTAY: 151 | plat->low = sec->floorheight-args[3]*8*FRACUNIT; 152 | if (plat->low > sec->floorheight) 153 | plat->low = sec->floorheight; 154 | plat->high = sec->floorheight; 155 | plat->wait = args[2]; 156 | plat->status = PLAT_DOWN; 157 | break; 158 | case PLAT_UPWAITDOWNSTAY: 159 | plat->high = P_FindHighestFloorSurrounding(sec); 160 | if (plat->high < sec->floorheight) 161 | plat->high = sec->floorheight; 162 | plat->low = sec->floorheight; 163 | plat->wait = args[2]; 164 | plat->status = PLAT_UP; 165 | break; 166 | case PLAT_UPBYVALUEWAITDOWNSTAY: 167 | plat->high = sec->floorheight+args[3]*8*FRACUNIT; 168 | if (plat->high < sec->floorheight) 169 | plat->high = sec->floorheight; 170 | plat->low = sec->floorheight; 171 | plat->wait = args[2]; 172 | plat->status = PLAT_UP; 173 | break; 174 | case PLAT_PERPETUALRAISE: 175 | plat->low = P_FindLowestFloorSurrounding(sec)+8*FRACUNIT; 176 | if (plat->low > sec->floorheight) 177 | plat->low = sec->floorheight; 178 | plat->high = P_FindHighestFloorSurrounding(sec); 179 | if (plat->high < sec->floorheight) 180 | plat->high = sec->floorheight; 181 | plat->wait = args[2]; 182 | plat->status = P_Random()&1; 183 | break; 184 | } 185 | P_AddActivePlat(plat); 186 | SN_StartSequence((mobj_t *)&sec->soundorg, SEQ_PLATFORM+sec->seqType); 187 | } 188 | return rtn; 189 | } 190 | 191 | #if 0 192 | void P_ActivateInStasis(int tag) 193 | { 194 | int i; 195 | 196 | for (i = 0;i < MAXPLATS;i++) 197 | if (activeplats[i] && 198 | (activeplats[i])->tag == tag && 199 | (activeplats[i])->status == PLAT_IN_STASIS) 200 | { 201 | (activeplats[i])->status = (activeplats[i])->oldstatus; 202 | (activeplats[i])->thinker.function = T_PlatRaise; 203 | } 204 | } 205 | #endif 206 | 207 | void EV_StopPlat(line_t *line, byte *args) 208 | { 209 | int i; 210 | 211 | for(i = 0; i < MAXPLATS; i++) 212 | { 213 | if((activeplats[i])->tag = args[0]) 214 | { 215 | (activeplats[i])->sector->specialdata = NULL; 216 | P_TagFinished((activeplats[i])->sector->tag); 217 | P_RemoveThinker(&(activeplats[i])->thinker); 218 | activeplats[i] = NULL; 219 | 220 | return; 221 | } 222 | } 223 | 224 | /* 225 | int j; 226 | 227 | for (j = 0;j < MAXPLATS;j++) 228 | { 229 | if (activeplats[j] && ((activeplats[j])->status != PLAT_IN_STASIS) && 230 | ((activeplats[j])->tag == args[0])) 231 | { 232 | (activeplats[j])->oldstatus = (activeplats[j])->status; 233 | (activeplats[j])->status = PLAT_IN_STASIS; 234 | (activeplats[j])->thinker.function = NULL; 235 | SN_StopSequence((mobj_t *)&(activeplats[j])->sector->soundorg); 236 | } 237 | } 238 | */ 239 | } 240 | 241 | void P_AddActivePlat(plat_t *plat) 242 | { 243 | int i; 244 | for (i = 0;i < MAXPLATS;i++) 245 | if (activeplats[i] == NULL) 246 | { 247 | activeplats[i] = plat; 248 | return; 249 | } 250 | I_Error ("P_AddActivePlat: no more plats!"); 251 | } 252 | 253 | void P_RemoveActivePlat(plat_t *plat) 254 | { 255 | int i; 256 | for (i = 0;i < MAXPLATS;i++) 257 | if (plat == activeplats[i]) 258 | { 259 | (activeplats[i])->sector->specialdata = NULL; 260 | P_TagFinished(plat->sector->tag); 261 | P_RemoveThinker(&(activeplats[i])->thinker); 262 | activeplats[i] = NULL; 263 | return; 264 | } 265 | I_Error ("P_RemoveActivePlat: can't find plat!"); 266 | } 267 | -------------------------------------------------------------------------------- /Hexen Source/SOUNDS.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** sounds.h : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: sounds.h,v $ 7 | //** $Revision: 1.74 $ 8 | //** $Date: 95/10/10 21:51:20 $ 9 | //** $Author: paul $ 10 | //** 11 | //************************************************************************** 12 | 13 | #ifndef __SOUNDSH__ 14 | #define __SOUNDSH__ 15 | 16 | #include "soundst.h" 17 | 18 | #define MAX_SND_DIST 2025 19 | #define MAX_CHANNELS 16 20 | 21 | // Music identifiers 22 | 23 | typedef enum 24 | { 25 | mus_e1m1, 26 | mus_e1m2, 27 | mus_e1m3, 28 | mus_e1m4, 29 | mus_e1m5, 30 | mus_e1m6, 31 | mus_e1m7, 32 | mus_e1m8, 33 | mus_e1m9, 34 | mus_e2m1, 35 | mus_e2m2, 36 | mus_e2m3, 37 | mus_e2m4, 38 | mus_e2m5, 39 | mus_e2m6, 40 | mus_e2m7, 41 | mus_e2m8, 42 | mus_e2m9, 43 | mus_e3m1, 44 | mus_e3m2, 45 | mus_e3m3, 46 | mus_e3m4, 47 | mus_e3m5, 48 | mus_e3m6, 49 | mus_e3m7, 50 | mus_e3m8, 51 | mus_e3m9, 52 | mus_e4m1, 53 | mus_titl, 54 | mus_intr, 55 | mus_cptd, 56 | NUMMUSIC 57 | } musicenum_t; 58 | 59 | // Sound identifiers 60 | 61 | typedef enum 62 | { 63 | SFX_NONE, 64 | SFX_PLAYER_FIGHTER_NORMAL_DEATH, // class specific death screams 65 | SFX_PLAYER_FIGHTER_CRAZY_DEATH, 66 | SFX_PLAYER_FIGHTER_EXTREME1_DEATH, 67 | SFX_PLAYER_FIGHTER_EXTREME2_DEATH, 68 | SFX_PLAYER_FIGHTER_EXTREME3_DEATH, 69 | SFX_PLAYER_FIGHTER_BURN_DEATH, 70 | SFX_PLAYER_CLERIC_NORMAL_DEATH, 71 | SFX_PLAYER_CLERIC_CRAZY_DEATH, 72 | SFX_PLAYER_CLERIC_EXTREME1_DEATH, 73 | SFX_PLAYER_CLERIC_EXTREME2_DEATH, 74 | SFX_PLAYER_CLERIC_EXTREME3_DEATH, 75 | SFX_PLAYER_CLERIC_BURN_DEATH, 76 | SFX_PLAYER_MAGE_NORMAL_DEATH, 77 | SFX_PLAYER_MAGE_CRAZY_DEATH, 78 | SFX_PLAYER_MAGE_EXTREME1_DEATH, 79 | SFX_PLAYER_MAGE_EXTREME2_DEATH, 80 | SFX_PLAYER_MAGE_EXTREME3_DEATH, 81 | SFX_PLAYER_MAGE_BURN_DEATH, 82 | SFX_PLAYER_FIGHTER_PAIN, 83 | SFX_PLAYER_CLERIC_PAIN, 84 | SFX_PLAYER_MAGE_PAIN, 85 | SFX_PLAYER_FIGHTER_GRUNT, 86 | SFX_PLAYER_CLERIC_GRUNT, 87 | SFX_PLAYER_MAGE_GRUNT, 88 | SFX_PLAYER_LAND, 89 | SFX_PLAYER_POISONCOUGH, 90 | SFX_PLAYER_FIGHTER_FALLING_SCREAM, // class specific falling screams 91 | SFX_PLAYER_CLERIC_FALLING_SCREAM, 92 | SFX_PLAYER_MAGE_FALLING_SCREAM, 93 | SFX_PLAYER_FALLING_SPLAT, 94 | SFX_PLAYER_FIGHTER_FAILED_USE, 95 | SFX_PLAYER_CLERIC_FAILED_USE, 96 | SFX_PLAYER_MAGE_FAILED_USE, 97 | SFX_PLATFORM_START, 98 | SFX_PLATFORM_STARTMETAL, 99 | SFX_PLATFORM_STOP, 100 | SFX_STONE_MOVE, 101 | SFX_METAL_MOVE, 102 | SFX_DOOR_OPEN, 103 | SFX_DOOR_LOCKED, 104 | SFX_DOOR_METAL_OPEN, 105 | SFX_DOOR_METAL_CLOSE, 106 | SFX_DOOR_LIGHT_CLOSE, 107 | SFX_DOOR_HEAVY_CLOSE, 108 | SFX_DOOR_CREAK, 109 | SFX_PICKUP_WEAPON, 110 | SFX_PICKUP_ARTIFACT, 111 | SFX_PICKUP_KEY, 112 | SFX_PICKUP_ITEM, 113 | SFX_PICKUP_PIECE, 114 | SFX_WEAPON_BUILD, 115 | SFX_ARTIFACT_USE, 116 | SFX_ARTIFACT_BLAST, 117 | SFX_TELEPORT, 118 | SFX_THUNDER_CRASH, 119 | SFX_FIGHTER_PUNCH_MISS, 120 | SFX_FIGHTER_PUNCH_HITTHING, 121 | SFX_FIGHTER_PUNCH_HITWALL, 122 | SFX_FIGHTER_GRUNT, 123 | SFX_FIGHTER_AXE_HITTHING, 124 | SFX_FIGHTER_HAMMER_MISS, 125 | SFX_FIGHTER_HAMMER_HITTHING, 126 | SFX_FIGHTER_HAMMER_HITWALL, 127 | SFX_FIGHTER_HAMMER_CONTINUOUS, 128 | SFX_FIGHTER_HAMMER_EXPLODE, 129 | SFX_FIGHTER_SWORD_FIRE, 130 | SFX_FIGHTER_SWORD_EXPLODE, 131 | SFX_CLERIC_CSTAFF_FIRE, 132 | SFX_CLERIC_CSTAFF_EXPLODE, 133 | SFX_CLERIC_CSTAFF_HITTHING, 134 | SFX_CLERIC_FLAME_FIRE, 135 | SFX_CLERIC_FLAME_EXPLODE, 136 | SFX_CLERIC_FLAME_CIRCLE, 137 | SFX_MAGE_WAND_FIRE, 138 | SFX_MAGE_LIGHTNING_FIRE, 139 | SFX_MAGE_LIGHTNING_ZAP, 140 | SFX_MAGE_LIGHTNING_CONTINUOUS, 141 | SFX_MAGE_LIGHTNING_READY, 142 | SFX_MAGE_SHARDS_FIRE, 143 | SFX_MAGE_SHARDS_EXPLODE, 144 | SFX_MAGE_STAFF_FIRE, 145 | SFX_MAGE_STAFF_EXPLODE, 146 | SFX_SWITCH1, 147 | SFX_SWITCH2, 148 | SFX_SERPENT_SIGHT, 149 | SFX_SERPENT_ACTIVE, 150 | SFX_SERPENT_PAIN, 151 | SFX_SERPENT_ATTACK, 152 | SFX_SERPENT_MELEEHIT, 153 | SFX_SERPENT_DEATH, 154 | SFX_SERPENT_BIRTH, 155 | SFX_SERPENTFX_CONTINUOUS, 156 | SFX_SERPENTFX_HIT, 157 | SFX_POTTERY_EXPLODE, 158 | SFX_DRIP, 159 | SFX_CENTAUR_SIGHT, 160 | SFX_CENTAUR_ACTIVE, 161 | SFX_CENTAUR_PAIN, 162 | SFX_CENTAUR_ATTACK, 163 | SFX_CENTAUR_DEATH, 164 | SFX_CENTAURLEADER_ATTACK, 165 | SFX_CENTAUR_MISSILE_EXPLODE, 166 | SFX_WIND, 167 | SFX_BISHOP_SIGHT, 168 | SFX_BISHOP_ACTIVE, 169 | SFX_BISHOP_PAIN, 170 | SFX_BISHOP_ATTACK, 171 | SFX_BISHOP_DEATH, 172 | SFX_BISHOP_MISSILE_EXPLODE, 173 | SFX_BISHOP_BLUR, 174 | SFX_DEMON_SIGHT, 175 | SFX_DEMON_ACTIVE, 176 | SFX_DEMON_PAIN, 177 | SFX_DEMON_ATTACK, 178 | SFX_DEMON_MISSILE_FIRE, 179 | SFX_DEMON_MISSILE_EXPLODE, 180 | SFX_DEMON_DEATH, 181 | SFX_WRAITH_SIGHT, 182 | SFX_WRAITH_ACTIVE, 183 | SFX_WRAITH_PAIN, 184 | SFX_WRAITH_ATTACK, 185 | SFX_WRAITH_MISSILE_FIRE, 186 | SFX_WRAITH_MISSILE_EXPLODE, 187 | SFX_WRAITH_DEATH, 188 | SFX_PIG_ACTIVE1, 189 | SFX_PIG_ACTIVE2, 190 | SFX_PIG_PAIN, 191 | SFX_PIG_ATTACK, 192 | SFX_PIG_DEATH, 193 | SFX_MAULATOR_SIGHT, 194 | SFX_MAULATOR_ACTIVE, 195 | SFX_MAULATOR_PAIN, 196 | SFX_MAULATOR_HAMMER_SWING, 197 | SFX_MAULATOR_HAMMER_HIT, 198 | SFX_MAULATOR_MISSILE_HIT, 199 | SFX_MAULATOR_DEATH, 200 | SFX_FREEZE_DEATH, 201 | SFX_FREEZE_SHATTER, 202 | SFX_ETTIN_SIGHT, 203 | SFX_ETTIN_ACTIVE, 204 | SFX_ETTIN_PAIN, 205 | SFX_ETTIN_ATTACK, 206 | SFX_ETTIN_DEATH, 207 | SFX_FIRED_SPAWN, 208 | SFX_FIRED_ACTIVE, 209 | SFX_FIRED_PAIN, 210 | SFX_FIRED_ATTACK, 211 | SFX_FIRED_MISSILE_HIT, 212 | SFX_FIRED_DEATH, 213 | SFX_ICEGUY_SIGHT, 214 | SFX_ICEGUY_ACTIVE, 215 | SFX_ICEGUY_ATTACK, 216 | SFX_ICEGUY_FX_EXPLODE, 217 | SFX_SORCERER_SIGHT, 218 | SFX_SORCERER_ACTIVE, 219 | SFX_SORCERER_PAIN, 220 | SFX_SORCERER_SPELLCAST, 221 | SFX_SORCERER_BALLWOOSH, 222 | SFX_SORCERER_DEATHSCREAM, 223 | SFX_SORCERER_BISHOPSPAWN, 224 | SFX_SORCERER_BALLPOP, 225 | SFX_SORCERER_BALLBOUNCE, 226 | SFX_SORCERER_BALLEXPLODE, 227 | SFX_SORCERER_BIGBALLEXPLODE, 228 | SFX_SORCERER_HEADSCREAM, 229 | SFX_DRAGON_SIGHT, 230 | SFX_DRAGON_ACTIVE, 231 | SFX_DRAGON_WINGFLAP, 232 | SFX_DRAGON_ATTACK, 233 | SFX_DRAGON_PAIN, 234 | SFX_DRAGON_DEATH, 235 | SFX_DRAGON_FIREBALL_EXPLODE, 236 | SFX_KORAX_SIGHT, 237 | SFX_KORAX_ACTIVE, 238 | SFX_KORAX_PAIN, 239 | SFX_KORAX_ATTACK, 240 | SFX_KORAX_COMMAND, 241 | SFX_KORAX_DEATH, 242 | SFX_KORAX_STEP, 243 | SFX_THRUSTSPIKE_RAISE, 244 | SFX_THRUSTSPIKE_LOWER, 245 | SFX_STAINEDGLASS_SHATTER, 246 | SFX_FLECHETTE_BOUNCE, 247 | SFX_FLECHETTE_EXPLODE, 248 | SFX_LAVA_MOVE, 249 | SFX_WATER_MOVE, 250 | SFX_ICE_STARTMOVE, 251 | SFX_EARTH_STARTMOVE, 252 | SFX_WATER_SPLASH, 253 | SFX_LAVA_SIZZLE, 254 | SFX_SLUDGE_GLOOP, 255 | SFX_CHOLY_FIRE, 256 | SFX_SPIRIT_ACTIVE, 257 | SFX_SPIRIT_ATTACK, 258 | SFX_SPIRIT_DIE, 259 | SFX_VALVE_TURN, 260 | SFX_ROPE_PULL, 261 | SFX_FLY_BUZZ, 262 | SFX_IGNITE, 263 | SFX_PUZZLE_SUCCESS, 264 | SFX_PUZZLE_FAIL_FIGHTER, 265 | SFX_PUZZLE_FAIL_CLERIC, 266 | SFX_PUZZLE_FAIL_MAGE, 267 | SFX_EARTHQUAKE, 268 | SFX_BELLRING, 269 | SFX_TREE_BREAK, 270 | SFX_TREE_EXPLODE, 271 | SFX_SUITOFARMOR_BREAK, 272 | SFX_POISONSHROOM_PAIN, 273 | SFX_POISONSHROOM_DEATH, 274 | SFX_AMBIENT1, 275 | SFX_AMBIENT2, 276 | SFX_AMBIENT3, 277 | SFX_AMBIENT4, 278 | SFX_AMBIENT5, 279 | SFX_AMBIENT6, 280 | SFX_AMBIENT7, 281 | SFX_AMBIENT8, 282 | SFX_AMBIENT9, 283 | SFX_AMBIENT10, 284 | SFX_AMBIENT11, 285 | SFX_AMBIENT12, 286 | SFX_AMBIENT13, 287 | SFX_AMBIENT14, 288 | SFX_AMBIENT15, 289 | SFX_STARTUP_TICK, 290 | SFX_SWITCH_OTHERLEVEL, 291 | SFX_RESPAWN, 292 | SFX_KORAX_VOICE_1, 293 | SFX_KORAX_VOICE_2, 294 | SFX_KORAX_VOICE_3, 295 | SFX_KORAX_VOICE_4, 296 | SFX_KORAX_VOICE_5, 297 | SFX_KORAX_VOICE_6, 298 | SFX_KORAX_VOICE_7, 299 | SFX_KORAX_VOICE_8, 300 | SFX_KORAX_VOICE_9, 301 | SFX_BAT_SCREAM, 302 | SFX_CHAT, 303 | SFX_MENU_MOVE, 304 | SFX_CLOCK_TICK, 305 | SFX_FIREBALL, 306 | SFX_PUPPYBEAT, 307 | SFX_MYSTICINCANT, 308 | NUMSFX 309 | } sfxenum_t; 310 | 311 | #endif 312 | -------------------------------------------------------------------------------- /Hexen Source/I_CYBER.C: -------------------------------------------------------------------------------- 1 | // I_cyber.c 2 | 3 | #include 4 | #include 5 | #include 6 | #include "st_start.h" // For ST_Message() 7 | 8 | 9 | // Prototypes 10 | unsigned char *I_AllocLow (int length); 11 | 12 | 13 | /* 14 | ==================================================== 15 | 16 | Doom control structure 17 | 18 | The keybaord and joystick will add to the values set by the cyberman, 19 | to a maximum of 0x19000 for forwardmove and sidemove. Angleturn is 20 | not bounded at all. 21 | 22 | parm normal fast 23 | ----- ------ ---- 24 | forwardmove 0xc800 0x19000 25 | sidemove 0xc000 0x14000 26 | angleturn 0x2800000 0x5000000 27 | 28 | The keyboard and joystick have a 1/3 second slow turn of 0x1400000 under 29 | normal speed to help aiming. 30 | 31 | 32 | 33 | ==================================================== 34 | */ 35 | /* old ticcmd_t 36 | typedef struct 37 | { 38 | char forwardmove; // *2048 for move 39 | char sidemove; // *2048 for move 40 | short angleturn; // <<16 for angle delta 41 | short consistancy; // checks for net game 42 | unsigned char chatchar; 43 | unsigned char buttons; 44 | } ticcmd_t; 45 | */ 46 | // ticcmd_t as it appears in h2def.h 47 | typedef struct 48 | { 49 | char forwardmove; 50 | char sidemove; 51 | short angleturn; 52 | short consistancy; 53 | unsigned char chatchar; 54 | unsigned char buttons; 55 | unsigned char lookfly; 56 | unsigned char arti; 57 | }ticcmd_t; 58 | 59 | 60 | #define BT_ATTACK 1 61 | #define BT_USE 2 62 | #define BT_CHANGE 4 // if true, the next 3 bits hold weapon num 63 | #define BT_WEAPONMASK (8+16+32) 64 | #define BT_WEAPONSHIFT 3 65 | 66 | //================================================== 67 | // 68 | // CyberMan detection and usage info 69 | // 70 | //================================================== 71 | #define DPMI_INT 0x31 72 | #define MOUSE_INT 0x33 73 | 74 | #define DOSMEMSIZE 64 // enough for any SWIFT structure 75 | 76 | typedef struct { 77 | short x; 78 | short y; 79 | short z; 80 | short pitch; 81 | short roll; 82 | short yaw; 83 | short buttons; 84 | } SWIFT_3DStatus; 85 | 86 | // DPMI real mode interrupt structure 87 | static struct rminfo { 88 | long EDI; 89 | long ESI; 90 | long EBP; 91 | long reserved_by_system; 92 | long EBX; 93 | long EDX; 94 | long ECX; 95 | long EAX; 96 | short flags; 97 | short ES,DS,FS,GS,IP,CS,SP,SS; 98 | } RMI; 99 | 100 | typedef struct { 101 | unsigned char deviceType; 102 | unsigned char majorVersion; 103 | unsigned char minorVersion; 104 | unsigned char absRelFlags; 105 | unsigned char centeringFlags; 106 | unsigned char reserved[5]; 107 | } StaticDeviceData; 108 | 109 | // values for deviceType: 110 | #define DEVTYPE_CYBERMAN 1 111 | 112 | short selector; 113 | unsigned short segment; // segment of DOS memory block 114 | SWIFT_3DStatus *cyberstat; 115 | int isCyberPresent; // is CyberMan present? 116 | 117 | 118 | static union REGS regs; 119 | static struct SREGS sregs; 120 | 121 | 122 | extern int mousepresent; 123 | 124 | //=========================================================== 125 | // 126 | // I_StartupCyberMan 127 | // 128 | // If a cyberman is present, init it and set isCyberPresent to 1 129 | //=========================================================== 130 | void I_StartupCyberMan(void) 131 | { 132 | StaticDeviceData *pbuf; 133 | 134 | ST_Message(" CyberMan: "); 135 | isCyberPresent = 0; 136 | 137 | cyberstat = (SWIFT_3DStatus *)I_AllocLow (DOSMEMSIZE); 138 | segment = (int)cyberstat>>4; 139 | 140 | pbuf = (StaticDeviceData *)cyberstat; 141 | memset(pbuf, 0, sizeof (StaticDeviceData)); 142 | 143 | 144 | // Use DPMI call 300h to issue mouse interrupt 145 | memset(&RMI, 0, sizeof(RMI)); 146 | RMI.EAX = 0x53C1; // SWIFT: Get Static Device Data 147 | RMI.ES = segment; 148 | RMI.EDX = 0; 149 | memset(&sregs, 0, sizeof (sregs)); 150 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 151 | regs.w.bx = MOUSE_INT; 152 | regs.w.cx = 0; 153 | regs.x.edi = FP_OFF(&RMI); 154 | sregs.es = FP_SEG(&RMI); 155 | int386x( DPMI_INT, ®s, ®s, &sregs ); 156 | 157 | if ((short)RMI.EAX != 1) 158 | { 159 | // SWIFT functions not present 160 | ST_Message("Wrong mouse driver - no SWIFT support (AX=%04x).\n", 161 | (unsigned)(short)RMI.EAX); 162 | } 163 | else if (pbuf->deviceType != DEVTYPE_CYBERMAN) 164 | { 165 | // no SWIFT device, or not CyberMan 166 | if (pbuf->deviceType == 0) 167 | { 168 | ST_Message("no SWIFT device connected.\n"); 169 | } 170 | else 171 | { 172 | ST_Message("SWIFT device is not a CyberMan! (type=%d)\n", 173 | pbuf->deviceType); 174 | } 175 | } 176 | else 177 | { 178 | ST_Message("CyberMan %d.%02d connected.\n", 179 | pbuf->majorVersion, pbuf->minorVersion); 180 | isCyberPresent = 1; 181 | mousepresent = 0; 182 | } 183 | } 184 | 185 | 186 | 187 | /* 188 | =============== 189 | = 190 | = I_ReadCyberCmds 191 | = 192 | =============== 193 | */ 194 | 195 | 196 | int oldpos; 197 | 198 | void I_ReadCyberCmd (ticcmd_t *cmd) 199 | { 200 | int delta; 201 | 202 | // Use DPMI call 300h to issue mouse interrupt 203 | memset(&RMI, 0, sizeof(RMI)); 204 | RMI.EAX = 0x5301; // SWIFT: Get Position and Buttons 205 | RMI.ES = segment; 206 | RMI.EDX = 0; 207 | memset(&sregs, 0, sizeof (sregs)); 208 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 209 | regs.w.bx = MOUSE_INT; 210 | regs.w.cx = 0; 211 | regs.x.edi = FP_OFF(&RMI); 212 | sregs.es = FP_SEG(&RMI); 213 | int386x( DPMI_INT, ®s, ®s, &sregs ); 214 | 215 | if (cyberstat->y < -7900) 216 | cmd->forwardmove = 0xc800/2048; 217 | else if (cyberstat->y > 7900) 218 | cmd->forwardmove = -0xc800/2048; 219 | 220 | if (cyberstat->buttons & 4) 221 | cmd->buttons |= BT_ATTACK; 222 | if (cyberstat->buttons & 2) 223 | cmd->buttons |= BT_USE; 224 | 225 | delta = cyberstat->x - oldpos; 226 | oldpos = cyberstat->x; 227 | 228 | if (cyberstat->buttons & 1) 229 | { // strafe 230 | if (cyberstat->x < -7900) 231 | cmd->sidemove = -0xc800/2048; 232 | else if (cyberstat->x > 7900) 233 | cmd->sidemove = 0xc800/2048; 234 | else 235 | cmd->sidemove = delta*40/2048; 236 | } 237 | else 238 | { 239 | if (cyberstat->x < -7900) 240 | cmd->angleturn = 0x280; 241 | else if (cyberstat->x > 7900) 242 | cmd->angleturn = -0x280; 243 | else 244 | cmd->angleturn = -delta*0xa/16; 245 | 246 | } 247 | 248 | } 249 | 250 | 251 | void I_Tactile (int on, int off, int total) 252 | { 253 | if (!isCyberPresent) 254 | return; 255 | 256 | on /= 5; 257 | off /= 5; 258 | total /= 40; 259 | if (on > 255) 260 | on = 255; 261 | if (off > 255) 262 | off = 255; 263 | if (total > 255) 264 | total = 255; 265 | 266 | memset(&RMI, 0, sizeof(RMI)); 267 | RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons 268 | RMI.EBX = on*256+off; 269 | RMI.ECX = total; 270 | memset(&sregs, 0, sizeof (sregs)); 271 | regs.w.ax = 0x0300; // DPMI: simulate interrupt 272 | regs.w.bx = MOUSE_INT; 273 | regs.w.cx = 0; 274 | regs.x.edi = FP_OFF(&RMI); 275 | sregs.es = FP_SEG(&RMI); 276 | int386x( DPMI_INT, ®s, ®s, &sregs ); 277 | } 278 | -------------------------------------------------------------------------------- /Hexen Source/LINEAR.ASM: -------------------------------------------------------------------------------- 1 | .386 2 | .MODEL small 3 | INCLUDE defs.inc 4 | 5 | 6 | ;============================================================================ 7 | ; 8 | ; unwound vertical scaling code 9 | ; 10 | ; eax light table pointer, 0 lowbyte overwritten 11 | ; ebx all 0, low byte overwritten 12 | ; ecx fractional step value 13 | ; edx fractional scale value 14 | ; esi start of source pixels 15 | ; edi bottom pixel in screenbuffer to blit into 16 | ; 17 | ; ebx should be set to 0 0 0 dh to feed the pipeline 18 | ; 19 | ; The graphics wrap vertically at 128 pixels 20 | ;============================================================================ 21 | 22 | .DATA 23 | 24 | EXTRN _centery:DWORD 25 | 26 | SCALEDEFINE MACRO number 27 | dd vscale&number 28 | ENDM 29 | 30 | ALIGN 4 31 | scalecalls LABEL 32 | LINE = 0 33 | REPT SCREENHEIGHT+1 34 | SCALEDEFINE %LINE 35 | LINE = LINE+1 36 | ENDM 37 | 38 | FUZZSCALEDEFINE MACRO number 39 | dd fuzzvscale&number 40 | ENDM 41 | 42 | ALIGN 4 43 | fuzzscalecalls LABEL 44 | LINE = 0 45 | REPT SCREENHEIGHT+1 46 | FUZZSCALEDEFINE %LINE 47 | LINE = LINE+1 48 | ENDM 49 | 50 | calladdr dd ? 51 | 52 | ;================================= 53 | 54 | 55 | .CODE 56 | 57 | ;================ 58 | ; 59 | ; R_DrawColumn 60 | ; 61 | ;================ 62 | 63 | PROC R_DrawColumn_ 64 | PUBLIC R_DrawColumn_ 65 | PUSHR 66 | 67 | mov ebp,[_dc_yh] 68 | mov ebx,ebp 69 | mov edi,[_ylookup+ebx*4] 70 | mov ebx,[_dc_x] 71 | add edi,[_columnofs + ebx*4] 72 | 73 | mov eax,[_dc_yl] 74 | sub ebp,eax ; ebp = pixel count 75 | or ebp,ebp 76 | js done 77 | 78 | mov ecx,[_dc_iscale] 79 | 80 | sub eax,[_centery] 81 | imul ecx 82 | mov edx,[_dc_texturemid] 83 | add edx,eax 84 | shl edx,9 ; 7 significant bits, 25 frac 85 | 86 | shl ecx,9 ; 7 significant bits, 25 frac 87 | mov esi,[_dc_source] 88 | 89 | mov eax,[_dc_colormap] 90 | 91 | xor ebx,ebx 92 | shld ebx,edx,7 ; get address of first location 93 | call [scalecalls+4+ebp*4] 94 | 95 | done: 96 | POPR 97 | ret 98 | 99 | ;============ HIGH DETAIL ============ 100 | 101 | SCALELABEL MACRO number 102 | vscale&number: 103 | ENDM 104 | 105 | LINE = SCREENHEIGHT 106 | REPT SCREENHEIGHT-1 107 | SCALELABEL %LINE 108 | mov al,[esi+ebx] ; get source pixel 109 | add edx,ecx ; calculate next location 110 | mov al,[eax] ; translate the color 111 | ; xor ebx,ebx 112 | ; shld ebx,edx,7 ; get address of next location 113 | mov ebx,edx 114 | shr ebx,25 115 | mov [edi-(LINE-1)*SCREENWIDTH],al ; draw a pixel to the buffer 116 | LINE = LINE-1 117 | ENDM 118 | vscale1: 119 | mov al,[esi+ebx] 120 | mov al,[eax] 121 | mov [edi],al 122 | vscale0: 123 | ret 124 | 125 | ENDP 126 | 127 | 128 | ;================ 129 | ; 130 | ; R_DrawFuzz 131 | ; 132 | ;================ 133 | 134 | PROC R_DrawFuzzColumn_ 135 | PUBLIC R_DrawFuzzColumn_ 136 | PUSHR 137 | 138 | mov ebp,[_dc_yh] 139 | mov ebx,ebp 140 | mov edi,[_ylookup+ebx*4] 141 | mov ebx,[_dc_x] 142 | add edi,[_columnofs + ebx*4] 143 | 144 | mov eax,[_dc_yl] 145 | sub ebp,eax ; ebp = pixel count 146 | or ebp,ebp 147 | js fuzzdone 148 | 149 | mov ecx,[_dc_iscale] 150 | 151 | sub eax,[_centery] 152 | imul ecx 153 | mov edx,[_dc_texturemid] 154 | add edx,eax 155 | shl edx,9 ; 7 significant bits, 25 frac 156 | 157 | shl ecx,9 ; 7 significant bits, 25 frac 158 | mov esi,[_dc_source] 159 | mov eax,[_dc_colormap] 160 | xor ebx,ebx 161 | shld ebx,edx,7 ;get address of first location 162 | 163 | mov ebp, [fuzzscalecalls+4+ebp*4] 164 | mov calladdr, ebp 165 | mov ebp, ecx 166 | xor ecx, ecx 167 | 168 | call [calladdr] 169 | 170 | fuzzdone: 171 | POPR 172 | ret 173 | 174 | 175 | FUZZSCALELABEL MACRO number 176 | fuzzvscale&number: 177 | ENDM 178 | 179 | LINE = SCREENHEIGHT 180 | REPT SCREENHEIGHT-1 181 | FUZZSCALELABEL %LINE 182 | mov al, byte ptr [esi+ebx] ; get source pixel 183 | add edx, ebp ; calculate next location 184 | 185 | mov cl, byte ptr [edi-(LINE-1)*SCREENWIDTH] 186 | mov ch, [eax] 187 | add ecx, [_tinttable] 188 | mov ebx, edx 189 | shr ebx, 25 190 | mov al, [ecx] 191 | mov [edi-(LINE-1)*SCREENWIDTH],al ; draw a pixel to the buffer 192 | xor ecx, ecx 193 | LINE = LINE-1 194 | ENDM 195 | fuzzvscale1: 196 | mov al,[esi+ebx] 197 | mov cl, byte ptr [edi-(LINE-1)*SCREENWIDTH] 198 | mov ch, [eax] 199 | add ecx, [_tinttable] 200 | mov al, [ecx] 201 | mov [edi],al 202 | fuzzvscale0: 203 | ret 204 | 205 | ENDP 206 | 207 | ;============================================================================ 208 | ; 209 | ; unwound horizontal texture mapping code 210 | ; 211 | ; eax lighttable 212 | ; ebx scratch register 213 | ; ecx position 6.10 bits x, 6.10 bits y 214 | ; edx step 6.10 bits x, 6.10 bits y 215 | ; esi start of block 216 | ; edi dest 217 | ; ebp fff to mask bx 218 | ; 219 | ; ebp should by preset from ebx / ecx before calling 220 | ;============================================================================ 221 | 222 | OP_SHLD = 0fh 223 | 224 | 225 | .DATA 226 | 227 | 228 | MAPDEFINE MACRO number 229 | dd hmap&number 230 | ENDM 231 | 232 | ALIGN 4 233 | mapcalls LABEL 234 | LINE = 0 235 | REPT SCREENWIDTH+1 236 | MAPDEFINE %LINE 237 | LINE = LINE+1 238 | ENDM 239 | 240 | 241 | callpoint dd 0 242 | returnpoint dd 0 243 | 244 | 245 | .CODE 246 | 247 | ;================ 248 | ; 249 | ; R_DrawSpan 250 | ; 251 | ; Horizontal texture mapping 252 | ; 253 | ;================ 254 | 255 | 256 | PROC R_DrawSpan_ 257 | PUBLIC R_DrawSpan_ 258 | PUSHR 259 | 260 | IFE SKIPPRIMITIVES 261 | 262 | mov eax,[_ds_x1] 263 | mov ebx,[_ds_x2] 264 | mov eax,[mapcalls+eax*4] 265 | mov [callpoint],eax ; spot to jump into unwound 266 | mov eax,[mapcalls+4+ebx*4] 267 | mov [returnpoint],eax ; spot to patch a ret at 268 | mov BYTE PTR [eax], OP_RET 269 | 270 | ; 271 | ; build composite position 272 | ; 273 | mov ecx,[_ds_xfrac] 274 | shl ecx,10 275 | and ecx,0ffff0000h 276 | mov eax,[_ds_yfrac] 277 | shr eax,6 278 | and eax,0ffffh 279 | or ecx,eax 280 | 281 | ; 282 | ; build composite step 283 | ; 284 | mov edx,[_ds_xstep] 285 | shl edx,10 286 | and edx,0ffff0000h 287 | mov eax,[_ds_ystep] 288 | shr eax,6 289 | and eax,0ffffh 290 | or edx,eax 291 | 292 | mov esi,[_ds_source] 293 | 294 | mov edi,[_ds_y] 295 | mov edi,[_ylookup+edi*4] 296 | add edi,[_columnofs] 297 | 298 | mov eax,[_ds_colormap] 299 | 300 | ; 301 | ; feed the pipeline and jump in 302 | ; 303 | mov ebp,0fffh ; used to mask off slop high bits from position 304 | shld ebx,ecx,22 ; shift y units in 305 | shld ebx,ecx,6 ; shift x units in 306 | and ebx,ebp ; mask off slop bits 307 | call [callpoint] 308 | 309 | mov ebx,[returnpoint] 310 | mov BYTE PTR [ebx],OP_MOVAL ; remove the ret patched in 311 | 312 | ENDIF 313 | POPR 314 | ret 315 | 316 | 317 | ;============= HIGH DETAIL ============ 318 | 319 | .CODE 320 | 321 | MAPLABEL MACRO number 322 | hmap&number: 323 | ENDM 324 | 325 | LINE = 0 326 | PCOL = 0 327 | REPT SCREENWIDTH/4 328 | PLANE = 0 329 | REPT 4 330 | MAPLABEL %LINE 331 | LINE = LINE + 1 332 | 333 | mov al,[esi+ebx] ; get source pixel 334 | shld ebx,ecx,22 ; shift y units in 335 | shld ebx,ecx,6 ; shift x units in 336 | mov al,[eax] ; translate color 337 | and ebx,ebp ; mask off slop bits 338 | add ecx,edx ; position += step 339 | mov [edi+PLANE+PCOL*4],al ; write pixel 340 | PLANE = PLANE + 1 341 | ENDM 342 | PCOL = PCOL + 1 343 | ENDM 344 | hmap320: 345 | ret 346 | 347 | ENDP 348 | 349 | END 350 | -------------------------------------------------------------------------------- /Hexen Source/DSTRINGS.H: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** DStrings.H 5 | //** 6 | //************************************************************************** 7 | 8 | // MN_menu.c --------------------------------------------------------------- 9 | 10 | #define PRESSKEY "press a key." 11 | #define PRESSYN "press y or n." 12 | #define TXT_PAUSED "PAUSED" 13 | #define QUITMSG "are you sure you want to\nquit this great game?" 14 | #define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY 15 | #define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY 16 | #define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY 17 | #define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY 18 | #define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN 19 | #define QLPROMPT "do you want to quickload the game named"\ 20 | "\n\n'%s'?\n\n"PRESSYN 21 | #define NEWGAME "you can't start a new game\n"\ 22 | "while in a network game.\n\n"PRESSKEY 23 | #define NIGHTMARE "are you sure? this skill level\n"\ 24 | "isn't even remotely fair.\n\n"PRESSYN 25 | #define SWSTRING "this is the shareware version of doom.\n\n"\ 26 | "you need to order the entire trilogy.\n\n"PRESSKEY 27 | #define MSGOFF "Messages OFF" 28 | #define MSGON "Messages ON" 29 | #define NETEND "you can't end a netgame!\n\n"PRESSKEY 30 | #define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN 31 | #define DOSY "(press y to quit to dos.)" 32 | #define DETAILHI "High detail" 33 | #define DETAILLO "Low detail" 34 | #define GAMMALVL0 "Gamma correction OFF" 35 | #define GAMMALVL1 "Gamma correction level 1" 36 | #define GAMMALVL2 "Gamma correction level 2" 37 | #define GAMMALVL3 "Gamma correction level 3" 38 | #define GAMMALVL4 "Gamma correction level 4" 39 | #define EMPTYSTRING "empty slot" 40 | 41 | // P_inter.c --------------------------------------------------------------- 42 | 43 | // Keys 44 | 45 | #define TXT_GOTBLUEKEY "BLUE KEY" 46 | #define TXT_GOTYELLOWKEY "YELLOW KEY" 47 | #define TXT_GOTGREENKEY "GREEN KEY" 48 | 49 | // Artifacts 50 | 51 | #define TXT_ARTIHEALTH "QUARTZ FLASK" 52 | #define TXT_ARTIFLY "WINGS OF WRATH" 53 | #define TXT_ARTIINVULNERABILITY "RING OF INVINCIBILITY" 54 | #define TXT_ARTITOMEOFPOWER "TOME OF POWER" 55 | #define TXT_ARTIINVISIBILITY "SHADOWSPHERE" 56 | #define TXT_ARTIEGG "MORPH OVUM" 57 | #define TXT_ARTISUPERHEALTH "MYSTIC URN" 58 | #define TXT_ARTITORCH "TORCH" 59 | #define TXT_ARTIFIREBOMB "TIME BOMB OF THE ANCIENTS" 60 | #define TXT_ARTITELEPORT "CHAOS DEVICE" 61 | 62 | // Items 63 | 64 | #define TXT_ITEMHEALTH "CRYSTAL VIAL" 65 | #define TXT_ITEMBAGOFHOLDING "BAG OF HOLDING" 66 | #define TXT_ITEMSHIELD1 "SILVER SHIELD" 67 | #define TXT_ITEMSHIELD2 "ENCHANTED SHIELD" 68 | #define TXT_ITEMSUPERMAP "MAP SCROLL" 69 | 70 | // Ammo 71 | 72 | #define TXT_AMMOGOLDWAND1 "WAND CRYSTAL" 73 | #define TXT_AMMOGOLDWAND2 "CRYSTAL GEODE" 74 | #define TXT_AMMOMACE1 "MACE SPHERES" 75 | #define TXT_AMMOMACE2 "PILE OF MACE SPHERES" 76 | #define TXT_AMMOCROSSBOW1 "ETHEREAL ARROWS" 77 | #define TXT_AMMOCROSSBOW2 "QUIVER OF ETHEREAL ARROWS" 78 | #define TXT_AMMOBLASTER1 "CLAW ORB" 79 | #define TXT_AMMOBLASTER2 "ENERGY ORB" 80 | #define TXT_AMMOSKULLROD1 "LESSER RUNES" 81 | #define TXT_AMMOSKULLROD2 "GREATER RUNES" 82 | #define TXT_AMMOPHOENIXROD1 "FLAME ORB" 83 | #define TXT_AMMOPHOENIXROD2 "INFERNO ORB" 84 | 85 | // Weapons 86 | 87 | #define TXT_WPNMACE "FIREMACE" 88 | #define TXT_WPNCROSSBOW "ETHEREAL CROSSBOW" 89 | #define TXT_WPNBLASTER "DRAGON CLAW" 90 | #define TXT_WPNSKULLROD "HELLSTAFF" 91 | #define TXT_WPNPHOENIXROD "PHOENIX ROD" 92 | #define TXT_WPNGAUNTLETS "GAUNTLETS OF THE NECROMANCER" 93 | 94 | // SB_bar.c ---------------------------------------------------------------- 95 | 96 | #define TXT_CHEATGODON "GOD MODE ON" 97 | #define TXT_CHEATGODOFF "GOD MODE OFF" 98 | #define TXT_CHEATNOCLIPON "NO CLIPPING ON" 99 | #define TXT_CHEATNOCLIPOFF "NO CLIPPING OFF" 100 | #define TXT_CHEATWEAPONS "ALL WEAPONS" 101 | #define TXT_CHEATFLIGHTON "FLIGHT ON" 102 | #define TXT_CHEATFLIGHTOFF "FLIGHT OFF" 103 | #define TXT_CHEATPOWERON "POWER ON" 104 | #define TXT_CHEATPOWEROFF "POWER OFF" 105 | #define TXT_CHEATHEALTH "FULL HEALTH" 106 | #define TXT_CHEATKEYS "ALL KEYS" 107 | #define TXT_CHEATSOUNDON "SOUND DEBUG ON" 108 | #define TXT_CHEATSOUNDOFF "SOUND DEBUG OFF" 109 | #define TXT_CHEATTICKERON "TICKER ON" 110 | #define TXT_CHEATTICKEROFF "TICKER OFF" 111 | #define TXT_CHEATARTIFACTS1 "CHOOSE AN ARTIFACT ( A - J )" 112 | #define TXT_CHEATARTIFACTS2 "HOW MANY ( 1 - 9 )" 113 | #define TXT_CHEATARTIFACTS3 "YOU GOT IT" 114 | #define TXT_CHEATARTIFACTSFAIL "BAD INPUT" 115 | #define TXT_CHEATWARP "LEVEL WARP" 116 | #define TXT_CHEATSCREENSHOT "SCREENSHOT" 117 | #define TXT_CHEATCHICKENON "CHICKEN ON" 118 | #define TXT_CHEATCHICKENOFF "CHICKEN OFF" 119 | #define TXT_CHEATMASSACRE "MASSACRE" 120 | #define TXT_CHEATIDDQD "TRYING TO CHEAT, EH? NOW YOU DIE!" 121 | #define TXT_CHEATIDKFA "CHEATER - YOU DON'T DESERVE WEAPONS" 122 | 123 | // P_doors.c --------------------------------------------------------------- 124 | 125 | #define TXT_NEEDBLUEKEY "YOU NEED A BLUE KEY TO OPEN THIS DOOR" 126 | #define TXT_NEEDGREENKEY "YOU NEED A GREEN KEY TO OPEN THIS DOOR" 127 | #define TXT_NEEDYELLOWKEY "YOU NEED A YELLOW KEY TO OPEN THIS DOOR" 128 | 129 | // G_game.c ---------------------------------------------------------------- 130 | 131 | #define TXT_GAMESAVED "GAME SAVED" 132 | 133 | // M_misc.c ---------------------------------------------------------------- 134 | 135 | #define HUSTR_CHATMACRO1 "I'm ready to kick butt!" 136 | #define HUSTR_CHATMACRO2 "I'm OK." 137 | #define HUSTR_CHATMACRO3 "I'm not looking too good!" 138 | #define HUSTR_CHATMACRO4 "Help!" 139 | #define HUSTR_CHATMACRO5 "You suck!" 140 | #define HUSTR_CHATMACRO6 "Next time, scumbag..." 141 | #define HUSTR_CHATMACRO7 "Come here!" 142 | #define HUSTR_CHATMACRO8 "I'll take care of it." 143 | #define HUSTR_CHATMACRO9 "Yes" 144 | #define HUSTR_CHATMACRO0 "No" 145 | 146 | // AM_map.c ---------------------------------------------------------------- 147 | 148 | #define AMSTR_FOLLOWON "FOLLOW MODE ON" 149 | #define AMSTR_FOLLOWOFF "FOLLOW MODE OFF" 150 | 151 | // F_finale.c -------------------------------------------------------------- 152 | 153 | #define E1TEXT "with the destruction of the iron\n"\ 154 | "liches and their minions, the last\n"\ 155 | "of the undead are cleared from this\n"\ 156 | "plane of existence.\n\n"\ 157 | "those creatures had to come from\n"\ 158 | "somewhere, though, and you have the\n"\ 159 | "sneaky suspicion that the fiery\n"\ 160 | "portal of hell's maw opens onto\n"\ 161 | "their home dimension.\n\n"\ 162 | "to make sure that more undead\n"\ 163 | "(or even worse things) don't come\n"\ 164 | "through, you'll have to seal hell's\n"\ 165 | "maw from the other side. of course\n"\ 166 | "this means you may get stuck in a\n"\ 167 | "very unfriendly world, but no one\n"\ 168 | "ever said being a Heretic was easy!" 169 | 170 | #define E2TEXT "the mighty maulotaurs have proved\n"\ 171 | "to be no match for you, and as\n"\ 172 | "their steaming corpses slide to the\n"\ 173 | "ground you feel a sense of grim\n"\ 174 | "satisfaction that they have been\n"\ 175 | "destroyed.\n\n"\ 176 | "the gateways which they guarded\n"\ 177 | "have opened, revealing what you\n"\ 178 | "hope is the way home. but as you\n"\ 179 | "step through, mocking laughter\n"\ 180 | "rings in your ears.\n\n"\ 181 | "was some other force controlling\n"\ 182 | "the maulotaurs? could there be even\n"\ 183 | "more horrific beings through this\n"\ 184 | "gate? the sweep of a crystal dome\n"\ 185 | "overhead where the sky should be is\n"\ 186 | "certainly not a good sign...." 187 | 188 | #define E3TEXT "the death of d'sparil has loosed\n"\ 189 | "the magical bonds holding his\n"\ 190 | "creatures on this plane, their\n"\ 191 | "dying screams overwhelming his own\n"\ 192 | "cries of agony.\n\n"\ 193 | "your oath of vengeance fulfilled,\n"\ 194 | "you enter the portal to your own\n"\ 195 | "world, mere moments before the dome\n"\ 196 | "shatters into a million pieces.\n\n"\ 197 | "but if d'sparil's power is broken\n"\ 198 | "forever, why don't you feel safe?\n"\ 199 | "was it that last shout just before\n"\ 200 | "his death, the one that sounded\n"\ 201 | "like a curse? or a summoning? you\n"\ 202 | "can't really be sure, but it might\n"\ 203 | "just have been a scream.\n\n"\ 204 | "then again, what about the other\n"\ 205 | "serpent riders?" 206 | -------------------------------------------------------------------------------- /Hexen Source/P_CEILNG.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_ceilng.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_ceilng.c,v $ 7 | //** $Revision: 1.17 $ 8 | //** $Date: 95/09/11 22:06:25 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | #include "soundst.h" 16 | 17 | //================================================================== 18 | //================================================================== 19 | // 20 | // CEILINGS 21 | // 22 | //================================================================== 23 | //================================================================== 24 | 25 | ceiling_t *activeceilings[MAXCEILINGS]; 26 | 27 | //================================================================== 28 | // 29 | // T_MoveCeiling 30 | // 31 | //================================================================== 32 | void T_MoveCeiling (ceiling_t *ceiling) 33 | { 34 | result_e res; 35 | 36 | switch(ceiling->direction) 37 | { 38 | // case 0: // IN STASIS 39 | // break; 40 | case 1: // UP 41 | res = T_MovePlane(ceiling->sector,ceiling->speed, 42 | ceiling->topheight, false, 1, ceiling->direction); 43 | if (res == RES_PASTDEST) 44 | { 45 | SN_StopSequence((mobj_t *)&ceiling->sector->soundorg); 46 | switch(ceiling->type) 47 | { 48 | case CLEV_CRUSHANDRAISE: 49 | ceiling->direction = -1; 50 | ceiling->speed = ceiling->speed*2; 51 | break; 52 | default: 53 | P_RemoveActiveCeiling(ceiling); 54 | break; 55 | } 56 | } 57 | break; 58 | case -1: // DOWN 59 | res = T_MovePlane(ceiling->sector,ceiling->speed, 60 | ceiling->bottomheight, ceiling->crush, 1, ceiling->direction); 61 | if(res == RES_PASTDEST) 62 | { 63 | SN_StopSequence((mobj_t *)&ceiling->sector->soundorg); 64 | switch(ceiling->type) 65 | { 66 | case CLEV_CRUSHANDRAISE: 67 | case CLEV_CRUSHRAISEANDSTAY: 68 | ceiling->direction = 1; 69 | ceiling->speed = ceiling->speed/2; 70 | break; 71 | default: 72 | P_RemoveActiveCeiling(ceiling); 73 | break; 74 | } 75 | } 76 | else if(res == RES_CRUSHED) 77 | { 78 | switch(ceiling->type) 79 | { 80 | case CLEV_CRUSHANDRAISE: 81 | case CLEV_LOWERANDCRUSH: 82 | case CLEV_CRUSHRAISEANDSTAY: 83 | //ceiling->speed = ceiling->speed/4; 84 | break; 85 | default: 86 | break; 87 | } 88 | } 89 | break; 90 | } 91 | } 92 | 93 | //================================================================== 94 | // 95 | // EV_DoCeiling 96 | // Move a ceiling up/down and all around! 97 | // 98 | //================================================================== 99 | int EV_DoCeiling (line_t *line, byte *arg, ceiling_e type) 100 | { 101 | int secnum,rtn; 102 | sector_t *sec; 103 | ceiling_t *ceiling; 104 | 105 | secnum = -1; 106 | rtn = 0; 107 | 108 | /* Old Ceiling stasis code 109 | // 110 | // Reactivate in-stasis ceilings...for certain types. 111 | // 112 | switch(type) 113 | { 114 | case CLEV_CRUSHANDRAISE: 115 | P_ActivateInStasisCeiling(line); 116 | default: 117 | break; 118 | } 119 | */ 120 | while ((secnum = P_FindSectorFromTag(arg[0], secnum)) >= 0) 121 | { 122 | sec = §ors[secnum]; 123 | if (sec->specialdata) 124 | continue; 125 | 126 | // 127 | // new door thinker 128 | // 129 | rtn = 1; 130 | ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); 131 | P_AddThinker (&ceiling->thinker); 132 | sec->specialdata = ceiling; 133 | ceiling->thinker.function = T_MoveCeiling; 134 | ceiling->sector = sec; 135 | ceiling->crush = 0; 136 | ceiling->speed = arg[1]*(FRACUNIT/8); 137 | switch(type) 138 | { 139 | case CLEV_CRUSHRAISEANDSTAY: 140 | ceiling->crush = arg[2]; // arg[2] = crushing value 141 | ceiling->topheight = sec->ceilingheight; 142 | ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); 143 | ceiling->direction = -1; 144 | break; 145 | case CLEV_CRUSHANDRAISE: 146 | ceiling->topheight = sec->ceilingheight; 147 | case CLEV_LOWERANDCRUSH: 148 | ceiling->crush = arg[2]; // arg[2] = crushing value 149 | case CLEV_LOWERTOFLOOR: 150 | ceiling->bottomheight = sec->floorheight; 151 | if(type != CLEV_LOWERTOFLOOR) 152 | { 153 | ceiling->bottomheight += 8*FRACUNIT; 154 | } 155 | ceiling->direction = -1; 156 | break; 157 | case CLEV_RAISETOHIGHEST: 158 | ceiling->topheight = P_FindHighestCeilingSurrounding(sec); 159 | ceiling->direction = 1; 160 | break; 161 | case CLEV_LOWERBYVALUE: 162 | ceiling->bottomheight = sec->ceilingheight-arg[2]*FRACUNIT; 163 | ceiling->direction = -1; 164 | break; 165 | case CLEV_RAISEBYVALUE: 166 | ceiling->topheight = sec->ceilingheight+arg[2]*FRACUNIT; 167 | ceiling->direction = 1; 168 | break; 169 | case CLEV_MOVETOVALUETIMES8: 170 | { 171 | int destHeight = arg[2]*FRACUNIT*8; 172 | 173 | if(arg[3]) 174 | { 175 | destHeight = -destHeight; 176 | } 177 | if(sec->ceilingheight <= destHeight) 178 | { 179 | ceiling->direction = 1; 180 | ceiling->topheight = destHeight; 181 | if(sec->ceilingheight == destHeight) 182 | { 183 | rtn = 0; 184 | } 185 | } 186 | else if(sec->ceilingheight > destHeight) 187 | { 188 | ceiling->direction = -1; 189 | ceiling->bottomheight = destHeight; 190 | } 191 | break; 192 | } 193 | default: 194 | rtn = 0; 195 | break; 196 | } 197 | ceiling->tag = sec->tag; 198 | ceiling->type = type; 199 | P_AddActiveCeiling(ceiling); 200 | if(rtn) 201 | { 202 | SN_StartSequence((mobj_t *)&ceiling->sector->soundorg, 203 | SEQ_PLATFORM+ceiling->sector->seqType); 204 | } 205 | } 206 | return rtn; 207 | } 208 | 209 | //================================================================== 210 | // 211 | // Add an active ceiling 212 | // 213 | //================================================================== 214 | void P_AddActiveCeiling(ceiling_t *c) 215 | { 216 | int i; 217 | for (i = 0; i < MAXCEILINGS;i++) 218 | if (activeceilings[i] == NULL) 219 | { 220 | activeceilings[i] = c; 221 | return; 222 | } 223 | } 224 | 225 | //================================================================== 226 | // 227 | // Remove a ceiling's thinker 228 | // 229 | //================================================================== 230 | void P_RemoveActiveCeiling(ceiling_t *c) 231 | { 232 | int i; 233 | 234 | for (i = 0;i < MAXCEILINGS;i++) 235 | if (activeceilings[i] == c) 236 | { 237 | activeceilings[i]->sector->specialdata = NULL; 238 | P_RemoveThinker (&activeceilings[i]->thinker); 239 | P_TagFinished(activeceilings[i]->sector->tag); 240 | activeceilings[i] = NULL; 241 | break; 242 | } 243 | } 244 | 245 | #if 0 246 | //================================================================== 247 | // 248 | // Restart a ceiling that's in-stasis 249 | // 250 | //================================================================== 251 | void P_ActivateInStasisCeiling(line_t *line) 252 | { 253 | int i; 254 | 255 | for (i = 0;i < MAXCEILINGS;i++) 256 | if (activeceilings[i] && (activeceilings[i]->tag == line->arg1) && 257 | (activeceilings[i]->direction == 0)) 258 | { 259 | activeceilings[i]->direction = activeceilings[i]->olddirection; 260 | activeceilings[i]->thinker.function = T_MoveCeiling; 261 | SN_StartSequence((mobj_t *)&activeceilings[i]->sector->soundorg, 262 | SEQ_PLATFORM+activeceilings[i]->sector->seqType); 263 | } 264 | } 265 | #endif 266 | 267 | //================================================================== 268 | // 269 | // EV_CeilingCrushStop 270 | // Stop a ceiling from crushing! 271 | // 272 | //================================================================== 273 | 274 | int EV_CeilingCrushStop(line_t *line, byte *args) 275 | { 276 | int i; 277 | int rtn; 278 | 279 | rtn = 0; 280 | for (i = 0;i < MAXCEILINGS;i++) 281 | { 282 | if(activeceilings[i] && activeceilings[i]->tag == args[0]) 283 | { 284 | rtn = 1; 285 | SN_StopSequence((mobj_t*)&activeceilings[i]->sector->soundorg); 286 | activeceilings[i]->sector->specialdata = NULL; 287 | P_RemoveThinker (&activeceilings[i]->thinker); 288 | P_TagFinished(activeceilings[i]->sector->tag); 289 | activeceilings[i] = NULL; 290 | break; 291 | } 292 | } 293 | return rtn; 294 | } 295 | -------------------------------------------------------------------------------- /Hexen Source/P_DOORS.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_doors.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_doors.c,v $ 7 | //** $Revision: 1.13 $ 8 | //** $Date: 96/01/06 03:23:47 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | #include "soundst.h" 16 | 17 | //================================================================== 18 | //================================================================== 19 | // 20 | // VERTICAL DOORS 21 | // 22 | //================================================================== 23 | //================================================================== 24 | 25 | //================================================================== 26 | // 27 | // T_VerticalDoor 28 | // 29 | //================================================================== 30 | void T_VerticalDoor(vldoor_t *door) 31 | { 32 | result_e res; 33 | 34 | switch(door->direction) 35 | { 36 | case 0: // WAITING 37 | if(!--door->topcountdown) 38 | switch(door->type) 39 | { 40 | case DREV_NORMAL: 41 | door->direction = -1; // time to go back down 42 | SN_StartSequence((mobj_t *)&door->sector->soundorg, 43 | SEQ_DOOR_STONE+door->sector->seqType); 44 | break; 45 | case DREV_CLOSE30THENOPEN: 46 | door->direction = 1; 47 | break; 48 | default: 49 | break; 50 | } 51 | break; 52 | case 2: // INITIAL WAIT 53 | if(!--door->topcountdown) 54 | { 55 | switch(door->type) 56 | { 57 | case DREV_RAISEIN5MINS: 58 | door->direction = 1; 59 | door->type = DREV_NORMAL; 60 | break; 61 | default: 62 | break; 63 | } 64 | } 65 | break; 66 | case -1: // DOWN 67 | res = T_MovePlane(door->sector, door->speed, 68 | door->sector->floorheight, false, 1, door->direction); 69 | if(res == RES_PASTDEST) 70 | { 71 | SN_StopSequence((mobj_t *)&door->sector->soundorg); 72 | switch(door->type) 73 | { 74 | case DREV_NORMAL: 75 | case DREV_CLOSE: 76 | door->sector->specialdata = NULL; 77 | P_TagFinished(door->sector->tag); 78 | P_RemoveThinker(&door->thinker); // unlink and free 79 | break; 80 | case DREV_CLOSE30THENOPEN: 81 | door->direction = 0; 82 | door->topcountdown = 35*30; 83 | break; 84 | default: 85 | break; 86 | } 87 | } 88 | else if(res == RES_CRUSHED) 89 | { 90 | switch(door->type) 91 | { 92 | case DREV_CLOSE: // DON'T GO BACK UP! 93 | break; 94 | default: 95 | door->direction = 1; 96 | break; 97 | } 98 | } 99 | break; 100 | case 1: // UP 101 | res = T_MovePlane(door->sector, door->speed, 102 | door->topheight, false, 1, door->direction); 103 | if(res == RES_PASTDEST) 104 | { 105 | SN_StopSequence((mobj_t *)&door->sector->soundorg); 106 | switch(door->type) 107 | { 108 | case DREV_NORMAL: 109 | door->direction = 0; // wait at top 110 | door->topcountdown = door->topwait; 111 | break; 112 | case DREV_CLOSE30THENOPEN: 113 | case DREV_OPEN: 114 | door->sector->specialdata = NULL; 115 | P_TagFinished(door->sector->tag); 116 | P_RemoveThinker (&door->thinker); // unlink and free 117 | break; 118 | default: 119 | break; 120 | } 121 | } 122 | break; 123 | } 124 | } 125 | 126 | //---------------------------------------------------------------------------- 127 | // 128 | // EV_DoDoor 129 | // 130 | // Move a door up/down 131 | // 132 | //---------------------------------------------------------------------------- 133 | 134 | int EV_DoDoor(line_t *line, byte *args, vldoor_e type) 135 | { 136 | int secnum; 137 | int retcode; 138 | sector_t *sec; 139 | vldoor_t *door; 140 | fixed_t speed; 141 | 142 | speed = args[1]*FRACUNIT/8; 143 | secnum = -1; 144 | retcode = 0; 145 | while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) 146 | { 147 | sec = §ors[secnum]; 148 | if(sec->specialdata) 149 | { 150 | continue; 151 | } 152 | // Add new door thinker 153 | retcode = 1; 154 | door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0); 155 | P_AddThinker(&door->thinker); 156 | sec->specialdata = door; 157 | door->thinker.function = T_VerticalDoor; 158 | door->sector = sec; 159 | switch(type) 160 | { 161 | case DREV_CLOSE: 162 | door->topheight = P_FindLowestCeilingSurrounding(sec); 163 | door->topheight -= 4*FRACUNIT; 164 | door->direction = -1; 165 | break; 166 | case DREV_CLOSE30THENOPEN: 167 | door->topheight = sec->ceilingheight; 168 | door->direction = -1; 169 | break; 170 | case DREV_NORMAL: 171 | case DREV_OPEN: 172 | door->direction = 1; 173 | door->topheight = P_FindLowestCeilingSurrounding(sec); 174 | door->topheight -= 4*FRACUNIT; 175 | break; 176 | default: 177 | break; 178 | } 179 | door->type = type; 180 | door->speed = speed; 181 | door->topwait = args[2]; // line->arg3 182 | SN_StartSequence((mobj_t *)&door->sector->soundorg, 183 | SEQ_DOOR_STONE+door->sector->seqType); 184 | } 185 | return(retcode); 186 | } 187 | 188 | //================================================================== 189 | // 190 | // EV_VerticalDoor : open a door manually, no tag value 191 | // 192 | //================================================================== 193 | boolean EV_VerticalDoor(line_t *line, mobj_t *thing) 194 | { 195 | int secnum; 196 | sector_t *sec; 197 | vldoor_t *door; 198 | int side; 199 | 200 | side = 0; // only front sides can be used 201 | 202 | // if the sector has an active thinker, use it 203 | sec = sides[line->sidenum[side^1]].sector; 204 | secnum = sec-sectors; 205 | if(sec->specialdata) 206 | { 207 | return false; 208 | /* 209 | door = sec->specialdata; 210 | switch(line->special) 211 | { // only for raise doors 212 | case 12: 213 | if(door->direction == -1) 214 | { 215 | door->direction = 1; // go back up 216 | } 217 | else 218 | { 219 | if(!thing->player) 220 | { // Monsters don't close doors 221 | return; 222 | } 223 | door->direction = -1; // start going down immediately 224 | } 225 | return; 226 | } 227 | */ 228 | } 229 | // 230 | // new door thinker 231 | // 232 | door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); 233 | P_AddThinker(&door->thinker); 234 | sec->specialdata = door; 235 | door->thinker.function = T_VerticalDoor; 236 | door->sector = sec; 237 | door->direction = 1; 238 | switch(line->special) 239 | { 240 | case 11: 241 | door->type = DREV_OPEN; 242 | line->special = 0; 243 | break; 244 | case 12: 245 | case 13: 246 | door->type = DREV_NORMAL; 247 | break; 248 | default: 249 | door->type = DREV_NORMAL; 250 | break; 251 | } 252 | door->speed = line->arg2*(FRACUNIT/8); 253 | door->topwait = line->arg3; 254 | 255 | // 256 | // find the top and bottom of the movement range 257 | // 258 | door->topheight = P_FindLowestCeilingSurrounding(sec); 259 | door->topheight -= 4*FRACUNIT; 260 | SN_StartSequence((mobj_t *)&door->sector->soundorg, 261 | SEQ_DOOR_STONE+door->sector->seqType); 262 | return true; 263 | } 264 | 265 | //================================================================== 266 | // 267 | // Spawn a door that closes after 30 seconds 268 | // 269 | //================================================================== 270 | 271 | /* 272 | void P_SpawnDoorCloseIn30(sector_t *sec) 273 | { 274 | vldoor_t *door; 275 | 276 | door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0); 277 | P_AddThinker(&door->thinker); 278 | sec->specialdata = door; 279 | sec->special = 0; 280 | door->thinker.function = T_VerticalDoor; 281 | door->sector = sec; 282 | door->direction = 0; 283 | door->type = DREV_NORMAL; 284 | door->speed = VDOORSPEED; 285 | door->topcountdown = 30*35; 286 | } 287 | */ 288 | 289 | //================================================================== 290 | // 291 | // Spawn a door that opens after 5 minutes 292 | // 293 | //================================================================== 294 | 295 | /* 296 | void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum) 297 | { 298 | vldoor_t *door; 299 | 300 | door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0); 301 | P_AddThinker(&door->thinker); 302 | sec->specialdata = door; 303 | sec->special = 0; 304 | door->thinker.function = T_VerticalDoor; 305 | door->sector = sec; 306 | door->direction = 2; 307 | door->type = DREV_RAISEIN5MINS; 308 | door->speed = VDOORSPEED; 309 | door->topheight = P_FindLowestCeilingSurrounding(sec); 310 | door->topheight -= 4*FRACUNIT; 311 | door->topwait = VDOORWAIT; 312 | door->topcountdown = 5*60*35; 313 | } 314 | */ 315 | -------------------------------------------------------------------------------- /Hexen Source/P_LIGHTS.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_lights.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_lights.c,v $ 7 | //** $Revision: 1.2 $ 8 | //** $Date: 95/07/11 10:23:36 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | 16 | //============================================================================ 17 | // 18 | // T_Light 19 | // 20 | //============================================================================ 21 | 22 | void T_Light(light_t *light) 23 | { 24 | if(light->count) 25 | { 26 | light->count--; 27 | return; 28 | } 29 | switch(light->type) 30 | { 31 | case LITE_FADE: 32 | light->sector->lightlevel = ((light->sector->lightlevel<value2)>>FRACBITS; 34 | if(light->tics2 == 1) 35 | { 36 | if(light->sector->lightlevel >= light->value1) 37 | { 38 | light->sector->lightlevel = light->value1; 39 | P_RemoveThinker(&light->thinker); 40 | } 41 | } 42 | else if(light->sector->lightlevel <= light->value1) 43 | { 44 | light->sector->lightlevel = light->value1; 45 | P_RemoveThinker(&light->thinker); 46 | } 47 | break; 48 | case LITE_GLOW: 49 | light->sector->lightlevel = ((light->sector->lightlevel<tics1)>>FRACBITS; 51 | if(light->tics2 == 1) 52 | { 53 | if(light->sector->lightlevel >= light->value1) 54 | { 55 | light->sector->lightlevel = light->value1; 56 | light->tics1 = -light->tics1; 57 | light->tics2 = -1; // reverse direction 58 | } 59 | } 60 | else if(light->sector->lightlevel <= light->value2) 61 | { 62 | light->sector->lightlevel = light->value2; 63 | light->tics1 = -light->tics1; 64 | light->tics2 = 1; // reverse direction 65 | } 66 | break; 67 | case LITE_FLICKER: 68 | if(light->sector->lightlevel == light->value1) 69 | { 70 | light->sector->lightlevel = light->value2; 71 | light->count = (P_Random()&7)+1; 72 | } 73 | else 74 | { 75 | light->sector->lightlevel = light->value1; 76 | light->count = (P_Random()&31)+1; 77 | } 78 | break; 79 | case LITE_STROBE: 80 | if(light->sector->lightlevel == light->value1) 81 | { 82 | light->sector->lightlevel = light->value2; 83 | light->count = light->tics2; 84 | } 85 | else 86 | { 87 | light->sector->lightlevel = light->value1; 88 | light->count = light->tics1; 89 | } 90 | break; 91 | default: 92 | break; 93 | } 94 | } 95 | 96 | //============================================================================ 97 | // 98 | // EV_SpawnLight 99 | // 100 | //============================================================================ 101 | 102 | boolean EV_SpawnLight(line_t *line, byte *arg, lighttype_t type) 103 | { 104 | light_t *light; 105 | sector_t *sec; 106 | int secNum; 107 | int arg1, arg2, arg3, arg4; 108 | boolean think; 109 | boolean rtn; 110 | 111 | arg1 = arg[1] > 255 ? 255 : arg[1]; 112 | arg1 = arg1 < 0 ? 0 : arg1; 113 | arg2 = arg[2] > 255 ? 255 : arg[2]; 114 | arg2 = arg2 < 0 ? 0 : arg2; 115 | arg3 = arg[3] > 255 ? 255 : arg[3]; 116 | arg3 = arg3 < 0 ? 0 : arg3; 117 | arg4 = arg[4] > 255 ? 255 : arg[4]; 118 | arg4 = arg4 < 0 ? 0 : arg4; 119 | 120 | secNum = -1; 121 | rtn = false; 122 | think = false; 123 | while((secNum = P_FindSectorFromTag(arg[0], secNum)) >= 0) 124 | { 125 | think = false; 126 | sec = §ors[secNum]; 127 | 128 | light = (light_t *)Z_Malloc(sizeof(light_t), PU_LEVSPEC, 0); 129 | light->type = type; 130 | light->sector = sec; 131 | light->count = 0; 132 | rtn = true; 133 | switch(type) 134 | { 135 | case LITE_RAISEBYVALUE: 136 | sec->lightlevel += arg1; 137 | if(sec->lightlevel > 255) 138 | { 139 | sec->lightlevel = 255; 140 | } 141 | break; 142 | case LITE_LOWERBYVALUE: 143 | sec->lightlevel -= arg1; 144 | if(sec->lightlevel < 0) 145 | { 146 | sec->lightlevel = 0; 147 | } 148 | break; 149 | case LITE_CHANGETOVALUE: 150 | sec->lightlevel = arg1; 151 | if(sec->lightlevel < 0) 152 | { 153 | sec->lightlevel = 0; 154 | } 155 | else if(sec->lightlevel > 255) 156 | { 157 | sec->lightlevel = 255; 158 | } 159 | break; 160 | case LITE_FADE: 161 | think = true; 162 | light->value1 = arg1; // destination lightlevel 163 | light->value2 = FixedDiv((arg1-sec->lightlevel)<lightlevel <= arg1) 166 | { 167 | light->tics2 = 1; // get brighter 168 | } 169 | else 170 | { 171 | light->tics2 = -1; 172 | } 173 | break; 174 | case LITE_GLOW: 175 | think = true; 176 | light->value1 = arg1; // upper lightlevel 177 | light->value2 = arg2; // lower lightlevel 178 | light->tics1 = FixedDiv((arg1-sec->lightlevel)<lightlevel <= arg1) 181 | { 182 | light->tics2 = 1; // get brighter 183 | } 184 | else 185 | { 186 | light->tics2 = -1; 187 | } 188 | break; 189 | case LITE_FLICKER: 190 | think = true; 191 | light->value1 = arg1; // upper lightlevel 192 | light->value2 = arg2; // lower lightlevel 193 | sec->lightlevel = light->value1; 194 | light->count = (P_Random()&64)+1; 195 | break; 196 | case LITE_STROBE: 197 | think = true; 198 | light->value1 = arg1; // upper lightlevel 199 | light->value2 = arg2; // lower lightlevel 200 | light->tics1 = arg3; // upper tics 201 | light->tics2 = arg4; // lower tics 202 | light->count = arg3; 203 | sec->lightlevel = light->value1; 204 | break; 205 | default: 206 | rtn = false; 207 | break; 208 | } 209 | if(think) 210 | { 211 | P_AddThinker(&light->thinker); 212 | light->thinker.function = T_Light; 213 | } 214 | else 215 | { 216 | Z_Free(light); 217 | } 218 | } 219 | return rtn; 220 | } 221 | 222 | //============================================================================ 223 | // 224 | // T_Phase 225 | // 226 | //============================================================================ 227 | 228 | int PhaseTable[64] = 229 | { 230 | 128, 112, 96, 80, 64, 48, 32, 32, 231 | 16, 16, 16, 0, 0, 0, 0, 0, 232 | 0, 0, 0, 0, 0, 0, 0, 0, 233 | 0, 0, 0, 0, 0, 0, 0, 0, 234 | 0, 0, 0, 0, 0, 0, 0, 0, 235 | 0, 0, 0, 0, 0, 0, 0, 0, 236 | 0, 0, 0, 0, 0, 16, 16, 16, 237 | 32, 32, 48, 64, 80, 96, 112, 128 238 | }; 239 | 240 | void T_Phase(phase_t *phase) 241 | { 242 | phase->index = (phase->index+1)&63; 243 | phase->sector->lightlevel = phase->base+PhaseTable[phase->index]; 244 | } 245 | 246 | //========================================================================== 247 | // 248 | // P_SpawnPhasedLight 249 | // 250 | //========================================================================== 251 | 252 | void P_SpawnPhasedLight(sector_t *sector, int base, int index) 253 | { 254 | phase_t *phase; 255 | 256 | phase = Z_Malloc(sizeof(*phase), PU_LEVSPEC, 0); 257 | P_AddThinker(&phase->thinker); 258 | phase->sector = sector; 259 | if(index == -1) 260 | { // sector->lightlevel as the index 261 | phase->index = sector->lightlevel&63; 262 | } 263 | else 264 | { 265 | phase->index = index&63; 266 | } 267 | phase->base = base&255; 268 | sector->lightlevel = phase->base+PhaseTable[phase->index]; 269 | phase->thinker.function = T_Phase; 270 | 271 | sector->special = 0; 272 | } 273 | 274 | //========================================================================== 275 | // 276 | // P_SpawnLightSequence 277 | // 278 | //========================================================================== 279 | 280 | void P_SpawnLightSequence(sector_t *sector, int indexStep) 281 | { 282 | sector_t *sec; 283 | sector_t *nextSec; 284 | sector_t *tempSec; 285 | int seqSpecial; 286 | int i; 287 | int count; 288 | fixed_t index; 289 | fixed_t indexDelta; 290 | int base; 291 | 292 | seqSpecial = LIGHT_SEQUENCE; // look for Light_Sequence, first 293 | sec = sector; 294 | count = 1; 295 | do 296 | { 297 | nextSec = NULL; 298 | sec->special = LIGHT_SEQUENCE_START; // make sure that the search doesn't back up. 299 | for(i = 0; i < sec->linecount; i++) 300 | { 301 | tempSec = getNextSector(sec->lines[i], sec); 302 | if(!tempSec) 303 | { 304 | continue; 305 | } 306 | if(tempSec->special == seqSpecial) 307 | { 308 | if(seqSpecial == LIGHT_SEQUENCE) 309 | { 310 | seqSpecial = LIGHT_SEQUENCE_ALT; 311 | } 312 | else 313 | { 314 | seqSpecial = LIGHT_SEQUENCE; 315 | } 316 | nextSec = tempSec; 317 | count++; 318 | } 319 | } 320 | sec = nextSec; 321 | } while(sec); 322 | 323 | sec = sector; 324 | count *= indexStep; 325 | index = 0; 326 | indexDelta = FixedDiv(64*FRACUNIT, count*FRACUNIT); 327 | base = sector->lightlevel; 328 | do 329 | { 330 | nextSec = NULL; 331 | if(sec->lightlevel) 332 | { 333 | base = sec->lightlevel; 334 | } 335 | P_SpawnPhasedLight(sec, base, index>>FRACBITS); 336 | index += indexDelta; 337 | for(i = 0; i < sec->linecount; i++) 338 | { 339 | tempSec = getNextSector(sec->lines[i], sec); 340 | if(!tempSec) 341 | { 342 | continue; 343 | } 344 | if(tempSec->special == LIGHT_SEQUENCE_START) 345 | { 346 | nextSec = tempSec; 347 | } 348 | } 349 | sec = nextSec; 350 | } while(sec); 351 | } -------------------------------------------------------------------------------- /Hexen Source/I_SOUND.C: -------------------------------------------------------------------------------- 1 | 2 | // I_SOUND.C 3 | 4 | #include 5 | #include "h2def.h" 6 | #include "dmx.h" 7 | #include "sounds.h" 8 | #include "i_sound.h" 9 | 10 | /* 11 | =============== 12 | = 13 | = I_StartupTimer 14 | = 15 | =============== 16 | */ 17 | 18 | int tsm_ID = -1; 19 | 20 | void I_StartupTimer (void) 21 | { 22 | #ifndef NOTIMER 23 | extern int I_TimerISR(void); 24 | 25 | ST_Message(" I_StartupTimer()\n"); 26 | // installs master timer. Must be done before StartupTimer()! 27 | TSM_Install(SND_TICRATE); 28 | tsm_ID = TSM_NewService (I_TimerISR, 35, 255, 0); // max priority 29 | if (tsm_ID == -1) 30 | { 31 | I_Error("Can't register 35 Hz timer w/ DMX library"); 32 | } 33 | #endif 34 | } 35 | 36 | void I_ShutdownTimer (void) 37 | { 38 | TSM_DelService(tsm_ID); 39 | TSM_Remove(); 40 | } 41 | 42 | /* 43 | * 44 | * SOUND HEADER & DATA 45 | * 46 | * 47 | */ 48 | 49 | // sound information 50 | #if 0 51 | const char *dnames[] = {"None", 52 | "PC_Speaker", 53 | "Adlib", 54 | "Sound_Blaster", 55 | "ProAudio_Spectrum16", 56 | "Gravis_Ultrasound", 57 | "MPU", 58 | "AWE32" 59 | }; 60 | #endif 61 | 62 | const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 63 | 'M', 'M', 'S' }; 64 | 65 | int snd_Channels; 66 | int snd_DesiredMusicDevice, snd_DesiredSfxDevice; 67 | int snd_MusicDevice, // current music card # (index to dmxCodes) 68 | snd_SfxDevice, // current sfx card # (index to dmxCodes) 69 | snd_MaxVolume, // maximum volume for sound 70 | snd_MusicVolume; // maximum volume for music 71 | int dmxCodes[NUM_SCARDS]; // the dmx code for a given card 72 | 73 | int snd_SBport, snd_SBirq, snd_SBdma; // sound blaster variables 74 | int snd_Mport; // midi variables 75 | 76 | extern boolean snd_MusicAvail, // whether music is available 77 | snd_SfxAvail; // whether sfx are available 78 | 79 | void I_PauseSong(int handle) 80 | { 81 | MUS_PauseSong(handle); 82 | } 83 | 84 | void I_ResumeSong(int handle) 85 | { 86 | MUS_ResumeSong(handle); 87 | } 88 | 89 | void I_SetMusicVolume(int volume) 90 | { 91 | MUS_SetMasterVolume(volume*8); 92 | // snd_MusicVolume = volume; 93 | } 94 | 95 | void I_SetSfxVolume(int volume) 96 | { 97 | snd_MaxVolume = volume; // THROW AWAY? 98 | } 99 | 100 | /* 101 | * 102 | * SONG API 103 | * 104 | */ 105 | 106 | int I_RegisterSong(void *data) 107 | { 108 | int rc = MUS_RegisterSong(data); 109 | #ifdef SNDDEBUG 110 | if (rc<0) ST_Message(" MUS_Reg() returned %d\n", rc); 111 | #endif 112 | return rc; 113 | } 114 | 115 | void I_UnRegisterSong(int handle) 116 | { 117 | int rc = MUS_UnregisterSong(handle); 118 | #ifdef SNDDEBUG 119 | if (rc < 0) ST_Message(" MUS_Unreg() returned %d\n", rc); 120 | #endif 121 | } 122 | 123 | int I_QrySongPlaying(int handle) 124 | { 125 | int rc = MUS_QrySongPlaying(handle); 126 | #ifdef SNDDEBUG 127 | if (rc < 0) ST_Message(" MUS_QrySP() returned %d\n", rc); 128 | #endif 129 | return rc; 130 | } 131 | 132 | // Stops a song. MUST be called before I_UnregisterSong(). 133 | 134 | void I_StopSong(int handle) 135 | { 136 | int rc; 137 | rc = MUS_StopSong(handle); 138 | #ifdef SNDDEBUG 139 | if (rc < 0) ST_Message(" MUS_StopSong() returned %d\n", rc); 140 | #endif 141 | /* 142 | // Fucking kluge pause 143 | { 144 | int s; 145 | extern volatile int ticcount; 146 | for (s=ticcount ; ticcount - s < 10 ; ); 147 | } 148 | */ 149 | } 150 | 151 | void I_PlaySong(int handle, boolean looping) 152 | { 153 | int rc; 154 | rc = MUS_ChainSong(handle, looping ? handle : -1); 155 | #ifdef SNDDEBUG 156 | if (rc < 0) ST_Message(" MUS_ChainSong() returned %d\n", rc); 157 | #endif 158 | rc = MUS_PlaySong(handle, snd_MusicVolume); 159 | #ifdef SNDDEBUG 160 | if (rc < 0) ST_Message(" MUS_PlaySong() returned %d\n", rc); 161 | #endif 162 | 163 | } 164 | 165 | /* 166 | * 167 | * SOUND FX API 168 | * 169 | */ 170 | 171 | // Gets lump nums of the named sound. Returns pointer which will be 172 | // passed to I_StartSound() when you want to start an SFX. Must be 173 | // sure to pass this to UngetSoundEffect() so that they can be 174 | // freed! 175 | 176 | 177 | int I_GetSfxLumpNum(sfxinfo_t *sound) 178 | { 179 | return W_GetNumForName(sound->lumpname); 180 | 181 | } 182 | 183 | int I_StartSound (int id, void *data, int vol, int sep, int pitch, int priority) 184 | { 185 | return SFX_PlayPatch(data, pitch, sep, vol, 0, 0); 186 | } 187 | 188 | void I_StopSound(int handle) 189 | { 190 | // extern volatile long gDmaCount; 191 | // long waittocount; 192 | SFX_StopPatch(handle); 193 | // waittocount = gDmaCount + 2; 194 | // while (gDmaCount < waittocount) ; 195 | } 196 | 197 | int I_SoundIsPlaying(int handle) 198 | { 199 | return SFX_Playing(handle); 200 | } 201 | 202 | void I_UpdateSoundParams(int handle, int vol, int sep, int pitch) 203 | { 204 | SFX_SetOrigin(handle, pitch, sep, vol); 205 | } 206 | 207 | /* 208 | * 209 | * SOUND STARTUP STUFF 210 | * 211 | * 212 | */ 213 | 214 | // 215 | // Why PC's Suck, Reason #8712 216 | // 217 | 218 | void I_sndArbitrateCards(void) 219 | { 220 | char tmp[160]; 221 | boolean gus, adlib, pc, sb, midi; 222 | int i, rc, mputype, p, opltype, wait, dmxlump; 223 | 224 | snd_MusicDevice = snd_DesiredMusicDevice; 225 | snd_SfxDevice = snd_DesiredSfxDevice; 226 | 227 | // check command-line parameters- overrides config file 228 | // 229 | if (M_CheckParm("-nosound")) snd_MusicDevice = snd_SfxDevice = snd_none; 230 | if (M_CheckParm("-nosfx")) snd_SfxDevice = snd_none; 231 | if (M_CheckParm("-nomusic")) snd_MusicDevice = snd_none; 232 | 233 | if (snd_MusicDevice > snd_MPU && snd_MusicDevice <= snd_MPU3) 234 | snd_MusicDevice = snd_MPU; 235 | if (snd_MusicDevice == snd_SB) 236 | snd_MusicDevice = snd_Adlib; 237 | if (snd_MusicDevice == snd_PAS) 238 | snd_MusicDevice = snd_Adlib; 239 | 240 | // figure out what i've got to initialize 241 | // 242 | gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS; 243 | sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB; 244 | adlib = snd_MusicDevice == snd_Adlib ; 245 | pc = snd_SfxDevice == snd_PC; 246 | midi = snd_MusicDevice == snd_MPU; 247 | 248 | // initialize whatever i've got 249 | // 250 | if (gus) 251 | { 252 | if (GF1_Detect()) ST_Message(" Dude. The GUS ain't responding.\n"); 253 | else 254 | { 255 | dmxlump = W_GetNumForName("dmxgus"); 256 | GF1_SetMap(W_CacheLumpNum(dmxlump, PU_CACHE), lumpinfo[dmxlump].size); 257 | } 258 | 259 | } 260 | if (sb) 261 | { 262 | if(debugmode) 263 | { 264 | ST_Message(" Sound cfg p=0x%x, i=%d, d=%d\n", 265 | snd_SBport, snd_SBirq, snd_SBdma); 266 | } 267 | if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0)) 268 | { 269 | ST_Message(" SB isn't responding at p=0x%x, i=%d, d=%d\n", 270 | snd_SBport, snd_SBirq, snd_SBdma); 271 | } 272 | else SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma); 273 | 274 | if(debugmode) 275 | { 276 | ST_Message(" SB_Detect returned p=0x%x, i=%d, d=%d\n", 277 | snd_SBport, snd_SBirq, snd_SBdma); 278 | } 279 | } 280 | 281 | if (adlib) 282 | { 283 | if (AL_Detect(&wait,0)) 284 | { 285 | ST_Message(" Dude. The Adlib isn't responding.\n"); 286 | } 287 | else 288 | { 289 | AL_SetCard(wait, W_CacheLumpName("genmidi", PU_STATIC)); 290 | } 291 | } 292 | 293 | if (midi) 294 | { 295 | if (debugmode) 296 | { 297 | ST_Message(" cfg p=0x%x\n", snd_Mport); 298 | } 299 | 300 | if (MPU_Detect(&snd_Mport, &i)) 301 | { 302 | ST_Message(" The MPU-401 isn't reponding @ p=0x%x.\n", snd_Mport); 303 | } 304 | else MPU_SetCard(snd_Mport); 305 | } 306 | 307 | } 308 | 309 | // inits all sound stuff 310 | 311 | void I_StartupSound (void) 312 | { 313 | int rc, i; 314 | 315 | if (debugmode) 316 | ST_Message("I_StartupSound: Hope you hear a pop.\n"); 317 | 318 | // initialize dmxCodes[] 319 | dmxCodes[0] = 0; 320 | dmxCodes[snd_PC] = AHW_PC_SPEAKER; 321 | dmxCodes[snd_Adlib] = AHW_ADLIB; 322 | dmxCodes[snd_SB] = AHW_SOUND_BLASTER; 323 | dmxCodes[snd_PAS] = AHW_MEDIA_VISION; 324 | dmxCodes[snd_GUS] = AHW_ULTRA_SOUND; 325 | dmxCodes[snd_MPU] = AHW_MPU_401; 326 | dmxCodes[snd_MPU2] = AHW_MPU_401; 327 | dmxCodes[snd_MPU3] = AHW_MPU_401; 328 | dmxCodes[snd_AWE] = AHW_AWE32; 329 | dmxCodes[snd_CDMUSIC] = 0; 330 | 331 | // inits sound library timer stuff 332 | I_StartupTimer(); 333 | 334 | // pick the sound cards i'm going to use 335 | // 336 | I_sndArbitrateCards(); 337 | 338 | if (debugmode) 339 | { 340 | ST_Message(" Music device #%d & dmxCode=%d,", snd_MusicDevice, 341 | dmxCodes[snd_MusicDevice]); 342 | ST_Message(" Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, 343 | dmxCodes[snd_SfxDevice]); 344 | } 345 | 346 | // inits DMX sound library 347 | ST_Message(" Calling DMX_Init..."); 348 | rc = DMX_Init(SND_TICRATE, SND_MAXSONGS, dmxCodes[snd_MusicDevice], 349 | dmxCodes[snd_SfxDevice]); 350 | 351 | if (debugmode) 352 | { 353 | ST_Message(" DMX_Init() returned %d\n", rc); 354 | } 355 | 356 | } 357 | 358 | // shuts down all sound stuff 359 | 360 | void I_ShutdownSound (void) 361 | { 362 | DMX_DeInit(); 363 | I_ShutdownTimer(); 364 | } 365 | 366 | void I_SetChannels(int channels) 367 | { 368 | WAV_PlayMode(channels, SND_SAMPLERATE); 369 | } 370 | -------------------------------------------------------------------------------- /Hexen Source/F_FINALE.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** f_finale.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: f_finale.c,v $ 7 | //** $Revision: 1.7 $ 8 | //** $Date: 96/01/05 23:33:26 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | // HEADER FILES ------------------------------------------------------------ 14 | 15 | #include "h2def.h" 16 | #include "soundst.h" 17 | #include "p_local.h" 18 | #include 19 | 20 | // MACROS ------------------------------------------------------------------ 21 | 22 | #define TEXTSPEED 3 23 | #define TEXTWAIT 250 24 | 25 | // TYPES ------------------------------------------------------------------- 26 | 27 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 28 | 29 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 30 | 31 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 32 | 33 | static void TextWrite(void); 34 | static void DrawPic(void); 35 | static void InitializeFade(boolean fadeIn); 36 | static void DeInitializeFade(void); 37 | static void FadePic(void); 38 | static char *GetFinaleText(int sequence); 39 | 40 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 41 | 42 | extern boolean automapactive; 43 | extern boolean viewactive; 44 | 45 | // PUBLIC DATA DECLARATIONS ------------------------------------------------ 46 | 47 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 48 | 49 | static int FinaleStage; 50 | static int FinaleCount; 51 | static int FinaleEndCount; 52 | static int FinaleLumpNum; 53 | static int FontABaseLump; 54 | static char *FinaleText; 55 | 56 | static fixed_t *Palette; 57 | static fixed_t *PaletteDelta; 58 | static byte *RealPalette; 59 | 60 | // CODE -------------------------------------------------------------------- 61 | 62 | //=========================================================================== 63 | // 64 | // F_StartFinale 65 | // 66 | //=========================================================================== 67 | 68 | void F_StartFinale (void) 69 | { 70 | gameaction = ga_nothing; 71 | gamestate = GS_FINALE; 72 | viewactive = false; 73 | automapactive = false; 74 | P_ClearMessage(&players[consoleplayer]); 75 | 76 | FinaleStage = 0; 77 | FinaleCount = 0; 78 | FinaleText = GetFinaleText(0); 79 | FinaleEndCount = 70; 80 | FinaleLumpNum = W_GetNumForName("FINALE1"); 81 | FontABaseLump = W_GetNumForName("FONTA_S")+1; 82 | InitializeFade(1); 83 | 84 | // S_ChangeMusic(mus_victor, true); 85 | S_StartSongName("hall", false); // don't loop the song 86 | } 87 | 88 | //=========================================================================== 89 | // 90 | // F_Responder 91 | // 92 | //=========================================================================== 93 | 94 | boolean F_Responder(event_t *event) 95 | { 96 | return false; 97 | } 98 | 99 | //=========================================================================== 100 | // 101 | // F_Ticker 102 | // 103 | //=========================================================================== 104 | 105 | void F_Ticker (void) 106 | { 107 | FinaleCount++; 108 | if(FinaleStage < 5 && FinaleCount >= FinaleEndCount) 109 | { 110 | FinaleCount = 0; 111 | FinaleStage++; 112 | switch(FinaleStage) 113 | { 114 | case 1: // Text 1 115 | FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT; 116 | break; 117 | case 2: // Pic 2, Text 2 118 | FinaleText = GetFinaleText(1); 119 | FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT; 120 | FinaleLumpNum = W_GetNumForName("FINALE2"); 121 | S_StartSongName("orb", false); 122 | break; 123 | case 3: // Pic 2 -- Fade out 124 | FinaleEndCount = 70; 125 | DeInitializeFade(); 126 | InitializeFade(0); 127 | break; 128 | case 4: // Pic 3 -- Fade in 129 | FinaleLumpNum = W_GetNumForName("FINALE3"); 130 | FinaleEndCount = 71; 131 | DeInitializeFade(); 132 | InitializeFade(1); 133 | S_StartSongName("chess", true); 134 | break; 135 | case 5: // Pic 3 , Text 3 136 | FinaleText = GetFinaleText(2); 137 | DeInitializeFade(); 138 | break; 139 | default: 140 | break; 141 | } 142 | return; 143 | } 144 | if(FinaleStage == 0 || FinaleStage == 3 || FinaleStage == 4) 145 | { 146 | FadePic(); 147 | } 148 | } 149 | 150 | //=========================================================================== 151 | // 152 | // TextWrite 153 | // 154 | //=========================================================================== 155 | 156 | static void TextWrite (void) 157 | { 158 | int count; 159 | char *ch; 160 | int c; 161 | int cx, cy; 162 | patch_t *w; 163 | 164 | memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE), 165 | SCREENWIDTH*SCREENHEIGHT); 166 | if(FinaleStage == 5) 167 | { // Chess pic, draw the correct character graphic 168 | if(netgame) 169 | { 170 | V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE)); 171 | } 172 | else if(PlayerClass[consoleplayer]) 173 | { 174 | V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc") 175 | +PlayerClass[consoleplayer]-1, PU_CACHE)); 176 | } 177 | } 178 | // Draw the actual text 179 | if(FinaleStage == 5) 180 | { 181 | cy = 135; 182 | } 183 | else 184 | { 185 | cy = 5; 186 | } 187 | cx = 20; 188 | ch = FinaleText; 189 | count = (FinaleCount-10)/TEXTSPEED; 190 | if (count < 0) 191 | { 192 | count = 0; 193 | } 194 | for(; count; count--) 195 | { 196 | c = *ch++; 197 | if(!c) 198 | { 199 | break; 200 | } 201 | if(c == '\n') 202 | { 203 | cx = 20; 204 | cy += 9; 205 | continue; 206 | } 207 | if(c < 32) 208 | { 209 | continue; 210 | } 211 | c = toupper(c); 212 | if(c == 32) 213 | { 214 | cx += 5; 215 | continue; 216 | } 217 | w = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); 218 | if(cx+w->width > SCREENWIDTH) 219 | { 220 | break; 221 | } 222 | V_DrawPatch(cx, cy, w); 223 | cx += w->width; 224 | } 225 | } 226 | 227 | //=========================================================================== 228 | // 229 | // InitializeFade 230 | // 231 | //=========================================================================== 232 | 233 | static void InitializeFade(boolean fadeIn) 234 | { 235 | unsigned i; 236 | 237 | Palette = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0); 238 | PaletteDelta = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0); 239 | RealPalette = Z_Malloc(768*sizeof(byte), PU_STATIC, 0); 240 | 241 | if(fadeIn) 242 | { 243 | memset(RealPalette, 0, 768*sizeof(byte)); 244 | for(i = 0; i < 768; i++) 245 | { 246 | Palette[i] = 0; 247 | PaletteDelta[i] = FixedDiv((*((byte *)W_CacheLumpName("playpal", 248 | PU_CACHE)+i))<>FRACBITS; 290 | } 291 | I_SetPalette(RealPalette); 292 | } 293 | 294 | //=========================================================================== 295 | // 296 | // DrawPic 297 | // 298 | //=========================================================================== 299 | 300 | static void DrawPic(void) 301 | { 302 | memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE), 303 | SCREENWIDTH*SCREENHEIGHT); 304 | if(FinaleStage == 4 || FinaleStage == 5) 305 | { // Chess pic, draw the correct character graphic 306 | if(netgame) 307 | { 308 | V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE)); 309 | } 310 | else if(PlayerClass[consoleplayer]) 311 | { 312 | V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc") 313 | +PlayerClass[consoleplayer]-1, PU_CACHE)); 314 | } 315 | } 316 | } 317 | 318 | //=========================================================================== 319 | // 320 | // F_Drawer 321 | // 322 | //=========================================================================== 323 | 324 | void F_Drawer(void) 325 | { 326 | switch(FinaleStage) 327 | { 328 | case 0: // Fade in initial finale screen 329 | DrawPic(); 330 | break; 331 | case 1: 332 | case 2: 333 | TextWrite(); 334 | break; 335 | case 3: // Fade screen out 336 | DrawPic(); 337 | break; 338 | case 4: // Fade in chess screen 339 | DrawPic(); 340 | break; 341 | case 5: 342 | TextWrite(); 343 | break; 344 | } 345 | UpdateState |= I_FULLSCRN; 346 | } 347 | 348 | //========================================================================== 349 | // 350 | // GetFinaleText 351 | // 352 | //========================================================================== 353 | 354 | static char *GetFinaleText(int sequence) 355 | { 356 | char *msgLumpName; 357 | int msgSize; 358 | int msgLump; 359 | static char *winMsgLumpNames[] = 360 | { 361 | "win1msg", 362 | "win2msg", 363 | "win3msg" 364 | }; 365 | 366 | msgLumpName = winMsgLumpNames[sequence]; 367 | msgLump = W_GetNumForName(msgLumpName); 368 | msgSize = W_LumpLength(msgLump); 369 | if(msgSize >= MAX_INTRMSN_MESSAGE_SIZE) 370 | { 371 | I_Error("Finale message too long (%s)", msgLumpName); 372 | } 373 | W_ReadLump(msgLump, ClusterMessage); 374 | ClusterMessage[msgSize] = 0; // Append terminator 375 | return ClusterMessage; 376 | } 377 | -------------------------------------------------------------------------------- /Hexen Source/ST_START.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** st_start.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: st_start.c,v $ 7 | //** $Revision: 1.21 $ 8 | //** $Date: 95/12/21 15:03:51 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | 14 | // HEADER FILES ------------------------------------------------------------ 15 | #ifdef __WATCOMC__ 16 | #include 17 | #include 18 | #include 19 | #else 20 | #include 21 | #include 22 | #define O_BINARY 0 23 | #endif 24 | #include "h2def.h" 25 | #include 26 | #include // Needed for next as well as dos 27 | #include "st_start.h" 28 | 29 | 30 | // MACROS ------------------------------------------------------------------ 31 | #define ST_MAX_NOTCHES 32 32 | #define ST_NOTCH_WIDTH 16 33 | #define ST_NOTCH_HEIGHT 23 34 | #define ST_PROGRESS_X 64 // Start of notches x screen pos. 35 | #define ST_PROGRESS_Y 441 // Start of notches y screen pos. 36 | 37 | #define ST_NETPROGRESS_X 288 38 | #define ST_NETPROGRESS_Y 32 39 | #define ST_NETNOTCH_WIDTH 8 40 | #define ST_NETNOTCH_HEIGHT 16 41 | #define ST_MAX_NETNOTCHES 8 42 | 43 | // TYPES ------------------------------------------------------------------- 44 | 45 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 46 | extern void SetVideoModeHR(void); 47 | extern void ClearScreenHR(void); 48 | extern void SlamHR(char *buffer); 49 | extern void SlamBlockHR(int x, int y, int w, int h, char *src); 50 | extern void InitPaletteHR(void); 51 | extern void SetPaletteHR(byte *palette); 52 | extern void GetPaletteHR(byte *palette); 53 | extern void FadeToPaletteHR(byte *palette); 54 | extern void FadeToBlackHR(void); 55 | extern void BlackPaletteHR(void); 56 | extern void I_StartupReadKeys(void); 57 | 58 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 59 | 60 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 61 | char *ST_LoadScreen(void); 62 | void ST_UpdateNotches(int notchPosition); 63 | void ST_UpdateNetNotches(int notchPosition); 64 | 65 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 66 | 67 | // PUBLIC DATA DEFINITIONS ------------------------------------------------- 68 | 69 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 70 | char *bitmap = NULL; 71 | 72 | char notchTable[]= 73 | { 74 | // plane 0 75 | 0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 76 | 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xC0, 77 | 0x0F, 0x90, 0x1B, 0x68, 0x3D, 0xBC, 0x3F, 0xFC, 0x20, 0x08, 0x20, 0x08, 78 | 0x2F, 0xD8, 0x37, 0xD8, 0x37, 0xF8, 0x1F, 0xF8, 0x1C, 0x50, 79 | 80 | // plane 1 81 | 0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x40, 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0xA0, 83 | 0x30, 0x6C, 0x24, 0x94, 0x42, 0x4A, 0x60, 0x0E, 0x60, 0x06, 0x7F, 0xF6, 84 | 0x7F, 0xF6, 0x7F, 0xF6, 0x5E, 0xF6, 0x38, 0x16, 0x23, 0xAC, 85 | 86 | // plane 2 87 | 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02, 0x40, 0x02, 0x40, 88 | 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xE0, 89 | 0x30, 0x6C, 0x24, 0x94, 0x52, 0x6A, 0x7F, 0xFE, 0x60, 0x0E, 0x60, 0x0E, 90 | 0x6F, 0xD6, 0x77, 0xD6, 0x56, 0xF6, 0x38, 0x36, 0x23, 0xAC, 91 | 92 | // plane 3 93 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 94 | 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0x80, 0x02, 0x40, 95 | 0x0F, 0x90, 0x1B, 0x68, 0x3D, 0xB4, 0x1F, 0xF0, 0x1F, 0xF8, 0x1F, 0xF8, 96 | 0x10, 0x28, 0x08, 0x28, 0x29, 0x08, 0x07, 0xE8, 0x1C, 0x50 97 | }; 98 | 99 | 100 | // Red Network Progress notches 101 | char netnotchTable[]= 102 | { 103 | // plane 0 104 | 0x80, 0x50, 0xD0, 0xf0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xD0, 0xF0, 0xC0, 105 | 0x70, 0x50, 0x80, 0x60, 106 | 107 | // plane 1 108 | 0x60, 0xE0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0xA0, 0xE0, 0xA0, 109 | 0xA0, 0xE0, 0x60, 0x00, 110 | 111 | // plane 2 112 | 0x80, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 113 | 0x10, 0x10, 0x80, 0x60, 114 | 115 | // plane 3 116 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 117 | 0x00, 0x00, 0x00, 0x00 118 | }; 119 | 120 | // CODE -------------------------------------------------------------------- 121 | 122 | 123 | 124 | //-------------------------------------------------------------------------- 125 | // 126 | // Startup Screen Functions 127 | // 128 | //-------------------------------------------------------------------------- 129 | 130 | 131 | //========================================================================== 132 | // 133 | // ST_Init - Do the startup screen 134 | // 135 | //========================================================================== 136 | 137 | void ST_Init(void) 138 | { 139 | #ifdef __WATCOMC__ 140 | char *pal; 141 | char *buffer; 142 | 143 | if (!debugmode) 144 | { 145 | // Set 640x480x16 mode 146 | SetVideoModeHR(); 147 | ClearScreenHR(); 148 | InitPaletteHR(); 149 | BlackPaletteHR(); 150 | 151 | // Load graphic 152 | buffer = ST_LoadScreen(); 153 | pal = buffer; 154 | bitmap = buffer + 16*3; 155 | 156 | SlamHR(bitmap); 157 | FadeToPaletteHR(pal); 158 | Z_Free(buffer); 159 | } 160 | #endif 161 | } 162 | 163 | 164 | void ST_Done(void) 165 | { 166 | #ifdef __WATCOMC__ 167 | ClearScreenHR(); 168 | #endif 169 | } 170 | 171 | 172 | //========================================================================== 173 | // 174 | // ST_UpdateNotches 175 | // 176 | //========================================================================== 177 | 178 | void ST_UpdateNotches(int notchPosition) 179 | { 180 | #ifdef __WATCOMC__ 181 | int x = ST_PROGRESS_X + notchPosition*ST_NOTCH_WIDTH; 182 | int y = ST_PROGRESS_Y; 183 | SlamBlockHR(x,y, ST_NOTCH_WIDTH,ST_NOTCH_HEIGHT, notchTable); 184 | #endif 185 | } 186 | 187 | 188 | //========================================================================== 189 | // 190 | // ST_UpdateNetNotches - indicates network progress 191 | // 192 | //========================================================================== 193 | 194 | void ST_UpdateNetNotches(int notchPosition) 195 | { 196 | #ifdef __WATCOMC__ 197 | int x = ST_NETPROGRESS_X + notchPosition*ST_NETNOTCH_WIDTH; 198 | int y = ST_NETPROGRESS_Y; 199 | SlamBlockHR(x,y, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT, netnotchTable); 200 | #endif 201 | } 202 | 203 | 204 | //========================================================================== 205 | // 206 | // ST_Progress - increments progress indicator 207 | // 208 | //========================================================================== 209 | 210 | void ST_Progress(void) 211 | { 212 | #ifdef __WATCOMC__ 213 | static int notchPosition=0; 214 | 215 | // Check for ESC press -- during startup all events eaten here 216 | I_StartupReadKeys(); 217 | 218 | if (debugmode) 219 | { 220 | printf("."); 221 | } 222 | else 223 | { 224 | if(notchPosition= 80 ) 291 | { 292 | I_Error("Long debug message has overwritten memory"); 293 | } 294 | 295 | #ifdef __WATCOMC__ 296 | if (debugmode) 297 | { 298 | printf(buffer); 299 | } 300 | #else 301 | printf(buffer); 302 | #endif 303 | } 304 | 305 | //========================================================================== 306 | // 307 | // ST_RealMessage - gives user message 308 | // 309 | //========================================================================== 310 | 311 | void ST_RealMessage(char *message, ...) 312 | { 313 | va_list argptr; 314 | char buffer[80]; 315 | 316 | va_start(argptr, message); 317 | vsprintf(buffer, message, argptr); 318 | va_end(argptr); 319 | 320 | if ( strlen(buffer) >= 80 ) 321 | { 322 | I_Error("Long debug message has overwritten memory\n"); 323 | } 324 | 325 | printf(buffer); // Always print these messages 326 | } 327 | 328 | 329 | 330 | //========================================================================== 331 | // 332 | // ST_LoadScreen - loads startup graphic 333 | // 334 | //========================================================================== 335 | 336 | 337 | char *ST_LoadScreen(void) 338 | { 339 | int length,lump; 340 | char *buffer; 341 | 342 | lump = W_GetNumForName("STARTUP"); 343 | length = W_LumpLength(lump); 344 | buffer = (char *)Z_Malloc(length, PU_STATIC, NULL); 345 | W_ReadLump(lump, buffer); 346 | return(buffer); 347 | } 348 | -------------------------------------------------------------------------------- /Hexen Source/P_SIGHT.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_sight.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_sight.c,v $ 7 | //** $Revision: 1.1 $ 8 | //** $Date: 95/05/11 00:22:50 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | #include "p_local.h" 15 | 16 | /* 17 | ============================================================================== 18 | 19 | P_CheckSight 20 | 21 | This uses specialized forms of the maputils routines for optimized performance 22 | 23 | ============================================================================== 24 | */ 25 | 26 | fixed_t sightzstart; // eye z of looker 27 | fixed_t topslope, bottomslope; // slopes to top and bottom of target 28 | 29 | int sightcounts[3]; 30 | 31 | /* 32 | ============== 33 | = 34 | = PTR_SightTraverse 35 | = 36 | ============== 37 | */ 38 | 39 | boolean PTR_SightTraverse (intercept_t *in) 40 | { 41 | line_t *li; 42 | fixed_t slope; 43 | 44 | li = in->d.line; 45 | 46 | // 47 | // crosses a two sided line 48 | // 49 | P_LineOpening (li); 50 | 51 | if (openbottom >= opentop) // quick test for totally closed doors 52 | return false; // stop 53 | 54 | if (li->frontsector->floorheight != li->backsector->floorheight) 55 | { 56 | slope = FixedDiv (openbottom - sightzstart , in->frac); 57 | if (slope > bottomslope) 58 | bottomslope = slope; 59 | } 60 | 61 | if (li->frontsector->ceilingheight != li->backsector->ceilingheight) 62 | { 63 | slope = FixedDiv (opentop - sightzstart , in->frac); 64 | if (slope < topslope) 65 | topslope = slope; 66 | } 67 | 68 | if (topslope <= bottomslope) 69 | return false; // stop 70 | 71 | return true; // keep going 72 | } 73 | 74 | 75 | 76 | /* 77 | ================== 78 | = 79 | = P_SightBlockLinesIterator 80 | = 81 | =================== 82 | */ 83 | 84 | boolean P_SightBlockLinesIterator (int x, int y ) 85 | { 86 | int offset; 87 | short *list; 88 | line_t *ld; 89 | int s1, s2; 90 | divline_t dl; 91 | 92 | polyblock_t *polyLink; 93 | seg_t **segList; 94 | int i; 95 | extern polyblock_t **PolyBlockMap; 96 | 97 | offset = y*bmapwidth+x; 98 | 99 | polyLink = PolyBlockMap[offset]; 100 | while(polyLink) 101 | { 102 | if(polyLink->polyobj) 103 | { // only check non-empty links 104 | if(polyLink->polyobj->validcount != validcount) 105 | { 106 | segList = polyLink->polyobj->segs; 107 | for(i = 0; i < polyLink->polyobj->numsegs; i++, segList++) 108 | { 109 | ld = (*segList)->linedef; 110 | if(ld->validcount == validcount) 111 | { 112 | continue; 113 | } 114 | ld->validcount = validcount; 115 | s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); 116 | s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); 117 | if (s1 == s2) 118 | continue; // line isn't crossed 119 | P_MakeDivline (ld, &dl); 120 | s1 = P_PointOnDivlineSide (trace.x, trace.y, &dl); 121 | s2 = P_PointOnDivlineSide (trace.x+trace.dx, trace.y+trace.dy, &dl); 122 | if (s1 == s2) 123 | continue; // line isn't crossed 124 | 125 | // try to early out the check 126 | if (!ld->backsector) 127 | return false; // stop checking 128 | 129 | // store the line for later intersection testing 130 | intercept_p->d.line = ld; 131 | intercept_p++; 132 | } 133 | polyLink->polyobj->validcount = validcount; 134 | } 135 | } 136 | polyLink = polyLink->next; 137 | } 138 | 139 | offset = *(blockmap+offset); 140 | 141 | for ( list = blockmaplump+offset ; *list != -1 ; list++) 142 | { 143 | ld = &lines[*list]; 144 | if (ld->validcount == validcount) 145 | continue; // line has already been checked 146 | ld->validcount = validcount; 147 | 148 | s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); 149 | s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); 150 | if (s1 == s2) 151 | continue; // line isn't crossed 152 | P_MakeDivline (ld, &dl); 153 | s1 = P_PointOnDivlineSide (trace.x, trace.y, &dl); 154 | s2 = P_PointOnDivlineSide (trace.x+trace.dx, trace.y+trace.dy, &dl); 155 | if (s1 == s2) 156 | continue; // line isn't crossed 157 | 158 | // try to early out the check 159 | if (!ld->backsector) 160 | return false; // stop checking 161 | 162 | // store the line for later intersection testing 163 | intercept_p->d.line = ld; 164 | intercept_p++; 165 | 166 | } 167 | 168 | return true; // everything was checked 169 | } 170 | 171 | /* 172 | ==================== 173 | = 174 | = P_SightTraverseIntercepts 175 | = 176 | = Returns true if the traverser function returns true for all lines 177 | ==================== 178 | */ 179 | 180 | boolean P_SightTraverseIntercepts ( void ) 181 | { 182 | int count; 183 | fixed_t dist; 184 | intercept_t *scan, *in; 185 | divline_t dl; 186 | 187 | count = intercept_p - intercepts; 188 | // 189 | // calculate intercept distance 190 | // 191 | for (scan = intercepts ; scand.line, &dl); 194 | scan->frac = P_InterceptVector (&trace, &dl); 195 | } 196 | 197 | // 198 | // go through in order 199 | // 200 | in = 0; // shut up compiler warning 201 | 202 | while (count--) 203 | { 204 | dist = MAXINT; 205 | for (scan = intercepts ; scanfrac < dist) 207 | { 208 | dist = scan->frac; 209 | in = scan; 210 | } 211 | 212 | if ( !PTR_SightTraverse (in) ) 213 | return false; // don't bother going farther 214 | in->frac = MAXINT; 215 | } 216 | 217 | return true; // everything was traversed 218 | } 219 | 220 | 221 | 222 | /* 223 | ================== 224 | = 225 | = P_SightPathTraverse 226 | = 227 | = Traces a line from x1,y1 to x2,y2, calling the traverser function for each 228 | = Returns true if the traverser function returns true for all lines 229 | ================== 230 | */ 231 | 232 | boolean P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) 233 | { 234 | fixed_t xt1,yt1,xt2,yt2; 235 | fixed_t xstep,ystep; 236 | fixed_t partial; 237 | fixed_t xintercept, yintercept; 238 | int mapx, mapy, mapxstep, mapystep; 239 | int count; 240 | 241 | validcount++; 242 | intercept_p = intercepts; 243 | 244 | if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) 245 | x1 += FRACUNIT; // don't side exactly on a line 246 | if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) 247 | y1 += FRACUNIT; // don't side exactly on a line 248 | trace.x = x1; 249 | trace.y = y1; 250 | trace.dx = x2 - x1; 251 | trace.dy = y2 - y1; 252 | 253 | x1 -= bmaporgx; 254 | y1 -= bmaporgy; 255 | xt1 = x1>>MAPBLOCKSHIFT; 256 | yt1 = y1>>MAPBLOCKSHIFT; 257 | 258 | x2 -= bmaporgx; 259 | y2 -= bmaporgy; 260 | xt2 = x2>>MAPBLOCKSHIFT; 261 | yt2 = y2>>MAPBLOCKSHIFT; 262 | 263 | // points should never be out of bounds, but check once instead of 264 | // each block 265 | if (xt1<0 || yt1<0 || xt1>=bmapwidth || yt1>=bmapheight 266 | || xt2<0 || yt2<0 || xt2>=bmapwidth || yt2>=bmapheight) 267 | return false; 268 | 269 | if (xt2 > xt1) 270 | { 271 | mapxstep = 1; 272 | partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1)); 273 | ystep = FixedDiv (y2-y1,abs(x2-x1)); 274 | } 275 | else if (xt2 < xt1) 276 | { 277 | mapxstep = -1; 278 | partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1); 279 | ystep = FixedDiv (y2-y1,abs(x2-x1)); 280 | } 281 | else 282 | { 283 | mapxstep = 0; 284 | partial = FRACUNIT; 285 | ystep = 256*FRACUNIT; 286 | } 287 | yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep); 288 | 289 | 290 | if (yt2 > yt1) 291 | { 292 | mapystep = 1; 293 | partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1)); 294 | xstep = FixedDiv (x2-x1,abs(y2-y1)); 295 | } 296 | else if (yt2 < yt1) 297 | { 298 | mapystep = -1; 299 | partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1); 300 | xstep = FixedDiv (x2-x1,abs(y2-y1)); 301 | } 302 | else 303 | { 304 | mapystep = 0; 305 | partial = FRACUNIT; 306 | xstep = 256*FRACUNIT; 307 | } 308 | xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep); 309 | 310 | 311 | // 312 | // step through map blocks 313 | // Count is present to prevent a round off error from skipping the break 314 | mapx = xt1; 315 | mapy = yt1; 316 | 317 | 318 | for (count = 0 ; count < 64 ; count++) 319 | { 320 | if (!P_SightBlockLinesIterator (mapx, mapy)) 321 | { 322 | sightcounts[1]++; 323 | return false; // early out 324 | } 325 | 326 | if (mapx == xt2 && mapy == yt2) 327 | break; 328 | 329 | if ( (yintercept >> FRACBITS) == mapy) 330 | { 331 | yintercept += ystep; 332 | mapx += mapxstep; 333 | } 334 | else if ( (xintercept >> FRACBITS) == mapx) 335 | { 336 | xintercept += xstep; 337 | mapy += mapystep; 338 | } 339 | 340 | } 341 | 342 | 343 | // 344 | // couldn't early out, so go through the sorted list 345 | // 346 | sightcounts[2]++; 347 | 348 | return P_SightTraverseIntercepts ( ); 349 | } 350 | 351 | 352 | 353 | /* 354 | ===================== 355 | = 356 | = P_CheckSight 357 | = 358 | = Returns true if a straight line between t1 and t2 is unobstructed 359 | = look from eyes of t1 to any part of t2 360 | = 361 | ===================== 362 | */ 363 | 364 | boolean P_CheckSight (mobj_t *t1, mobj_t *t2) 365 | { 366 | int s1, s2; 367 | int pnum, bytenum, bitnum; 368 | 369 | // 370 | // check for trivial rejection 371 | // 372 | s1 = (t1->subsector->sector - sectors); 373 | s2 = (t2->subsector->sector - sectors); 374 | pnum = s1*numsectors + s2; 375 | bytenum = pnum>>3; 376 | bitnum = 1 << (pnum&7); 377 | 378 | if (rejectmatrix[bytenum]&bitnum) 379 | { 380 | sightcounts[0]++; 381 | return false; // can't possibly be connected 382 | } 383 | 384 | // 385 | // check precisely 386 | // 387 | sightzstart = t1->z + t1->height - (t1->height>>2); 388 | topslope = (t2->z+t2->height) - sightzstart; 389 | bottomslope = (t2->z) - sightzstart; 390 | 391 | return P_SightPathTraverse ( t1->x, t1->y, t2->x, t2->y ); 392 | } 393 | 394 | 395 | 396 | -------------------------------------------------------------------------------- /Hexen Source/Z_ZONE.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** z_zone.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: z_zone.c,v $ 7 | //** $Revision: 1.2 $ 8 | //** $Date: 96/01/06 03:23:53 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include 14 | #include "h2def.h" 15 | 16 | /* 17 | ============================================================================== 18 | 19 | ZONE MEMORY ALLOCATION 20 | 21 | There is never any space between memblocks, and there will never be two 22 | contiguous free memblocks. 23 | 24 | The rover can be left pointing at a non-empty block 25 | 26 | It is of no value to free a cachable block, because it will get overwritten 27 | automatically if needed 28 | 29 | ============================================================================== 30 | */ 31 | 32 | #define ZONEID 0x1d4a11 33 | 34 | 35 | typedef struct 36 | { 37 | int size; // total bytes malloced, including header 38 | memblock_t blocklist; // start / end cap for linked list 39 | memblock_t *rover; 40 | } memzone_t; 41 | 42 | memzone_t *mainzone; 43 | 44 | /* 45 | ======================== 46 | = 47 | = Z_ClearZone 48 | = 49 | ======================== 50 | */ 51 | 52 | /* 53 | void Z_ClearZone (memzone_t *zone) 54 | { 55 | memblock_t *block; 56 | 57 | // set the entire zone to one free block 58 | 59 | zone->blocklist.next = zone->blocklist.prev = block = 60 | (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); 61 | zone->blocklist.user = (void *)zone; 62 | zone->blocklist.tag = PU_STATIC; 63 | zone->rover = block; 64 | 65 | block->prev = block->next = &zone->blocklist; 66 | block->user = NULL; // free block 67 | block->size = zone->size - sizeof(memzone_t); 68 | } 69 | */ 70 | 71 | 72 | /* 73 | ======================== 74 | = 75 | = Z_Init 76 | = 77 | ======================== 78 | */ 79 | 80 | void Z_Init (void) 81 | { 82 | memblock_t *block; 83 | int size; 84 | 85 | mainzone = (memzone_t *)I_ZoneBase (&size); 86 | mainzone->size = size; 87 | 88 | // set the entire zone to one free block 89 | 90 | mainzone->blocklist.next = mainzone->blocklist.prev = block = 91 | (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) ); 92 | mainzone->blocklist.user = (void *)mainzone; 93 | mainzone->blocklist.tag = PU_STATIC; 94 | mainzone->rover = block; 95 | 96 | block->prev = block->next = &mainzone->blocklist; 97 | block->user = NULL; // free block 98 | block->size = mainzone->size - sizeof(memzone_t); 99 | } 100 | 101 | 102 | /* 103 | ======================== 104 | = 105 | = Z_Free 106 | = 107 | ======================== 108 | */ 109 | 110 | void Z_Free (void *ptr) 111 | { 112 | memblock_t *block, *other; 113 | 114 | block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); 115 | if (block->id != ZONEID) 116 | I_Error ("Z_Free: freed a pointer without ZONEID"); 117 | 118 | if (block->user > (void **)0x100) // smaller values are not pointers 119 | *block->user = 0; // clear the user's mark 120 | block->user = NULL; // mark as free 121 | block->tag = 0; 122 | block->id = 0; 123 | 124 | other = block->prev; 125 | if (!other->user) 126 | { // merge with previous free block 127 | other->size += block->size; 128 | other->next = block->next; 129 | other->next->prev = other; 130 | if (block == mainzone->rover) 131 | mainzone->rover = other; 132 | block = other; 133 | } 134 | 135 | other = block->next; 136 | if (!other->user) 137 | { // merge the next free block onto the end 138 | block->size += other->size; 139 | block->next = other->next; 140 | block->next->prev = block; 141 | if (other == mainzone->rover) 142 | mainzone->rover = block; 143 | } 144 | } 145 | 146 | 147 | /* 148 | ======================== 149 | = 150 | = Z_Malloc 151 | = 152 | = You can pass a NULL user if the tag is < PU_PURGELEVEL 153 | ======================== 154 | */ 155 | 156 | #define MINFRAGMENT 64 157 | 158 | void *Z_Malloc (int size, int tag, void *user) 159 | { 160 | int extra; 161 | memblock_t *start, *rover, *new, *base; 162 | 163 | // 164 | // scan through the block list looking for the first free block 165 | // of sufficient size, throwing out any purgable blocks along the way 166 | // 167 | size += sizeof(memblock_t); // account for size of block header 168 | 169 | 170 | // 171 | // if there is a free block behind the rover, back up over them 172 | // 173 | base = mainzone->rover; 174 | if (!base->prev->user) 175 | base = base->prev; 176 | 177 | rover = base; 178 | start = base->prev; 179 | 180 | do 181 | { 182 | if (rover == start) // scaned all the way around the list 183 | I_Error ("Z_Malloc: failed on allocation of %i bytes",size); 184 | if (rover->user) 185 | { 186 | if (rover->tag < PU_PURGELEVEL) 187 | // hit a block that can't be purged, so move base past it 188 | base = rover = rover->next; 189 | else 190 | { 191 | // free the rover block (adding the size to base) 192 | base = base->prev; // the rover can be the base block 193 | Z_Free ((byte *)rover+sizeof(memblock_t)); 194 | base = base->next; 195 | rover = base->next; 196 | } 197 | } 198 | else 199 | rover = rover->next; 200 | } while (base->user || base->size < size); 201 | 202 | // 203 | // found a block big enough 204 | // 205 | extra = base->size - size; 206 | if (extra > MINFRAGMENT) 207 | { // there will be a free fragment after the allocated block 208 | new = (memblock_t *) ((byte *)base + size ); 209 | new->size = extra; 210 | new->user = NULL; // free block 211 | new->tag = 0; 212 | new->prev = base; 213 | new->next = base->next; 214 | new->next->prev = new; 215 | base->next = new; 216 | base->size = size; 217 | } 218 | 219 | if (user) 220 | { 221 | base->user = user; // mark as an in use block 222 | *(void **)user = (void *) ((byte *)base + sizeof(memblock_t)); 223 | } 224 | else 225 | { 226 | if (tag >= PU_PURGELEVEL) 227 | I_Error ("Z_Malloc: an owner is required for purgable blocks"); 228 | base->user = (void *)2; // mark as in use, but unowned 229 | } 230 | base->tag = tag; 231 | 232 | mainzone->rover = base->next; // next allocation will start looking here 233 | 234 | base->id = ZONEID; 235 | return (void *) ((byte *)base + sizeof(memblock_t)); 236 | } 237 | 238 | 239 | /* 240 | ======================== 241 | = 242 | = Z_FreeTags 243 | = 244 | ======================== 245 | */ 246 | 247 | void Z_FreeTags (int lowtag, int hightag) 248 | { 249 | memblock_t *block, *next; 250 | 251 | for (block = mainzone->blocklist.next ; block != &mainzone->blocklist 252 | ; block = next) 253 | { 254 | next = block->next; // get link before freeing 255 | if (!block->user) 256 | continue; // free block 257 | if (block->tag >= lowtag && block->tag <= hightag) 258 | Z_Free ( (byte *)block+sizeof(memblock_t)); 259 | } 260 | } 261 | 262 | /* 263 | ======================== 264 | = 265 | = Z_DumpHeap 266 | = 267 | ======================== 268 | */ 269 | 270 | /* 271 | void Z_DumpHeap (int lowtag, int hightag) 272 | { 273 | memblock_t *block; 274 | 275 | printf ("zone size: %i location: %p\n",mainzone->size,mainzone); 276 | printf ("tag range: %i to %i\n",lowtag, hightag); 277 | 278 | for (block = mainzone->blocklist.next ; ; block = block->next) 279 | { 280 | if (block->tag >= lowtag && block->tag <= hightag) 281 | printf ("block:%p size:%7i user:%p tag:%3i\n", 282 | block, block->size, block->user, block->tag); 283 | 284 | if (block->next == &mainzone->blocklist) 285 | break; // all blocks have been hit 286 | if ( (byte *)block + block->size != (byte *)block->next) 287 | printf ("ERROR: block size does not touch the next block\n"); 288 | if ( block->next->prev != block) 289 | printf ("ERROR: next block doesn't have proper back link\n"); 290 | if (!block->user && !block->next->user) 291 | printf ("ERROR: two consecutive free blocks\n"); 292 | } 293 | } 294 | */ 295 | 296 | /* 297 | ======================== 298 | = 299 | = Z_FileDumpHeap 300 | = 301 | ======================== 302 | */ 303 | 304 | /* 305 | void Z_FileDumpHeap (FILE *f) 306 | { 307 | memblock_t *block; 308 | 309 | fprintf (f,"zone size: %i location: %p\n",mainzone->size,mainzone); 310 | 311 | for (block = mainzone->blocklist.next ; ; block = block->next) 312 | { 313 | fprintf (f,"block:%p size:%7i user:%p tag:%3i\n", 314 | block, block->size, block->user, block->tag); 315 | 316 | if (block->next == &mainzone->blocklist) 317 | break; // all blocks have been hit 318 | if ( (byte *)block + block->size != (byte *)block->next) 319 | fprintf (f,"ERROR: block size does not touch the next block\n"); 320 | if ( block->next->prev != block) 321 | fprintf (f,"ERROR: next block doesn't have proper back link\n"); 322 | if (!block->user && !block->next->user) 323 | fprintf (f,"ERROR: two consecutive free blocks\n"); 324 | } 325 | } 326 | */ 327 | 328 | /* 329 | ======================== 330 | = 331 | = Z_CheckHeap 332 | = 333 | ======================== 334 | */ 335 | 336 | void Z_CheckHeap (void) 337 | { 338 | memblock_t *block; 339 | 340 | for (block = mainzone->blocklist.next ; ; block = block->next) 341 | { 342 | if (block->next == &mainzone->blocklist) 343 | break; // all blocks have been hit 344 | if ( (byte *)block + block->size != (byte *)block->next) 345 | I_Error ("Z_CheckHeap: block size does not touch the next block\n"); 346 | if ( block->next->prev != block) 347 | I_Error ("Z_CheckHeap: next block doesn't have proper back link\n"); 348 | if (!block->user && !block->next->user) 349 | I_Error ("Z_CheckHeap: two consecutive free blocks\n"); 350 | } 351 | } 352 | 353 | 354 | /* 355 | ======================== 356 | = 357 | = Z_ChangeTag 358 | = 359 | ======================== 360 | */ 361 | 362 | void Z_ChangeTag2 (void *ptr, int tag) 363 | { 364 | memblock_t *block; 365 | 366 | block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); 367 | if (block->id != ZONEID) 368 | I_Error ("Z_ChangeTag: freed a pointer without ZONEID"); 369 | if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100) 370 | I_Error ("Z_ChangeTag: an owner is required for purgable blocks"); 371 | block->tag = tag; 372 | } 373 | 374 | 375 | /* 376 | ======================== 377 | = 378 | = Z_FreeMemory 379 | = 380 | ======================== 381 | */ 382 | 383 | /* 384 | int Z_FreeMemory (void) 385 | { 386 | memblock_t *block; 387 | int free; 388 | 389 | free = 0; 390 | for (block = mainzone->blocklist.next ; block != &mainzone->blocklist 391 | ; block = block->next) 392 | if (!block->user || block->tag >= PU_PURGELEVEL) 393 | free += block->size; 394 | return free; 395 | } 396 | */ 397 | -------------------------------------------------------------------------------- /Hexen Source/V_VIDEO.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** v_video.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: v_video.c,v $ 7 | //** $Revision: 1.2 $ 8 | //** $Date: 95/09/11 14:58:16 $ 9 | //** $Author: cjr $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include "h2def.h" 14 | 15 | #define SC_INDEX 0x3c4 16 | 17 | byte *screen; 18 | int dirtybox[4]; 19 | int usegamma; 20 | 21 | byte gammatable[5][256] = 22 | { 23 | {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,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}, 24 | 25 | {2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55,56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175,175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189,190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204,205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218,219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232,233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246,247,248,249,250,251,252,252,253,254,255}, 26 | 27 | {4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42,43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69,70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159,160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173,174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188,188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201,202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215,216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228,229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241,242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254,255}, 28 | 29 | {8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55,57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85,86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140,141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169,169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182,183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195,195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207,207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219,219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230,231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241,242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252,253,253,254,254,255}, 30 | 31 | {16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76,78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155,156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169,169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181,182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193,193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203,204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214,214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224,224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233,234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,254,254,255,255} 32 | }; 33 | 34 | //--------------------------------------------------------------------------- 35 | // 36 | // PROC V_DrawPatch 37 | // 38 | // Draws a column based masked pic to the screen. 39 | // 40 | //--------------------------------------------------------------------------- 41 | 42 | void V_DrawPatch(int x, int y, patch_t *patch) 43 | { 44 | int count; 45 | int col; 46 | column_t *column; 47 | byte *desttop; 48 | byte *dest; 49 | byte *source; 50 | int w; 51 | 52 | y -= SHORT(patch->topoffset); 53 | x -= SHORT(patch->leftoffset); 54 | if(x < 0 || x+SHORT(patch->width) > SCREENWIDTH || y < 0 55 | || y+SHORT(patch->height) > SCREENHEIGHT) 56 | { 57 | I_Error("Bad V_DrawPatch"); 58 | } 59 | col = 0; 60 | desttop = screen+y*SCREENWIDTH+x; 61 | w = SHORT(patch->width); 62 | for(; col < w; x++, col++, desttop++) 63 | { 64 | column = (column_t *)((byte *)patch+LONG(patch->columnofs[col])); 65 | // Step through the posts in a column 66 | while(column->topdelta != 0xff) 67 | { 68 | source = (byte *)column+3; 69 | dest = desttop+column->topdelta*SCREENWIDTH; 70 | count = column->length; 71 | while(count--) 72 | { 73 | *dest = *source++; 74 | dest += SCREENWIDTH; 75 | } 76 | column = (column_t *)((byte *)column+column->length+4); 77 | } 78 | } 79 | } 80 | 81 | /* 82 | ================== 83 | = 84 | = V_DrawFuzzPatch 85 | = 86 | = Masks a column based translucent masked pic to the screen. 87 | = 88 | ================== 89 | */ 90 | extern byte *tinttable; 91 | 92 | void V_DrawFuzzPatch (int x, int y, patch_t *patch) 93 | { 94 | int count,col; 95 | column_t *column; 96 | byte *desttop, *dest, *source; 97 | int w; 98 | 99 | y -= SHORT(patch->topoffset); 100 | x -= SHORT(patch->leftoffset); 101 | 102 | if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 || y+SHORT(patch->height)>SCREENHEIGHT ) 103 | I_Error ("Bad V_DrawPatch"); 104 | 105 | col = 0; 106 | desttop = screen+y*SCREENWIDTH+x; 107 | 108 | w = SHORT(patch->width); 109 | for ( ; colcolumnofs[col])); 112 | 113 | // step through the posts in a column 114 | 115 | while (column->topdelta != 0xff ) 116 | { 117 | source = (byte *)column + 3; 118 | dest = desttop + column->topdelta*SCREENWIDTH; 119 | count = column->length; 120 | 121 | while (count--) 122 | { 123 | *dest = tinttable[*dest + ((*source++)<<8)]; 124 | dest += SCREENWIDTH; 125 | } 126 | column = (column_t *)((byte *)column+column->length+4); 127 | } 128 | } 129 | } 130 | 131 | /* 132 | ================== 133 | = 134 | = V_DrawAltFuzzPatch 135 | = 136 | = Masks a column based translucent masked pic to the screen. 137 | = 138 | ================== 139 | */ 140 | extern byte *tinttable; 141 | 142 | void V_DrawAltFuzzPatch (int x, int y, patch_t *patch) 143 | { 144 | int count,col; 145 | column_t *column; 146 | byte *desttop, *dest, *source; 147 | int w; 148 | 149 | y -= SHORT(patch->topoffset); 150 | x -= SHORT(patch->leftoffset); 151 | 152 | if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 153 | || y+SHORT(patch->height)>SCREENHEIGHT ) 154 | { 155 | I_Error ("Bad V_DrawPatch"); 156 | } 157 | 158 | col = 0; 159 | desttop = screen+y*SCREENWIDTH+x; 160 | 161 | w = SHORT(patch->width); 162 | for ( ; colcolumnofs[col])); 165 | 166 | // step through the posts in a column 167 | 168 | while (column->topdelta != 0xff ) 169 | { 170 | source = (byte *)column + 3; 171 | dest = desttop + column->topdelta*SCREENWIDTH; 172 | count = column->length; 173 | 174 | while (count--) 175 | { 176 | *dest = tinttable[((*dest)<<8) + *source++]; 177 | dest += SCREENWIDTH; 178 | } 179 | column = (column_t *)((byte *)column+column->length+4); 180 | } 181 | } 182 | } 183 | 184 | /* 185 | ================== 186 | = 187 | = V_DrawShadowedPatch 188 | = 189 | = Masks a column based masked pic to the screen. 190 | = 191 | ================== 192 | */ 193 | 194 | void V_DrawShadowedPatch(int x, int y, patch_t *patch) 195 | { 196 | int count,col; 197 | column_t *column; 198 | byte *desttop, *dest, *source; 199 | byte *desttop2, *dest2; 200 | int w; 201 | 202 | y -= SHORT(patch->topoffset); 203 | x -= SHORT(patch->leftoffset); 204 | 205 | if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 || y+SHORT(patch->height)>SCREENHEIGHT ) 206 | I_Error ("Bad V_DrawPatch"); 207 | 208 | col = 0; 209 | desttop = screen+y*SCREENWIDTH+x; 210 | desttop2 = screen+(y+2)*SCREENWIDTH+x+2; 211 | 212 | w = SHORT(patch->width); 213 | for ( ; colcolumnofs[col])); 216 | 217 | // step through the posts in a column 218 | 219 | while (column->topdelta != 0xff ) 220 | { 221 | source = (byte *)column + 3; 222 | dest = desttop + column->topdelta*SCREENWIDTH; 223 | dest2 = desttop2 + column->topdelta*SCREENWIDTH; 224 | count = column->length; 225 | 226 | while (count--) 227 | { 228 | *dest2 = tinttable[((*dest2)<<8)]; 229 | dest2 += SCREENWIDTH; 230 | *dest = *source++; 231 | dest += SCREENWIDTH; 232 | 233 | } 234 | column = (column_t *)( (byte *)column + column->length 235 | + 4 ); 236 | } 237 | } 238 | } 239 | 240 | //--------------------------------------------------------------------------- 241 | // 242 | // PROC V_DrawRawScreen 243 | // 244 | //--------------------------------------------------------------------------- 245 | 246 | void V_DrawRawScreen(byte *raw) 247 | { 248 | memcpy(screen, raw, SCREENWIDTH*SCREENHEIGHT); 249 | } 250 | 251 | //--------------------------------------------------------------------------- 252 | // 253 | // PROC V_Init 254 | // 255 | //--------------------------------------------------------------------------- 256 | 257 | void V_Init(void) 258 | { 259 | // I_AllocLow will put screen in low dos memory on PCs. 260 | screen = I_AllocLow(SCREENWIDTH*SCREENHEIGHT); 261 | } 262 | -------------------------------------------------------------------------------- /Hexen Source/P_ANIM.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** p_anim.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: p_anim.c,v $ 7 | //** $Revision: 1.9 $ 8 | //** $Date: 95/07/17 18:50:37 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | // HEADER FILES ------------------------------------------------------------ 14 | 15 | #include "h2def.h" 16 | #include "p_local.h" 17 | 18 | // MACROS ------------------------------------------------------------------ 19 | 20 | #define ANIM_SCRIPT_NAME "ANIMDEFS" 21 | #define MAX_ANIM_DEFS 20 22 | #define MAX_FRAME_DEFS 96 23 | #define ANIM_FLAT 0 24 | #define ANIM_TEXTURE 1 25 | #define SCI_FLAT "flat" 26 | #define SCI_TEXTURE "texture" 27 | #define SCI_PIC "pic" 28 | #define SCI_TICS "tics" 29 | #define SCI_RAND "rand" 30 | 31 | #define LIGHTNING_SPECIAL 198 32 | #define LIGHTNING_SPECIAL2 199 33 | #define SKYCHANGE_SPECIAL 200 34 | 35 | // TYPES ------------------------------------------------------------------- 36 | 37 | typedef struct 38 | { 39 | int index; 40 | int tics; 41 | } frameDef_t; 42 | 43 | typedef struct 44 | { 45 | int type; 46 | int index; 47 | int tics; 48 | int currentFrameDef; 49 | int startFrameDef; 50 | int endFrameDef; 51 | } animDef_t; 52 | 53 | // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- 54 | 55 | // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 56 | 57 | // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- 58 | 59 | static void P_LightningFlash(void); 60 | 61 | // EXTERNAL DATA DECLARATIONS ---------------------------------------------- 62 | 63 | extern fixed_t Sky1ColumnOffset; 64 | extern fixed_t Sky2ColumnOffset; 65 | extern int Sky1Texture; 66 | extern boolean DoubleSky; 67 | 68 | // PUBLIC DATA DEFINITIONS ------------------------------------------------- 69 | 70 | fixed_t Sky1ScrollDelta; 71 | fixed_t Sky2ScrollDelta; 72 | 73 | // PRIVATE DATA DEFINITIONS ------------------------------------------------ 74 | 75 | static animDef_t AnimDefs[MAX_ANIM_DEFS]; 76 | static frameDef_t FrameDefs[MAX_FRAME_DEFS]; 77 | static int AnimDefCount; 78 | static boolean LevelHasLightning; 79 | static int NextLightningFlash; 80 | static int LightningFlash; 81 | static int *LightningLightLevels; 82 | 83 | // CODE -------------------------------------------------------------------- 84 | 85 | //========================================================================== 86 | // 87 | // P_AnimateSurfaces 88 | // 89 | //========================================================================== 90 | 91 | void P_AnimateSurfaces(void) 92 | { 93 | int i; 94 | animDef_t *ad; 95 | line_t *line; 96 | 97 | // Animate flats and textures 98 | for(i = 0; i < AnimDefCount; i++) 99 | { 100 | ad = &AnimDefs[i]; 101 | ad->tics--; 102 | if(ad->tics == 0) 103 | { 104 | if(ad->currentFrameDef == ad->endFrameDef) 105 | { 106 | ad->currentFrameDef = ad->startFrameDef; 107 | } 108 | else 109 | { 110 | ad->currentFrameDef++; 111 | } 112 | ad->tics = FrameDefs[ad->currentFrameDef].tics; 113 | if(ad->tics > 255) 114 | { // Random tics 115 | ad->tics = (ad->tics>>16) 116 | +P_Random()%((ad->tics&0xff00)>>8); 117 | } 118 | if(ad->type == ANIM_FLAT) 119 | { 120 | flattranslation[ad->index] = 121 | FrameDefs[ad->currentFrameDef].index; 122 | } 123 | else 124 | { // Texture 125 | texturetranslation[ad->index] = 126 | FrameDefs[ad->currentFrameDef].index; 127 | } 128 | } 129 | } 130 | 131 | // Update scrolling textures 132 | for(i = 0; i < numlinespecials; i++) 133 | { 134 | line = linespeciallist[i]; 135 | switch(line->special) 136 | { 137 | case 100: // Scroll_Texture_Left 138 | sides[line->sidenum[0]].textureoffset += line->arg1<<10; 139 | break; 140 | case 101: // Scroll_Texture_Right 141 | sides[line->sidenum[0]].textureoffset -= line->arg1<<10; 142 | break; 143 | case 102: // Scroll_Texture_Up 144 | sides[line->sidenum[0]].rowoffset += line->arg1<<10; 145 | break; 146 | case 103: // Scroll_Texture_Down 147 | sides[line->sidenum[0]].rowoffset -= line->arg1<<10; 148 | break; 149 | } 150 | } 151 | 152 | // Update sky column offsets 153 | Sky1ColumnOffset += Sky1ScrollDelta; 154 | Sky2ColumnOffset += Sky2ScrollDelta; 155 | 156 | if(LevelHasLightning) 157 | { 158 | if(!NextLightningFlash || LightningFlash) 159 | { 160 | P_LightningFlash(); 161 | } 162 | else 163 | { 164 | NextLightningFlash--; 165 | } 166 | } 167 | } 168 | 169 | //========================================================================== 170 | // 171 | // P_LightningFlash 172 | // 173 | //========================================================================== 174 | 175 | static void P_LightningFlash(void) 176 | { 177 | int i; 178 | sector_t *tempSec; 179 | int *tempLight; 180 | boolean foundSec; 181 | int flashLight; 182 | 183 | if(LightningFlash) 184 | { 185 | LightningFlash--; 186 | if(LightningFlash) 187 | { 188 | tempLight = LightningLightLevels; 189 | tempSec = sectors; 190 | for(i = 0; i < numsectors; i++, tempSec++) 191 | { 192 | if(tempSec->ceilingpic == skyflatnum 193 | || tempSec->special == LIGHTNING_SPECIAL 194 | || tempSec->special == LIGHTNING_SPECIAL2) 195 | { 196 | if(*tempLight < tempSec->lightlevel-4) 197 | { 198 | tempSec->lightlevel -= 4; 199 | } 200 | tempLight++; 201 | } 202 | } 203 | } 204 | else 205 | { // remove the alternate lightning flash special 206 | tempLight = LightningLightLevels; 207 | tempSec = sectors; 208 | for(i = 0; i < numsectors; i++, tempSec++) 209 | { 210 | if(tempSec->ceilingpic == skyflatnum 211 | || tempSec->special == LIGHTNING_SPECIAL 212 | || tempSec->special == LIGHTNING_SPECIAL2) 213 | { 214 | tempSec->lightlevel = *tempLight; 215 | tempLight++; 216 | } 217 | } 218 | Sky1Texture = P_GetMapSky1Texture(gamemap); 219 | } 220 | return; 221 | } 222 | LightningFlash = (P_Random()&7)+8; 223 | flashLight = 200+(P_Random()&31); 224 | tempSec = sectors; 225 | tempLight = LightningLightLevels; 226 | foundSec = false; 227 | for(i = 0; i < numsectors; i++, tempSec++) 228 | { 229 | if(tempSec->ceilingpic == skyflatnum 230 | || tempSec->special == LIGHTNING_SPECIAL 231 | || tempSec->special == LIGHTNING_SPECIAL2) 232 | { 233 | *tempLight = tempSec->lightlevel; 234 | if(tempSec->special == LIGHTNING_SPECIAL) 235 | { 236 | tempSec->lightlevel += 64; 237 | if(tempSec->lightlevel > flashLight) 238 | { 239 | tempSec->lightlevel = flashLight; 240 | } 241 | } 242 | else if(tempSec->special == LIGHTNING_SPECIAL2) 243 | { 244 | tempSec->lightlevel += 32; 245 | if(tempSec->lightlevel > flashLight) 246 | { 247 | tempSec->lightlevel = flashLight; 248 | } 249 | } 250 | else 251 | { 252 | tempSec->lightlevel = flashLight; 253 | } 254 | if(tempSec->lightlevel < *tempLight) 255 | { 256 | tempSec->lightlevel = *tempLight; 257 | } 258 | tempLight++; 259 | foundSec = true; 260 | } 261 | } 262 | if(foundSec) 263 | { 264 | Sky1Texture = P_GetMapSky2Texture(gamemap); // set alternate sky 265 | S_StartSound(NULL, SFX_THUNDER_CRASH); 266 | } 267 | // Calculate the next lighting flash 268 | if(!NextLightningFlash) 269 | { 270 | if(P_Random() < 50) 271 | { // Immediate Quick flash 272 | NextLightningFlash = (P_Random()&15)+16; 273 | } 274 | else 275 | { 276 | if(P_Random() < 128 && !(leveltime&32)) 277 | { 278 | NextLightningFlash = ((P_Random()&7)+2)*35; 279 | } 280 | else 281 | { 282 | NextLightningFlash = ((P_Random()&15)+5)*35; 283 | } 284 | } 285 | } 286 | } 287 | 288 | //========================================================================== 289 | // 290 | // P_ForceLightning 291 | // 292 | //========================================================================== 293 | 294 | void P_ForceLightning(void) 295 | { 296 | NextLightningFlash = 0; 297 | } 298 | 299 | //========================================================================== 300 | // 301 | // P_InitLightning 302 | // 303 | //========================================================================== 304 | 305 | void P_InitLightning(void) 306 | { 307 | int i; 308 | int secCount; 309 | 310 | if(!P_GetMapLightning(gamemap)) 311 | { 312 | LevelHasLightning = false; 313 | LightningFlash = 0; 314 | return; 315 | } 316 | LightningFlash = 0; 317 | secCount = 0; 318 | for(i = 0; i < numsectors; i++) 319 | { 320 | if(sectors[i].ceilingpic == skyflatnum 321 | || sectors[i].special == LIGHTNING_SPECIAL 322 | || sectors[i].special == LIGHTNING_SPECIAL2) 323 | { 324 | secCount++; 325 | } 326 | } 327 | if(secCount) 328 | { 329 | LevelHasLightning = true; 330 | } 331 | else 332 | { 333 | LevelHasLightning = false; 334 | return; 335 | } 336 | LightningLightLevels = (int *)Z_Malloc(secCount*sizeof(int), PU_LEVEL, 337 | NULL); 338 | NextLightningFlash = ((P_Random()&15)+5)*35; // don't flash at level start 339 | } 340 | 341 | //========================================================================== 342 | // 343 | // P_InitFTAnims 344 | // 345 | // Initialize flat and texture animation lists. 346 | // 347 | //========================================================================== 348 | 349 | void P_InitFTAnims(void) 350 | { 351 | int base; 352 | int mod; 353 | int fd; 354 | animDef_t *ad; 355 | boolean ignore; 356 | boolean done; 357 | 358 | fd = 0; 359 | ad = AnimDefs; 360 | AnimDefCount = 0; 361 | SC_Open(ANIM_SCRIPT_NAME); 362 | while(SC_GetString()) 363 | { 364 | if(AnimDefCount == MAX_ANIM_DEFS) 365 | { 366 | I_Error("P_InitFTAnims: too many AnimDefs."); 367 | } 368 | if(SC_Compare(SCI_FLAT)) 369 | { 370 | ad->type = ANIM_FLAT; 371 | } 372 | else if(SC_Compare(SCI_TEXTURE)) 373 | { 374 | ad->type = ANIM_TEXTURE; 375 | } 376 | else 377 | { 378 | SC_ScriptError(NULL); 379 | } 380 | SC_MustGetString(); // Name 381 | ignore = false; 382 | if(ad->type == ANIM_FLAT) 383 | { 384 | if(W_CheckNumForName(sc_String) == -1) 385 | { 386 | ignore = true; 387 | } 388 | else 389 | { 390 | ad->index = R_FlatNumForName(sc_String); 391 | } 392 | } 393 | else 394 | { // Texture 395 | if(R_CheckTextureNumForName(sc_String) == -1) 396 | { 397 | ignore = true; 398 | } 399 | else 400 | { 401 | ad->index = R_TextureNumForName(sc_String); 402 | } 403 | } 404 | ad->startFrameDef = fd; 405 | done = false; 406 | while(done == false) 407 | { 408 | if(SC_GetString()) 409 | { 410 | if(SC_Compare(SCI_PIC)) 411 | { 412 | if(fd == MAX_FRAME_DEFS) 413 | { 414 | I_Error("P_InitFTAnims: too many FrameDefs."); 415 | } 416 | SC_MustGetNumber(); 417 | if(ignore == false) 418 | { 419 | FrameDefs[fd].index = ad->index+sc_Number-1; 420 | } 421 | SC_MustGetString(); 422 | if(SC_Compare(SCI_TICS)) 423 | { 424 | SC_MustGetNumber(); 425 | if(ignore == false) 426 | { 427 | FrameDefs[fd].tics = sc_Number; 428 | fd++; 429 | } 430 | } 431 | else if(SC_Compare(SCI_RAND)) 432 | { 433 | SC_MustGetNumber(); 434 | base = sc_Number; 435 | SC_MustGetNumber(); 436 | if(ignore == false) 437 | { 438 | mod = sc_Number-base+1; 439 | FrameDefs[fd].tics = (base<<16)+(mod<<8); 440 | fd++; 441 | } 442 | } 443 | else 444 | { 445 | SC_ScriptError(NULL); 446 | } 447 | } 448 | else 449 | { 450 | SC_UnGet(); 451 | done = true; 452 | } 453 | } 454 | else 455 | { 456 | done = true; 457 | } 458 | } 459 | if((ignore == false) && (fd-ad->startFrameDef < 2)) 460 | { 461 | I_Error("P_InitFTAnims: AnimDef has framecount < 2."); 462 | } 463 | if(ignore == false) 464 | { 465 | ad->endFrameDef = fd-1; 466 | ad->currentFrameDef = ad->endFrameDef; 467 | ad->tics = 1; // Force 1st game tic to animate 468 | AnimDefCount++; 469 | ad++; 470 | } 471 | } 472 | SC_Close(); 473 | } 474 | -------------------------------------------------------------------------------- /Hexen Source/CT_CHAT.C: -------------------------------------------------------------------------------- 1 | 2 | //************************************************************************** 3 | //** 4 | //** ct_chat.c : Heretic 2 : Raven Software, Corp. 5 | //** 6 | //** $RCSfile: ct_chat.c,v $ 7 | //** $Revision: 1.12 $ 8 | //** $Date: 96/01/16 10:35:26 $ 9 | //** $Author: bgokey $ 10 | //** 11 | //************************************************************************** 12 | 13 | #include 14 | #include 15 | #include "h2def.h" 16 | #include "p_local.h" 17 | #include "soundst.h" 18 | 19 | #define NUMKEYS 256 20 | 21 | #define QUEUESIZE 128 22 | #define MESSAGESIZE 128 23 | #define MESSAGELEN 265 24 | 25 | // 8-player note: Change this stuff (CT_PLR_*, and the key mappings) 26 | enum 27 | { 28 | CT_PLR_BLUE = 1, 29 | CT_PLR_RED, 30 | CT_PLR_YELLOW, 31 | CT_PLR_GREEN, 32 | CT_PLR_PLAYER5, 33 | CT_PLR_PLAYER6, 34 | CT_PLR_PLAYER7, 35 | CT_PLR_PLAYER8, 36 | CT_PLR_ALL 37 | }; 38 | 39 | #define CT_KEY_BLUE 'b' 40 | #define CT_KEY_RED 'r' 41 | #define CT_KEY_YELLOW 'y' 42 | #define CT_KEY_GREEN 'g' 43 | #define CT_KEY_PLAYER5 'j' // Jade 44 | #define CT_KEY_PLAYER6 'w' // White 45 | #define CT_KEY_PLAYER7 'h' // Hazel 46 | #define CT_KEY_PLAYER8 'p' // Purple 47 | #define CT_KEY_ALL 't' 48 | #define CT_ESCAPE 6 49 | 50 | // Public data 51 | 52 | void CT_Init(void); 53 | void CT_Drawer(void); 54 | boolean CT_Responder(event_t *ev); 55 | void CT_Ticker(void); 56 | char CT_dequeueChatChar(void); 57 | 58 | boolean chatmodeon; 59 | 60 | // Private data 61 | 62 | void CT_queueChatChar(char ch); 63 | void CT_ClearChatMessage(int player); 64 | void CT_AddChar(int player, char c); 65 | void CT_BackSpace(int player); 66 | 67 | int head; 68 | int tail; 69 | byte ChatQueue[QUEUESIZE]; 70 | int chat_dest[MAXPLAYERS]; 71 | char chat_msg[MAXPLAYERS][MESSAGESIZE]; 72 | char plr_lastmsg[MAXPLAYERS][MESSAGESIZE+9]; 73 | int msgptr[MAXPLAYERS]; 74 | int msglen[MAXPLAYERS]; 75 | 76 | boolean cheated; 77 | 78 | static int FontABaseLump; 79 | 80 | char *CT_FromPlrText[MAXPLAYERS] = 81 | { 82 | "BLUE: ", 83 | "RED: ", 84 | "YELLOW: ", 85 | "GREEN: ", 86 | "JADE: ", 87 | "WHITE: ", 88 | "HAZEL: ", 89 | "PURPLE: " 90 | }; 91 | 92 | char *chat_macros[10]; 93 | 94 | boolean altdown; 95 | boolean shiftdown; 96 | 97 | extern boolean usearti; 98 | 99 | //=========================================================================== 100 | // 101 | // CT_Init 102 | // 103 | // Initialize chat mode data 104 | //=========================================================================== 105 | 106 | void CT_Init(void) 107 | { 108 | int i; 109 | 110 | head = 0; //initialize the queue index 111 | tail = 0; 112 | chatmodeon = false; 113 | memset(ChatQueue, 0, QUEUESIZE); 114 | for(i = 0; i < MAXPLAYERS; i++) 115 | { 116 | chat_dest[i] = 0; 117 | msgptr[i] = 0; 118 | memset(plr_lastmsg[i], 0, MESSAGESIZE); 119 | memset(chat_msg[i], 0, MESSAGESIZE); 120 | } 121 | FontABaseLump = W_GetNumForName("FONTA_S")+1; 122 | return; 123 | } 124 | 125 | //=========================================================================== 126 | // 127 | // CT_Stop 128 | // 129 | //=========================================================================== 130 | 131 | void CT_Stop(void) 132 | { 133 | chatmodeon = false; 134 | return; 135 | } 136 | 137 | //=========================================================================== 138 | // 139 | // CT_Responder 140 | // 141 | //=========================================================================== 142 | 143 | boolean CT_Responder(event_t *ev) 144 | { 145 | char *macro; 146 | 147 | int sendto; 148 | 149 | if(!netgame) 150 | { 151 | return false; 152 | } 153 | if(ev->data1 == KEY_RALT) 154 | { 155 | altdown = (ev->type == ev_keydown); 156 | return false; 157 | } 158 | if(ev->data1 == KEY_RSHIFT) 159 | { 160 | shiftdown = (ev->type == ev_keydown); 161 | return false; 162 | } 163 | if(gamestate != GS_LEVEL || ev->type != ev_keydown) 164 | { 165 | return false; 166 | } 167 | if(!chatmodeon) 168 | { 169 | sendto = 0; 170 | if(ev->data1 == CT_KEY_ALL) 171 | { 172 | sendto = CT_PLR_ALL; 173 | } 174 | else if(ev->data1 == CT_KEY_GREEN) 175 | { 176 | sendto = CT_PLR_GREEN; 177 | } 178 | else if(ev->data1 == CT_KEY_YELLOW) 179 | { 180 | sendto = CT_PLR_YELLOW; 181 | } 182 | else if(ev->data1 == CT_KEY_RED) 183 | { 184 | sendto = CT_PLR_RED; 185 | } 186 | else if(ev->data1 == CT_KEY_BLUE) 187 | { 188 | sendto = CT_PLR_BLUE; 189 | } 190 | else if(ev->data1 == CT_KEY_PLAYER5) 191 | { 192 | sendto = CT_PLR_PLAYER5; 193 | } 194 | else if(ev->data1 == CT_KEY_PLAYER6) 195 | { 196 | sendto = CT_PLR_PLAYER6; 197 | } 198 | else if(ev->data1 == CT_KEY_PLAYER7) 199 | { 200 | sendto = CT_PLR_PLAYER7; 201 | } 202 | else if(ev->data1 == CT_KEY_PLAYER8) 203 | { 204 | sendto = CT_PLR_PLAYER8; 205 | } 206 | if(sendto == 0 || (sendto != CT_PLR_ALL && !playeringame[sendto-1]) 207 | || sendto == consoleplayer+1) 208 | { 209 | return false; 210 | } 211 | CT_queueChatChar(sendto); 212 | chatmodeon = true; 213 | return true; 214 | } 215 | else 216 | { 217 | if(altdown) 218 | { 219 | if(ev->data1 >= '0' && ev->data1 <= '9') 220 | { 221 | if(ev->data1 == '0') 222 | { // macro 0 comes after macro 9 223 | ev->data1 = '9'+1; 224 | } 225 | macro = chat_macros[ev->data1-'1']; 226 | CT_queueChatChar(KEY_ENTER); //send old message 227 | CT_queueChatChar(chat_dest[consoleplayer]); // chose the dest. 228 | while(*macro) 229 | { 230 | CT_queueChatChar(toupper(*macro++)); 231 | } 232 | CT_queueChatChar(KEY_ENTER); //send it off... 233 | CT_Stop(); 234 | return true; 235 | } 236 | } 237 | if(ev->data1 == KEY_ENTER) 238 | { 239 | CT_queueChatChar(KEY_ENTER); 240 | usearti = false; 241 | CT_Stop(); 242 | return true; 243 | } 244 | else if(ev->data1 == KEY_ESCAPE) 245 | { 246 | CT_queueChatChar(CT_ESCAPE); 247 | CT_Stop(); 248 | return true; 249 | } 250 | else if(ev->data1 >= 'a' && ev->data1 <= 'z') 251 | { 252 | CT_queueChatChar(ev->data1-32); 253 | return true; 254 | } 255 | else if(shiftdown) 256 | { 257 | if(ev->data1 == '1') 258 | { 259 | CT_queueChatChar('!'); 260 | return true; 261 | } 262 | else if(ev->data1 == '/') 263 | { 264 | CT_queueChatChar('?'); 265 | return true; 266 | } 267 | } 268 | if(ev->data1 == ' ' || ev->data1 == ',' || ev->data1 == '.' 269 | || (ev->data1 >= '0' && ev->data1 <= '9') || ev->data1 == '\'' 270 | || ev->data1 == KEY_BACKSPACE || ev->data1 == '-' || ev->data1 == '=') 271 | { 272 | CT_queueChatChar(ev->data1); 273 | return true; 274 | } 275 | } 276 | return false; 277 | } 278 | 279 | //=========================================================================== 280 | // 281 | // CT_Ticker 282 | // 283 | //=========================================================================== 284 | 285 | void CT_Ticker(void) 286 | { 287 | int i; 288 | int j; 289 | char c; 290 | int numplayers; 291 | 292 | for(i=0; i < MAXPLAYERS; i++) 293 | { 294 | if(!playeringame[i]) 295 | { 296 | continue; 297 | } 298 | if((c = players[i].cmd.chatchar) != 0) 299 | { 300 | if(c <= CT_PLR_ALL) 301 | { 302 | chat_dest[i] = c; 303 | continue; 304 | } 305 | else if(c == CT_ESCAPE) 306 | { 307 | CT_ClearChatMessage(i); 308 | } 309 | else if(c == KEY_ENTER) 310 | { 311 | numplayers = 0; 312 | for(j = 0; j < MAXPLAYERS; j++) 313 | { 314 | numplayers += playeringame[j]; 315 | } 316 | CT_AddChar(i, 0); // set the end of message character 317 | if(numplayers > 2) 318 | { 319 | strcpy(plr_lastmsg[i], CT_FromPlrText[i]); 320 | strcat(plr_lastmsg[i], chat_msg[i]); 321 | } 322 | else 323 | { 324 | strcpy(plr_lastmsg[i], chat_msg[i]); 325 | } 326 | if(i != consoleplayer && (chat_dest[i] == consoleplayer+1 327 | || chat_dest[i] == CT_PLR_ALL) && *chat_msg[i]) 328 | { 329 | P_SetMessage(&players[consoleplayer], plr_lastmsg[i], 330 | true); 331 | S_StartSound(NULL, SFX_CHAT); 332 | } 333 | else if(i == consoleplayer && (*chat_msg[i])) 334 | { 335 | if(numplayers <= 1) 336 | { 337 | P_SetMessage(&players[consoleplayer], 338 | "THERE ARE NO OTHER PLAYERS IN THE GAME!", true); 339 | S_StartSound(NULL, SFX_CHAT); 340 | } 341 | } 342 | CT_ClearChatMessage(i); 343 | } 344 | else if(c == KEY_BACKSPACE) 345 | { 346 | CT_BackSpace(i); 347 | } 348 | else 349 | { 350 | CT_AddChar(i, c); 351 | } 352 | } 353 | } 354 | return; 355 | } 356 | 357 | //=========================================================================== 358 | // 359 | // CT_Drawer 360 | // 361 | //=========================================================================== 362 | 363 | void CT_Drawer(void) 364 | { 365 | int i; 366 | int x; 367 | patch_t *patch; 368 | 369 | if(chatmodeon) 370 | { 371 | x = 25; 372 | for(i = 0; i < msgptr[consoleplayer]; i++) 373 | { 374 | if(chat_msg[consoleplayer][i] < 33) 375 | { 376 | x += 6; 377 | } 378 | else 379 | { 380 | patch=W_CacheLumpNum(FontABaseLump+ 381 | chat_msg[consoleplayer][i]-33, PU_CACHE); 382 | V_DrawPatch(x, 10, patch); 383 | x += patch->width; 384 | } 385 | } 386 | V_DrawPatch(x, 10, W_CacheLumpName("FONTA59", PU_CACHE)); 387 | BorderTopRefresh = true; 388 | UpdateState |= I_MESSAGES; 389 | } 390 | } 391 | 392 | //=========================================================================== 393 | // 394 | // CT_queueChatChar 395 | // 396 | //=========================================================================== 397 | 398 | void CT_queueChatChar(char ch) 399 | { 400 | if((tail+1)&(QUEUESIZE-1) == head) 401 | { // the queue is full 402 | return; 403 | } 404 | ChatQueue[tail] = ch; 405 | tail = (tail+1)&(QUEUESIZE-1); 406 | } 407 | 408 | //=========================================================================== 409 | // 410 | // CT_dequeueChatChar 411 | // 412 | //=========================================================================== 413 | 414 | char CT_dequeueChatChar(void) 415 | { 416 | byte temp; 417 | 418 | if(head == tail) 419 | { // queue is empty 420 | return 0; 421 | } 422 | temp = ChatQueue[head]; 423 | head = (head+1)&(QUEUESIZE-1); 424 | return temp; 425 | } 426 | 427 | //=========================================================================== 428 | // 429 | // CT_AddChar 430 | // 431 | //=========================================================================== 432 | 433 | void CT_AddChar(int player, char c) 434 | { 435 | patch_t *patch; 436 | 437 | if(msgptr[player]+1 >= MESSAGESIZE || msglen[player] >= MESSAGELEN) 438 | { // full. 439 | return; 440 | } 441 | chat_msg[player][msgptr[player]] = c; 442 | msgptr[player]++; 443 | if(c < 33) 444 | { 445 | msglen[player] += 6; 446 | } 447 | else 448 | { 449 | patch = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); 450 | msglen[player] += patch->width; 451 | } 452 | } 453 | 454 | //=========================================================================== 455 | // 456 | // CT_BackSpace 457 | // 458 | // Backs up a space, when the user hits (obviously) backspace 459 | //=========================================================================== 460 | 461 | void CT_BackSpace(int player) 462 | { 463 | patch_t *patch; 464 | char c; 465 | 466 | if(msgptr[player] == 0) 467 | { // message is already blank 468 | return; 469 | } 470 | msgptr[player]--; 471 | c = chat_msg[player][msgptr[player]]; 472 | if(c < 33) 473 | { 474 | msglen[player] -= 6; 475 | } 476 | else 477 | { 478 | patch = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); 479 | msglen[player] -= patch->width; 480 | } 481 | chat_msg[player][msgptr[player]] = 0; 482 | } 483 | 484 | //=========================================================================== 485 | // 486 | // CT_ClearChatMessage 487 | // 488 | // Clears out the data for the chat message, but the player's message 489 | // is still saved in plrmsg. 490 | //=========================================================================== 491 | 492 | void CT_ClearChatMessage(int player) 493 | { 494 | memset(chat_msg[player], 0, MESSAGESIZE); 495 | msgptr[player] = 0; 496 | msglen[player] = 0; 497 | } 498 | --------------------------------------------------------------------------------