diff options
Diffstat (limited to 'src')
47 files changed, 311 insertions, 4515 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c index ca722dc6..eb9454ac 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -1151,6 +1151,11 @@ static void LoadIwadDeh(void) } } +static void G_CheckDemoStatusAtExit (void) +{ + G_CheckDemoStatus(); +} + // // D_DoomMain // @@ -1498,7 +1503,7 @@ void D_DoomMain (void) printf("Playing demo %s.\n", file); } - I_AtExit((atexit_func_t) G_CheckDemoStatus, true); + I_AtExit(G_CheckDemoStatusAtExit, true); // Generate the WAD hash table. Speed things up a bit. W_GenerateHashTable(); diff --git a/src/doomtype.h b/src/doomtype.h index 83b119a0..10820c12 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -21,6 +21,10 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ +#if defined(_MSC_VER) && !defined(__cplusplus) +#define inline __inline +#endif + // #define macros to provide functions missing in Windows. // Outside Windows, we use strings.h for str[n]casecmp. diff --git a/src/heretic/Makefile.am b/src/heretic/Makefile.am index 88ccc7b8..0cf95c8c 100644 --- a/src/heretic/Makefile.am +++ b/src/heretic/Makefile.am @@ -53,10 +53,6 @@ sb_bar.c \ sounds.c sounds.h \ s_sound.c s_sound.h -EXTRA_DIST= \ -i_sound.c \ -i_ibm.c - FEATURE_DEHACKED_SOURCE_FILES = \ deh_ammo.c \ deh_frame.c \ diff --git a/src/heretic/i_ibm.c b/src/heretic/i_ibm.c deleted file mode 100644 index e2dffef8..00000000 --- a/src/heretic/i_ibm.c +++ /dev/null @@ -1,1642 +0,0 @@ -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2005-2014 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// - -// I_IBM.C - -#include <dos.h> -#include <conio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <graph.h> -#include "doomdef.h" -#include "r_local.h" -#include "dmx.h" -#include "v_video.h" - -// Macros - -#define DPMI_INT 0x31 -//#define NOKBD -//#define NOTIMER - -// Public Data - -int DisplayTicker = 0; - -// Code - -void main(int argc, char **argv) -{ - myargc = argc; - myargv = argv; - D_DoomMain(); -} - -void I_StartupNet(void); -void I_ShutdownNet(void); -void I_ReadExternDriver(void); - -typedef struct -{ - unsigned edi, esi, ebp, reserved, ebx, edx, ecx, eax; - unsigned short flags, es, ds, fs, gs, ip, cs, sp, ss; -} dpmiregs_t; - -extern dpmiregs_t dpmiregs; - -void I_ReadMouse(void); -void I_InitDiskFlash(void); - -extern int usemouse, usejoystick; - -extern void **lumpcache; - -/* -============================================================================= - - CONSTANTS - -============================================================================= -*/ - -#define SC_INDEX 0x3C4 -#define SC_RESET 0 -#define SC_CLOCK 1 -#define SC_MAPMASK 2 -#define SC_CHARMAP 3 -#define SC_MEMMODE 4 - -#define CRTC_INDEX 0x3D4 -#define CRTC_H_TOTAL 0 -#define CRTC_H_DISPEND 1 -#define CRTC_H_BLANK 2 -#define CRTC_H_ENDBLANK 3 -#define CRTC_H_RETRACE 4 -#define CRTC_H_ENDRETRACE 5 -#define CRTC_V_TOTAL 6 -#define CRTC_OVERFLOW 7 -#define CRTC_ROWSCAN 8 -#define CRTC_MAXSCANLINE 9 -#define CRTC_CURSORSTART 10 -#define CRTC_CURSOREND 11 -#define CRTC_STARTHIGH 12 -#define CRTC_STARTLOW 13 -#define CRTC_CURSORHIGH 14 -#define CRTC_CURSORLOW 15 -#define CRTC_V_RETRACE 16 -#define CRTC_V_ENDRETRACE 17 -#define CRTC_V_DISPEND 18 -#define CRTC_OFFSET 19 -#define CRTC_UNDERLINE 20 -#define CRTC_V_BLANK 21 -#define CRTC_V_ENDBLANK 22 -#define CRTC_MODE 23 -#define CRTC_LINECOMPARE 24 - - -#define GC_INDEX 0x3CE -#define GC_SETRESET 0 -#define GC_ENABLESETRESET 1 -#define GC_COLORCOMPARE 2 -#define GC_DATAROTATE 3 -#define GC_READMAP 4 -#define GC_MODE 5 -#define GC_MISCELLANEOUS 6 -#define GC_COLORDONTCARE 7 -#define GC_BITMASK 8 - -#define ATR_INDEX 0x3c0 -#define ATR_MODE 16 -#define ATR_OVERSCAN 17 -#define ATR_COLORPLANEENABLE 18 -#define ATR_PELPAN 19 -#define ATR_COLORSELECT 20 - -#define STATUS_REGISTER_1 0x3da - -#define PEL_WRITE_ADR 0x3c8 -#define PEL_READ_ADR 0x3c7 -#define PEL_DATA 0x3c9 -#define PEL_MASK 0x3c6 - -boolean grmode; - -//================================================== -// -// joystick vars -// -//================================================== - -boolean joystickpresent; -extern unsigned joystickx, joysticky; -boolean I_ReadJoystick(void); // returns false if not connected - - -//================================================== - -#define VBLCOUNTER 34000 // hardware tics to a frame - - -#define TIMERINT 8 -#define KEYBOARDINT 9 - -#define CRTCOFF (_inbyte(STATUS_REGISTER_1)&1) -#define CLI _disable() -#define STI _enable() - -#define _outbyte(x,y) (outp(x,y)) -#define _outhword(x,y) (outpw(x,y)) - -#define _inbyte(x) (inp(x)) -#define _inhword(x) (inpw(x)) - -#define MOUSEB1 1 -#define MOUSEB2 2 -#define MOUSEB3 4 - -boolean mousepresent; -//static int tsm_ID = -1; // tsm init flag - -//=============================== - -int ticcount; - -// REGS stuff used for int calls -union REGS regs; -struct SREGS segregs; - -boolean novideo; // if true, stay in text mode for debugging - -#define KBDQUESIZE 32 -byte keyboardque[KBDQUESIZE]; -int kbdtail, kbdhead; - -#define KEY_LSHIFT 0xfe - -#define KEY_INS (0x80+0x52) -#define KEY_DEL (0x80+0x53) -#define KEY_PGUP (0x80+0x49) -#define KEY_PGDN (0x80+0x51) -#define KEY_HOME (0x80+0x47) -#define KEY_END (0x80+0x4f) - -#define SC_RSHIFT 0x36 -#define SC_LSHIFT 0x2a - -byte scantokey[128] = { -// 0 1 2 3 4 5 6 7 -// 8 9 A B C D E F - 0, 27, '1', '2', '3', '4', '5', '6', - '7', '8', '9', '0', '-', '=', KEY_BACKSPACE, 9, // 0 - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', - 'o', 'p', '[', ']', 13, KEY_RCTRL, 'a', 's', // 1 - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - 39, '`', KEY_LSHIFT, 92, 'z', 'x', 'c', 'v', // 2 - 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT, '*', - KEY_RALT, ' ', 0, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, // 3 - KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, 0, 0, KEY_HOME, - KEY_UPARROW, KEY_PGUP, '-', KEY_LEFTARROW, '5', KEY_RIGHTARROW, '+', KEY_END, //4 - KEY_DOWNARROW, KEY_PGDN, KEY_INS, KEY_DEL, 0, 0, 0, KEY_F11, - KEY_F12, 0, 0, 0, 0, 0, 0, 0, // 5 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, // 6 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 // 7 -}; - -//========================================================================== - -//-------------------------------------------------------------------------- -// -// FUNC I_GetTime -// -// Returns time in 1/35th second tics. -// -//-------------------------------------------------------------------------- - -int I_GetTime(void) -{ -#ifdef NOTIMER - ticcount++; -#endif - return (ticcount); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ColorBorder -// -//-------------------------------------------------------------------------- - -void I_ColorBorder(void) -{ - int i; - - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for (i = 0; i < 3; i++) - { - _outbyte(PEL_DATA, 63); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_UnColorBorder -// -//-------------------------------------------------------------------------- - -void I_UnColorBorder(void) -{ - int i; - - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for (i = 0; i < 3; i++) - { - _outbyte(PEL_DATA, 0); - } -} - -/* -============================================================================ - - USER INPUT - -============================================================================ -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_WaitVBL -// -//-------------------------------------------------------------------------- - -void I_WaitVBL(int vbls) -{ - int i; - int old; - int stat; - - if (novideo) - { - return; - } - while (vbls--) - { - do - { - stat = inp(STATUS_REGISTER_1); - if (stat & 8) - { - break; - } - } - while (1); - do - { - stat = inp(STATUS_REGISTER_1); - if ((stat & 8) == 0) - { - break; - } - } - while (1); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_SetPalette -// -// Palette source must use 8 bit RGB elements. -// -//-------------------------------------------------------------------------- - -void I_SetPalette(byte * palette) -{ - int i; - - if (novideo) - { - return; - } - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for (i = 0; i < 768; i++) - { - _outbyte(PEL_DATA, (gammatable[usegamma][*palette++]) >> 2); - } -} - -/* -============================================================================ - - GRAPHICS MODE - -============================================================================ -*/ - -byte *pcscreen, *destscreen, *destview; - - -/* -============== -= -= I_Update -= -============== -*/ - -int UpdateState; -extern int screenblocks; - -void I_Update(void) -{ - int i; - byte *dest; - int tics; - static int lasttic; - -// -// blit screen to video -// - if (DisplayTicker) - { - if (screenblocks > 9 || UpdateState & (I_FULLSCRN | I_MESSAGES)) - { - dest = (byte *) screen; - } - else - { - dest = (byte *) pcscreen; - } - tics = ticcount - lasttic; - lasttic = ticcount; - if (tics > 20) - { - tics = 20; - } - for (i = 0; i < tics; i++) - { - *dest = 0xff; - dest += 2; - } - for (i = tics; i < 20; i++) - { - *dest = 0x00; - dest += 2; - } - } - if (UpdateState == I_NOUPDATE) - { - return; - } - if (UpdateState & I_FULLSCRN) - { - memcpy(pcscreen, screen, SCREENWIDTH * SCREENHEIGHT); - UpdateState = I_NOUPDATE; // clear out all draw types - } - if (UpdateState & I_FULLVIEW) - { - if (UpdateState & I_MESSAGES && screenblocks > 7) - { - for (i = 0; i < - (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) - { - memcpy(pcscreen + i, screen + i, SCREENWIDTH); - } - UpdateState &= ~(I_FULLVIEW | I_MESSAGES); - } - else - { - for (i = viewwindowy * SCREENWIDTH + viewwindowx; i < - (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) - { - memcpy(pcscreen + i, screen + i, viewwidth); - } - UpdateState &= ~I_FULLVIEW; - } - } - if (UpdateState & I_STATBAR) - { - memcpy(pcscreen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), - screen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), - SCREENWIDTH * SBARHEIGHT); - UpdateState &= ~I_STATBAR; - } - if (UpdateState & I_MESSAGES) - { - memcpy(pcscreen, screen, SCREENWIDTH * 28); - UpdateState &= ~I_MESSAGES; - } - -// memcpy(pcscreen, screen, SCREENHEIGHT*SCREENWIDTH); -} - -//-------------------------------------------------------------------------- -// -// PROC I_InitGraphics -// -//-------------------------------------------------------------------------- - -void I_InitGraphics(void) -{ - if (novideo) - { - return; - } - grmode = true; - regs.w.ax = 0x13; - int386(0x10, (const union REGS *) ®s, ®s); - pcscreen = destscreen = (byte *) 0xa0000; - I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); - I_InitDiskFlash(); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ShutdownGraphics -// -//-------------------------------------------------------------------------- - -void I_ShutdownGraphics(void) -{ - - if (*(byte *) 0x449 == 0x13) // don't reset mode if it didn't get set - { - regs.w.ax = 3; - int386(0x10, ®s, ®s); // back to text mode - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_ReadScreen -// -// Reads the screen currently displayed into a linear buffer. -// -//-------------------------------------------------------------------------- - -void I_ReadScreen(byte * scr) -{ - memcpy(scr, screen, SCREENWIDTH * SCREENHEIGHT); -} - - -//=========================================================================== - -/* -=================== -= -= I_StartTic -= -// called by D_DoomLoop -// called before processing each tic in a frame -// can call D_PostEvent -// asyncronous interrupt functions should maintain private ques that are -// read by the syncronous functions to be converted into events -=================== -*/ - -/* - OLD STARTTIC STUFF - -void I_StartTic (void) -{ - int k; - event_t ev; - - - I_ReadMouse (); - -// -// keyboard events -// - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; - -// if (k==14) -// I_Error ("exited"); - - kbdtail++; - - // extended keyboard shift key bullshit - if ( (k&0x7f)==KEY_RSHIFT ) - { - if ( keyboardque[(kbdtail-2)&(KBDQUESIZE-1)]==0xe0 ) - continue; - k &= 0x80; - k |= KEY_RSHIFT; - } - - if (k==0xe0) - continue; // special / pause keys - if (keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0xe1) - continue; // pause key bullshit - - if (k==0xc5 && keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0x9d) - { - ev.type = ev_keydown; - ev.data1 = KEY_PAUSE; - D_PostEvent (&ev); - continue; - } - - if (k&0x80) - ev.type = ev_keyup; - else - ev.type = ev_keydown; - k &= 0x7f; - - ev.data1 = k; - //ev.data1 = scantokey[k]; - - D_PostEvent (&ev); - } -} -*/ - -#define SC_UPARROW 0x48 -#define SC_DOWNARROW 0x50 -#define SC_LEFTARROW 0x4b -#define SC_RIGHTARROW 0x4d - -void I_StartTic(void) -{ - int k; - event_t ev; - - - I_ReadMouse(); - -// -// keyboard events -// - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; - kbdtail++; - - // extended keyboard shift key bullshit - if ((k & 0x7f) == SC_LSHIFT || (k & 0x7f) == SC_RSHIFT) - { - if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe0) - continue; - k &= 0x80; - k |= SC_RSHIFT; - } - - if (k == 0xe0) - continue; // special / pause keys - if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe1) - continue; // pause key bullshit - - if (k == 0xc5 - && keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0x9d) - { - ev.type = ev_keydown; - ev.data1 = KEY_PAUSE; - D_PostEvent(&ev); - continue; - } - - if (k & 0x80) - ev.type = ev_keyup; - else - ev.type = ev_keydown; - k &= 0x7f; - switch (k) - { - case SC_UPARROW: - ev.data1 = KEY_UPARROW; - break; - case SC_DOWNARROW: - ev.data1 = KEY_DOWNARROW; - break; - case SC_LEFTARROW: - ev.data1 = KEY_LEFTARROW; - break; - case SC_RIGHTARROW: - ev.data1 = KEY_RIGHTARROW; - break; - default: - ev.data1 = scantokey[k]; - break; - } - D_PostEvent(&ev); - } - -} - - -void I_ReadKeys(void) -{ - int k; - event_t ev; - - - while (1) - { - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; - kbdtail++; - printf("0x%x\n", k); - if (k == 1) - I_Quit(); - } - } -} - -/* -=============== -= -= I_StartFrame -= -=============== -*/ - -void I_StartFrame(void) -{ - I_JoystickEvents(); - I_ReadExternDriver(); -} - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - -void I_ColorBlack(int r, int g, int b) -{ - _outbyte(PEL_WRITE_ADR, 0); - _outbyte(PEL_DATA, r); - _outbyte(PEL_DATA, g); - _outbyte(PEL_DATA, b); -} - - -/* -================ -= -= I_TimerISR -= -================ -*/ - -int I_TimerISR(void) -{ - ticcount++; - return 0; -} - -/* -============================================================================ - - KEYBOARD - -============================================================================ -*/ - -void (__interrupt __far * oldkeyboardisr) () = NULL; - -int lastpress; - -/* -================ -= -= I_KeyboardISR -= -================ -*/ - -void __interrupt I_KeyboardISR(void) -{ -// Get the scan code - - keyboardque[kbdhead & (KBDQUESIZE - 1)] = lastpress = _inbyte(0x60); - kbdhead++; - -// acknowledge the interrupt - - _outbyte(0x20, 0x20); -} - - - -/* -=============== -= -= I_StartupKeyboard -= -=============== -*/ - -void I_StartupKeyboard(void) -{ -#ifndef NOKBD - oldkeyboardisr = _dos_getvect(KEYBOARDINT); - _dos_setvect(0x8000 | KEYBOARDINT, I_KeyboardISR); -#endif - -//I_ReadKeys (); -} - - -void I_ShutdownKeyboard(void) -{ - if (oldkeyboardisr) - _dos_setvect(KEYBOARDINT, oldkeyboardisr); - *(short *) 0x41c = *(short *) 0x41a; // clear bios key buffer -} - - - -/* -============================================================================ - - MOUSE - -============================================================================ -*/ - - -int I_ResetMouse(void) -{ - regs.w.ax = 0; // reset - int386(0x33, ®s, ®s); - return regs.w.ax; -} - - - -/* -================ -= -= StartupMouse -= -================ -*/ - -void I_StartupCyberMan(void); - -void I_StartupMouse(void) -{ - int (far * function) (); - - // - // General mouse detection - // - mousepresent = 0; - if (M_CheckParm("-nomouse") || !usemouse) - return; - - if (I_ResetMouse() != 0xffff) - { - tprintf("Mouse: not present ", 0); - return; - } - tprintf("Mouse: detected ", 0); - - mousepresent = 1; - - I_StartupCyberMan(); -} - - -/* -================ -= -= ShutdownMouse -= -================ -*/ - -void I_ShutdownMouse(void) -{ - if (!mousepresent) - return; - - I_ResetMouse(); -} - - -/* -================ -= -= I_ReadMouse -= -================ -*/ - -void I_ReadMouse(void) -{ - event_t ev; - -// -// mouse events -// - if (!mousepresent) - return; - - ev.type = ev_mouse; - - memset(&dpmiregs, 0, sizeof(dpmiregs)); - dpmiregs.eax = 3; // read buttons / position - DPMIInt(0x33); - ev.data1 = dpmiregs.ebx; - - dpmiregs.eax = 11; // read counters - DPMIInt(0x33); - ev.data2 = (short) dpmiregs.ecx; - ev.data3 = -(short) dpmiregs.edx; - - D_PostEvent(&ev); -} - -/* -============================================================================ - - JOYSTICK - -============================================================================ -*/ - -int joyxl, joyxh, joyyl, joyyh; - -boolean WaitJoyButton(void) -{ - int oldbuttons, buttons; - - oldbuttons = 0; - do - { - I_WaitVBL(1); - buttons = ((inp(0x201) >> 4) & 1) ^ 1; - if (buttons != oldbuttons) - { - oldbuttons = buttons; - continue; - } - - if ((lastpress & 0x7f) == 1) - { - joystickpresent = false; - return false; - } - } - while (!buttons); - - do - { - I_WaitVBL(1); - buttons = ((inp(0x201) >> 4) & 1) ^ 1; - if (buttons != oldbuttons) - { - oldbuttons = buttons; - continue; - } - - if ((lastpress & 0x7f) == 1) - { - joystickpresent = false; - return false; - } - } - while (buttons); - - return true; -} - - - -/* -=============== -= -= I_StartupJoystick -= -=============== -*/ - -int basejoyx, basejoyy; - -void I_StartupJoystick(void) -{ - int buttons; - int count; - int centerx, centery; - - joystickpresent = 0; - if (M_CheckParm("-nojoy") || !usejoystick) - return; - - if (!I_ReadJoystick()) - { - joystickpresent = false; - tprintf("joystick not found ", 0); - return; - } - printf("joystick found\n"); - joystickpresent = true; - - printf("CENTER the joystick and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - centerx = joystickx; - centery = joysticky; - - printf - ("\nPush the joystick to the UPPER LEFT corner and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - joyxl = (centerx + joystickx) / 2; - joyyl = (centerx + joysticky) / 2; - - printf - ("\nPush the joystick to the LOWER RIGHT corner and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - joyxh = (centerx + joystickx) / 2; - joyyh = (centery + joysticky) / 2; - printf("\n"); -} - -/* -=============== -= -= I_JoystickEvents -= -=============== -*/ - -void I_JoystickEvents(void) -{ - event_t ev; - -// -// joystick events -// - if (!joystickpresent) - return; - - I_ReadJoystick(); - ev.type = ev_joystick; - ev.data1 = ((inp(0x201) >> 4) & 15) ^ 15; - - if (joystickx < joyxl) - ev.data2 = -1; - else if (joystickx > joyxh) - ev.data2 = 1; - else - ev.data2 = 0; - if (joysticky < joyyl) - ev.data3 = -1; - else if (joysticky > joyyh) - ev.data3 = 1; - else - ev.data3 = 0; - - D_PostEvent(&ev); -} - - - -/* -============================================================================ - - DPMI STUFF - -============================================================================ -*/ - -#define REALSTACKSIZE 1024 - -dpmiregs_t dpmiregs; - -unsigned realstackseg; - -void I_DivException(void); -int I_SetDivException(void); - -void DPMIFarCall(void) -{ - segread(&segregs); - regs.w.ax = 0x301; - regs.w.bx = 0; - regs.w.cx = 0; - regs.x.edi = (unsigned) &dpmiregs; - segregs.es = segregs.ds; - int386x(DPMI_INT, ®s, ®s, &segregs); -} - - -void DPMIInt(int i) -{ - dpmiregs.ss = realstackseg; - dpmiregs.sp = REALSTACKSIZE - 4; - - segread(&segregs); - regs.w.ax = 0x300; - regs.w.bx = i; - regs.w.cx = 0; - regs.x.edi = (unsigned) &dpmiregs; - segregs.es = segregs.ds; - int386x(DPMI_INT, ®s, ®s, &segregs); -} - - -/* -============== -= -= I_StartupDPMI -= -============== -*/ - -void I_StartupDPMI(void) -{ - extern char __begtext; - extern char ___argc; - int n, d; - -// -// allocate a decent stack for real mode ISRs -// - realstackseg = (int) I_AllocLow(1024) >> 4; - -// -// lock the entire program down -// - -// _dpmi_lockregion (&__begtext, &___argc - &__begtext); - - -// -// catch divide by 0 exception -// -#if 0 - segread(&segregs); - regs.w.ax = 0x0203; // DPMI set processor exception handler vector - regs.w.bx = 0; // int 0 - regs.w.cx = segregs.cs; - regs.x.edx = (int) &I_DivException; - printf("%x : %x\n", regs.w.cx, regs.x.edx); - int386(DPMI_INT, ®s, ®s); -#endif - -#if 0 - n = I_SetDivException(); - printf("return: %i\n", n); - n = 100; - d = 0; - printf("100 / 0 = %i\n", n / d); - - exit(1); -#endif -} - - - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - -void (__interrupt __far * oldtimerisr) (); - - -void IO_ColorBlack(int r, int g, int b) -{ - _outbyte(PEL_WRITE_ADR, 0); - _outbyte(PEL_DATA, r); - _outbyte(PEL_DATA, g); - _outbyte(PEL_DATA, b); -} - - -/* -================ -= -= IO_TimerISR -= -================ -*/ - -//void __interrupt IO_TimerISR (void) - -void __interrupt __far IO_TimerISR(void) -{ - ticcount++; - _outbyte(0x20, 0x20); // Ack the interrupt -} - -/* -===================== -= -= IO_SetTimer0 -= -= Sets system timer 0 to the specified speed -= -===================== -*/ - -void IO_SetTimer0(int speed) -{ - if (speed > 0 && speed < 150) - I_Error("INT_SetTimer0: %i is a bad value", speed); - - _outbyte(0x43, 0x36); // Change timer 0 - _outbyte(0x40, speed); - _outbyte(0x40, speed >> 8); -} - - - -/* -=============== -= -= IO_StartupTimer -= -=============== -*/ - -void IO_StartupTimer(void) -{ - oldtimerisr = _dos_getvect(TIMERINT); - - _dos_setvect(0x8000 | TIMERINT, IO_TimerISR); - IO_SetTimer0(VBLCOUNTER); -} - -void IO_ShutdownTimer(void) -{ - if (oldtimerisr) - { - IO_SetTimer0(0); // back to 18.4 ips - _dos_setvect(TIMERINT, oldtimerisr); - } -} - -//=========================================================================== - - -/* -=============== -= -= I_Init -= -= hook interrupts and set graphics mode -= -=============== -*/ - -void I_Init(void) -{ - extern void I_StartupTimer(void); - - novideo = M_CheckParm("novideo"); - tprintf("I_StartupDPMI", 1); - I_StartupDPMI(); - tprintf("I_StartupMouse ", 1); - I_StartupMouse(); -// tprintf("I_StartupJoystick ",1); -// I_StartupJoystick(); -// tprintf("I_StartupKeyboard ",1); -// I_StartupKeyboard(); -} - - -/* -=============== -= -= I_Shutdown -= -= return to default system state -= -=============== -*/ - -void I_Shutdown(void) -{ - I_ShutdownGraphics(); - IO_ShutdownTimer(); - S_ShutDown(); - I_ShutdownMouse(); - I_ShutdownKeyboard(); - - IO_SetTimer0(0); -} - - -/* -================ -= -= I_Error -= -================ -*/ - -void I_Error(char *error, ...) -{ - union REGS regs; - - va_list argptr; - - D_QuitNetGame(); - I_Shutdown(); - va_start(argptr, error); - regs.x.eax = 0x3; - int386(0x10, ®s, ®s); - vprintf(error, argptr); - va_end(argptr); - printf("\n"); - exit(1); -} - -//-------------------------------------------------------------------------- -// -// I_Quit -// -// Shuts down net game, saves defaults, prints the exit text message, -// goes to text mode, and exits. -// -//-------------------------------------------------------------------------- - -void I_Quit(void) -{ - byte *scr; - char *lumpName; - int r; - - D_QuitNetGame(); - M_SaveDefaults(); - scr = (byte *) W_CacheLumpName("ENDTEXT", PU_CACHE); - I_Shutdown(); - memcpy((void *) 0xb8000, scr, 80 * 25 * 2); - regs.w.ax = 0x0200; - regs.h.bh = 0; - regs.h.dl = 0; - regs.h.dh = 23; - int386(0x10, (const union REGS *) ®s, ®s); // Set text pos - _settextposition(24, 1); - exit(0); -} - -/* -=============== -= -= I_ZoneBase -= -=============== -*/ - -byte *I_ZoneBase(int *size) -{ - int meminfo[32]; - int heap; - int i; - int block; - byte *ptr; - - memset(meminfo, 0, sizeof(meminfo)); - segread(&segregs); - segregs.es = segregs.ds; - regs.w.ax = 0x500; // get memory info - regs.x.edi = (int) &meminfo; - int386x(0x31, ®s, ®s, &segregs); - - heap = meminfo[0]; - printf("DPMI memory: 0x%x, ", heap); - - do - { - heap -= 0x10000; // leave 64k alone - if (heap > 0x800000) - heap = 0x800000; - ptr = malloc(heap); - } - while (!ptr); - - printf("0x%x allocated for zone\n", heap); - if (heap < 0x180000) - I_Error("Insufficient DPMI memory!"); -#if 0 - regs.w.ax = 0x501; // allocate linear block - regs.w.bx = heap >> 16; - regs.w.cx = heap & 0xffff; - int386(0x31, ®s, ®s); - if (regs.w.cflag) - I_Error("Couldn't allocate DPMI memory!"); - - block = (regs.w.si << 16) + regs.w.di; -#endif - - *size = heap; - return ptr; -} - -/* -============================================================================= - - DISK ICON FLASHING - -============================================================================= -*/ - -void I_InitDiskFlash(void) -{ -#if 0 - void *pic; - byte *temp; - - pic = W_CacheLumpName("STDISK", PU_CACHE); - temp = destscreen; - destscreen = (byte *) 0xac000; - V_DrawPatchDirect(SCREENWIDTH - 16, SCREENHEIGHT - 16, 0, pic); - destscreen = temp; -#endif -} - -// draw disk icon -void I_BeginRead(void) -{ -#if 0 - byte *src, *dest; - int y; - - if (!grmode) - return; - -// write through all planes - outp(SC_INDEX, SC_MAPMASK); - outp(SC_INDEX + 1, 15); -// set write mode 1 - outp(GC_INDEX, GC_MODE); - outp(GC_INDEX + 1, inp(GC_INDEX + 1) | 1); - -// copy to backup - src = currentscreen + 184 * 80 + 304 / 4; - dest = (byte *) 0xac000 + 184 * 80 + 288 / 4; - for (y = 0; y < 16; y++) - { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - dest[3] = src[3]; - src += 80; - dest += 80; - } - -// copy disk over - dest = currentscreen + 184 * 80 + 304 / 4; - src = (byte *) 0xac000 + 184 * 80 + 304 / 4; - for (y = 0; y < 16; y++) - { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - dest[3] = src[3]; - src += 80; - dest += 80; - } - - -// set write mode 0 - outp(GC_INDEX, GC_MODE); - outp(GC_INDEX + 1, inp(GC_INDEX + 1) & ~1); -#endif -} - -// erase disk icon -void I_EndRead(void) -{ -#if 0 - byte *src, *dest; - int y; - - if (!grmode) - return; - -// write through all planes - outp(SC_INDEX, SC_MAPMASK); - outp(SC_INDEX + 1, 15); -// set write mode 1 - outp(GC_INDEX, GC_MODE); - outp(GC_INDEX + 1, inp(GC_INDEX + 1) | 1); - - -// copy disk over - dest = currentscreen + 184 * 80 + 304 / 4; - src = (byte *) 0xac000 + 184 * 80 + 288 / 4; - for (y = 0; y < 16; y++) - { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - dest[3] = src[3]; - src += 80; - dest += 80; - } - -// set write mode 0 - outp(GC_INDEX, GC_MODE); - outp(GC_INDEX + 1, inp(GC_INDEX + 1) & ~1); -#endif -} - - - -/* -============= -= -= I_AllocLow -= -============= -*/ - -byte *I_AllocLow(int length) -{ - byte *mem; - - // DPMI call 100h allocates DOS memory - segread(&segregs); - regs.w.ax = 0x0100; // DPMI allocate DOS memory - regs.w.bx = (length + 15) / 16; - int386(DPMI_INT, ®s, ®s); -// segment = regs.w.ax; -// selector = regs.w.dx; - if (regs.w.cflag != 0) - I_Error("I_AllocLow: DOS alloc of %i failed, %i free", - length, regs.w.bx * 16); - - - mem = (void *) ((regs.x.eax & 0xFFFF) << 4); - - memset(mem, 0, length); - return mem; -} - -/* -============================================================================ - - NETWORKING - -============================================================================ -*/ - -/* // FUCKED LINES -typedef struct -{ - char priv[508]; - } doomdata_t; -*/// FUCKED LINES - -#define DOOMCOM_ID 0x12345678l - -/* // FUCKED LINES -typedef struct -{ - long id; - short intnum; // DOOM executes an int to execute commands - -// communication between DOOM and the driver - short command; // CMD_SEND or CMD_GET - short remotenode; // dest for send, set by get (-1 = no packet) - short datalength; // bytes in doomdata to be sent - -// info common to all nodes - short numnodes; // console is allways node 0 - short ticdup; // 1 = no duplication, 2-5 = dup for slow nets - short extratics; // 1 = send a backup tic in every packet - short deathmatch; // 1 = deathmatch - short savegame; // -1 = new game, 0-5 = load savegame - short episode; // 1-3 - short map; // 1-9 - short skill; // 1-5 - -// info specific to this node - short consoleplayer; - short numplayers; - short angleoffset; // 1 = left, 0 = center, -1 = right - short drone; // 1 = drone - -// packet data to be sent - doomdata_t data; - } doomcom_t; -*/// FUCKED LINES - -extern doomcom_t *doomcom; - -/* -==================== -= -= I_InitNetwork -= -==================== -*/ - -void I_InitNetwork(void) -{ - int i; - - i = M_CheckParm("-net"); - if (!i) - { - // - // single player game - // - doomcom = malloc(sizeof(*doomcom)); - memset(doomcom, 0, sizeof(*doomcom)); - netgame = false; - doomcom->id = DOOMCOM_ID; - doomcom->numplayers = doomcom->numnodes = 1; - doomcom->deathmatch = false; - doomcom->consoleplayer = 0; - doomcom->ticdup = 1; - doomcom->extratics = 0; - return; - } - - netgame = true; - doomcom = (doomcom_t *) atoi(myargv[i + 1]); -//DEBUG - doomcom->skill = startskill; - doomcom->episode = startepisode; - doomcom->map = startmap; - doomcom->deathmatch = deathmatch; - -} - -void I_NetCmd(void) -{ - if (!netgame) - I_Error("I_NetCmd when not in netgame"); - DPMIInt(doomcom->intnum); -} - -int i_Vector; -externdata_t *i_ExternData; -boolean useexterndriver; - -//========================================================================= -// -// I_CheckExternDriver -// -// Checks to see if a vector, and an address for an external driver -// have been passed. -//========================================================================= - -void I_CheckExternDriver(void) -{ - int i; - - if (!(i = M_CheckParm("-externdriver"))) - { - return; - } - i_ExternData = (externdata_t *) atoi(myargv[i + 1]); - i_Vector = i_ExternData->vector; - - useexterndriver = true; -} - -//========================================================================= -// -// I_ReadExternDriver -// -// calls the external interrupt, which should then update i_ExternDriver -//========================================================================= - -void I_ReadExternDriver(void) -{ - event_t ev; - - if (useexterndriver) - { - DPMIInt(i_Vector); - } -} diff --git a/src/heretic/i_sound.c b/src/heretic/i_sound.c deleted file mode 100644 index 97f736cf..00000000 --- a/src/heretic/i_sound.c +++ /dev/null @@ -1,426 +0,0 @@ -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2005-2014 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// - -// I_SOUND.C - -#include <stdio.h> -#include "doomdef.h" -#include "dmx.h" -#include "sounds.h" -#include "i_sound.h" -#include "v_video.h" - -/* -=============== -= -= I_StartupTimer -= -=============== -*/ - -int tsm_ID = -1; - -void I_StartupTimer(void) -{ -#ifndef NOTIMER - extern int I_TimerISR(void); - - tprintf("I_StartupTimer()\n", 0); - // installs master timer. Must be done before StartupTimer()! - TSM_Install(SND_TICRATE); - tsm_ID = TSM_NewService(I_TimerISR, 35, 255, 0); // max priority - if (tsm_ID == -1) - { - I_Error("Can't register 35 Hz timer w/ DMX library"); - } -#endif -} - -void I_ShutdownTimer(void) -{ - TSM_DelService(tsm_ID); - TSM_Remove(); -} - -/* - * - * SOUND HEADER & DATA - * - * - */ - -// sound information -#if 0 -const char *dnames[] = { "None", - "PC_Speaker", - "Adlib", - "Sound_Blaster", - "ProAudio_Spectrum16", - "Gravis_Ultrasound", - "MPU", - "AWE32" -}; -#endif - -const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', - 'M', 'M', 'S' -}; - -int snd_Channels; -int snd_DesiredMusicDevice, snd_DesiredSfxDevice; -int snd_MusicDevice, // current music card # (index to dmxCodes) - snd_SfxDevice, // current sfx card # (index to dmxCodes) - snd_MaxVolume, // maximum volume for sound - snd_MusicVolume; // maximum volume for music -int dmxCodes[NUM_SCARDS]; // the dmx code for a given card - -int snd_SBport, snd_SBirq, snd_SBdma; // sound blaster variables -int snd_Mport; // midi variables - -extern boolean snd_MusicAvail, // whether music is available - snd_SfxAvail; // whether sfx are available - -void I_PauseSong(int handle) -{ - MUS_PauseSong(handle); -} - -void I_ResumeSong(int handle) -{ - MUS_ResumeSong(handle); -} - -void I_SetMusicVolume(int volume) -{ - MUS_SetMasterVolume(volume * 8); -// snd_MusicVolume = volume; -} - -void I_SetSfxVolume(int volume) -{ - snd_MaxVolume = volume; // THROW AWAY? -} - -/* - * - * SONG API - * - */ - -int I_RegisterSong(void *data) -{ - int rc = MUS_RegisterSong(data); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_Reg() returned %d\n", rc); -#endif - return rc; -} - -void I_UnRegisterSong(int handle) -{ - int rc = MUS_UnregisterSong(handle); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_Unreg() returned %d\n", rc); -#endif -} - -int I_QrySongPlaying(int handle) -{ - int rc = MUS_QrySongPlaying(handle); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_QrySP() returned %d\n", rc); -#endif - return rc; -} - -// Stops a song. MUST be called before I_UnregisterSong(). - -void I_StopSong(int handle) -{ - int rc; - rc = MUS_StopSong(handle); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_StopSong() returned %d\n", rc); -#endif - // Fucking kluge pause - { - int s; - extern volatile int ticcount; - for (s = ticcount; ticcount - s < 10;); - } -} - -void I_PlaySong(int handle, boolean looping) -{ - int rc; - rc = MUS_ChainSong(handle, looping ? handle : -1); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_ChainSong() returned %d\n", rc); -#endif - rc = MUS_PlaySong(handle, snd_MusicVolume); -#ifdef SNDDEBUG - if (rc < 0) - printf("MUS_PlaySong() returned %d\n", rc); -#endif - -} - -/* - * - * SOUND FX API - * - */ - -// Gets lump nums of the named sound. Returns pointer which will be -// passed to I_StartSound() when you want to start an SFX. Must be -// sure to pass this to UngetSoundEffect() so that they can be -// freed! - - -int I_GetSfxLumpNum(sfxinfo_t * sound) -{ - char namebuf[9]; - - if (sound->name == 0) - return 0; - if (sound->link) - sound = sound->link; -// M_snprintf(namebuf, sizeof(namebuf), "d%c%s", -// snd_prefixen[snd_SfxDevice], sound->name); - return W_GetNumForName(sound->name); - -} - -int I_StartSound(int id, void *data, int vol, int sep, int pitch, - int priority) -{ -/* - // hacks out certain PC sounds - if (snd_SfxDevice == PC - && (data == S_sfx[sfx_posact].data - || data == S_sfx[sfx_bgact].data - || data == S_sfx[sfx_dmact].data - || data == S_sfx[sfx_dmpain].data - || data == S_sfx[sfx_popain].data - || data == S_sfx[sfx_sawidl].data)) return -1; - - else - */ - return SFX_PlayPatch(data, pitch, sep, vol, 0, 0); - -} - -void I_StopSound(int handle) -{ -// extern volatile long gDmaCount; -// long waittocount; - SFX_StopPatch(handle); -// waittocount = gDmaCount + 2; -// while (gDmaCount < waittocount) ; -} - -int I_SoundIsPlaying(int handle) -{ - return SFX_Playing(handle); -} - -void I_UpdateSoundParams(int handle, int vol, int sep, int pitch) -{ - SFX_SetOrigin(handle, pitch, sep, vol); -} - -/* - * - * SOUND STARTUP STUFF - * - * - */ - -// -// Why PC's Suck, Reason #8712 -// - -void I_sndArbitrateCards(void) -{ - char tmp[160]; - boolean gus, adlib, pc, sb, midi; - int i, rc, mputype, p, opltype, wait, dmxlump; - -// snd_MaxVolume = 127; - //Damn you, Dave Taylor! - - snd_MusicDevice = snd_DesiredMusicDevice; - snd_SfxDevice = snd_DesiredSfxDevice; - - // check command-line parameters- overrides config file - // - if (M_CheckParm("-nosound")) - snd_MusicDevice = snd_SfxDevice = snd_none; - if (M_CheckParm("-nosfx")) - snd_SfxDevice = snd_none; - if (M_CheckParm("-nomusic")) - snd_MusicDevice = snd_none; - - if (snd_MusicDevice > snd_MPU && snd_MusicDevice <= snd_MPU3) - snd_MusicDevice = snd_MPU; - if (snd_MusicDevice == snd_SB) - snd_MusicDevice = snd_Adlib; - if (snd_MusicDevice == snd_PAS) - snd_MusicDevice = snd_Adlib; - - // figure out what i've got to initialize - // - gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS; - sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB; - adlib = snd_MusicDevice == snd_Adlib; - pc = snd_SfxDevice == snd_PC; - midi = snd_MusicDevice == snd_MPU; - - // initialize whatever i've got - // - if (gus) - { - if (GF1_Detect()) - tprintf("Dude. The GUS ain't responding.\n", 1); - else - { - dmxlump = W_GetNumForName("dmxgus"); - GF1_SetMap(W_CacheLumpNum(dmxlump, PU_CACHE), - lumpinfo[dmxlump].size); - } - - } - if (sb) - { - if (debugmode) - { - M_snprintf(tmp, sizeof(tmp), "cfg p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - tprintf(tmp, 0); - } - if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0)) - { - M_snprintf(tmp, sizeof(tmp), - "SB isn't responding at p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - tprintf(tmp, 0); - } - else - SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma); - - if (debugmode) - { - M_snprintf(tmp, sizeof(tmp), "SB_Detect returned p=0x%x,i=%d,d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - tprintf(tmp, 0); - } - } - - if (adlib) - { - if (AL_Detect(&wait, 0)) - tprintf("Dude. The Adlib isn't responding.\n", 1); - else - AL_SetCard(wait, W_CacheLumpName("genmidi", PU_STATIC)); - } - - if (midi) - { - if (debugmode) - { - M_snprintf(tmp, sizeof(tmp), "cfg p=0x%x\n", snd_Mport); - tprintf(tmp, 0); - } - - if (MPU_Detect(&snd_Mport, &i)) - { - M_snprintf(tmp, sizeof(tmp), - "The MPU-401 isn't reponding @ p=0x%x.\n", snd_Mport); - tprintf(tmp, 0); - } - else - MPU_SetCard(snd_Mport); - } - -} - -// inits all sound stuff - -void I_StartupSound(void) -{ - char tmp[80]; - int rc, i; - - if (debugmode) - tprintf("I_StartupSound: Hope you hear a pop.\n", 1); - - // initialize dmxCodes[] - dmxCodes[0] = 0; - dmxCodes[snd_PC] = AHW_PC_SPEAKER; - dmxCodes[snd_Adlib] = AHW_ADLIB; - dmxCodes[snd_SB] = AHW_SOUND_BLASTER; - dmxCodes[snd_PAS] = AHW_MEDIA_VISION; - dmxCodes[snd_GUS] = AHW_ULTRA_SOUND; - dmxCodes[snd_MPU] = AHW_MPU_401; - dmxCodes[snd_AWE] = AHW_AWE32; - - // inits sound library timer stuff - I_StartupTimer(); - - // pick the sound cards i'm going to use - // - I_sndArbitrateCards(); - - if (debugmode) - { - M_snprintf(tmp, sizeof(tmp), " Music device #%d & dmxCode=%d", - snd_MusicDevice, dmxCodes[snd_MusicDevice]); - tprintf(tmp, 0); - M_snprintf(tmp, sizeof(tmp), " Sfx device #%d & dmxCode=%d\n", - snd_SfxDevice, dmxCodes[snd_SfxDevice]); - tprintf(tmp, 0); - } - - // inits DMX sound library - tprintf(" calling DMX_Init", 0); - rc = DMX_Init(SND_TICRATE, SND_MAXSONGS, dmxCodes[snd_MusicDevice], - dmxCodes[snd_SfxDevice]); - - if (debugmode) - { - M_snprintf(tmp, sizeof(tmp), " DMX_Init() returned %d", rc); - tprintf(tmp, 0); - } - -} - -// shuts down all sound stuff - -void I_ShutdownSound(void) -{ - DMX_DeInit(); - I_ShutdownTimer(); -} - -void I_SetChannels(int channels) -{ - WAV_PlayMode(channels, SND_SAMPLERATE); -} diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c index b0a8d6b7..4cd52a0d 100644 --- a/src/heretic/mn_menu.c +++ b/src/heretic/mn_menu.c @@ -16,6 +16,7 @@ // MN_menu.c +#include <stdlib.h> #include <ctype.h> #include "deh_str.h" diff --git a/src/heretic/p_saveg.c b/src/heretic/p_saveg.c index 3bd7c2b2..34e9e906 100644 --- a/src/heretic/p_saveg.c +++ b/src/heretic/p_saveg.c @@ -16,6 +16,8 @@ // P_tick.c +#include <stdlib.h> + #include "doomdef.h" #include "i_swap.h" #include "i_system.h" diff --git a/src/hexen/Makefile.am b/src/hexen/Makefile.am index b3953ce6..bd51c6e0 100644 --- a/src/hexen/Makefile.am +++ b/src/hexen/Makefile.am @@ -13,7 +13,6 @@ f_finale.c \ g_game.c \ h2def.h \ h2_main.c \ - i_header.h \ info.c info.h \ in_lude.c \ m_misc.c \ @@ -60,8 +59,4 @@ sv_save.c \ textdefs.h \ xddefs.h -EXTRA_DIST= \ -i_ibm.c \ -i_sound.c - libhexen_a_SOURCES=$(SOURCE_FILES) diff --git a/src/hexen/a_action.c b/src/hexen/a_action.c index c4c194e3..1923ff70 100644 --- a/src/hexen/a_action.c +++ b/src/hexen/a_action.c @@ -211,7 +211,7 @@ void A_PotteryCheck(mobj_t * actor) } else { - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -905,7 +905,7 @@ void A_Quake(mobj_t * actor) if (actor->args[1]-- > 0) { - for (playnum = 0; playnum < MAXPLAYERS; playnum++) + for (playnum = 0; playnum < maxplayers; playnum++) { player = &players[playnum]; if (!playeringame[playnum]) @@ -934,7 +934,7 @@ void A_Quake(mobj_t * actor) } else { - for (playnum = 0; playnum < MAXPLAYERS; playnum++) + for (playnum = 0; playnum < maxplayers; playnum++) { localQuakeHappening[playnum] = false; } diff --git a/src/hexen/am_map.c b/src/hexen/am_map.c index 2d082415..6a28b45c 100644 --- a/src/hexen/am_map.c +++ b/src/hexen/am_map.c @@ -292,7 +292,7 @@ void AM_initVariables(void) // find player to center on initially if (!playeringame[pnum = consoleplayer]) - for (pnum = 0; pnum < MAXPLAYERS; pnum++) + for (pnum = 0; pnum < maxplayers; pnum++) if (playeringame[pnum]) break; plr = &players[pnum]; @@ -1280,7 +1280,7 @@ void AM_drawPlayers(void) return; } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { their_color++; p = &players[i]; @@ -1418,12 +1418,12 @@ void AM_DrawDeathmatchStats(void) char textBuffer[80]; int yPosition; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { fragCount[i] = 0; order[i] = -1; } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -1431,14 +1431,14 @@ void AM_DrawDeathmatchStats(void) } else { - for (j = 0; j < MAXPLAYERS; j++) + for (j = 0; j < maxplayers; j++) { if (playeringame[j]) { fragCount[i] += players[i].frags[j]; } } - for (k = 0; k < MAXPLAYERS; k++) + for (k = 0; k < maxplayers; k++) { if (order[k] == -1) { @@ -1447,7 +1447,7 @@ void AM_DrawDeathmatchStats(void) } else if (fragCount[i] > fragCount[order[k]]) { - for (m = MAXPLAYERS - 1; m > k; m--) + for (m = maxplayers - 1; m > k; m--) { order[m] = order[m - 1]; } @@ -1458,7 +1458,7 @@ void AM_DrawDeathmatchStats(void) } } yPosition = 15; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[order[i]]) { diff --git a/src/hexen/ct_chat.c b/src/hexen/ct_chat.c index 4785f8b2..55934006 100644 --- a/src/hexen/ct_chat.c +++ b/src/hexen/ct_chat.c @@ -116,7 +116,7 @@ void CT_Init(void) tail = 0; chatmodeon = false; memset(ChatQueue, 0, QUEUESIZE); - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { chat_dest[i] = 0; msgptr[i] = 0; @@ -292,7 +292,7 @@ void CT_Ticker(void) char c; int numplayers; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -312,7 +312,7 @@ void CT_Ticker(void) else if (c == KEY_ENTER) { numplayers = 0; - for (j = 0; j < MAXPLAYERS; j++) + for (j = 0; j < maxplayers; j++) { numplayers += playeringame[j]; } diff --git a/src/hexen/d_net.c b/src/hexen/d_net.c index 5bd0eed0..bd0e8b21 100644 --- a/src/hexen/d_net.c +++ b/src/hexen/d_net.c @@ -76,7 +76,7 @@ static void RunTic(ticcmd_t *cmds, boolean *ingame) // Check for player quits. - for (i = 0; i < MAXPLAYERS; ++i) + for (i = 0; i < maxplayers; ++i) { if (!demoplayback && playeringame[i] && !ingame[i]) { @@ -120,7 +120,7 @@ static void LoadGameSettings(net_gamesettings_t *settings) respawnparm = settings->respawn_monsters; consoleplayer = settings->consoleplayer; - for (i=0; i<MAXPLAYERS; ++i) + for (i=0; i<maxplayers; ++i) { playeringame[i] = i < settings->num_players; PlayerClass[i] = settings->player_classes[i]; @@ -172,7 +172,7 @@ static void InitConnectData(net_connect_data_t *connect_data) connect_data->lowres_turn = false; connect_data->drone = false; - connect_data->max_players = MAXPLAYERS; + connect_data->max_players = maxplayers; //! // @category net diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index 3593ffe2..e0a7afac 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -639,7 +639,7 @@ void G_DoLoadLevel(void) levelstarttic = gametic; // for time calculation gamestate = GS_LEVEL; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; @@ -756,7 +756,7 @@ boolean G_Responder(event_t * ev) do { displayplayer++; - if (displayplayer == MAXPLAYERS) + if (displayplayer == maxplayers) { displayplayer = 0; } @@ -899,7 +899,7 @@ void G_Ticker(void) // // do player reborns if needed // - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) if (playeringame[i] && players[i].playerstate == PST_REBORN) G_DoReborn(i); @@ -963,7 +963,7 @@ void G_Ticker(void) //buf = gametic%BACKUPTICS; buf = (gametic / ticdup) % BACKUPTICS; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) if (playeringame[i]) { cmd = &players[i].cmd; @@ -993,7 +993,7 @@ void G_Ticker(void) // // check for special buttons // - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) if (playeringame[i]) { if (players[i].cmd.buttons & BT_SPECIAL) @@ -1335,7 +1335,7 @@ void G_DoReborn(int playernum) else { // Try to spawn at one of the other player start spots - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (G_CheckSpot(playernum, &playerstarts[RebornPosition][i])) { // Found an open start spot @@ -1471,6 +1471,13 @@ void G_SecretExitLevel (void) void G_Completed(int map, int position) { + if (gamemode == shareware && map > 4) + { + P_SetMessage(&players[consoleplayer], "ACCESS DENIED -- DEMO", true); + S_StartSound(NULL, SFX_CHAT); + return; + } + gameaction = ga_completed; LeaveMap = map; LeavePosition = position; @@ -1485,7 +1492,7 @@ void G_DoCompleted(void) { return; } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { @@ -1512,7 +1519,7 @@ void G_DoCompleted(void) { return; } - for(i = 0; i < MAXPLAYERS; i++) + for(i = 0; i < maxplayers; i++) { if(playeringame[i]) { @@ -1725,7 +1732,7 @@ void G_InitNew(skill_t skill, int episode, int map) } M_ClearRandom(); // Force players to be initialized upon first level load - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { players[i].playerstate = PST_REBORN; players[i].worldTimer = 0; @@ -1748,7 +1755,7 @@ void G_InitNew(skill_t skill, int episode, int map) // Give one null ticcmd_t //gametic = 0; //maketic = 1; - //for (i=0 ; i<MAXPLAYERS ; i++) + //for (i=0 ; i<maxplayers ; i++) // nettics[i] = 1; // one null event for this gametic //memset (localcmds,0,sizeof(localcmds)); //memset (netcmds,0,sizeof(netcmds)); @@ -1819,7 +1826,7 @@ void G_RecordDemo(skill_t skill, int numplayers, int episode, int map, *demo_p++ = episode; *demo_p++ = map; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { *demo_p++ = playeringame[i]; *demo_p++ = PlayerClass[i]; @@ -1855,7 +1862,7 @@ void G_DoPlayDemo(void) episode = *demo_p++; map = *demo_p++; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playeringame[i] = *demo_p++; PlayerClass[i] = *demo_p++; @@ -1890,7 +1897,7 @@ void G_TimeDemo(char *name) episode = *demo_p++; map = *demo_p++; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playeringame[i] = *demo_p++; PlayerClass[i] = *demo_p++; diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 9d92a65b..7084ceec 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -93,6 +93,7 @@ extern boolean askforquit; // PUBLIC DATA DEFINITIONS ------------------------------------------------- GameMode_t gamemode; +char *gamedescription; char *iwadfile; static char demolumpname[9]; // Demo lump to start playing. boolean nomonsters; // checkparm of -nomonsters @@ -112,6 +113,7 @@ boolean autostart; boolean advancedemo; FILE *debugfile; int UpdateState; +int maxplayers = MAXPLAYERS; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -253,6 +255,46 @@ static void D_AddFile(char *filename) W_AddFile(filename); } +// Find out what version of Hexen is playing. + +void D_IdentifyVersion(void) +{ + // The Hexen Shareware, ne 4 Level Demo Version, is missing the SKY1 lump + // and uses the SKY2 lump instead. Let's use this fact and the missing + // levels from MAP05 onward to identify it and set gamemode accordingly. + + if (W_CheckNumForName("SKY1") == -1 && + W_CheckNumForName("MAP05") == -1 ) + { + gamemode = shareware; + maxplayers = 4; + } +} + +// Set the gamedescription string. + +void D_SetGameDescription(void) +{ +/* + NB: The 4 Level Demo Version actually prints a four-lined banner + (and indeed waits for a keypress): + + Hexen: Beyond Heretic + + 4 Level Demo Version + Press any key to continue. +*/ + + if (gamemode == shareware) + { + gamedescription = "Hexen: 4 Level Demo Version"; + } + else + { + gamedescription = "Hexen"; + } +} + //========================================================================== // // H2_Main @@ -332,11 +374,13 @@ void D_DoomMain(void) D_AddFile(iwadfile); W_CheckCorrectIWAD(hexen); + D_IdentifyVersion(); + D_SetGameDescription(); AdjustForMacIWAD(); HandleArgs(); - I_PrintStartupBanner("Hexen"); + I_PrintStartupBanner(gamedescription); ST_Message("MN_Init: Init menu system.\n"); MN_Init(); @@ -664,7 +708,7 @@ void H2_GameLoop(void) M_snprintf(filename, sizeof(filename), "debug%i.txt", consoleplayer); debugfile = fopen(filename, "w"); } - I_SetWindowTitle("Hexen"); + I_SetWindowTitle(gamedescription); I_GraphicsCheckCommandLine(); I_SetGrabMouseCallback(D_GrabMouseCallback); I_InitGraphics(); diff --git a/src/hexen/h2def.h b/src/hexen/h2def.h index 43e7c91b..0658b7d5 100644 --- a/src/hexen/h2def.h +++ b/src/hexen/h2def.h @@ -655,6 +655,7 @@ extern int RebornPosition; #define MAX_PLAYER_STARTS 8 extern mapthing_t playerstarts[MAX_PLAYER_STARTS][MAXPLAYERS]; +extern int maxplayers; extern int mouseSensitivity; diff --git a/src/hexen/i_header.h b/src/hexen/i_header.h deleted file mode 100644 index 95a1532f..00000000 --- a/src/hexen/i_header.h +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2005-2014 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -#ifndef __I_HEADER_H__ -#define __I_HEADER_H__ - -#include "h2def.h" - -//-------- -//SOUND IO -//-------- -#define FREQ_LOW 0x40 -#define FREQ_NORM 0x80 -#define FREQ_HIGH 0xff - -void I_SetMasterVolume(int volume); - -void I_TurnOffSfx(void); -void I_TurnOnSfx(void); -void I_TurnOffMusic(void); -void I_TurnOnMusic(void); - -// MUSIC I/O -// - -int I_RegisterSong(void *songdata); -// called by anything that wants to register a song lump with the sound lib -// calls Paul's function of the similar name to register music only. -// note that the song data is the same for any sound card and is paul's -// MUS format. Returns a handle which will be passed to all other music -// functions. - -void I_UnregisterSong(int handle); -// called by anything which is finished with a song and no longer needs -// the sound library to be aware of it. All songs should be stopped -// before calling this, but it will double check and stop it if necessary. - -void I_LoopSong(int handle); -// called by anything that wishes to start music. -// plays a song, and when the song is done, starts playing it again in -// an endless loop. the start is faded in over three seconds. - -void I_FadeOutSong(int handle, int fotime); -// called by anything that wishes to stop music. -// fades out the song over <fotime> milliseconds. - -void I_StopSong(int handle); -// called by anything that wishes to stop music. -// stops a song abruptly. - -// SFX I/O -// - -void *I_GetSoundEffect(char *soundname); -// called by routines which wish to play a sound effect at some later -// time. Pass it the lump name of a sound effect WITHOUT the sfx -// prefix. This means the maximum name length is 7 letters/digits. -// The prefixes for different sound cards are 'S','M','A', and 'P'. -// They refer to the card type. The routine will cache in the -// appropriate sound effect when it is played. - -void I_UngetSoundEffect(void *soundset); -// called by routines which wish to no longer use the sounds at all -// frees up the associated structure. It stops any currently playing -// sound effects. - -void I_StartSound(channel_t * c, int vol, int sep, int pitch, int priority); -// Starts a sound in a particular sound channel - -void I_UpdateSoundParams(channel_t * c, int vol, int sep, int pitch); -// Updates the volume, separation, and pitch of a sound channel - -void I_StopSound(channel_t * c); -// Stops a sound channel - -int I_SoundIsPlaying(channel_t * c); -// called by S_*()'s to see if a channel is still playing. Returns 0 -// if no longer playing, 1 if playing. - -#endif diff --git a/src/hexen/i_ibm.c b/src/hexen/i_ibm.c deleted file mode 100644 index 82247ce8..00000000 --- a/src/hexen/i_ibm.c +++ /dev/null @@ -1,1837 +0,0 @@ -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2005-2014 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// - - -#include <dos.h> -#include <conio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <graph.h> -#include "h2def.h" -#include "i_system.h" -#include "m_argv.h" -#include "r_local.h" -#include "p_local.h" // for P_AproxDistance -#include "sounds.h" -#include "i_sound.h" -#include "st_start.h" -#include "dmx.h" -#include "dpmiapi.h" - -// Macros - -#define DPMI_INT 0x31 - -#define SEQ_ADDR 0x3C4 -#define SEQ_DATA 0x3C5 -#define REG_MAPMASK 0x02 - -#define MASK_PLANE0 0x01 -#define MASK_PLANE1 0x02 -#define MASK_PLANE2 0x04 -#define MASK_PLANE3 0x08 - -#define P0OFFSET 38400*0 -#define P1OFFSET 38400*1 -#define P2OFFSET 38400*2 -#define P3OFFSET 38400*3 - -#define VID_INT 0x10 -#define VB_SYNC {while(!(inp(0x3da)&8)); while(inp(0x3da)&8);} -#define BITPLANE(p) (outp(SEQ_ADDR,REG_MAPMASK),outp(SEQ_DATA,(p))) - -//#define NOKBD -//#define NOTIMER - -// Public Data - -int DisplayTicker = 0; - -// Code - -void main(int argc, char **argv) -{ - myargc = argc; - myargv = argv; - H2_Main(); -} - -void I_StartupNet(void); -void I_ShutdownNet(void); -void I_ReadExternDriver(void); - -typedef struct -{ - unsigned edi, esi, ebp, reserved, ebx, edx, ecx, eax; - unsigned short flags, es, ds, fs, gs, ip, cs, sp, ss; -} dpmiregs_t; - -extern dpmiregs_t dpmiregs; - -void I_ReadMouse(void); - -extern int usemouse, usejoystick; - -extern void **lumpcache; - -int i_Vector; -externdata_t *i_ExternData; -boolean useexterndriver; - -//========================================================================== -// -// I_UpdateCDMusic -// -// Updates playing time for current track, and restarts the track, if -// needed -// -//========================================================================== - -void I_UpdateCDMusic(void) -{ - extern boolean MenuActive; - - if (MusicPaused || i_CDMusicLength < 0 || (paused && !MenuActive)) - { // Non-looping song/song paused - return; - } - i_CDMusicLength -= gametic - oldTic; - oldTic = gametic; - if (i_CDMusicLength <= 0) - { - S_StartSong(gamemap, true); - } -} - -/* -============================================================================ - - CONSTANTS - -============================================================================ -*/ - -#define SC_INDEX 0x3C4 -#define SC_RESET 0 -#define SC_CLOCK 1 -#define SC_MAPMASK 2 -#define SC_CHARMAP 3 -#define SC_MEMMODE 4 - -#define CRTC_INDEX 0x3D4 -#define CRTC_H_TOTAL 0 -#define CRTC_H_DISPEND 1 -#define CRTC_H_BLANK 2 -#define CRTC_H_ENDBLANK 3 -#define CRTC_H_RETRACE 4 -#define CRTC_H_ENDRETRACE 5 -#define CRTC_V_TOTAL 6 -#define CRTC_OVERFLOW 7 -#define CRTC_ROWSCAN 8 -#define CRTC_MAXSCANLINE 9 -#define CRTC_CURSORSTART 10 -#define CRTC_CURSOREND 11 -#define CRTC_STARTHIGH 12 -#define CRTC_STARTLOW 13 -#define CRTC_CURSORHIGH 14 -#define CRTC_CURSORLOW 15 -#define CRTC_V_RETRACE 16 -#define CRTC_V_ENDRETRACE 17 -#define CRTC_V_DISPEND 18 -#define CRTC_OFFSET 19 -#define CRTC_UNDERLINE 20 -#define CRTC_V_BLANK 21 -#define CRTC_V_ENDBLANK 22 -#define CRTC_MODE 23 -#define CRTC_LINECOMPARE 24 - - -#define GC_INDEX 0x3CE -#define GC_SETRESET 0 -#define GC_ENABLESETRESET 1 -#define GC_COLORCOMPARE 2 -#define GC_DATAROTATE 3 -#define GC_READMAP 4 -#define GC_MODE 5 -#define GC_MISCELLANEOUS 6 -#define GC_COLORDONTCARE 7 -#define GC_BITMASK 8 - -#define ATR_INDEX 0x3c0 -#define ATR_MODE 16 -#define ATR_OVERSCAN 17 -#define ATR_COLORPLANEENABLE 18 -#define ATR_PELPAN 19 -#define ATR_COLORSELECT 20 - -#define STATUS_REGISTER_1 0x3da - -#define PEL_WRITE_ADR 0x3c8 -#define PEL_READ_ADR 0x3c7 -#define PEL_DATA 0x3c9 -#define PEL_MASK 0x3c6 - -// boolean grmode; - -//================================================== -// -// joystick vars -// -//================================================== - -boolean joystickpresent; -extern unsigned joystickx, joysticky; -boolean I_ReadJoystick(void); // returns false if not connected - - -//================================================== - -#define VBLCOUNTER 34000 // hardware tics to a frame - - -#define TIMERINT 8 -#define KEYBOARDINT 9 - -#define CRTCOFF (_inbyte(STATUS_REGISTER_1)&1) -#define CLI _disable() -#define STI _enable() - -#define _outbyte(x,y) (outp(x,y)) -#define _outhword(x,y) (outpw(x,y)) - -#define _inbyte(x) (inp(x)) -#define _inhword(x) (inpw(x)) - -#define MOUSEB1 1 -#define MOUSEB2 2 -#define MOUSEB3 4 - -boolean mousepresent; -//static int tsm_ID = -1; // tsm init flag - -//=============================== - -int ticcount; - -// REGS stuff used for int calls -union REGS regs; -struct SREGS segregs; - -boolean novideo; // if true, stay in text mode for debugging - -#define KBDQUESIZE 32 -byte keyboardque[KBDQUESIZE]; -int kbdtail, kbdhead; - -#define KEY_LSHIFT 0xfe - -#define KEY_INS (0x80+0x52) -#define KEY_DEL (0x80+0x53) -#define KEY_PGUP (0x80+0x49) -#define KEY_PGDN (0x80+0x51) -#define KEY_HOME (0x80+0x47) -#define KEY_END (0x80+0x4f) - -#define SC_RSHIFT 0x36 -#define SC_LSHIFT 0x2a - -byte scantokey[128] = { -// 0 1 2 3 4 5 6 7 -// 8 9 A B C D E F - 0, 27, '1', '2', '3', '4', '5', '6', - '7', '8', '9', '0', '-', '=', KEY_BACKSPACE, 9, // 0 - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', - 'o', 'p', '[', ']', 13, KEY_RCTRL, 'a', 's', // 1 - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - 39, '`', KEY_LSHIFT, 92, 'z', 'x', 'c', 'v', // 2 - 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT, '*', - KEY_RALT, ' ', 0, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, // 3 - KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, 0, 0, KEY_HOME, - KEY_UPARROW, KEY_PGUP, '-', KEY_LEFTARROW, '5', KEY_RIGHTARROW, '+', KEY_END, //4 - KEY_DOWNARROW, KEY_PGDN, KEY_INS, KEY_DEL, 0, 0, 0, KEY_F11, - KEY_F12, 0, 0, 0, 0, 0, 0, 0, // 5 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, // 6 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 // 7 -}; - -//========================================================================== - -//-------------------------------------------------------------------------- -// -// FUNC I_GetTime -// -// Returns time in 1/35th second tics. -// -//-------------------------------------------------------------------------- - -int I_GetTime(void) -{ -#ifdef NOTIMER - ticcount++; -#endif - return (ticcount); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ColorBorder -// -//-------------------------------------------------------------------------- - -/* -void I_ColorBorder(void) -{ - int i; - - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for(i = 0; i < 3; i++) - { - _outbyte(PEL_DATA, 63); - } -} -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_UnColorBorder -// -//-------------------------------------------------------------------------- - -/* -void I_UnColorBorder(void) -{ - int i; - - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for(i = 0; i < 3; i++) - { - _outbyte(PEL_DATA, 0); - } -} -*/ - -/* -============================================================================ - - USER INPUT - -============================================================================ -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_WaitVBL -// -//-------------------------------------------------------------------------- - -void I_WaitVBL(int vbls) -{ - int stat; - - if (novideo) - { - return; - } - while (vbls--) - { - do - { - stat = inp(STATUS_REGISTER_1); - if (stat & 8) - { - break; - } - } - while (1); - do - { - stat = inp(STATUS_REGISTER_1); - if ((stat & 8) == 0) - { - break; - } - } - while (1); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_SetPalette -// -// Palette source must use 8 bit RGB elements. -// -//-------------------------------------------------------------------------- - -void I_SetPalette(byte * palette) -{ - int i; - - if (novideo) - { - return; - } - I_WaitVBL(1); - _outbyte(PEL_WRITE_ADR, 0); - for (i = 0; i < 768; i++) - { - _outbyte(PEL_DATA, (gammatable[usegamma][*palette++]) >> 2); - } -} - -/* -============================================================================ - - GRAPHICS MODE - -============================================================================ -*/ - -byte *pcscreen, *destscreen, *destview; - - -/* -============== -= -= I_Update -= -============== -*/ - -int UpdateState; -extern int screenblocks; - -void I_Update(void) -{ - int i; - byte *dest; - int tics; - static int lasttic; - -// -// blit screen to video -// - if (DisplayTicker) - { - if (screenblocks > 9 || UpdateState & (I_FULLSCRN | I_MESSAGES)) - { - dest = (byte *) screen; - } - else - { - dest = (byte *) pcscreen; - } - tics = ticcount - lasttic; - lasttic = ticcount; - if (tics > 20) - { - tics = 20; - } - for (i = 0; i < tics; i++) - { - *dest = 0xff; - dest += 2; - } - for (i = tics; i < 20; i++) - { - *dest = 0x00; - dest += 2; - } - } - - //memset(pcscreen, 255, SCREENHEIGHT*SCREENWIDTH); - - if (UpdateState == I_NOUPDATE) - { - return; - } - if (UpdateState & I_FULLSCRN) - { - memcpy(pcscreen, screen, SCREENWIDTH * SCREENHEIGHT); - UpdateState = I_NOUPDATE; // clear out all draw types - } - if (UpdateState & I_FULLVIEW) - { - if (UpdateState & I_MESSAGES && screenblocks > 7) - { - for (i = 0; i < - (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) - { - memcpy(pcscreen + i, screen + i, SCREENWIDTH); - } - UpdateState &= ~(I_FULLVIEW | I_MESSAGES); - } - else - { - for (i = viewwindowy * SCREENWIDTH + viewwindowx; i < - (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) - { - memcpy(pcscreen + i, screen + i, viewwidth); - } - UpdateState &= ~I_FULLVIEW; - } - } - if (UpdateState & I_STATBAR) - { - memcpy(pcscreen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), - screen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), - SCREENWIDTH * SBARHEIGHT); - UpdateState &= ~I_STATBAR; - } - if (UpdateState & I_MESSAGES) - { - memcpy(pcscreen, screen, SCREENWIDTH * 28); - UpdateState &= ~I_MESSAGES; - } - - -// memcpy(pcscreen, screen, SCREENHEIGHT*SCREENWIDTH); -} - -//-------------------------------------------------------------------------- -// -// PROC I_InitGraphics -// -//-------------------------------------------------------------------------- - -void I_InitGraphics(void) -{ - if (novideo) - { - return; - } - //grmode = true; - regs.w.ax = 0x13; - int386(0x10, (const union REGS *) ®s, ®s); - pcscreen = destscreen = (byte *) 0xa0000; - I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ShutdownGraphics -// -//-------------------------------------------------------------------------- - -void I_ShutdownGraphics(void) -{ - byte mode; - - // don't reset mode if it didn't get set - mode = *(byte *) 0x449; - if (mode == 0x12 || mode == 0x13) - { - regs.w.ax = 3; - int386(0x10, ®s, ®s); // back to text mode - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_ReadScreen -// -// Reads the screen currently displayed into a linear buffer. -// -//-------------------------------------------------------------------------- - -/* -void I_ReadScreen(byte *scr) -{ - memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); -} -*/ - -//=========================================================================== - -/* -=================== -= -= I_StartTic -= -// called by D_DoomLoop -// called before processing each tic in a frame -// can call D_PostEvent -// asyncronous interrupt functions should maintain private ques that are -// read by the syncronous functions to be converted into events -=================== -*/ - -/* - OLD STARTTIC STUFF - -void I_StartTic (void) -{ - int k; - event_t ev; - - - I_ReadMouse (); - -// -// keyboard events -// - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; - -// if (k==14) -// I_Error ("exited"); - - kbdtail++; - - // extended keyboard shift key bullshit - if ( (k&0x7f)==KEY_RSHIFT ) - { - if ( keyboardque[(kbdtail-2)&(KBDQUESIZE-1)]==0xe0 ) - continue; - k &= 0x80; - k |= KEY_RSHIFT; - } - - if (k==0xe0) - continue; // special / pause keys - if (keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0xe1) - continue; // pause key bullshit - - if (k==0xc5 && keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0x9d) - { - ev.type = ev_keydown; - ev.data1 = KEY_PAUSE; - D_PostEvent (&ev); - continue; - } - - if (k&0x80) - ev.type = ev_keyup; - else - ev.type = ev_keydown; - k &= 0x7f; - - ev.data1 = k; - //ev.data1 = scantokey[k]; - - D_PostEvent (&ev); - } -} -*/ - -#define SC_UPARROW 0x48 -#define SC_DOWNARROW 0x50 -#define SC_LEFTARROW 0x4b -#define SC_RIGHTARROW 0x4d - -void I_StartTic(void) -{ - int k; - event_t ev; - - - I_ReadMouse(); - -// -// keyboard events -// - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; - kbdtail++; - - // extended keyboard shift key bullshit - if ((k & 0x7f) == SC_LSHIFT || (k & 0x7f) == SC_RSHIFT) - { - if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe0) - continue; - k &= 0x80; - k |= SC_RSHIFT; - } - - if (k == 0xe0) - continue; // special / pause keys - if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe1) - continue; // pause key bullshit - - if (k == 0xc5 - && keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0x9d) - { - ev.type = ev_keydown; - ev.data1 = KEY_PAUSE; - H2_PostEvent(&ev); - continue; - } - - if (k & 0x80) - ev.type = ev_keyup; - else - ev.type = ev_keydown; - k &= 0x7f; - switch (k) - { - case SC_UPARROW: - ev.data1 = KEY_UPARROW; - break; - case SC_DOWNARROW: - ev.data1 = KEY_DOWNARROW; - break; - case SC_LEFTARROW: - ev.data1 = KEY_LEFTARROW; - break; - case SC_RIGHTARROW: - ev.data1 = KEY_RIGHTARROW; - break; - default: - ev.data1 = scantokey[k]; - break; - } - H2_PostEvent(&ev); - } - -} - - -/* -void I_ReadKeys (void) -{ - int k; - - - while (1) - { - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; - kbdtail++; - printf ("0x%x\n",k); - if (k == 1) - I_Quit (); - } - } -} -*/ - -/* -=============== -= -= I_StartFrame -= -=============== -*/ - -void I_StartFrame(void) -{ - I_JoystickEvents(); - if (useexterndriver) - { - DPMIInt(i_Vector); - } -} - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - -/* -void I_ColorBlack (int r, int g, int b) -{ -_outbyte (PEL_WRITE_ADR,0); -_outbyte(PEL_DATA,r); -_outbyte(PEL_DATA,g); -_outbyte(PEL_DATA,b); -} -*/ - - -/* -================ -= -= I_TimerISR -= -================ -*/ - -int I_TimerISR(void) -{ - ticcount++; - return 0; -} - -/* -============================================================================ - - KEYBOARD - -============================================================================ -*/ - -void (__interrupt __far * oldkeyboardisr) () = NULL; - -int lastpress; - -/* -================ -= -= I_KeyboardISR -= -================ -*/ - -void __interrupt I_KeyboardISR(void) -{ -// Get the scan code - - keyboardque[kbdhead & (KBDQUESIZE - 1)] = lastpress = _inbyte(0x60); - kbdhead++; - -// acknowledge the interrupt - - _outbyte(0x20, 0x20); -} - - - -/* -=============== -= -= I_StartupKeyboard -= -=============== -*/ - -void I_StartupKeyboard(void) -{ -#ifndef NOKBD - oldkeyboardisr = _dos_getvect(KEYBOARDINT); - _dos_setvect(0x8000 | KEYBOARDINT, I_KeyboardISR); -#endif - -//I_ReadKeys (); -} - - -void I_ShutdownKeyboard(void) -{ - if (oldkeyboardisr) - _dos_setvect(KEYBOARDINT, oldkeyboardisr); - *(short *) 0x41c = *(short *) 0x41a; // clear bios key buffer -} - - - -/* -============================================================================ - - MOUSE - -============================================================================ -*/ - - -int I_ResetMouse(void) -{ - regs.w.ax = 0; // reset - int386(0x33, ®s, ®s); - return regs.w.ax; -} - - - -/* -================ -= -= StartupMouse -= -================ -*/ - -void I_StartupCyberMan(void); - -void I_StartupMouse(void) -{ - // - // General mouse detection - // - mousepresent = 0; - if (M_CheckParm("-nomouse") || !usemouse) - return; - - if (I_ResetMouse() != 0xffff) - { - ST_Message("Mouse: not present\n"); - return; - } - ST_Message("Mouse: detected\n"); - - mousepresent = 1; - - I_StartupCyberMan(); -} - - -/* -================ -= -= ShutdownMouse -= -================ -*/ - -void I_ShutdownMouse(void) -{ - if (!mousepresent) - return; - - I_ResetMouse(); -} - - -/* -================ -= -= I_ReadMouse -= -================ -*/ - -void I_ReadMouse(void) -{ - event_t ev; - -// -// mouse events -// - if (!mousepresent) - return; - - ev.type = ev_mouse; - - memset(&dpmiregs, 0, sizeof(dpmiregs)); - dpmiregs.eax = 3; // read buttons / position - DPMIInt(0x33); - ev.data1 = dpmiregs.ebx; - - dpmiregs.eax = 11; // read counters - DPMIInt(0x33); - ev.data2 = (short) dpmiregs.ecx; - ev.data3 = -(short) dpmiregs.edx; - - H2_PostEvent(&ev); -} - -/* -============================================================================ - - JOYSTICK - -============================================================================ -*/ - -int joyxl, joyxh, joyyl, joyyh; - -boolean WaitJoyButton(void) -{ - int oldbuttons, buttons; - - oldbuttons = 0; - do - { - I_WaitVBL(1); - buttons = ((inp(0x201) >> 4) & 1) ^ 1; - if (buttons != oldbuttons) - { - oldbuttons = buttons; - continue; - } - - if ((lastpress & 0x7f) == 1) - { - joystickpresent = false; - return false; - } - } - while (!buttons); - - do - { - I_WaitVBL(1); - buttons = ((inp(0x201) >> 4) & 1) ^ 1; - if (buttons != oldbuttons) - { - oldbuttons = buttons; - continue; - } - - if ((lastpress & 0x7f) == 1) - { - joystickpresent = false; - return false; - } - } - while (buttons); - - return true; -} - - - -/* -=============== -= -= I_StartupJoystick -= -=============== -*/ - -int basejoyx, basejoyy; - -void I_StartupJoystick(void) -{ - int centerx, centery; - - joystickpresent = 0; - if (M_CheckParm("-nojoy") || !usejoystick) - return; - - if (!I_ReadJoystick()) - { - joystickpresent = false; - ST_Message("joystick not found\n "); - return; - } - ST_Message("joystick found\n"); - joystickpresent = true; - - ST_RealMessage("CENTER the joystick and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - centerx = joystickx; - centery = joysticky; - - ST_RealMessage - ("\nPush the joystick to the UPPER LEFT corner and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - joyxl = (centerx + joystickx) / 2; - joyyl = (centerx + joysticky) / 2; - - ST_RealMessage - ("\nPush the joystick to the LOWER RIGHT corner and press button 1:"); - if (!WaitJoyButton()) - return; - I_ReadJoystick(); - joyxh = (centerx + joystickx) / 2; - joyyh = (centery + joysticky) / 2; - ST_RealMessage("\n"); -} - -/* -=============== -= -= I_JoystickEvents -= -=============== -*/ - -void I_JoystickEvents(void) -{ - event_t ev; - -// -// joystick events -// - if (!joystickpresent) - return; - - I_ReadJoystick(); - ev.type = ev_joystick; - ev.data1 = ((inp(0x201) >> 4) & 15) ^ 15; - - if (joystickx < joyxl) - ev.data2 = -1; - else if (joystickx > joyxh) - ev.data2 = 1; - else - ev.data2 = 0; - if (joysticky < joyyl) - ev.data3 = -1; - else if (joysticky > joyyh) - ev.data3 = 1; - else - ev.data3 = 0; - - H2_PostEvent(&ev); -} - - - -/* -============================================================================ - - DPMI STUFF - -============================================================================ -*/ - -#define REALSTACKSIZE 1024 - -dpmiregs_t dpmiregs; - -unsigned realstackseg; - -void I_DivException(void); -int I_SetDivException(void); - -/* -void DPMIFarCall (void) -{ - segread (&segregs); - regs.w.ax = 0x301; - regs.w.bx = 0; - regs.w.cx = 0; - regs.x.edi = (unsigned)&dpmiregs; - segregs.es = segregs.ds; - int386x( DPMI_INT, ®s, ®s, &segregs ); -} -*/ - -void DPMIInt(int i) -{ - dpmiregs.ss = realstackseg; - dpmiregs.sp = REALSTACKSIZE - 4; - - segread(&segregs); - regs.w.ax = 0x300; - regs.w.bx = i; - regs.w.cx = 0; - regs.x.edi = (unsigned) &dpmiregs; - segregs.es = segregs.ds; - int386x(DPMI_INT, ®s, ®s, &segregs); -} - - -/* -============== -= -= I_StartupDPMI -= -============== -*/ - -void I_StartupDPMI(void) -{ -// extern char __begtext; -// extern char ___argc; -// int n,d; - -// -// allocate a decent stack for real mode ISRs -// - realstackseg = (int) I_AllocLow(1024) >> 4; - -// -// lock the entire program down -// - -// _dpmi_lockregion (&__begtext, &___argc - &__begtext); - - -// -// catch divide by 0 exception -// -#if 0 - segread(&segregs); - regs.w.ax = 0x0203; // DPMI set processor exception handler vector - regs.w.bx = 0; // int 0 - regs.w.cx = segregs.cs; - regs.x.edx = (int) &I_DivException; - printf("%x : %x\n", regs.w.cx, regs.x.edx); - int386(DPMI_INT, ®s, ®s); -#endif - -#if 0 - n = I_SetDivException(); - printf("return: %i\n", n); - n = 100; - d = 0; - printf("100 / 0 = %i\n", n / d); - - exit(1); -#endif -} - - - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - -void (__interrupt __far * oldtimerisr) (); - - -/* -void IO_ColorBlack (int r, int g, int b) -{ -_outbyte (PEL_WRITE_ADR,0); -_outbyte(PEL_DATA,r); -_outbyte(PEL_DATA,g); -_outbyte(PEL_DATA,b); -} -*/ - - -/* -================ -= -= IO_TimerISR -= -================ -*/ - -//void __interrupt IO_TimerISR (void) - -void __interrupt __far IO_TimerISR(void) -{ - ticcount++; - _outbyte(0x20, 0x20); // Ack the interrupt -} - -/* -===================== -= -= IO_SetTimer0 -= -= Sets system timer 0 to the specified speed -= -===================== -*/ - -void IO_SetTimer0(int speed) -{ - if (speed > 0 && speed < 150) - I_Error("INT_SetTimer0: %i is a bad value", speed); - - _outbyte(0x43, 0x36); // Change timer 0 - _outbyte(0x40, speed); - _outbyte(0x40, speed >> 8); -} - - - -/* -=============== -= -= IO_StartupTimer -= -=============== -*/ - -/* -void IO_StartupTimer (void) -{ - oldtimerisr = _dos_getvect(TIMERINT); - - _dos_setvect (0x8000 | TIMERINT, IO_TimerISR); - IO_SetTimer0 (VBLCOUNTER); -} -*/ - -void IO_ShutdownTimer(void) -{ - if (oldtimerisr) - { - IO_SetTimer0(0); // back to 18.4 ips - _dos_setvect(TIMERINT, oldtimerisr); - } -} - -//=========================================================================== - - -/* -=============== -= -= I_Init -= -= hook interrupts and set graphics mode -= -=============== -*/ - -void I_Init(void) -{ - extern void I_StartupTimer(void); - - novideo = M_CheckParm("novideo"); - ST_Message(" I_StartupDPMI\n"); - I_StartupDPMI(); - ST_Message(" I_StartupMouse "); - I_StartupMouse(); -// tprintf("I_StartupJoystick ",1); -// I_StartupJoystick(); -// tprintf("I_StartupKeyboard ",1); -// I_StartupKeyboard(); - ST_Message(" S_Init... "); - S_Init(); - //IO_StartupTimer(); - S_Start(); -} - - -/* -=============== -= -= I_Shutdown -= -= return to default system state -= -=============== -*/ - -void I_Shutdown(void) -{ - I_ShutdownGraphics(); - IO_ShutdownTimer(); - S_ShutDown(); - I_ShutdownMouse(); - I_ShutdownKeyboard(); - - IO_SetTimer0(0); -} - - -/* -================ -= -= I_Error -= -================ -*/ - -void I_Error(char *error, ...) -{ - union REGS regs; - - va_list argptr; - - D_QuitNetGame(); - I_Shutdown(); - va_start(argptr, error); - regs.x.eax = 0x3; - int386(0x10, ®s, ®s); - vprintf(error, argptr); - va_end(argptr); - printf("\n"); - exit(1); -} - -//-------------------------------------------------------------------------- -// -// I_Quit -// -// Shuts down net game, saves defaults, prints the exit text message, -// goes to text mode, and exits. -// -//-------------------------------------------------------------------------- - -void I_Quit(void) -{ - D_QuitNetGame(); - M_SaveDefaults(); - I_Shutdown(); - -// scr = (byte *)W_CacheLumpName("ENDTEXT", PU_CACHE); -/* - memcpy((void *)0xb8000, scr, 80*25*2); - regs.w.ax = 0x0200; - regs.h.bh = 0; - regs.h.dl = 0; - regs.h.dh = 23; - int386(0x10, (const union REGS *)®s, ®s); // Set text pos - _settextposition(24, 1); -*/ - printf("\nHexen: Beyond Heretic\n"); - exit(0); -} - -/* -=============== -= -= I_ZoneBase -= -=============== -*/ - -byte *I_ZoneBase(int *size) -{ - int meminfo[32]; - int heap; - byte *ptr; - - memset(meminfo, 0, sizeof(meminfo)); - segread(&segregs); - segregs.es = segregs.ds; - regs.w.ax = 0x500; // get memory info - regs.x.edi = (int) &meminfo; - int386x(0x31, ®s, ®s, &segregs); - - heap = meminfo[0]; - ST_Message(" DPMI memory: 0x%x, ", heap); - ST_Message("Maxzone: 0x%x\n", maxzone); - - do - { - heap -= 0x10000; // leave 64k alone - if (heap > maxzone) - heap = maxzone; - ptr = malloc(heap); - } - while (!ptr); - - ST_Message(" 0x%x allocated for zone, ", heap); - ST_Message("ZoneBase: 0x%X\n", (int) ptr); - - if (heap < 0x180000) - I_Error(" Insufficient DPMI memory!"); -#if 0 - regs.w.ax = 0x501; // allocate linear block - regs.w.bx = heap >> 16; - regs.w.cx = heap & 0xffff; - int386(0x31, ®s, ®s); - if (regs.w.cflag) - I_Error(" Couldn't allocate DPMI memory!"); - - block = (regs.w.si << 16) + regs.w.di; -#endif - - *size = heap; - return ptr; -} - -/* -============= -= -= I_AllocLow -= -============= -*/ - -byte *I_AllocLow(int length) -{ - byte *mem; - - // DPMI call 100h allocates DOS memory - segread(&segregs); - regs.w.ax = 0x0100; // DPMI allocate DOS memory - regs.w.bx = (length + 15) / 16; - int386(DPMI_INT, ®s, ®s); -// segment = regs.w.ax; -// selector = regs.w.dx; - if (regs.w.cflag != 0) - I_Error("I_AllocLow: DOS alloc of %i failed, %i free", - length, regs.w.bx * 16); - - - mem = (void *) ((regs.x.eax & 0xFFFF) << 4); - - memset(mem, 0, length); - return mem; -} - -/* -============================================================================ - - NETWORKING - -============================================================================ -*/ - -/* // FUCKED LINES -typedef struct -{ - char priv[508]; - } doomdata_t; -*/// FUCKED LINES - -#define DOOMCOM_ID 0x12345678l - -/* // FUCKED LINES -typedef struct -{ - long id; - short intnum; // DOOM executes an int to execute commands - -// communication between DOOM and the driver - short command; // CMD_SEND or CMD_GET - short remotenode; // dest for send, set by get (-1 = no packet) - short datalength; // bytes in doomdata to be sent - -// info common to all nodes - short numnodes; // console is allways node 0 - short ticdup; // 1 = no duplication, 2-5 = dup for slow nets - short extratics; // 1 = send a backup tic in every packet - short deathmatch; // 1 = deathmatch - short savegame; // -1 = new game, 0-5 = load savegame - short episode; // 1-3 - short map; // 1-9 - short skill; // 1-5 - -// info specific to this node - short consoleplayer; - short numplayers; - short angleoffset; // 1 = left, 0 = center, -1 = right - short drone; // 1 = drone - -// packet data to be sent - doomdata_t data; - } doomcom_t; -*/// FUCKED LINES - -extern doomcom_t *doomcom; - -/* -==================== -= -= I_InitNetwork -= -==================== -*/ - -void I_InitNetwork(void) -{ - int i; - - i = M_CheckParm("-net"); - if (!i) - { - // - // single player game - // - doomcom = malloc(sizeof(*doomcom)); - memset(doomcom, 0, sizeof(*doomcom)); - netgame = false; - doomcom->id = DOOMCOM_ID; - doomcom->numplayers = doomcom->numnodes = 1; - doomcom->deathmatch = false; - doomcom->consoleplayer = 0; - doomcom->ticdup = 1; - doomcom->extratics = 0; - return; - } - - netgame = true; - doomcom = (doomcom_t *) atoi(myargv[i + 1]); -//DEBUG - doomcom->skill = startskill; - doomcom->episode = startepisode; - doomcom->map = startmap; - doomcom->deathmatch = deathmatch; - -} - -void I_NetCmd(void) -{ - if (!netgame) - I_Error("I_NetCmd when not in netgame"); - DPMIInt(doomcom->intnum); -} - -//========================================================================= -// -// I_CheckExternDriver -// -// Checks to see if a vector, and an address for an external driver -// have been passed. -//========================================================================= - -void I_CheckExternDriver(void) -{ - int i; - - if (!(i = M_CheckParm("-externdriver"))) - { - return; - } - i_ExternData = (externdata_t *) atoi(myargv[i + 1]); - i_Vector = i_ExternData->vector; - - useexterndriver = true; -} - -//========================================================================= -//========================================================================= -// Hi-Res (mode 12) stuff -//========================================================================= -//========================================================================= - - -//========================================================================== -// -// SetVideoModeHR - Set video mode to 640x480x16 -// -//========================================================================== - - -void SetVideoModeHR(void) -{ - union REGS regs; - regs.x.eax = 0x12; - int386(VID_INT, ®s, ®s); -} - - -//========================================================================== -// -// ClearScreenHR - Clear the screen to color 0 -// -//========================================================================== - -void ClearScreenHR(void) -{ - BITPLANE(MASK_PLANE0 | MASK_PLANE1 | MASK_PLANE2 | MASK_PLANE3); - memset((char *) 0xa0000, 0, 38400); -} - - -//========================================================================== -// -// SlamHR - copy 4-plane buffer to screen -// -//========================================================================== - -void SlamHR(char *buffer) -{ - BITPLANE(MASK_PLANE0); - memcpy((char *) 0xA0000, buffer + P0OFFSET, 38400); - BITPLANE(MASK_PLANE1); - memcpy((char *) 0xA0000, buffer + P1OFFSET, 38400); - BITPLANE(MASK_PLANE2); - memcpy((char *) 0xA0000, buffer + P2OFFSET, 38400); - BITPLANE(MASK_PLANE3); - memcpy((char *) 0xA0000, buffer + P3OFFSET, 38400); -} - - -//========================================================================== -// -// SlamHR - copy 4-plane buffer to screen -// -// X and Width should be a multiple of 8 -// src should be 4 planes of block size, back to back -//========================================================================== - -void SlamBlockHR(int x, int y, int w, int h, char *src) -{ - int srcwid = w >> 3; - char *dest = ((char *) 0xA0000) + (y * (640 / 8)) + (x >> 3); - char *dst; - int i; - - VB_SYNC; - - BITPLANE(MASK_PLANE0); - dst = dest; - for (i = 0; i < h; i++) - { - memcpy(dst, src, srcwid); - dst += 640 / 8; - src += srcwid; - } - BITPLANE(MASK_PLANE1); - dst = dest; - for (i = 0; i < h; i++) - { - memcpy(dst, src, srcwid); - dst += 640 / 8; - src += srcwid; - } - BITPLANE(MASK_PLANE2); - dst = dest; - for (i = 0; i < h; i++) - { - memcpy(dst, src, srcwid); - dst += 640 / 8; - src += srcwid; - } - BITPLANE(MASK_PLANE3); - dst = dest; - for (i = 0; i < h; i++) - { - memcpy(dst, src, srcwid); - dst += 640 / 8; - src += srcwid; - } -} - -//========================================================================== -// -// InitPaletteHR -// -//========================================================================== - -void InitPaletteHR(void) -{ - int i; - union REGS regs; - - // Set palette registers to point into color registers - for (i = 0; i < 16; i++) - { - regs.x.eax = (0x10 << 8) | 0x00; - regs.x.ebx = (i << 8) | i; - int386(VID_INT, ®s, ®s); - } - -} - - -//========================================================================== -// -// SetPaletteHR - Set the HR palette -// -//========================================================================== - -void SetPaletteHR(byte * palette) -{ - int i; - VB_SYNC; - outp(PEL_WRITE_ADR, 0); - - for (i = 0; i < 16 * 3; i++) - { - outp(PEL_DATA, (*palette++)); - } -} - - -//========================================================================== -// -// GetPaletteHR - Get the HR palette -// -//========================================================================== - -void GetPaletteHR(byte * palette) -{ - int i; - outp(PEL_READ_ADR, 0); - for (i = 0; i < 16 * 3; i++) - { - *palette++ = inp(PEL_DATA); - } -} - - -//========================================================================== -// -// FadeToPaletteHR -// -//========================================================================== - -void FadeToPaletteHR(byte * palette) -{ - int i, j; - int steps = 140; // two-seconds - byte basep[16 * 3]; - byte work[16 * 3]; - int delta; - - GetPaletteHR(basep); - for (i = 0; i < steps; i++) - { - for (j = 0; j < 16 * 3; j++) - { - delta = palette[j] - basep[j]; - work[j] = basep[j] + delta * i / steps; - } - SetPaletteHR(work); - } - SetPaletteHR(palette); -} - - -//========================================================================== -// -// FadeToBlackHR - Fades the palette out to black -// -//========================================================================== - -/* -void FadeToBlackHR(void) -{ - char work[16*3]; - char base[16*3]; - int i,j,steps=70; - - GetPaletteHR(base); - for (i=0; i<steps; i++) - { - for (j=0; j<16*3; j++) - { - work[j] = base[j]-(base[j]*i/steps); - } - VB_SYNC; - SetPaletteHR(work); - } - memset(work,0,16*3); - SetPaletteHR(work); -} -*/ - -//========================================================================== -// -// BlackPaletteHR - Instantly blacks out the palette -// -//========================================================================== - -void BlackPaletteHR(void) -{ - char blackpal[16 * 3]; - - memset(blackpal, 0, 16 * 3); - SetPaletteHR(blackpal); -} - -//========================================================================== -// -// -// I_StartupReadKeys -// -// -//========================================================================== - -void I_StartupReadKeys(void) -{ - int k; - - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; - kbdtail++; - if (k == 1) - I_Quit(); - } -} diff --git a/src/hexen/i_sound.c b/src/hexen/i_sound.c deleted file mode 100644 index e6313bc0..00000000 --- a/src/hexen/i_sound.c +++ /dev/null @@ -1,402 +0,0 @@ -// -// Copyright(C) 1993-1996 Id Software, Inc. -// Copyright(C) 1993-2008 Raven Software -// Copyright(C) 2005-2014 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// - -// I_SOUND.C - -#include <stdio.h> -#include "h2def.h" -#include "i_system.h" -#include "m_argv.h" -#include "dmx.h" -#include "sounds.h" -#include "i_sound.h" - -/* -=============== -= -= I_StartupTimer -= -=============== -*/ - -int tsm_ID = -1; - -void I_StartupTimer(void) -{ -#ifndef NOTIMER - extern int I_TimerISR(void); - - ST_Message(" I_StartupTimer()\n"); - // installs master timer. Must be done before StartupTimer()! - TSM_Install(SND_TICRATE); - tsm_ID = TSM_NewService(I_TimerISR, 35, 255, 0); // max priority - if (tsm_ID == -1) - { - I_Error("Can't register 35 Hz timer w/ DMX library"); - } -#endif -} - -void I_ShutdownTimer(void) -{ - TSM_DelService(tsm_ID); - TSM_Remove(); -} - -/* - * - * SOUND HEADER & DATA - * - * - */ - -// sound information -#if 0 -const char *dnames[] = { "None", - "PC_Speaker", - "Adlib", - "Sound_Blaster", - "ProAudio_Spectrum16", - "Gravis_Ultrasound", - "MPU", - "AWE32" -}; -#endif - -const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', - 'M', 'M', 'S' -}; - -int snd_Channels; -int snd_DesiredMusicDevice, snd_DesiredSfxDevice; -int snd_MusicDevice, // current music card # (index to dmxCodes) - snd_SfxDevice, // current sfx card # (index to dmxCodes) - snd_MaxVolume, // maximum volume for sound - snd_MusicVolume; // maximum volume for music -int dmxCodes[NUM_SCARDS]; // the dmx code for a given card - -int snd_SBport, snd_SBirq, snd_SBdma; // sound blaster variables -int snd_Mport; // midi variables - -extern boolean snd_MusicAvail, // whether music is available - snd_SfxAvail; // whether sfx are available - -void I_PauseSong(int handle) -{ - MUS_PauseSong(handle); -} - -void I_ResumeSong(int handle) -{ - MUS_ResumeSong(handle); -} - -void I_SetMusicVolume(int volume) -{ - MUS_SetMasterVolume(volume * 8); -// snd_MusicVolume = volume; -} - -void I_SetSfxVolume(int volume) -{ - snd_MaxVolume = volume; // THROW AWAY? -} - -/* - * - * SONG API - * - */ - -int I_RegisterSong(void *data) -{ - int rc = MUS_RegisterSong(data); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_Reg() returned %d\n", rc); -#endif - return rc; -} - -void I_UnRegisterSong(int handle) -{ - int rc = MUS_UnregisterSong(handle); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_Unreg() returned %d\n", rc); -#endif -} - -int I_QrySongPlaying(int handle) -{ - int rc = MUS_QrySongPlaying(handle); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_QrySP() returned %d\n", rc); -#endif - return rc; -} - -// Stops a song. MUST be called before I_UnregisterSong(). - -void I_StopSong(int handle) -{ - int rc; - rc = MUS_StopSong(handle); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_StopSong() returned %d\n", rc); -#endif -/* - // Fucking kluge pause - { - int s; - extern volatile int ticcount; - for (s=ticcount ; ticcount - s < 10 ; ); - } -*/ -} - -void I_PlaySong(int handle, boolean looping) -{ - int rc; - rc = MUS_ChainSong(handle, looping ? handle : -1); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_ChainSong() returned %d\n", rc); -#endif - rc = MUS_PlaySong(handle, snd_MusicVolume); -#ifdef SNDDEBUG - if (rc < 0) - ST_Message(" MUS_PlaySong() returned %d\n", rc); -#endif - -} - -/* - * - * SOUND FX API - * - */ - -// Gets lump nums of the named sound. Returns pointer which will be -// passed to I_StartSound() when you want to start an SFX. Must be -// sure to pass this to UngetSoundEffect() so that they can be -// freed! - - -int I_GetSfxLumpNum(sfxinfo_t * sound) -{ - return W_GetNumForName(sound->lumpname); - -} - -int I_StartSound(int id, void *data, int vol, int sep, int pitch, - int priority) -{ - return SFX_PlayPatch(data, pitch, sep, vol, 0, 0); -} - -void I_StopSound(int handle) -{ -// extern volatile long gDmaCount; -// long waittocount; - SFX_StopPatch(handle); -// waittocount = gDmaCount + 2; -// while (gDmaCount < waittocount) ; -} - -int I_SoundIsPlaying(int handle) -{ - return SFX_Playing(handle); -} - -void I_UpdateSoundParams(int handle, int vol, int sep, int pitch) -{ - SFX_SetOrigin(handle, pitch, sep, vol); -} - -/* - * - * SOUND STARTUP STUFF - * - * - */ - -// -// Why PC's Suck, Reason #8712 -// - -void I_sndArbitrateCards(void) -{ - char tmp[160]; - boolean gus, adlib, pc, sb, midi; - int i, rc, mputype, p, opltype, wait, dmxlump; - - snd_MusicDevice = snd_DesiredMusicDevice; - snd_SfxDevice = snd_DesiredSfxDevice; - - // check command-line parameters- overrides config file - // - if (M_CheckParm("-nosound")) - snd_MusicDevice = snd_SfxDevice = snd_none; - if (M_CheckParm("-nosfx")) - snd_SfxDevice = snd_none; - if (M_CheckParm("-nomusic")) - snd_MusicDevice = snd_none; - - if (snd_MusicDevice > snd_MPU && snd_MusicDevice <= snd_MPU3) - snd_MusicDevice = snd_MPU; - if (snd_MusicDevice == snd_SB) - snd_MusicDevice = snd_Adlib; - if (snd_MusicDevice == snd_PAS) - snd_MusicDevice = snd_Adlib; - - // figure out what i've got to initialize - // - gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS; - sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB; - adlib = snd_MusicDevice == snd_Adlib; - pc = snd_SfxDevice == snd_PC; - midi = snd_MusicDevice == snd_MPU; - - // initialize whatever i've got - // - if (gus) - { - if (GF1_Detect()) - ST_Message(" Dude. The GUS ain't responding.\n"); - else - { - dmxlump = W_GetNumForName("dmxgus"); - GF1_SetMap(W_CacheLumpNum(dmxlump, PU_CACHE), - lumpinfo[dmxlump].size); - } - - } - if (sb) - { - if (debugmode) - { - ST_Message(" Sound cfg p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - } - if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0)) - { - ST_Message(" SB isn't responding at p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - } - else - SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma); - - if (debugmode) - { - ST_Message(" SB_Detect returned p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); - } - } - - if (adlib) - { - if (AL_Detect(&wait, 0)) - { - ST_Message(" Dude. The Adlib isn't responding.\n"); - } - else - { - AL_SetCard(wait, W_CacheLumpName("genmidi", PU_STATIC)); - } - } - - if (midi) - { - if (debugmode) - { - ST_Message(" cfg p=0x%x\n", snd_Mport); - } - - if (MPU_Detect(&snd_Mport, &i)) - { - ST_Message(" The MPU-401 isn't reponding @ p=0x%x.\n", - snd_Mport); - } - else - MPU_SetCard(snd_Mport); - } - -} - -// inits all sound stuff - -void I_StartupSound(void) -{ - int rc, i; - - if (debugmode) - ST_Message("I_StartupSound: Hope you hear a pop.\n"); - - // initialize dmxCodes[] - dmxCodes[0] = 0; - dmxCodes[snd_PC] = AHW_PC_SPEAKER; - dmxCodes[snd_Adlib] = AHW_ADLIB; - dmxCodes[snd_SB] = AHW_SOUND_BLASTER; - dmxCodes[snd_PAS] = AHW_MEDIA_VISION; - dmxCodes[snd_GUS] = AHW_ULTRA_SOUND; - dmxCodes[snd_MPU] = AHW_MPU_401; - dmxCodes[snd_MPU2] = AHW_MPU_401; - dmxCodes[snd_MPU3] = AHW_MPU_401; - dmxCodes[snd_AWE] = AHW_AWE32; - dmxCodes[snd_CDMUSIC] = 0; - - // inits sound library timer stuff - I_StartupTimer(); - - // pick the sound cards i'm going to use - // - I_sndArbitrateCards(); - - if (debugmode) - { - ST_Message(" Music device #%d & dmxCode=%d,", snd_MusicDevice, - dmxCodes[snd_MusicDevice]); - ST_Message(" Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, - dmxCodes[snd_SfxDevice]); - } - - // inits DMX sound library - ST_Message(" Calling DMX_Init..."); - rc = DMX_Init(SND_TICRATE, SND_MAXSONGS, dmxCodes[snd_MusicDevice], - dmxCodes[snd_SfxDevice]); - - if (debugmode) - { - ST_Message(" DMX_Init() returned %d\n", rc); - } - -} - -// shuts down all sound stuff - -void I_ShutdownSound(void) -{ - DMX_DeInit(); - I_ShutdownTimer(); -} - -void I_SetChannels(int channels) -{ - WAV_PlayMode(channels, SND_SAMPLERATE); -} diff --git a/src/hexen/in_lude.c b/src/hexen/in_lude.c index daabf497..7b137006 100644 --- a/src/hexen/in_lude.c +++ b/src/hexen/in_lude.c @@ -106,7 +106,7 @@ void IN_Start(void) skipintermission = false; intertime = 0; AM_Stop(); - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { players[i].messageTics = 0; players[i].message[0] = 0; @@ -208,13 +208,13 @@ static void InitStats(void) posnum = 0; playercount = 0; slaughtercount = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { totalFrags[i] = 0; if (playeringame[i]) { playercount++; - for (j = 0; j < MAXPLAYERS; j++) + for (j = 0; j < maxplayers; j++) { if (playeringame[j]) { @@ -338,7 +338,7 @@ static void CheckForSkip(void) player_t *player; static boolean triedToSkip; - for (i = 0, player = players; i < MAXPLAYERS; i++, player++) + for (i = 0, player = players; i < maxplayers; i++, player++) { if (playeringame[i]) { @@ -478,10 +478,10 @@ static void DrDeathTally(void) S_StartSound(NULL, SFX_PLATFORM_STOP); } y = yPos >> FRACBITS; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { xPos = xStart; - for (j = 0; j < MAXPLAYERS; j++, xPos += xDelta) + for (j = 0; j < maxplayers; j++, xPos += xDelta) { x = xPos >> FRACBITS; bold = (i == consoleplayer || j == consoleplayer); diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index ff573317..15170279 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -1190,11 +1190,13 @@ boolean MN_Responder(event_t * event) if (InfoType) { + /* The 4-Level Demo Version also has 3 Info pages if (gamemode == shareware) { InfoType = (InfoType + 1) % 5; } else + */ { InfoType = (InfoType + 1) % 4; } diff --git a/src/hexen/p_acs.c b/src/hexen/p_acs.c index b9fd8f08..b7a63fe9 100644 --- a/src/hexen/p_acs.c +++ b/src/hexen/p_acs.c @@ -1681,7 +1681,7 @@ static int CmdEndPrintBold(void) { int i; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { @@ -1722,7 +1722,7 @@ static int CmdPlayerCount(void) int count; count = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { count += playeringame[i]; } diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c index 18cc79eb..dc2c9fe5 100644 --- a/src/hexen/p_enemy.c +++ b/src/hexen/p_enemy.c @@ -546,8 +546,8 @@ boolean P_LookForPlayers(mobj_t * actor, boolean allaround) // stop = (actor->lastlook - 1) & 3; // for (;; actor->lastlook = (actor->lastlook + 1) & 3) - stop = (actor->lastlook + MAXPLAYERS - 1) % MAXPLAYERS; - for (;; actor->lastlook = (actor->lastlook + 1) % MAXPLAYERS) + stop = (actor->lastlook + maxplayers - 1) % maxplayers; + for (;; actor->lastlook = (actor->lastlook + 1) % maxplayers) { if (!playeringame[actor->lastlook]) continue; @@ -1179,7 +1179,7 @@ void A_MinotaurLook(mobj_t * actor) actor->target = NULL; if (deathmatch) // Quick search for players { - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) continue; diff --git a/src/hexen/p_inter.c b/src/hexen/p_inter.c index 587614ff..4f1ecda8 100644 --- a/src/hexen/p_inter.c +++ b/src/hexen/p_inter.c @@ -747,6 +747,12 @@ static void TryPickupArtifact(player_t * player, artitype_t artifactType, TXT_ARTIPUZZGEAR }; + if (gamemode == shareware) + { + artifactMessages[arti_blastradius] = TXT_ARTITELEPORT; + artifactMessages[arti_teleport] = TXT_ARTIBLASTRADIUS; + } + if (P_GiveArtifact(player, artifactType, artifact)) { if (artifact->special) diff --git a/src/hexen/p_mobj.c b/src/hexen/p_mobj.c index 98f81984..b868da8c 100644 --- a/src/hexen/p_mobj.c +++ b/src/hexen/p_mobj.c @@ -1190,7 +1190,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { mobj->reactiontime = info->reactiontime; } - mobj->lastlook = P_Random() % MAXPLAYERS; + mobj->lastlook = P_Random() % maxplayers; // Set the state, but do not use P_SetMobjState, because action // routines can't be called yet. If the spawnstate has an action @@ -1295,7 +1295,7 @@ void P_SpawnPlayer(mapthing_t * mthing) fixed_t x, y, z; mobj_t *mobj; - if (mthing->type - 1 >= MAXPLAYERS || !playeringame[mthing->type - 1]) + if (mthing->type - 1 >= maxplayers || !playeringame[mthing->type - 1]) { // Not playing return; } @@ -1500,7 +1500,7 @@ void P_SpawnMapThing(mapthing_t * mthing) else if (deathmatch == false) { // Cooperative spawnMask = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { diff --git a/src/hexen/p_setup.c b/src/hexen/p_setup.c index 1ff6cef5..f24fb34e 100644 --- a/src/hexen/p_setup.c +++ b/src/hexen/p_setup.c @@ -387,7 +387,7 @@ void P_LoadThings(int lump) return; } playerCount = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playerCount += playeringame[i]; } @@ -672,7 +672,7 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) int lumpnum; mobj_t *mobj; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { players[i].killcount = players[i].secretcount = players[i].itemcount = 0; @@ -722,7 +722,7 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) TimerGame = 0; if (deathmatch) { - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { // must give a player spot before deathmatchspawn @@ -796,16 +796,22 @@ static void InitMapInfo(void) int mcmdValue; mapInfo_t *info; char songMulch[10]; + char *default_sky_name = DEFAULT_SKY_NAME; mapMax = 1; + if (gamemode == shareware) + { + default_sky_name = "SKY2"; + } + // Put defaults into MapInfo[0] info = MapInfo; info->cluster = 0; info->warpTrans = 0; info->nextMap = 1; // Always go to map 1 if not specified info->cdTrack = 1; - info->sky1Texture = R_TextureNumForName(DEFAULT_SKY_NAME); + info->sky1Texture = R_TextureNumForName(default_sky_name); info->sky2Texture = info->sky1Texture; info->sky1ScrollDelta = 0; info->sky2ScrollDelta = 0; diff --git a/src/hexen/p_switch.c b/src/hexen/p_switch.c index 9d86f92a..a90269a7 100644 --- a/src/hexen/p_switch.c +++ b/src/hexen/p_switch.c @@ -25,7 +25,14 @@ // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE // //================================================================== -switchlist_t alphSwitchList[] = { +switchlist_t alphSwitchListDemo[] = { + {"SW_1_UP", "SW_1_DN", SFX_SWITCH1}, + {"SW_2_UP", "SW_2_DN", SFX_SWITCH1}, + {"SW52_OFF", "SW52_ON", SFX_SWITCH2}, + {"\0", "\0", 0} +}; + +switchlist_t alphSwitchListFull[] = { {"SW_1_UP", "SW_1_DN", SFX_SWITCH1}, {"SW_2_UP", "SW_2_DN", SFX_SWITCH1}, {"VALVE1", "VALVE2", SFX_VALVE_TURN}, @@ -39,6 +46,8 @@ switchlist_t alphSwitchList[] = { {"\0", "\0", 0} }; +switchlist_t *alphSwitchList = NULL; + int switchlist[MAXSWITCHES * 2]; int numswitches; button_t buttonlist[MAXBUTTONS]; @@ -58,6 +67,18 @@ void P_InitSwitchList(void) int i; int index; + if (!alphSwitchList) + { + if (gamemode == shareware) + { + alphSwitchList = alphSwitchListDemo; + } + else + { + alphSwitchList = alphSwitchListFull; + } + } + for (index = 0, i = 0; i < MAXSWITCHES; i++) { if (!alphSwitchList[i].soundID) diff --git a/src/hexen/p_tick.c b/src/hexen/p_tick.c index aac61ff8..95242ccd 100644 --- a/src/hexen/p_tick.c +++ b/src/hexen/p_tick.c @@ -58,7 +58,7 @@ void P_Ticker(void) { return; } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { diff --git a/src/hexen/p_user.c b/src/hexen/p_user.c index d24ec053..c7fa7a3f 100644 --- a/src/hexen/p_user.c +++ b/src/hexen/p_user.c @@ -480,7 +480,7 @@ int P_GetPlayerNum(player_t * player) { int i; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (player == &players[i]) { @@ -1017,7 +1017,7 @@ void P_TeleportToPlayerStarts(mobj_t * victim) fixed_t destX, destY; angle_t destAngle; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) continue; diff --git a/src/hexen/r_draw.c b/src/hexen/r_draw.c index e7481934..13a0421b 100644 --- a/src/hexen/r_draw.c +++ b/src/hexen/r_draw.c @@ -320,9 +320,9 @@ void R_InitTranslationTables(void) V_LoadTintTable(); // Allocate translation tables - translationtables = Z_Malloc(256 * 3 * (MAXPLAYERS - 1), PU_STATIC, 0); + translationtables = Z_Malloc(256 * 3 * (maxplayers - 1), PU_STATIC, 0); - for (i = 0; i < 3 * (MAXPLAYERS - 1); i++) + for (i = 0; i < 3 * (maxplayers - 1); i++) { lumpnum = W_GetNumForName("trantbl0") + i; transLump = W_CacheLumpNum(lumpnum, PU_STATIC); diff --git a/src/hexen/r_things.c b/src/hexen/r_things.c index aae6dc60..9d1cb6b5 100644 --- a/src/hexen/r_things.c +++ b/src/hexen/r_things.c @@ -388,7 +388,7 @@ void R_DrawVisSprite(vissprite_t * vis, int x1, int x2) { colfunc = R_DrawTranslatedTLColumn; dc_translation = translationtables - 256 - + vis->class * ((MAXPLAYERS - 1) * 256) + + + vis->class * ((maxplayers - 1) * 256) + ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT - 8)); } else if (vis->mobjflags & MF_SHADOW) @@ -405,7 +405,7 @@ void R_DrawVisSprite(vissprite_t * vis, int x1, int x2) // Draw using translated column function colfunc = R_DrawTranslatedColumn; dc_translation = translationtables - 256 - + vis->class * ((MAXPLAYERS - 1) * 256) + + + vis->class * ((maxplayers - 1) * 256) + ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT - 8)); } diff --git a/src/hexen/sb_bar.c b/src/hexen/sb_bar.c index bcc5b675..3846f4c6 100644 --- a/src/hexen/sb_bar.c +++ b/src/hexen/sb_bar.c @@ -303,6 +303,34 @@ void SB_Init(void) PatchKILLS = W_CacheLumpName("KILLS", PU_STATIC); } SB_SetClassData(); + + if (gamemode == shareware) + { + CheatGodSeq = (cheatseq_t) CHEAT("bgokey", 0); + CheatNoClipSeq = (cheatseq_t) CHEAT("rjohnson", 0); + CheatWeaponsSeq = (cheatseq_t) CHEAT("crhinehart", 0); + CheatHealthSeq = (cheatseq_t) CHEAT("sgurno", 0); + CheatKeysSeq = (cheatseq_t) CHEAT("mraymondjudy", 0); + CheatSoundSeq = (cheatseq_t) CHEAT("kschilder", 0); + CheatTickerSeq = (cheatseq_t) CHEAT("rrettenmund", 0); + CheatArtifactAllSeq = (cheatseq_t) CHEAT("braffel", 0); + CheatPuzzleSeq = (cheatseq_t) CHEAT("tmoore", 0); + CheatWarpSeq = (cheatseq_t) CHEAT("bpelletier", 2); + CheatPigSeq = (cheatseq_t) CHEAT("ebiessman", 0); + CheatMassacreSeq = (cheatseq_t) CHEAT("cstika", 0); + CheatIDKFASeq = (cheatseq_t) CHEAT("rambo", 0); + CheatQuickenSeq1 = (cheatseq_t) CHEAT("quicken", 0); + CheatQuickenSeq2 = (cheatseq_t) CHEAT("quickenquicken", 0); + CheatQuickenSeq3 = (cheatseq_t) CHEAT("quickenquickenquicken", 0); + CheatClass1Seq = (cheatseq_t) CHEAT("plipo", 0); + CheatClass2Seq = (cheatseq_t) CHEAT("plipo", 1); + CheatVersionSeq = (cheatseq_t) CHEAT("pmacarther", 0); + CheatDebugSeq = (cheatseq_t) CHEAT("jsumwalt", 0); + CheatScriptSeq1 = (cheatseq_t) CHEAT("mwagabaza", 0); + CheatScriptSeq2 = (cheatseq_t) CHEAT("mwagabaza", 1); + CheatScriptSeq3 = (cheatseq_t) CHEAT("mwagabaza", 2); + CheatRevealSeq = (cheatseq_t) CHEAT("reveal", 0); + } } //========================================================================== @@ -330,12 +358,12 @@ void SB_SetClassData(void) if (!netgame) { // single player game uses red life gem (the second gem) PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem") - + MAXPLAYERS * class + 1, PU_STATIC); + + maxplayers * class + 1, PU_STATIC); } else { PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem") - + MAXPLAYERS * class + consoleplayer, + + maxplayers * class + consoleplayer, PU_STATIC); } SB_state = -1; @@ -1024,7 +1052,7 @@ void DrawMainBar(void) if (deathmatch) { temp = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { temp += CPlayer->frags[i]; } @@ -1351,7 +1379,7 @@ void DrawFullScreenStuff(void) if (deathmatch) { temp = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { diff --git a/src/hexen/sv_save.c b/src/hexen/sv_save.c index b210ad9d..7837b837 100644 --- a/src/hexen/sv_save.c +++ b/src/hexen/sv_save.c @@ -416,7 +416,7 @@ static void StreamIn_player_t(player_t *str) str->pieces = GET_LONG; // signed int frags[MAXPLAYERS]; - for (i=0; i<MAXPLAYERS; ++i) + for (i=0; i<maxplayers; ++i) { str->frags[i] = GET_LONG; } @@ -585,7 +585,7 @@ static void StreamOut_player_t(player_t *str) StreamOutLong(str->pieces); // signed int frags[MAXPLAYERS]; - for (i=0; i<MAXPLAYERS; ++i) + for (i=0; i<maxplayers; ++i) { StreamOutLong(str->frags[i]); } @@ -2081,7 +2081,7 @@ void SV_LoadGame(int slot) Z_Free(SaveBuffer); // Save player structs - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playerBackup[i] = players[i]; } @@ -2095,7 +2095,7 @@ void SV_LoadGame(int slot) // Restore player structs inv_ptr = 0; curpos = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { mobj = players[i].mo; players[i] = playerBackup[i]; @@ -2170,7 +2170,7 @@ void SV_MapTeleport(int map, int position) // Store player structs for later rClass = randomclass; randomclass = false; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playerBackup[i] = players[i]; } @@ -2194,7 +2194,7 @@ void SV_MapTeleport(int map, int position) G_InitNew(gameskill, gameepisode, gamemap); // Destroy all freshly spawned players - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { @@ -2205,7 +2205,7 @@ void SV_MapTeleport(int map, int position) // Restore player structs targetPlayerMobj = NULL; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -2286,7 +2286,7 @@ void SV_MapTeleport(int map, int position) } // Destroy all things touching players - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (playeringame[i]) { @@ -2403,11 +2403,11 @@ static void ArchivePlayers(void) int i; StreamOutLong(ASEG_PLAYERS); - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { StreamOutByte(playeringame[i]); } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -2429,11 +2429,11 @@ static void UnarchivePlayers(void) int i; AssertSegment(ASEG_PLAYERS); - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { playeringame[i] = GET_BYTE; } - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { @@ -2968,7 +2968,7 @@ static void ArchiveMisc(void) int ix; StreamOutLong(ASEG_MISC); - for (ix = 0; ix < MAXPLAYERS; ix++) + for (ix = 0; ix < maxplayers; ix++) { StreamOutLong(localQuakeHappening[ix]); } @@ -2985,7 +2985,7 @@ static void UnarchiveMisc(void) int ix; AssertSegment(ASEG_MISC); - for (ix = 0; ix < MAXPLAYERS; ix++) + for (ix = 0; ix < maxplayers; ix++) { localQuakeHappening[ix] = GET_LONG; } diff --git a/src/i_scale.c b/src/i_scale.c index 4d7bb22c..545a1f13 100644 --- a/src/i_scale.c +++ b/src/i_scale.c @@ -28,10 +28,6 @@ #include "m_argv.h" #include "z_zone.h" -#if defined(_MSC_VER) && !defined(__cplusplus) -#define inline __inline -#endif - // Should be I_VideoBuffer static byte *src_buffer; diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index 63a3467a..6acb528f 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -20,6 +20,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> + #include "SDL.h" #include "SDL_mixer.h" diff --git a/src/i_video.c b/src/i_video.c index 8fb1f178..d0140a0b 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -479,9 +479,7 @@ static int TranslateKey(SDL_keysym *sym) case SDLK_PAUSE: return KEY_PAUSE; -#if !SDL_VERSION_ATLEAST(1, 3, 0) case SDLK_EQUALS: return KEY_EQUALS; -#endif case SDLK_MINUS: return KEY_MINUS; @@ -495,10 +493,8 @@ static int TranslateKey(SDL_keysym *sym) case SDLK_LALT: case SDLK_RALT: -#if !SDL_VERSION_ATLEAST(1, 3, 0) case SDLK_LMETA: case SDLK_RMETA: -#endif return KEY_RALT; case SDLK_CAPSLOCK: return KEY_CAPSLOCK; @@ -829,11 +825,7 @@ static void CenterMouse(void) // Clear any relative movement caused by warping SDL_PumpEvents(); -#if SDL_VERSION_ATLEAST(1, 3, 0) - SDL_GetRelativeMouseState(0, NULL, NULL); -#else SDL_GetRelativeMouseState(NULL, NULL); -#endif } // @@ -847,11 +839,7 @@ static void I_ReadMouse(void) int x, y; event_t ev; -#if SDL_VERSION_ATLEAST(1, 3, 0) - SDL_GetRelativeMouseState(0, &x, &y); -#else SDL_GetRelativeMouseState(&x, &y); -#endif if (x != 0 || y != 0) { @@ -2023,9 +2011,7 @@ void I_InitGraphics(void) // has to be done before the call to SDL_SetVideoMode. I_InitWindowTitle(); -#if !SDL_VERSION_ATLEAST(1, 3, 0) I_InitWindowIcon(); -#endif // Warning to OS X users... though they might never see it :( #ifdef __MACOSX__ diff --git a/src/m_misc.c b/src/m_misc.c index 2e363412..53b86dba 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -372,12 +372,20 @@ char *M_StringReplace(const char *haystack, const char *needle, boolean M_StringCopy(char *dest, const char *src, size_t dest_size) { + size_t len; + if (dest_size >= 1) { dest[dest_size - 1] = '\0'; strncpy(dest, src, dest_size - 1); } - return strlen(dest) == strlen(src); + else + { + return false; + } + + len = strlen(dest); + return src[len] == '\0'; } // Safe string concat function that works like OpenBSD's strlcat(). diff --git a/src/net_sdl.c b/src/net_sdl.c index 7de61cb7..da667ff7 100644 --- a/src/net_sdl.c +++ b/src/net_sdl.c @@ -302,15 +302,27 @@ static boolean NET_SDL_RecvPacket(net_addr_t **addr, net_packet_t **packet) void NET_SDL_AddrToString(net_addr_t *addr, char *buffer, int buffer_len) { IPaddress *ip; + uint32_t host; + uint16_t port; ip = (IPaddress *) addr->handle; - - M_snprintf(buffer, buffer_len, - "%i.%i.%i.%i", - ip->host & 0xff, - (ip->host >> 8) & 0xff, - (ip->host >> 16) & 0xff, - (ip->host >> 24) & 0xff); + host = SDLNet_Read32(&ip->host); + port = SDLNet_Read16(&ip->port); + + M_snprintf(buffer, buffer_len, "%i.%i.%i.%i", + (host >> 24) & 0xff, (host >> 16) & 0xff, + (host >> 8) & 0xff, host & 0xff); + + // If we are using the default port we just need to show the IP address, + // but otherwise we need to include the port. This is important because + // we use the string representation in the setup tool to provided an + // address to connect to. + if (port != DEFAULT_PORT) + { + char portbuf[10]; + M_snprintf(portbuf, sizeof(portbuf), ":%i", port); + M_StringConcat(buffer, portbuf, buffer_len); + } } net_addr_t *NET_SDL_ResolveAddress(char *address) diff --git a/src/setup/compatibility.c b/src/setup/compatibility.c index df202117..14d5bc35 100644 --- a/src/setup/compatibility.c +++ b/src/setup/compatibility.c @@ -22,6 +22,8 @@ #include "compatibility.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-compat" + int vanilla_savegame_limit = 1; int vanilla_demo_limit = 1; @@ -31,7 +33,9 @@ void CompatibilitySettings(void) window = TXT_NewWindow("Compatibility"); - TXT_AddWidgets(window, + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + + TXT_AddWidgets(window, TXT_NewCheckBox("Vanilla savegame limit", &vanilla_savegame_limit), TXT_NewCheckBox("Vanilla demo limit", diff --git a/src/setup/display.c b/src/setup/display.c index 1398aaf0..e94db94e 100644 --- a/src/setup/display.c +++ b/src/setup/display.c @@ -28,6 +28,8 @@ #include "display.h" #include "config.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-display" + extern void RestartTextscreen(void); typedef struct @@ -535,6 +537,8 @@ static void AdvancedDisplayConfig(TXT_UNCAST_ARG(widget), window = TXT_NewWindow("Advanced display options"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_SetColumnWidths(window, 35); TXT_AddWidgets(window, @@ -595,6 +599,8 @@ void ConfigDisplay(void) window = TXT_NewWindow("Display Configuration"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + // Some machines can have lots of video modes. This tries to // keep a limit of six lines by increasing the number of // columns. In extreme cases, the window is moved up slightly. diff --git a/src/setup/execute.c b/src/setup/execute.c index bbb23c38..26f59fd8 100644 --- a/src/setup/execute.c +++ b/src/setup/execute.c @@ -18,6 +18,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <sys/types.h> diff --git a/src/setup/joystick.c b/src/setup/joystick.c index 2a07d181..07beadcd 100644 --- a/src/setup/joystick.c +++ b/src/setup/joystick.c @@ -14,6 +14,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "doomtype.h" #include "i_joystick.h" @@ -28,6 +29,8 @@ #include "txt_joyaxis.h" #include "txt_joybinput.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-gamepad" + typedef struct { char *name; // Config file name @@ -292,6 +295,24 @@ static const joystick_config_t buffalo_classic_controller[] = {NULL, 0}, }; +// Config for if the user is actually using an old PC joystick or gamepad, +// probably via a USB-Gameport adapter. +static const joystick_config_t pc_gameport_controller[] = +{ + {"joystick_x_axis", 0}, + {"joystick_y_axis", 1}, + // Button configuration is the default as used for Vanilla Doom, + // Heretic and Hexen. When playing with a Gravis Gamepad, this + // layout should also be vaguely similar to the standard layout + // described above. + {"joyb_fire", 0}, + {"joyb_strafe", 1}, + {"joyb_use", 3}, + {"joyb_speed", 2}, + {NULL, 0}, +}; + + static const known_joystick_t known_joysticks[] = { { @@ -364,6 +385,18 @@ static const known_joystick_t known_joysticks[] = 6, 14, 1, ps4_ds4_controller, }, + + // This is the configuration for the USB-Gameport adapter listed on + // this page as the "Mayflash USB to Gameport Adapter" (though the + // device is labeled as "Super Joy Box 7"): + // https://sites.google.com/site/joystickrehab/itemcatal + // TODO: Add extra configurations here for other USB-Gameport adapters, + // which should just be the same configuration. + { + "WiseGroup.,Ltd Gameport to USB Controller", + 3, 8, 1, + pc_gameport_controller, + }, }; static const known_joystick_t *GetJoystickType(int index) @@ -692,6 +725,8 @@ void ConfigJoystick(void) window = TXT_NewWindow("Gamepad/Joystick configuration"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_AddWidgets(window, TXT_NewCheckBox("Enable gamepad/joystick", &usejoystick), joystick_table = TXT_NewTable(2), diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 0d672436..4bbe1507 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -25,6 +25,8 @@ #include "joystick.h" #include "keyboard.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-keyboard" + int vanilla_keyboard_mapping = 1; static int always_run = 0; @@ -181,6 +183,8 @@ static void ConfigExtraKeys(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) window = TXT_NewWindow("Extra keyboard controls"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + table = TXT_NewTable(2); TXT_SetColumnWidths(table, 21, 9); @@ -270,6 +274,8 @@ static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) window = TXT_NewWindow("Other keys"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + table = TXT_NewTable(2); TXT_SetColumnWidths(table, 25, 9); @@ -356,6 +362,8 @@ void ConfigKeyboard(void) window = TXT_NewWindow("Keyboard configuration"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_AddWidgets(window, TXT_NewSeparator("Movement"), movement_table = TXT_NewTable(4), diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index a599812e..e35decd5 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -38,6 +38,8 @@ #include "multiplayer.h" #include "sound.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup" + static const int cheat_sequence[] = { KEY_UPARROW, KEY_UPARROW, KEY_DOWNARROW, KEY_DOWNARROW, @@ -209,6 +211,8 @@ void MainMenu(void) window = TXT_NewWindow("Main Menu"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_AddWidgets(window, TXT_NewButton2("Configure Display", (TxtWidgetSignalFunc) ConfigDisplay, NULL), @@ -247,7 +251,7 @@ void MainMenu(void) NULL); quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit"); - warp_action = TXT_NewWindowAction(KEY_F1, "Warp"); + warp_action = TXT_NewWindowAction(KEY_F2, "Warp"); TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL); TXT_SignalConnect(warp_action, "pressed", (TxtWidgetSignalFunc) WarpMenu, NULL); diff --git a/src/setup/mouse.c b/src/setup/mouse.c index 9fdfc833..91e38870 100644 --- a/src/setup/mouse.c +++ b/src/setup/mouse.c @@ -25,6 +25,8 @@ #include "mode.h" #include "mouse.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-mouse" + static int usemouse = 1; static int mouseSensitivity = 5; @@ -84,6 +86,8 @@ static void ConfigExtraButtons(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) window = TXT_NewWindow("Additional mouse buttons"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_AddWidgets(window, buttons_table = TXT_NewTable(2), NULL); @@ -112,6 +116,8 @@ void ConfigMouse(void) window = TXT_NewWindow("Mouse configuration"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_AddWidgets(window, TXT_NewCheckBox("Enable mouse", &usemouse), TXT_NewInvertedCheckBox("Allow vertical mouse movement", diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 6b294077..53b8ba26 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -957,7 +957,7 @@ static void ServerQueryWindow(char *title) TXT_NewScrollPane(70, 10, results_table = TXT_NewTable(3))); - TXT_SetColumnWidths(results_table, 7, 16, 46); + TXT_SetColumnWidths(results_table, 7, 22, 40); TXT_SetPeriodicCallback(QueryPeriodicCallback, results_table, 1); TXT_SignalConnect(query_window, "closed", QueryWindowClosed, NULL); diff --git a/src/setup/sound.c b/src/setup/sound.c index e7670feb..280a6bc2 100644 --- a/src/setup/sound.c +++ b/src/setup/sound.c @@ -25,6 +25,8 @@ #include "mode.h" #include "sound.h" +#define WINDOW_HELP_URL "http://www.chocolate-doom.org/setup-sound" + typedef enum { SFXMODE_DISABLED, @@ -237,6 +239,8 @@ void ConfigSound(void) window = TXT_NewWindow("Sound configuration"); + TXT_SetWindowHelpURL(window, WINDOW_HELP_URL); + TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, TXT_SCREEN_W / 2, 5); diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 35d2c908..186ba28b 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -1285,6 +1285,11 @@ void D_IntroTick(void) // //============================================================================= +static void G_CheckDemoStatusAtExit (void) +{ + G_CheckDemoStatus(); +} + // // D_DoomMain // @@ -1634,7 +1639,7 @@ void D_DoomMain (void) printf("Playing demo %s.\n", file); } - I_AtExit((atexit_func_t) G_CheckDemoStatus, true); + I_AtExit(G_CheckDemoStatusAtExit, true); // Generate the WAD hash table. Speed things up a bit. |