From 13ede78546d37a39034e311a6586b12cc574a81a Mon Sep 17 00:00:00 2001 From: theoddone33 Date: Tue, 7 May 2002 04:40:06 +0000 Subject: [PATCH] Drop in SDL Fix compilation for gcc 3 series It compiles under icc too git-svn-id: svn://svn.icculus.org/hhexen/trunk@11 c79c8604-0f32-0410-912e-ea7021435596 --- Makefile.in | 55 +- base/a_action.c | 1 + base/am_map.c | 1 + base/c_console.c | 1 + base/c_cvar.c | 103 ++++ base/ct_chat.c | 1 + base/d_net.c | 1 + base/f_finale.c | 1 + base/g_game.c | 3 +- base/h2_main.c | 4 +- base/i_action.c | 1 + base/i_cdmus.c | 1 + base/i_cyber.c | 294 ---------- base/i_linux.c | 30 +- base/i_sound.c | 1 + base/in_lude.c | 1 + base/m_misc.c | 7 +- base/mn_menu.c | 1 + base/oss.c | 1 + base/p_acs.c | 1 + base/p_anim.c | 1 + base/p_ceilng.c | 1 + base/p_doors.c | 1 + base/p_floor.c | 1 + base/p_inter.c | 3 +- base/p_lights.c | 2 +- base/p_maputl.c | 1 + base/p_mobj.c | 1 + base/p_plats.c | 1 + base/p_pspr.c | 1 + base/p_setup.c | 8 +- base/p_spec.c | 1 + base/p_switch.c | 1 + base/p_telept.c | 1 + base/p_things.c | 1 + base/p_tick.c | 1 + base/p_user.c | 1 + base/po_man.c | 1 + base/r_data.c | 18 +- base/r_main.c | 1 + base/r_plane.c | 2 +- base/r_segs.c | 1 + base/sb_bar.c | 1 + base/sc_man.c | 1 + base/sn_sonix.c | 1 + base/sounds.c | 1 + base/st_start.c | 1 + base/sv_save.c | 1 + base/template.c | 1 + base/v_video.c | 1 + base/w_wad.c | 8 +- base/z_zone.c | 1 + config.sub | 956 ++++++++++++++++++++++++++++++++ configure.in | 105 ++-- include/am_data.h | 1 + include/am_map.h | 1 + include/audio_plugin.h | 1 + include/config.h | 11 +- include/config.h.in | 9 - include/ct_chat.h | 1 + include/cvar.h | 7 + include/drcoord.h | 1 + include/dstrings.h | 1 + include/h2def.h | 21 +- include/i_cdmus.h | 1 + include/i_header.h | 1 + include/m_bams.h | 2 +- include/ogl_def.h | 1 + include/ogl_font.h | 1 + include/ogl_rl.h | 1 + include/ogl_tex.h | 2 +- include/oss.h | 1 + include/p_local.h | 3 +- include/p_spec.h | 10 +- include/sounds.h | 1 + include/soundst.h | 1 + include/st_start.h | 1 + include/textdefs.h | 1 + include/vgaview.h | 1 + include/x11window.h | 3 +- include/xddefs.h | 1 + include/xshmext.h | 1 + install-sh | 251 +++++++++ opengl/i_gl.cpp | 700 ------------------------ opengl/m_bams.c | 2 +- opengl/ogl_clip.c | 9 +- opengl/ogl_draw.c | 1 + opengl/ogl_font.c | 1 + opengl/ogl_rend.c | 1 + opengl/ogl_rl.c | 6 +- opengl/ogl_sky.c | 1 + opengl/ogl_tex.c | 35 +- sdl/i_sdl.c | 517 ++++++++++++++++++ sdl/i_sdlgl.c | 485 ++++++++++++++++ svgalib/i_svgalib.c | 632 --------------------- x11/i_x11.cpp | 1184 ---------------------------------------- x11/x11window.cpp | 604 -------------------- x11/xshmext.cpp | 236 -------- 98 files changed, 2556 insertions(+), 3833 deletions(-) create mode 100644 base/c_cvar.c delete mode 100644 base/i_cyber.c create mode 100755 config.sub create mode 100644 include/cvar.h create mode 100755 install-sh delete mode 100644 opengl/i_gl.cpp create mode 100644 sdl/i_sdl.c create mode 100644 sdl/i_sdlgl.c delete mode 100644 svgalib/i_svgalib.c delete mode 100644 x11/i_x11.cpp delete mode 100644 x11/x11window.cpp delete mode 100644 x11/xshmext.cpp diff --git a/Makefile.in b/Makefile.in index 255fac4..a96c0c2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,7 @@ # This Makefile understands the following targets: # # x11 (default): build X11 version +# sdl build SDL (software) version # svgalib: build SVGALib version # opengl build OpenGL version # clean: remove all intermediate files @@ -20,15 +21,18 @@ mandir = $(prefix)/man/man1 includedir = $(prefix)/include CC = @CC@ +CXX = @CXX@ DEFS = @DEFS@ CPPFLAGS = @CPPFLAGS@ @CFLAGS@ -CFLAGS = $(CPPFLAGS) +CFLAGS = $(CPPFLAGS) LDFLAGS = @LDFLAGS@ BLIBS = @BASELIBS@ -XLIBS = $(BLIBS) @LIBS@ SVGALIBS = $(BLIBS) @SVGALIBS@ - +GLLIBS = @GLLIBS@ -L/usr/X11R6/lib -lGL -lGLU +SDLLIBS = @SDL_LIBS@ +SDLFLAGS = @SDL_CFLAGS@ GLHEXEN = @GLHEXEN@ +HAVE_SDL = @HAVESDL@ # Directories @@ -44,17 +48,12 @@ CPPFLAGS += -I./include -I/usr/X11R6/include # Objects to build -X11OBJS = \ - x11/i_x11.o \ - x11/x11window.o \ - x11/xshmext.o +SDLOBJS = \ + sdl/i_sdl.o -SVGAOBJS = \ - svgalib/i_svgalib.o +GLBASE = @GLBASE@ GLOBJS = \ - opengl/i_gl.o \ - x11/x11window.o \ opengl/ogl_clip.o \ opengl/ogl_draw.o \ opengl/ogl_font.o \ @@ -69,11 +68,11 @@ BASEOBJS = \ base/oss.o \ base/i_sound.o \ base/i_cdmus.o \ - base/i_cyber.o \ base/am_map.o \ base/a_action.o \ base/ct_chat.o \ base/c_console.o \ + base/c_cvar.o \ base/d_net.o \ base/f_finale.o \ base/g_game.o \ @@ -122,29 +121,20 @@ BASEOBJS = \ base/w_wad.o \ base/z_zone.o -ifeq ($(GLHEXEN),true) -opengl: $(GLOBJS) $(BASEOBJS) - $(CC) -o HHexenGL $(GLOBJS) $(BASEOBJS) $(XLIBS) - -x11: - echo "You are trying to compile the X11 version after enabling OpenGL." - echo "Please type './configure' before you try this again." - -svgalib: - echo "You are trying to compile the SVGALib version after enabling OpenGL." - echo "Please type './configure' before you try this again." +ifeq "$(GLHEXEN)" "true" +opengl: $(GLBASE) $(GLOBJS) $(BASEOBJS) + $(CC) -o hhexen-gl $(GLBASE) $(GLOBJS) $(BASEOBJS) $(GLLIBS) $(SDLLIBS) +else +ifeq "$(HAVE_SDL)" "yes" +sdl: $(SDLOBJS) $(BASEOBJS) + $(CC) -o hhexen-sdl $(SDLOBJS) $(BASEOBJS) $(SDLLIBS) endif - -ifeq ($(GLHEXEN),false) x11: $(X11OBJS) $(BASEOBJS) - $(CC) -o HHexenX $(X11OBJS) $(BASEOBJS) $(XLIBS) + $(CC) -o hhexen-x11 $(X11OBJS) $(BASEOBJS) $(XLIBS) svgalib: $(SVGAOBJS) $(BASEOBJS) - $(CC) -o HHexenS $(SVGAOBJS) $(BASEOBJS) $(SVGALIBS) + $(CC) -o hhexen-vga $(SVGAOBJS) $(BASEOBJS) $(SVGALIBS) -opengl: - echo "You have not enabled GL. Please type './configure --enable-gl-mesa'" - echo "or './configure --enable-gl-tnt' to enable OpenGL mode." endif clean: @@ -152,9 +142,10 @@ clean: $(RM) x11/*.o $(RM) svgalib/*.o $(RM) opengl/*.o + $(RM) sdl/*.o %.o: %.c - $(CC) $< -o $@ -c $(CFLAGS) + $(CC) $< -o $@ -c $(CFLAGS) $(SDLFLAGS) %.o: %.cpp - $(CXX) $< -o $@ -c $(CPPFLAGS) + $(CXX) $< -o $@ -c $(CPPFLAGS) $(SDLFLAGS) diff --git a/base/a_action.c b/base/a_action.c index f670227..f143b0c 100644 --- a/base/a_action.c +++ b/base/a_action.c @@ -1317,3 +1317,4 @@ void A_NoGravity(mobj_t *actor) { actor->flags |= MF_NOGRAVITY; } + diff --git a/base/am_map.c b/base/am_map.c index 1ce0558..12150a1 100644 --- a/base/am_map.c +++ b/base/am_map.c @@ -1560,3 +1560,4 @@ static void DrawWorldTimer(void) } } } + diff --git a/base/c_console.c b/base/c_console.c index eb42502..40f08df 100644 --- a/base/c_console.c +++ b/base/c_console.c @@ -77,3 +77,4 @@ int CFQuit(int argc, char **argv) { return 0; } + diff --git a/base/c_cvar.c b/base/c_cvar.c new file mode 100644 index 0000000..2e0417f --- /dev/null +++ b/base/c_cvar.c @@ -0,0 +1,103 @@ +//************************************************************************* +//** +//** cvar.c : HHexen : Dan Olson +//** +//** This material is not supported by Activision +//** +//************************************************************************* + +// HEADER FILES ----------------------------------------------------------- + +#include +#include "h2def.h" +#include "cvar.h" + +// MACROS ----------------------------------------------------------------- + +// TYPES ------------------------------------------------------------------ + +// EXTERNAL FUNCTION PROTOTYPES ------------------------------------------- + +// PUBLIC FUNCTION PROTOTYPES --------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES -------------------------------------------- + +void CV_Init (void); +cvar_t *CV_Find (char *name); +void CV_Set (char *name, char *string); +cvar_t *CV_Get (char *name, char *string); +void CV_Shutdown (void); + +// EXTERNAL DATA DECLARATIONS --------------------------------------------- + +// PUBLIC DATA DEFINITIONS ------------------------------------------------ + +// PRIVATE DATA DEFINITIONS ----------------------------------------------- + +cvar_t *cvar_list; + +// CODE ------------------------------------------------------------------- + +void CV_Init (void) +{ +} + +cvar_t *CV_Find (char *name) +{ + cvar_t *c; + + for (c = cvar_list ; c ; c = c->next) + { + if (!strcmp (c->name, name)) + return c; + } + return NULL; +} + +void CV_Set (char *name, char *string) +{ + cvar_t *c; + + c = CV_Find (name); + if (!c) + { + ST_Message ("Tried to access non-existent cvar.\n"); + return; + } + c->value = atof(string); + c->string = string; +} + +cvar_t *CV_Get (char *name, char *string) +{ + cvar_t *c; + + if ((c = CV_Find(name)) != NULL) + { + // Malloc + c = (cvar_t *) malloc (sizeof (cvar_t)); + c->name = strdup (name); + c->string = strdup (string); + // Set + c->next = cvar_list; + cvar_list = c; + CV_Set (name, string); + } + return c; +} + +void CV_Shutdown (void) +{ + cvar_t *v,*next; + + v = cvar_list; + + while (v) + { + next = v->next; + free (v->name); + free (v->string); + free (v); + v = next; + } +} diff --git a/base/ct_chat.c b/base/ct_chat.c index 46aa6e9..fdaa69e 100644 --- a/base/ct_chat.c +++ b/base/ct_chat.c @@ -502,3 +502,4 @@ void CT_ClearChatMessage(int player) msgptr[player] = 0; msglen[player] = 0; } + diff --git a/base/d_net.c b/base/d_net.c index 5a22384..46747c0 100644 --- a/base/d_net.c +++ b/base/d_net.c @@ -912,3 +912,4 @@ if (debugfile) NetUpdate (); // check for new console commands } } + diff --git a/base/f_finale.c b/base/f_finale.c index 844b8c7..5cbbf17 100644 --- a/base/f_finale.c +++ b/base/f_finale.c @@ -379,3 +379,4 @@ static char *GetFinaleText(int sequence) ClusterMessage[msgSize] = 0; // Append terminator return ClusterMessage; } + diff --git a/base/g_game.c b/base/g_game.c index 438930a..cc17abc 100644 --- a/base/g_game.c +++ b/base/g_game.c @@ -212,8 +212,6 @@ void G_BuildTiccmd (ticcmd_t *cmd) cmd->consistancy = consistancy[consoleplayer][maketic%BACKUPTICS]; - if (isCyberPresent) - I_ReadCyberCmd (cmd); //printf ("cons: %i\n",cmd->consistancy); strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] @@ -1855,3 +1853,4 @@ boolean G_CheckDemoStatus (void) return false; } + diff --git a/base/h2_main.c b/base/h2_main.c index 63f1d94..66202fb 100644 --- a/base/h2_main.c +++ b/base/h2_main.c @@ -595,7 +595,8 @@ void H2_ProcessEvents(void) void H2_PostEvent(event_t *ev) { events[eventhead] = *ev; - eventhead = (++eventhead)&(MAXEVENTS-1); + eventhead++; + eventhead &= (MAXEVENTS-1); } //========================================================================== @@ -912,3 +913,4 @@ static void CreateBasePath(void) basePath = base; mkdir( base, S_IRWXU|S_IRWXG|S_IRWXO ); } + diff --git a/base/i_action.c b/base/i_action.c index f61e969..6132c75 100644 --- a/base/i_action.c +++ b/base/i_action.c @@ -108,3 +108,4 @@ char *C_ScanToKey(int code) return con->name; return NULL; } + diff --git a/base/i_cdmus.c b/base/i_cdmus.c index b47f6dd..32e5ca0 100644 --- a/base/i_cdmus.c +++ b/base/i_cdmus.c @@ -179,3 +179,4 @@ void I_CDMusUpdate(void) { } + diff --git a/base/i_cyber.c b/base/i_cyber.c deleted file mode 100644 index 97dbf1d..0000000 --- a/base/i_cyber.c +++ /dev/null @@ -1,294 +0,0 @@ -// I_cyber.c - -#ifndef __linux -#include -#endif -#include -#include -#include "st_start.h" // For ST_Message() - - -// Prototypes -unsigned char *I_AllocLow (int length); - - -/* -==================================================== - -Doom control structure - -The keybaord and joystick will add to the values set by the cyberman, -to a maximum of 0x19000 for forwardmove and sidemove. Angleturn is -not bounded at all. - -parm normal fast ------ ------ ---- -forwardmove 0xc800 0x19000 -sidemove 0xc000 0x14000 -angleturn 0x2800000 0x5000000 - -The keyboard and joystick have a 1/3 second slow turn of 0x1400000 under -normal speed to help aiming. - - - -==================================================== -*/ -/* old ticcmd_t -typedef struct -{ - char forwardmove; // *2048 for move - char sidemove; // *2048 for move - short angleturn; // <<16 for angle delta - short consistancy; // checks for net game - unsigned char chatchar; - unsigned char buttons; -} ticcmd_t; -*/ -// ticcmd_t as it appears in h2def.h -typedef struct -{ - char forwardmove; - char sidemove; - short angleturn; - short consistancy; - unsigned char chatchar; - unsigned char buttons; - unsigned char lookfly; - unsigned char arti; -}ticcmd_t; - - -#define BT_ATTACK 1 -#define BT_USE 2 -#define BT_CHANGE 4 // if true, the next 3 bits hold weapon num -#define BT_WEAPONMASK (8+16+32) -#define BT_WEAPONSHIFT 3 - -//================================================== -// -// CyberMan detection and usage info -// -//================================================== -#define DPMI_INT 0x31 -#define MOUSE_INT 0x33 - -#define DOSMEMSIZE 64 // enough for any SWIFT structure - -typedef struct { - short x; - short y; - short z; - short pitch; - short roll; - short yaw; - short buttons; -} SWIFT_3DStatus; - -// DPMI real mode interrupt structure -/* -static struct rminfo { - long EDI; - long ESI; - long EBP; - long reserved_by_system; - long EBX; - long EDX; - long ECX; - long EAX; - short flags; - short ES,DS,FS,GS,IP,CS,SP,SS; -} RMI; -*/ -typedef struct { - unsigned char deviceType; - unsigned char majorVersion; - unsigned char minorVersion; - unsigned char absRelFlags; - unsigned char centeringFlags; - unsigned char reserved[5]; -} StaticDeviceData; - -// values for deviceType: -#define DEVTYPE_CYBERMAN 1 - -short selector; -unsigned short segment; // segment of DOS memory block -SWIFT_3DStatus *cyberstat; -int isCyberPresent; // is CyberMan present? - - -#ifndef __linux -static union REGS regs; -static struct SREGS sregs; -#endif - - -extern int mousepresent; - -//=========================================================== -// -// I_StartupCyberMan -// -// If a cyberman is present, init it and set isCyberPresent to 1 -//=========================================================== -void I_StartupCyberMan(void) -{ -#ifdef __linux - isCyberPresent = 0; -#else - StaticDeviceData *pbuf; - - ST_Message(" CyberMan: "); - isCyberPresent = 0; - - cyberstat = (SWIFT_3DStatus *)I_AllocLow (DOSMEMSIZE); - segment = (int)cyberstat>>4; - - pbuf = (StaticDeviceData *)cyberstat; - memset(pbuf, 0, sizeof (StaticDeviceData)); - - - // Use DPMI call 300h to issue mouse interrupt - memset(&RMI, 0, sizeof(RMI)); - RMI.EAX = 0x53C1; // SWIFT: Get Static Device Data - RMI.ES = segment; - RMI.EDX = 0; - memset(&sregs, 0, sizeof (sregs)); - regs.w.ax = 0x0300; // DPMI: simulate interrupt - regs.w.bx = MOUSE_INT; - regs.w.cx = 0; - regs.x.edi = FP_OFF(&RMI); - sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); - - if ((short)RMI.EAX != 1) - { - // SWIFT functions not present - ST_Message("Wrong mouse driver - no SWIFT support (AX=%04x).\n", - (unsigned)(short)RMI.EAX); - } - else if (pbuf->deviceType != DEVTYPE_CYBERMAN) - { - // no SWIFT device, or not CyberMan - if (pbuf->deviceType == 0) - { - ST_Message("no SWIFT device connected.\n"); - } - else - { - ST_Message("SWIFT device is not a CyberMan! (type=%d)\n", - pbuf->deviceType); - } - } - else - { - ST_Message("CyberMan %d.%02d connected.\n", - pbuf->majorVersion, pbuf->minorVersion); - isCyberPresent = 1; - mousepresent = 0; - } -#endif -} - - - -/* -=============== -= -= I_ReadCyberCmds -= -=============== -*/ - - -int oldpos; - -void I_ReadCyberCmd (ticcmd_t *cmd) -{ -#ifdef __linux - return; -#else - int delta; - - // Use DPMI call 300h to issue mouse interrupt - memset(&RMI, 0, sizeof(RMI)); - RMI.EAX = 0x5301; // SWIFT: Get Position and Buttons - RMI.ES = segment; - RMI.EDX = 0; - memset(&sregs, 0, sizeof (sregs)); - regs.w.ax = 0x0300; // DPMI: simulate interrupt - regs.w.bx = MOUSE_INT; - regs.w.cx = 0; - regs.x.edi = FP_OFF(&RMI); - sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); - - if (cyberstat->y < -7900) - cmd->forwardmove = 0xc800/2048; - else if (cyberstat->y > 7900) - cmd->forwardmove = -0xc800/2048; - - if (cyberstat->buttons & 4) - cmd->buttons |= BT_ATTACK; - if (cyberstat->buttons & 2) - cmd->buttons |= BT_USE; - - delta = cyberstat->x - oldpos; - oldpos = cyberstat->x; - - if (cyberstat->buttons & 1) - { // strafe - if (cyberstat->x < -7900) - cmd->sidemove = -0xc800/2048; - else if (cyberstat->x > 7900) - cmd->sidemove = 0xc800/2048; - else - cmd->sidemove = delta*40/2048; - } - else - { - if (cyberstat->x < -7900) - cmd->angleturn = 0x280; - else if (cyberstat->x > 7900) - cmd->angleturn = -0x280; - else - cmd->angleturn = -delta*0xa/16; - - } - -#endif -} - - -void I_Tactile (int on, int off, int total) -{ -#ifdef __linux - return; -#else - if (!isCyberPresent) - return; - - on /= 5; - off /= 5; - total /= 40; - if (on > 255) - on = 255; - if (off > 255) - off = 255; - if (total > 255) - total = 255; - - memset(&RMI, 0, sizeof(RMI)); - RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons - RMI.EBX = on*256+off; - RMI.ECX = total; - memset(&sregs, 0, sizeof (sregs)); - regs.w.ax = 0x0300; // DPMI: simulate interrupt - regs.w.bx = MOUSE_INT; - regs.w.cx = 0; - regs.x.edi = FP_OFF(&RMI); - sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); -#endif -} diff --git a/base/i_linux.c b/base/i_linux.c index 237e3d8..9930395 100644 --- a/base/i_linux.c +++ b/base/i_linux.c @@ -35,8 +35,8 @@ extern void **lumpcache; -extern void I_StartupMouse(); -extern void I_ShutdownGraphics(); +extern void I_StartupMouse(void); +extern void I_ShutdownGraphics(void); int i_Vector; externdata_t *i_ExternData; @@ -1735,3 +1735,29 @@ int main( int argc, char** argv ) //EOF +fixed_t FixedMul (fixed_t a, fixed_t b) +{ + fixed_t retval; + __asm__ __volatile__( + "imull %%edx \n\t" + "shrdl $16, %%edx, %%eax \n\t" + : "=a" (retval) + : "a" (a), "d" (b) + : "cc" + ); + return retval; +} +fixed_t FixedDiv2 (fixed_t a, fixed_t b) +{ + fixed_t retval; + __asm__ __volatile__( + "cdq \n\t" + "shldl $16, %%eax, %%edx \n\t" + "sall $16, %%eax \n\t" + "idivl %%ebx \n\t" + : "=a" (retval) + : "a" (a), "b" (b) + : "%edx", "cc" + ); + return retval; +} diff --git a/base/i_sound.c b/base/i_sound.c index d3dda0b..34251d1 100644 --- a/base/i_sound.c +++ b/base/i_sound.c @@ -461,3 +461,4 @@ void I_SetChannels(int channels) /* EOF */ + diff --git a/base/in_lude.c b/base/in_lude.c index d0869c0..2b22ed7 100644 --- a/base/in_lude.c +++ b/base/in_lude.c @@ -595,3 +595,4 @@ static void DrawHubText(void) cx += w->width; } } + diff --git a/base/m_misc.c b/base/m_misc.c index 11056a1..a9fe350 100644 --- a/base/m_misc.c +++ b/base/m_misc.c @@ -130,7 +130,6 @@ void M_ExtractFileBase(char *path, char *dest) =============== */ - // This is the new flat distribution table unsigned char rndtable[256] = { 201, 1,243, 19, 18, 42,183,203,101,123,154,137, 34,118, 10,216, @@ -155,6 +154,11 @@ unsigned char rndtable[256] = { int rndindex = 0; int prndindex = 0; +unsigned char P_Random (void) +{ + return rndtable[(++prndindex)&0xff]; +} + int M_Random (void) { rndindex = (rndindex+1)&0xff; @@ -786,3 +790,4 @@ void M_ScreenShot (void) P_SetMessage(&players[consoleplayer], "SCREEN SHOT", false); } #endif + diff --git a/base/mn_menu.c b/base/mn_menu.c index 53c9504..9e4d77a 100644 --- a/base/mn_menu.c +++ b/base/mn_menu.c @@ -2257,3 +2257,4 @@ static void DrawSlider(Menu_t *menu, int item, int width, int slot) V_DrawPatch(x+4+slot*8, y+7, W_CacheLumpName("M_SLDKB", PU_CACHE)); #endif } + diff --git a/base/oss.c b/base/oss.c index d0d8c3e..b25d9bb 100644 --- a/base/oss.c +++ b/base/oss.c @@ -706,3 +706,4 @@ OutputPlugin *get_oplugin_info(void) /* EOF */ + diff --git a/base/p_acs.c b/base/p_acs.c index 65b2e45..5e12c1a 100644 --- a/base/p_acs.c +++ b/base/p_acs.c @@ -1780,3 +1780,4 @@ static int CmdSetLineSpecial(void) } return SCRIPT_CONTINUE; } + diff --git a/base/p_anim.c b/base/p_anim.c index 16385f1..62b0f69 100644 --- a/base/p_anim.c +++ b/base/p_anim.c @@ -471,3 +471,4 @@ void P_InitFTAnims(void) } SC_Close(); } + diff --git a/base/p_ceilng.c b/base/p_ceilng.c index 5754b64..57bf2b0 100644 --- a/base/p_ceilng.c +++ b/base/p_ceilng.c @@ -292,3 +292,4 @@ int EV_CeilingCrushStop(line_t *line, byte *args) } return rtn; } + diff --git a/base/p_doors.c b/base/p_doors.c index 399bdfa..7ab7690 100644 --- a/base/p_doors.c +++ b/base/p_doors.c @@ -312,3 +312,4 @@ void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum) door->topcountdown = 5*60*35; } */ + diff --git a/base/p_floor.c b/base/p_floor.c index 3a6b64e..770eb4e 100644 --- a/base/p_floor.c +++ b/base/p_floor.c @@ -929,3 +929,4 @@ boolean EV_StartFloorWaggle(int tag, int height, int speed, int offset, } return retCode; } + diff --git a/base/p_inter.c b/base/p_inter.c index 885ee6f..419444c 100644 --- a/base/p_inter.c +++ b/base/p_inter.c @@ -2027,7 +2027,7 @@ void P_DamageMobj temp = damage < 100 ? damage : 100; if(player == &players[consoleplayer]) { - I_Tactile(40, 10, 40+temp*2); + //I_Tactile(40, 10, 40+temp*2); SB_PaletteFlash(false); } } @@ -2274,3 +2274,4 @@ void P_PoisonDamage(player_t *player, mobj_t *source, int damage, } */ } + diff --git a/base/p_lights.c b/base/p_lights.c index 9b1b097..38c4b43 100644 --- a/base/p_lights.c +++ b/base/p_lights.c @@ -348,4 +348,4 @@ void P_SpawnLightSequence(sector_t *sector, int indexStep) } sec = nextSec; } while(sec); -} \ No newline at end of file +} diff --git a/base/p_maputl.c b/base/p_maputl.c index 5afc5ad..a0573dc 100644 --- a/base/p_maputl.c +++ b/base/p_maputl.c @@ -1059,3 +1059,4 @@ static mobj_t *RoughBlockCheck(mobj_t *mo, int index) } return NULL; } + diff --git a/base/p_mobj.c b/base/p_mobj.c index 1f22c5c..ed33dbd 100644 --- a/base/p_mobj.c +++ b/base/p_mobj.c @@ -2459,3 +2459,4 @@ mobj_t *P_SpawnKoraxMissile(fixed_t x, fixed_t y, fixed_t z, th->momz = (dest->z-z+(30*FRACUNIT))/dist; return(P_CheckMissileSpawn(th) ? th : NULL); } + diff --git a/base/p_plats.c b/base/p_plats.c index 6caaf7b..21c72c9 100644 --- a/base/p_plats.c +++ b/base/p_plats.c @@ -266,3 +266,4 @@ void P_RemoveActivePlat(plat_t *plat) } I_Error ("P_RemoveActivePlat: can't find plat!"); } + diff --git a/base/p_pspr.c b/base/p_pspr.c index 77219ea..b315a41 100644 --- a/base/p_pspr.c +++ b/base/p_pspr.c @@ -2704,3 +2704,4 @@ void A_AStaffAttack(player_t *player, pspdef_t *psp) angle = pmo->angle; } + diff --git a/base/p_setup.c b/base/p_setup.c index bd57809..6bec2a1 100644 --- a/base/p_setup.c +++ b/base/p_setup.c @@ -728,8 +728,7 @@ void P_ConvexCarver(subsector_t *ssec, int num, divline_t *list) //extern void OGL_DrawEdges(int num,fvertex_t *list,int,fdivline_t*,int); int numclippers = num+ssec->numlines; - fdivline_t *clippers = -(fdivline_t*)_alloca(numclippers*sizeof(fdivline_t)); + fdivline_t *clippers = (fdivline_t*)malloc(numclippers*sizeof(fdivline_t)); int i, k, numedgepoints; fvertex_t *edgepoints; unsigned char sidelist[MAX_CC_SIDES]; @@ -816,8 +815,7 @@ void P_ConvexCarver(subsector_t *ssec, int num, divline_t *list) // Add the new vertex. Also modify the sidelist. edgepoints = (fvertex_t*)realloc(edgepoints,(++numedgepoints)*sizeof(fvertex_t)); - if(numedgepoints >= MAX_CC_SIDES) I_Error("Too many points in -carver.\n"); + if(numedgepoints >= MAX_CC_SIDES) I_Error("Too many points in carver.\n"); // Make room for the new vertex. memmove(edgepoints+endIdx+1, edgepoints+endIdx, @@ -925,6 +923,7 @@ edgepoints[i].y; } // We're done, free the edgepoints memory. + free(clippers); free(edgepoints); } @@ -1614,3 +1613,4 @@ void My_Debug(void) } } */ + diff --git a/base/p_spec.c b/base/p_spec.c index 6510651..f26b311 100644 --- a/base/p_spec.c +++ b/base/p_spec.c @@ -1150,3 +1150,4 @@ line_t *P_FindLine(int lineTag, int *searchPosition) *searchPosition = -1; return NULL; } + diff --git a/base/p_switch.c b/base/p_switch.c index c390726..5b792d9 100644 --- a/base/p_switch.c +++ b/base/p_switch.c @@ -144,3 +144,4 @@ void P_ChangeSwitchTexture(line_t *line, int useAgain) } } } + diff --git a/base/p_telept.c b/base/p_telept.c index 5c23d57..8b6267a 100644 --- a/base/p_telept.c +++ b/base/p_telept.c @@ -175,3 +175,4 @@ boolean EV_Teleport(int tid, mobj_t *thing, boolean fog) if (!mo) I_Error("Can't find teleport mapspot\n"); return P_Teleport(thing, mo->x, mo->y, mo->angle, fog); } + diff --git a/base/p_things.c b/base/p_things.c index af69598..335481b 100644 --- a/base/p_things.c +++ b/base/p_things.c @@ -531,3 +531,4 @@ static boolean DeactivateThing(mobj_t *mobj) } return true; } + diff --git a/base/p_tick.c b/base/p_tick.c index e4db3cd..31ad39b 100644 --- a/base/p_tick.c +++ b/base/p_tick.c @@ -140,3 +140,4 @@ void P_RemoveThinker(thinker_t *thinker) { thinker->function = (think_t)-1; } + diff --git a/base/p_user.c b/base/p_user.c index 0c87206..9ec1f6d 100644 --- a/base/p_user.c +++ b/base/p_user.c @@ -1667,3 +1667,4 @@ void A_SpeedFade(mobj_t *actor) actor->flags &= ~MF_ALTSHADOW; actor->sprite = actor->target->sprite; } + diff --git a/base/po_man.c b/base/po_man.c index 6fe832a..895e2fa 100644 --- a/base/po_man.c +++ b/base/po_man.c @@ -1483,3 +1483,4 @@ boolean PO_Busy(int polyobj) return true; } } + diff --git a/base/r_data.c b/base/r_data.c index 25515ed..ca6084a 100644 --- a/base/r_data.c +++ b/base/r_data.c @@ -205,7 +205,7 @@ void R_GenerateLookup (int texnum) // fill in the lump / offset, so columns with only a single patch are // all done // - patchcount = (byte *)alloca (texture->width); + patchcount = (byte *)malloc (texture->width); memset (patchcount, 0, texture->width); patch = texture->patches; @@ -233,6 +233,7 @@ void R_GenerateLookup (int texnum) if (!patchcount[x]) { ST_Message ("R_GenerateLookup: column without a patch (%s)\n", texture->name); + free (patchcount); return; } // I_Error ("R_GenerateLookup: column without a patch"); @@ -245,6 +246,7 @@ void R_GenerateLookup (int texnum) texturecompositesize[texnum] += texture->height; } } + free (patchcount); } @@ -304,7 +306,7 @@ void R_InitTextures (void) names = W_CacheLumpName ("PNAMES", PU_STATIC); nummappatches = LONG ( *((int *)names) ); name_p = names+4; - patchlookup = alloca (nummappatches*sizeof(*patchlookup)); + patchlookup = (int *)malloc(nummappatches*sizeof(*patchlookup)); for (i=0 ; inext) @@ -690,4 +694,8 @@ void R_PrecacheLevel (void) } } } + free (flatpresent); + free (texturepresent); + free (spritepresent); } + diff --git a/base/r_main.c b/base/r_main.c index f8f5765..54c07ce 100644 --- a/base/r_main.c +++ b/base/r_main.c @@ -912,3 +912,4 @@ void R_RenderPlayerView (player_t *player) OGL_Restore2DState(2); #endif } + diff --git a/base/r_plane.c b/base/r_plane.c index eb32330..b29b769 100644 --- a/base/r_plane.c +++ b/base/r_plane.c @@ -559,6 +559,6 @@ void R_DrawPlanes(void) } Z_ChangeTag(tempSource, PU_CACHE); } -#endif !RENDER3D +#endif //!RENDER3D } diff --git a/base/r_segs.c b/base/r_segs.c index ab23487..c2dcf4e 100644 --- a/base/r_segs.c +++ b/base/r_segs.c @@ -656,3 +656,4 @@ void R_StoreWallRange (int start, int stop) } #endif + diff --git a/base/sb_bar.c b/base/sb_bar.c index de8122f..3afcb12 100644 --- a/base/sb_bar.c +++ b/base/sb_bar.c @@ -2342,3 +2342,4 @@ static void CheatTrackFunc2(player_t *player, Cheat_t *cheat) i_CDCurrentTrack = track; } } + diff --git a/base/sc_man.c b/base/sc_man.c index 080f965..ac1d83a 100644 --- a/base/sc_man.c +++ b/base/sc_man.c @@ -484,3 +484,4 @@ static void CheckOpen(void) I_Error("SC_ call before SC_Open()."); } } + diff --git a/base/sn_sonix.c b/base/sn_sonix.c index 8d1de2b..56f3b2c 100644 --- a/base/sn_sonix.c +++ b/base/sn_sonix.c @@ -504,3 +504,4 @@ void SN_ChangeNodeData(int nodeNum, int seqOffset, int delayTics, int volume, node->sequencePtr += seqOffset; node->currentSoundID = currentSoundID; } + diff --git a/base/sounds.c b/base/sounds.c index b1f267b..bf0e583 100644 --- a/base/sounds.c +++ b/base/sounds.c @@ -304,3 +304,4 @@ sfxinfo_t S_sfx[] = { "PuppyBeat", "", 30, -1, NULL, 0, 2, 1 }, { "MysticIncant", "", 32, -1, NULL, 0, 4, 1 } }; + diff --git a/base/st_start.c b/base/st_start.c index ae667be..07826e8 100644 --- a/base/st_start.c +++ b/base/st_start.c @@ -335,3 +335,4 @@ char *ST_LoadScreen(void) W_ReadLump(lump, buffer); return(buffer); } + diff --git a/base/sv_save.c b/base/sv_save.c index e290025..41d5b79 100644 --- a/base/sv_save.c +++ b/base/sv_save.c @@ -1754,3 +1754,4 @@ static void StreamOutLong(unsigned int val) { fwrite(&val, sizeof(int), 1, SavingFP); } + diff --git a/base/template.c b/base/template.c index d1a6e99..ea60ea9 100644 --- a/base/template.c +++ b/base/template.c @@ -30,3 +30,4 @@ // // //========================================================================== + diff --git a/base/v_video.c b/base/v_video.c index 3723ea2..52b9dee 100644 --- a/base/v_video.c +++ b/base/v_video.c @@ -262,3 +262,4 @@ void V_Init(void) // I_AllocLow will put screen in low dos memory on PCs. screen = I_AllocLow(SCREENWIDTH*SCREENHEIGHT); } + diff --git a/base/w_wad.c b/base/w_wad.c index 74d3621..b681b5a 100644 --- a/base/w_wad.c +++ b/base/w_wad.c @@ -18,11 +18,7 @@ #include #include /* jim open() etc. */ #include /* jim toupper() */ -#ifndef HAVE_ALLOCA_H -#include -#else #define O_BINARY 0 -#endif #include "h2def.h" // MACROS ------------------------------------------------------------------ @@ -269,7 +265,7 @@ void W_MergeLumps(char *start, char *end) int in_block = 0; int i; - newlumpinfo = (lumpinfo_t *) alloca(numlumps * sizeof(lumpinfo_t)); + newlumpinfo = (lumpinfo_t *) malloc(numlumps * sizeof(lumpinfo_t)); oldlumps = newlumps = 0; for(i=0;i < numlumps;i++) @@ -332,6 +328,7 @@ void W_MergeLumps(char *start, char *end) lumpinfo[numlumps].position = lumpinfo[numlumps].size = 0; numlumps++; } + free (newlumpinfo); } //========================================================================== @@ -719,3 +716,4 @@ void W_Profile (void) fclose (f); } */ + diff --git a/base/z_zone.c b/base/z_zone.c index b3c3e97..2bc416f 100644 --- a/base/z_zone.c +++ b/base/z_zone.c @@ -394,3 +394,4 @@ int Z_FreeMemory (void) return free; } */ + diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..da8b7ae --- /dev/null +++ b/config.sub @@ -0,0 +1,956 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64 | v850) + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + np1) + basic_machine=np1-gould + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | k6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | k6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -rhapsody* \ + | -openstep*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/configure.in b/configure.in index 0d1a3f0..f7a1473 100644 --- a/configure.in +++ b/configure.in @@ -4,8 +4,6 @@ AC_REVISION([configure.in 1.00]) AC_INIT(base/a_action.c) AC_CONFIG_HEADER(include/config.h) -# We want these before the checks, so the checks can modify their values. - dnl **** Command-line arguments **** dnl Default values @@ -14,18 +12,14 @@ GLLIBS="" BASELIBS="" SVGALIBS="" LIBS="-L/usr/X11R6/lib" -HAVESVGA="no" -HAVEX11="yes" -HAVEGL="yes" -FORCEMESAGL="no" +HAVEGL="no" +GLBASE="opengl/i_gl.cpp" +BUILDNAMES="" AC_ARG_ENABLE(gl, [ --enable-gl Enable OpenGL mode], -[GLHEXEN="true"; AC_DEFINE(RENDER3D)]) - -AC_ARG_ENABLE(gl-mesa, -[ --enable-gl-mesa Enable OpenGL mode for Mesa 3d acceleration], -[GLHEXEN="true"; FORCEMESAGL="yes" ;AC_DEFINE(RENDER3D)]) +[GLHEXEN="true";SDL_VERSION="1.1.2"; AC_DEFINE(RENDER3D)], +[SDL_VERSION="1.1.0"]) AC_ARG_ENABLE(demowad, [ --enable-demowad Enable compilation with the demo wadfile], @@ -49,15 +43,21 @@ AC_PROG_CPP dnl **** Check for some libraries **** dnl Check for pthread -AC_CHECK_LIB(pthread, pthread_create, [BASELIBS="-lpthread"]) +AC_CHECK_LIB(pthread, pthread_join, [BASELIBS="-lpthread"]) + AC_SUBST(BASELIBS) -dnl Check for SvgaLib -AC_CHECK_LIB(vga, vga_setmode, [SVGALIBS="-lvga"; HAVESVGA="yes"]) +dnl Check for SDL +AM_PATH_SDL($SDL_VERSION, + [HAVESDL="yes";GLBASE="sdl/i_sdlgl.o";BUILDNAMES="sdl $BUILDNAMES";GLLIBS=""], + [HAVESDL="no"] +) + +AC_SUBST(GLLIBS) +AC_SUBST(SDL_OGL) +AC_SUBST(HAVESDL) +AC_SUBST(GLBASE) -dnl Check for all libs needed by X11 version -AC_CHECK_LIB(Xext,XShmQueryExtension, [LIBS="$LIBS -lXext"],[HAVEX11="no"]) -AC_CHECK_LIB(X11, main, [LIBS="$LIBS -lX11"], [HAVEX11="no"]) AC_CHECK_LIB(dl, dlopen) AC_CHECK_LIB(m, sqrt) @@ -65,22 +65,16 @@ dnl Check for GL libraries if test "$GLHEXEN" = "true" then - if test "$FORCEMESAGL" = "yes" - then - AC_CHECK_LIB(MesaGL, glBindTexture, ,HAVEGL="no") - AC_CHECK_LIB(MesaGLU, gluOrtho2D, ,HAVEGL="no") - else AC_CHECK_LIB(GL, glBindTexture,[LIBS="$LIBS -lGL";] - AC_CHECK_LIB(GLU, gluOrtho2D, , + AC_CHECK_LIB(GLU, gluOrtho2D, [HAVEGL="yes"], AC_CHECK_LIB(MesaGL, glBindTexture,[LIBS="$LIBS -lMesaGL";] - AC_CHECK_LIB(MesaGLU, gluOrtho2D, , HAVEGL="no"), + AC_CHECK_LIB(MesaGLU, gluOrtho2D, [HAVEGL="yes"], HAVEGL="no"), HAVEGL="no") ), AC_CHECK_LIB(MesaGL, glBindTexture,[LIBS="$LIBS -lMesaGL";] - AC_CHECK_LIB(MesaGLU, gluOrtho2D, , HAVEGL="no"), + AC_CHECK_LIB(MesaGLU, gluOrtho2D, [HAVEGL="yes"], HAVEGL="no"), HAVEGL="no") ) - fi fi dnl **** Check for gcc strength-reduce bug **** @@ -127,8 +121,6 @@ dnl AC_C_BIGENDIAN dnl **** Check for functions **** -AC_FUNC_ALLOCA() - dnl **** Check for header files **** AC_CHECK_HEADERS(\ @@ -143,6 +135,16 @@ AC_C_INLINE() AC_TYPE_SIZE_T() AC_CHECK_SIZEOF(long long,0) +if test "$HAVEGL" = "yes" +then + if test "$HAVESDL" = "yes" + then + BUILDNAMES="OpenGL (SDL)" + else + BUILDNAMES="OpenGL (GLX)" + fi +fi + dnl **** Generate output files **** MAKE_NAME=Makefile @@ -150,41 +152,16 @@ AC_SUBST_FILE(MAKE_RULES) AC_OUTPUT(Makefile) -if test "$HAVESVGA" = "no" -then - echo - echo "Warning: It appears that you do not have SvgaLib installed on your system" - echo " If you want to compile with SvgaLib support, you will need to" - echo " download the library from 'http://www.svgalib.org'." -fi - -if test "$HAVEX11" = "no" +echo +echo "HHexen configuration finished." +echo "Enabled targets: $BUILDNAMES" +echo +if test "$HAVESDL" = "no" then + echo "It is recommended that you install SDL (http://www.libsdl.org)." + echo "Other targets will compile, but they are no longer supported." + echo "If SDL is installed, you will need to upgrade to version $SDL_VERSION" echo - echo "Warning: Configure did not find some necessary libraries for an X11" - echo " build. Perhaps you do not have X11 installed correctly." - echo " Until this problem is resolved, you won't be able to compile" - echo " the X11 or OpenGL versions." -dnl Add this line so we don't get two error messages - HAVEGL="yes" -fi - -if test "$HAVEGL" = "no" -then - echo - echo "Warning: Configure was not able to find your OpenGL libraries." - echo " Perhaps you do not have them installed correctly. Until" - echo " this problem is resolved, you won't be able to compile" - echo " the OpenGL version of HHexen." -fi - -if test "$GLHEXEN" = "true" -then - echo - echo "Configure finished. Do 'make clean', then 'make' to build the OpenGL version." - echo -else - echo - echo "Configure finished. Do 'make clean', then 'make x11' or 'make svgalib' to build" - echo -fi +fi +echo "Type 'make' to compile." +echo diff --git a/include/am_data.h b/include/am_data.h index 6daecfa..7399ac3 100644 --- a/include/am_data.h +++ b/include/am_data.h @@ -107,3 +107,4 @@ mline_t thintriangle_guy[] = { #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) #endif + diff --git a/include/am_map.h b/include/am_map.h index b278d7e..def567e 100644 --- a/include/am_map.h +++ b/include/am_map.h @@ -143,3 +143,4 @@ typedef struct // extern int f_x, f_y, f_w, f_h; #endif + diff --git a/include/audio_plugin.h b/include/audio_plugin.h index b6d7fd5..81b0938 100644 --- a/include/audio_plugin.h +++ b/include/audio_plugin.h @@ -56,3 +56,4 @@ OutputPlugin; #endif + diff --git a/include/config.h b/include/config.h index 608755d..5b6d9df 100644 --- a/include/config.h +++ b/include/config.h @@ -1,9 +1,6 @@ /* include/config.h. Generated automatically by configure. */ /* include/config.h.in. Generated automatically from configure.in by autoheader. */ -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -11,12 +8,6 @@ This function is required for alloca.c support on those systems. */ /* #undef CRAY_STACKSEG_END */ -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have and it should be used (not on Ultrix). */ -#define HAVE_ALLOCA_H 1 - /* Define as __inline if that's what the C compiler calls it. */ /* #undef inline */ @@ -42,7 +33,7 @@ #define ASSASSIN 1 /* Define if building for OpenGL */ -/* #undef RENDER3D */ +#define RENDER3D 1 /* Define if building for demo wadfile */ /* #undef DEMO_WAD */ diff --git a/include/config.h.in b/include/config.h.in index c12a6ff..66bef4e 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1,8 +1,5 @@ /* include/config.h.in. Generated automatically from configure.in by autoheader. */ -/* Define if using alloca.c. */ -#undef C_ALLOCA - /* Define to empty if the keyword does not work. */ #undef const @@ -10,12 +7,6 @@ This function is required for alloca.c support on those systems. */ #undef CRAY_STACKSEG_END -/* Define if you have alloca, as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define if you have and it should be used (not on Ultrix). */ -#undef HAVE_ALLOCA_H - /* Define as __inline if that's what the C compiler calls it. */ #undef inline diff --git a/include/ct_chat.h b/include/ct_chat.h index 0f8b282..e4d31c4 100644 --- a/include/ct_chat.h +++ b/include/ct_chat.h @@ -13,3 +13,4 @@ #define CT_KEY_RED 'r' #define CT_KEY_BLUE 'b' #define CT_KEY_ALL 't' + diff --git a/include/cvar.h b/include/cvar.h new file mode 100644 index 0000000..9019b8c --- /dev/null +++ b/include/cvar.h @@ -0,0 +1,7 @@ +typedef struct cvar_s +{ + char *string; + char *name; + float value; + struct cvar_s *next; +} cvar_t; diff --git a/include/drcoord.h b/include/drcoord.h index 00b8143..dd04dc0 100644 --- a/include/drcoord.h +++ b/include/drcoord.h @@ -27,3 +27,4 @@ - scale4: sender; @end + diff --git a/include/dstrings.h b/include/dstrings.h index 982867b..65e5888 100644 --- a/include/dstrings.h +++ b/include/dstrings.h @@ -203,3 +203,4 @@ "just have been a scream.\n\n"\ "then again, what about the other\n"\ "serpent riders?" + diff --git a/include/h2def.h b/include/h2def.h index f583c25..4b7c338 100644 --- a/include/h2def.h +++ b/include/h2def.h @@ -23,6 +23,7 @@ #define VERSION 110 #define VERSION_TEXT "v1.1" +#define HHEXEN_VERSION "1.4" #if defined(__linux) #define VERSION_PLATFORM "Linux" @@ -896,19 +897,6 @@ fixed_t FixedDiv (fixed_t a, fixed_t b); fixed_t FixedDiv2 (fixed_t a, fixed_t b); -//#ifdef __linux -#define FixedMul(fa,fb) ({ int __value, __fb = (fb); \ -__asm__("imul %%ebx; shrd $16,%%edx,%%eax" \ - : "=a" (__value) \ - : "0" (fa), "b" (__fb) \ - : "edx" ); __value; }) -#define FixedDiv2(fa,fb) ({ int __value; \ -__asm__("cdq; shld $16,%%eax,%%edx; sall $16,%%eax; idiv %%ebx" \ - : "=a" (__value) \ - : "0" (fa), "b" (fb) \ - : "edx" ); __value; }) -//#endif - #ifdef __BIG_ENDIAN__ short ShortSwap(short); long LongSwap(long); @@ -1277,11 +1265,7 @@ void M_ForceUppercase(char *text); int M_Random (void); // returns a number from 0 to 255 - -extern unsigned char rndtable[256]; -extern int prndindex; -#define P_Random() rndtable[(++prndindex)&0xff] -// as M_Random, but used only by the play simulation +extern unsigned char P_Random(void); void M_ClearRandom (void); // fix randoms for demos @@ -1500,3 +1484,4 @@ void V_DrawRawScreen(byte *raw); #endif #endif // __H2DEF__ + diff --git a/include/i_cdmus.h b/include/i_cdmus.h index 51e16b0..ec0490f 100644 --- a/include/i_cdmus.h +++ b/include/i_cdmus.h @@ -24,3 +24,4 @@ int I_CDMusLastTrack(void); int I_CDMusTrackLength(int track); #endif + diff --git a/include/i_header.h b/include/i_header.h index f07034d..000e2f4 100644 --- a/include/i_header.h +++ b/include/i_header.h @@ -75,3 +75,4 @@ int I_SoundIsPlaying(channel_t *c); // if no longer playing, 1 if playing. #endif + diff --git a/include/m_bams.h b/include/m_bams.h index 80e963d..6a77d48 100644 --- a/include/m_bams.h +++ b/include/m_bams.h @@ -32,4 +32,4 @@ typedef unsigned short binangle; void bamsInit(); // Fill in the tables. binangle bamsAtan2(int y,int x); -#endif \ No newline at end of file +#endif diff --git a/include/ogl_def.h b/include/ogl_def.h index e9bcae3..d384684 100644 --- a/include/ogl_def.h +++ b/include/ogl_def.h @@ -164,3 +164,4 @@ typedef struct void R_RenderSkyHemispheres(int hemis); #endif + diff --git a/include/ogl_font.h b/include/ogl_font.h index 705a4cf..55d565d 100644 --- a/include/ogl_font.h +++ b/include/ogl_font.h @@ -44,3 +44,4 @@ int FR_TextHeight(char *text); int FR_TextOut(int x, int y, char *text); #endif // __OGL_FONT_RENDERER_H__ + diff --git a/include/ogl_rl.h b/include/ogl_rl.h index 196c252..560ab10 100644 --- a/include/ogl_rl.h +++ b/include/ogl_rl.h @@ -50,3 +50,4 @@ void RL_RenderAllLists(); void SetVertexColor(float light, float dist, float alpha); #endif + diff --git a/include/ogl_tex.h b/include/ogl_tex.h index 8f7b83b..e1cc93d 100644 --- a/include/ogl_tex.h +++ b/include/ogl_tex.h @@ -2,4 +2,4 @@ #define __OGLTEX_H__ -#endif \ No newline at end of file +#endif diff --git a/include/oss.h b/include/oss.h index ca01e78..a7d9638 100644 --- a/include/oss.h +++ b/include/oss.h @@ -36,3 +36,4 @@ extern OSSConfig oss_cfg; #endif + diff --git a/include/p_local.h b/include/p_local.h index 00b1b42..b7e4801 100644 --- a/include/p_local.h +++ b/include/p_local.h @@ -318,7 +318,7 @@ typedef enum { PODOOR_NONE, PODOOR_SLIDE, - PODOOR_SWING, + PODOOR_SWING } podoortype_t; typedef struct @@ -377,3 +377,4 @@ boolean PO_Busy(int polyobj); #include "p_spec.h" #endif // __P_LOCAL__ + diff --git a/include/p_spec.h b/include/p_spec.h index b86e423..ca07a29 100644 --- a/include/p_spec.h +++ b/include/p_spec.h @@ -235,8 +235,7 @@ typedef enum { PLAT_UP, PLAT_DOWN, - PLAT_WAITING, -// PLAT_IN_STASIS + PLAT_WAITING } plat_e; typedef enum @@ -245,9 +244,7 @@ typedef enum PLAT_DOWNWAITUPSTAY, PLAT_DOWNBYVALUEWAITUPSTAY, PLAT_UPWAITDOWNSTAY, - PLAT_UPBYVALUEWAITDOWNSTAY, - //PLAT_RAISEANDCHANGE, - //PLAT_RAISETONEARESTANDCHANGE + PLAT_UPBYVALUEWAITDOWNSTAY } plattype_e; typedef struct @@ -291,7 +288,7 @@ typedef enum DREV_CLOSE30THENOPEN, DREV_CLOSE, DREV_OPEN, - DREV_RAISEIN5MINS, + DREV_RAISEIN5MINS } vldoor_e; typedef struct @@ -561,3 +558,4 @@ boolean EV_ThingActivate(int tid); boolean EV_ThingDeactivate(int tid); boolean EV_ThingRemove(int tid); boolean EV_ThingDestroy(int tid); + diff --git a/include/sounds.h b/include/sounds.h index 1fbb7f4..a3527b0 100644 --- a/include/sounds.h +++ b/include/sounds.h @@ -309,3 +309,4 @@ typedef enum } sfxenum_t; #endif + diff --git a/include/soundst.h b/include/soundst.h index 22b24f1..468c5ba 100644 --- a/include/soundst.h +++ b/include/soundst.h @@ -79,3 +79,4 @@ void S_SetMusicVolume(void); boolean S_GetSoundPlayingInfo(mobj_t *mobj, int sound_id); #endif + diff --git a/include/st_start.h b/include/st_start.h index 1aac7c0..31a2296 100644 --- a/include/st_start.h +++ b/include/st_start.h @@ -26,3 +26,4 @@ extern void ST_NetProgress(void); extern void ST_NetDone(void); // PUBLIC DATA DECLARATIONS ------------------------------------------------ + diff --git a/include/textdefs.h b/include/textdefs.h index 4f3ce6f..ac16aaf 100644 --- a/include/textdefs.h +++ b/include/textdefs.h @@ -169,3 +169,4 @@ #define AMSTR_FOLLOWON "FOLLOW MODE ON" #define AMSTR_FOLLOWOFF "FOLLOW MODE OFF" + diff --git a/include/vgaview.h b/include/vgaview.h index 3128f72..2fce41b 100644 --- a/include/vgaview.h +++ b/include/vgaview.h @@ -32,3 +32,4 @@ extern byte *bytebuffer; - setScale:(int)newscale; @end + diff --git a/include/x11window.h b/include/x11window.h index 9dde534..6337b63 100644 --- a/include/x11window.h +++ b/include/x11window.h @@ -109,7 +109,7 @@ private: enum eFlags { - kOpenedDisplay = 0x0001, + kOpenedDisplay = 0x0001 }; Display* _display; // The X11 display connection @@ -128,3 +128,4 @@ private: #endif // X11WINDOW_H + diff --git a/include/xddefs.h b/include/xddefs.h index a9b124d..4a74810 100644 --- a/include/xddefs.h +++ b/include/xddefs.h @@ -233,3 +233,4 @@ typedef struct } pic_t; #endif // __XDDEFS__ + diff --git a/include/xshmext.h b/include/xshmext.h index e447794..5d4078c 100644 --- a/include/xshmext.h +++ b/include/xshmext.h @@ -75,3 +75,4 @@ private: #endif // XSHMEXT_H + diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..e9de238 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/opengl/i_gl.cpp b/opengl/i_gl.cpp deleted file mode 100644 index ae9270b..0000000 --- a/opengl/i_gl.cpp +++ /dev/null @@ -1,700 +0,0 @@ -//************************************************************************** -//** -//** $Id$ -//** -//************************************************************************** - - -#include -#include -#include -#include -#include -#include -#include -#include "x11window.h" -#include -#include -#include - - -extern "C" { -#include "h2def.h" - -extern void OGL_InitData(); -extern void OGL_InitRenderer(); -extern void OGL_ResetData(); -extern void OGL_ResetLumpTexData(); -} - - -void OGL_GrabScreen(); - - -class HexenWindow : public X11Window -{ -public: - - HexenWindow(); - - ~HexenWindow(); - - void swap() { glXSwapBuffers( display(), window() ); } - - GLXContext context() { return _ctx; } - - void ungrabPointer() - { - XUngrabPointer( display(), CurrentTime ); - showCursor(); - _grabCursor = false; - } - - void grabPointer() - { - XGrabPointer( display(), window(), True, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask, - GrabModeAsync, GrabModeAsync, window(), None, CurrentTime ); - hideCursor(); - _grabCursor = true; - } - -protected: - - virtual void unknownEvent( XEvent* ); - virtual void configureEvent( XConfigureEvent* ); - virtual void deleteEvent( XEvent* ); - virtual void buttonDown( XButtonEvent* ); - virtual void buttonUp( XButtonEvent* ); - virtual void motionEvent( XMotionEvent* ); - virtual void keyDown( XKeyEvent* ); - virtual void keyUp( XKeyEvent* ); - virtual void exposeEvent( XExposeEvent* ); - -private: - - void postKey( evtype_t type, KeySym key ); - void postMouseEvent( int dx, int dy ); - - GLXContext _ctx; - XVisualInfo* _vinfo; - - int _prevX, _prevY; - int _buttons; - bool _grabCursor; -}; - - -HexenWindow* _win; - - -extern "C" { - - -// Public Data - -int screenWidth = SCREENWIDTH*2; -int screenHeight = SCREENHEIGHT*2; -int maxTexSize = 256; -int ratioLimit = 0; // Zero if none. -int test3dfx = 0; - -int DisplayTicker = 0; - -extern int ticcount; - -extern boolean novideo; // if true, stay in text mode for debugging - - -//================================================== - -#define MOUSEB1 1 -#define MOUSEB2 2 -#define MOUSEB3 4 - -//================================================== - -#define KEY_TAB 9 // From am_map.h - -#define KEY_INS 0x52 -#define KEY_DEL 0x53 -#define KEY_PGUP 0x49 -#define KEY_PGDN 0x51 -#define KEY_HOME 0x47 -#define KEY_END 0x4f - - -/* -============================================================================ - - USER INPUT - -============================================================================ -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_WaitVBL -// -//-------------------------------------------------------------------------- - -void I_WaitVBL(int vbls) -{ - if( novideo ) - { - return; - } - while( vbls-- ) - { - usleep( 16667 ); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_SetPalette -// -// Palette source must use 8 bit RGB elements. -// -//-------------------------------------------------------------------------- - -void I_SetPalette( byte *palette ) -{ -} - -/* -============================================================================ - - GRAPHICS MODE - -============================================================================ -*/ - -/* -============== -= -= I_Update -= -============== -*/ - -int UpdateState; -extern int screenblocks; - -void I_Update (void) -{ - if( UpdateState == I_NOUPDATE ) - return; - - _win->swap(); - - UpdateState = I_NOUPDATE; // clear out all draw types -} - - -//-------------------------------------------------------------------------- -// -// PROC I_InitGraphics -// -//-------------------------------------------------------------------------- - -void I_InitGraphics(void) -{ - int p; - - if( novideo ) - { - return; - } - p = M_CheckParm( "-height" ); - if (p && p < myargc - 1) - { - screenHeight = atoi(myargv[p+1]); - } - p = M_CheckParm( "-width" ); - if( p && p < myargc - 1 ) - { - screenWidth = atoi(myargv[p+1]); - } - ST_Message("Screen Width %d, Screen Height %d\n",screenWidth, screenHeight); - _win = new HexenWindow(); - if( ! _win ) - { - exit( 3 ); - } - - //OGL_InitData(); // JHexen has this at the end of R_Init(). - OGL_InitRenderer(); - - // Clear the buffers. - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - _win->swap(); - - // Print some OpenGL information. - ST_Message( "I_InitGraphics: OpenGL information:\n" ); - ST_Message( " Vendor: %s\n", glGetString(GL_VENDOR) ); - ST_Message( " Renderer: %s\n", glGetString(GL_RENDERER) ); - ST_Message( " Version: %s\n", glGetString(GL_VERSION) ); - ST_Message( " GLU Version: %s\n", gluGetString((GLenum)GLU_VERSION) ); - - // Check the maximum texture size. - glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTexSize ); - ST_Message(" Maximum texture size: %d\n", maxTexSize); - if( maxTexSize == 256 ) - { - //ST_Message(" Is this Voodoo? Using size ratio limit.\n"); - ratioLimit = 8; - } - - if( M_CheckParm("-3dfxtest") ) - { - test3dfx = 1; - ST_Message(" 3dfx test mode.\n"); - } - - _win->show(); - - //I_SetPalette( (byte*) W_CacheLumpName("PLAYPAL", PU_CACHE) ); - _win->grabPointer (); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ShutdownGraphics -// -//-------------------------------------------------------------------------- - -void I_ShutdownGraphics(void) -{ - OGL_ResetData(); - OGL_ResetLumpTexData(); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ReadScreen -// -// Reads the screen currently displayed into a linear buffer. -// -//-------------------------------------------------------------------------- - -/* -void I_ReadScreen(byte *scr) -{ - memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); -} -*/ - -//=========================================================================== - - -void I_StartTic (void) -{ - // Handle keyboard & mouse events. - - while( _win->eventsPending() ) - _win->handleNextEvent(); - - //I_ReadMouse(); -} - - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - - -/* -================ -= -= I_TimerISR -= -================ -*/ - -int I_TimerISR (void) -{ - ticcount++; - return 0; -} - - -/* -============================================================================ - - MOUSE - -============================================================================ -*/ - - -/* -================ -= -= StartupMouse -= -================ -*/ - -void I_StartupCyberMan(void); - -void I_StartupMouse (void) -{ - I_StartupCyberMan(); -} - - -/* -================ -= -= I_ReadMouse -= -================ -*/ - -void I_ReadMouse (void) -{ -} - - - -//========================================================================== -// -// -// I_StartupReadKeys -// -// -//========================================================================== - -void I_StartupReadKeys(void) -{ - //if( KEY_ESCAPE pressed ) - // I_Quit (); -} - - -void checkGLContext() -{ - GLXContext c = glXGetCurrentContext(); - if( ! c || (c != _win->context()) ) - printf( "Bad context!\n" ); - else - printf( "context ok\n" ); -} - -} // extern "C" - - -//--------------------------------------------------------------------------- - - -HexenWindow::HexenWindow() - : X11Window( "HHEXEN", 0, 0, screenWidth, screenHeight ) -{ - int attrib[] = { GLX_RGBA, - GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, - GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, None }; - - _ctx = 0; - _vinfo = 0; - _grabCursor = true; - - _buttons = 0; - _prevX = _prevY = 0; - - if( glXQueryExtension( display(), 0, 0 ) == 0 ) - { - fprintf( stderr, "GLX Extension not available!\n" ); - return; - } - - _vinfo = glXChooseVisual( display(), screen(), attrib ); - if( ! _vinfo ) - { - fprintf( stderr, "Couldn't get an RGB, double-buffered visual!\n" ); - return; - } - - _ctx = glXCreateContext( display(), _vinfo, NULL, True ); - glXMakeCurrent( display(), window(), _ctx ); - - setTitle( "HHexen v1.3" ); - setSizeHints( screenWidth,screenHeight,screenWidth,screenHeight ); - setIconName( "HHEXEN" ); -} - - -HexenWindow::~HexenWindow() -{ - if( _ctx ) - { - glXDestroyContext( display(), _ctx ); - } -} - - -void HexenWindow::deleteEvent( XEvent* ) -{ - I_Quit(); -} - -void HexenWindow::configureEvent( XConfigureEvent* e ) -{ - screenWidth = width(); - screenHeight = height(); -} - -void HexenWindow::unknownEvent( XEvent* e ) -{ -} - - -void HexenWindow::buttonDown( XButtonEvent* e ) -{ - if( ! _grabCursor ) - grabPointer(); - - switch( e->button ) - { - case Button1: _buttons |= MOUSEB1 ; break; - case Button2: _buttons |= MOUSEB2 ; break; - case Button3: _buttons |= MOUSEB3 ; break; - default: - return; - } - postMouseEvent( 0, 0 ); -} - - -void HexenWindow::buttonUp( XButtonEvent* e ) -{ - switch( e->button ) - { - case Button1: _buttons &= ~MOUSEB1 ; break; - case Button2: _buttons &= ~MOUSEB2 ; break; - case Button3: _buttons &= ~MOUSEB3 ; break; - default: - return; - } - postMouseEvent( 0, 0 ); -} - - -void HexenWindow::motionEvent( XMotionEvent* e ) -{ - - int dx,dy; - - if (e->x == width()/2 && e->y == height()/2) - { - _prevX = e->x; - _prevY = e->y; - return; - } - dx = (e->x - _prevX); - _prevX = e->x; - dy = (e->y - _prevY); - _prevY = e->y; - - if( dx || dy ) - { - postMouseEvent( dx, dy ); - - if( _grabCursor ) - { - if( (e->x < 30) || (e->x > (screenWidth-30)) || - (e->y < 30) || (e->y > (screenHeight-30)) ) - { - XWarpPointer( display(), None, window(), 0, 0, 0, 0, - screenWidth / 2, screenHeight / 2 ); - _prevX = e->x; _prevY = e->y; - } - } - } -} - -void HexenWindow::keyDown( XKeyEvent* e ) -{ - KeySym key = keysym( e ); - - //TODO: filter key repeat. - - if( e->state & Mod1Mask ) // Control key defaults to attack. - { - if( key == XK_s ) - { - OGL_GrabScreen(); - } - else if( key == XK_g ) - { - if( _grabCursor ) - { - ungrabPointer(); - } - else - { - grabPointer(); - } - } - } - else - { - postKey( ev_keydown, key ); - } -} - - -void HexenWindow::keyUp( XKeyEvent* e ) -{ - postKey( ev_keyup, keysym( e ) ); -} - - -void HexenWindow::exposeEvent( XExposeEvent* ) -{ - UpdateState |= I_FULLSCRN; -} - - -void HexenWindow::postKey( evtype_t type, KeySym key ) -{ - event_t ev; - - ev.type = type; - - switch( key ) - { - case XK_Up: ev.data1 = KEY_UPARROW; break; - case XK_Down: ev.data1 = KEY_DOWNARROW; break; - case XK_Left: ev.data1 = KEY_LEFTARROW; break; - case XK_Right: ev.data1 = KEY_RIGHTARROW; break; - - case XK_Escape: ev.data1 = KEY_ESCAPE; break; - case XK_Return: ev.data1 = KEY_ENTER; break; - case XK_F1: ev.data1 = KEY_F1; break; - case XK_F2: ev.data1 = KEY_F2; break; - case XK_F3: ev.data1 = KEY_F3; break; - case XK_F4: ev.data1 = KEY_F4; break; - case XK_F5: ev.data1 = KEY_F5; break; - case XK_F6: ev.data1 = KEY_F6; break; - case XK_F7: ev.data1 = KEY_F7; break; - case XK_F8: ev.data1 = KEY_F8; break; - case XK_F9: ev.data1 = KEY_F9; break; - case XK_F10: ev.data1 = KEY_F10; break; - case XK_F11: ev.data1 = KEY_F11; break; - case XK_F12: ev.data1 = KEY_F12; break; - - case XK_Insert: ev.data1 = KEY_INS; break; - case XK_Delete: ev.data1 = KEY_DEL; break; - case XK_Page_Up: ev.data1 = KEY_PGUP; break; - case XK_Page_Down: ev.data1 = KEY_PGDN; break; - case XK_Home: ev.data1 = KEY_HOME; break; - case XK_End: ev.data1 = KEY_END; break; - - case XK_Tab: ev.data1 = KEY_TAB; break; - - case XK_BackSpace: ev.data1 = KEY_BACKSPACE; break; - - case XK_Pause: ev.data1 = KEY_PAUSE; break; - - case XK_equal: ev.data1 = KEY_EQUALS; break; - - case XK_KP_Subtract: - case XK_minus: ev.data1 = KEY_MINUS; break; - - case XK_Shift_L: - case XK_Shift_R: ev.data1 = KEY_RSHIFT; break; - - case XK_Control_L: - case XK_Control_R: ev.data1 = KEY_RCTRL; break; - - case XK_Alt_L: - case XK_Alt_R: - case XK_Meta_L: - case XK_Meta_R: ev.data1 = KEY_RALT; break; - - default: - ev.data1 = key; - break; - } - - H2_PostEvent( &ev ); -} - - -void HexenWindow::postMouseEvent( int dx, int dy ) -{ - event_t ev; - - ev.type = ev_mouse; - ev.data1 = _buttons; - ev.data2 = (short) dx << 2; - ev.data3 = -(short) dy << 2; - - H2_PostEvent( &ev ); -} - - -// Returns zero if a unique file name could not be found. -static int makeUniqueFilename( char* filename ) -{ - int i; - - for( i = 0; i < 100; i++ ) - { - sprintf( filename, "hexen%02d.ppm", i ); - - if( access( filename, F_OK ) == -1 ) - { - // It does not exist. - return 1; - } - } - - return 0; -} - - -//-------------------------------------------------------------------------- -// -// Copies the current contents of the frame buffer and returns a pointer -// to data containing 24-bit RGB triplets. -// -//-------------------------------------------------------------------------- - -void OGL_GrabScreen() -{ - FILE* fp; - char filename[ 20 ]; - unsigned char* buffer = new unsigned char[ screenWidth * screenHeight * 3 ]; - - if( buffer && makeUniqueFilename( filename ) ) - { - glReadPixels( 0, 0, screenWidth, screenHeight, GL_RGB, - GL_UNSIGNED_BYTE, buffer ); - - fp = fopen( filename, "w" ); - if( fp ) - { - unsigned char* rgb = buffer + (screenWidth * screenHeight * 3); - - fprintf( fp, "P6\n%d %d\n255\n", screenWidth, screenHeight ); - - while( rgb > buffer ) - { - rgb -= 3 * screenWidth; - fwrite( rgb, 1, 3 * screenWidth, fp ); - } - - fclose( fp ); - } - } - - delete buffer; -} - -//EOF diff --git a/opengl/m_bams.c b/opengl/m_bams.c index 25feea4..004fe6d 100644 --- a/opengl/m_bams.c +++ b/opengl/m_bams.c @@ -55,4 +55,4 @@ binangle bamsAtan2(int y,int x) } // This is the final angle. return bang; -} \ No newline at end of file +} diff --git a/opengl/ogl_clip.c b/opengl/ogl_clip.c index b4aa06f..9db2625 100644 --- a/opengl/ogl_clip.c +++ b/opengl/ogl_clip.c @@ -377,8 +377,9 @@ int C_CheckSubsector(subsector_t *ssec) { int i; // clipnode_t *cnode=0; - binangle *anglist = _alloca(sizeof(binangle)*ssec->numedgeverts); + binangle *anglist = (binangle*)malloc(sizeof(binangle)*ssec->numedgeverts); + if (anglist == NULL) I_Error ("Couldn't allocate memory"); // extern perfclock_t miscclock; //PC_Start(&miscclock); @@ -427,14 +428,15 @@ int C_CheckSubsector(subsector_t *ssec) // Choose the start and end points so that length is < 180. if(angLen < BANG_180) { - if(C_SafeCheckRange(anglist[i], anglist[end])) return 1; + if(C_SafeCheckRange(anglist[i], anglist[end])) { free(anglist); return 1; } } else { - if(C_SafeCheckRange(anglist[end], anglist[i])) return 1; + if(C_SafeCheckRange(anglist[end], anglist[i])) { free(anglist); return 1; } } } // All the edges were clipped totally away. + free (anglist); return 0; /* truexit: @@ -478,3 +480,4 @@ truexit: */ } + diff --git a/opengl/ogl_draw.c b/opengl/ogl_draw.c index 90b1a68..d908053 100644 --- a/opengl/ogl_draw.c +++ b/opengl/ogl_draw.c @@ -373,3 +373,4 @@ int OGL_DrawFilter() glEnable( GL_TEXTURE_2D ); return 1; } + diff --git a/opengl/ogl_font.c b/opengl/ogl_font.c index de5c31e..641b95c 100644 --- a/opengl/ogl_font.c +++ b/opengl/ogl_font.c @@ -291,3 +291,4 @@ int FR_GetCurrent() if(current == -1) return 0; return fonts[current].id; } + diff --git a/opengl/ogl_rend.c b/opengl/ogl_rend.c index 863a5e6..968af36 100644 --- a/opengl/ogl_rend.c +++ b/opengl/ogl_rend.c @@ -1106,3 +1106,4 @@ void OGL_DrawPSprite(int x, int y, float scale, int flip, int lump) glEnd(); } + diff --git a/opengl/ogl_rl.c b/opengl/ogl_rl.c index 9d225c7..c3c9519 100644 --- a/opengl/ogl_rl.c +++ b/opengl/ogl_rl.c @@ -230,11 +230,11 @@ void RL_AddFlatQuads(rendquad_t *base, GLuint quadtex, int numvrts, } // Calculate the distance to each vertex. - distances = _alloca(sizeof(float)*numvrts); + distances = (float *)malloc(sizeof(float)*numvrts); for(i=0; imidpoint.x); if(!(base->flags & RQF_LIGHT) && middist > 256) @@ -301,6 +301,8 @@ void RL_AddFlatQuads(rendquad_t *base, GLuint quadtex, int numvrts, if(base->flags & RQF_LIGHT) RL_DynLightQuad(qi, (lumobj_t*)quadtex); } } + free (vrts); + free (distances); } void SetVertexColor(float light, float dist, float alpha) diff --git a/opengl/ogl_sky.c b/opengl/ogl_sky.c index 7457a93..5aff2d7 100644 --- a/opengl/ogl_sky.c +++ b/opengl/ogl_sky.c @@ -257,3 +257,4 @@ void R_RenderSkyHemispheres(int hemis) glPopAttrib(); glDepthMask(GL_TRUE); } + diff --git a/opengl/ogl_tex.c b/opengl/ogl_tex.c index ae6dff1..5f5de0e 100644 --- a/opengl/ogl_tex.c +++ b/opengl/ogl_tex.c @@ -199,7 +199,7 @@ unsigned int OGL_BindTexFlat(int lump) int p, i; byte *flatptr = W_CacheLumpNum(lump, PU_STATIC); byte *palette = W_CacheLumpNum(pallump=W_GetNumForName("PLAYPAL"), PU_CACHE); - byte *rgbflat = _alloca(3*lumpinfo[lump].size); + byte *rgbflat = (byte*)malloc(3*lumpinfo[lump].size); //printf( "OGL_SetFlat: Loading flat %d.\n",idx); // Convert the data to RGB. @@ -222,6 +222,7 @@ unsigned int OGL_BindTexFlat(int lump) // Change the tag. Z_ChangeTag(flatptr, PU_CACHE); + free (rgbflat); return name; } @@ -331,7 +332,7 @@ unsigned int OGL_PrepareTexture(int idx) int i, k, textype; texture_t *tex = textures[idx]; byte *palette = W_CacheLumpNum(pallump, PU_CACHE); - byte *rgbflat = _alloca(3*tex->width*tex->height); + byte *rgbflat = (byte *)malloc(3*tex->width*tex->height); byte *colptr; if(tex->patchcount > 1) @@ -347,11 +348,12 @@ unsigned int OGL_PrepareTexture(int idx) else { // This texture has only only one patch. It might be masked. - byte *rgbaflat = _alloca(4*tex->width*tex->height); + byte *rgbaflat = (byte*)malloc(4*tex->width*tex->height); memset(rgbaflat, 0, 4*tex->width*tex->height); textype = DrawRealPatch(rgbflat, rgbaflat, palette, tex->width, tex->height, W_CacheLumpNum(tex->patches[0].patch, PU_CACHE), false); if(textype == GL_RGBA) rgbflat = rgbaflat; + free (rgbaflat); } // Generate and bind the texture. @@ -364,6 +366,8 @@ unsigned int OGL_PrepareTexture(int idx) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if(textype == GL_RGBA) texmasked[idx] = 1; // Yes it is. + + free (rgbflat); } texw = textures[idx]->width; texh = textures[idx]->height; @@ -436,13 +440,13 @@ unsigned int OGL_PrepareSky(int idx, boolean zeroMask) if(zeroMask) { textype = GL_RGBA; - imgdata = _alloca(4*numpels); + imgdata = (byte *)malloc(4*numpels); memset(imgdata, 0, 4*numpels); } else { textype = GL_RGB; - imgdata = _alloca(3*numpels); + imgdata = (byte *)malloc(3*numpels); memset(imgdata, 0, 3*numpels); } if(tex->patchcount > 1) @@ -508,6 +512,8 @@ unsigned int OGL_PrepareSky(int idx, boolean zeroMask) texmasked[idx] = 1; else texmasked[idx] = 0; + + free (imgdata); } texw = textures[idx]->width; texh = textures[idx]->height; @@ -524,7 +530,7 @@ unsigned int OGL_PrepareSprite(int pnum) int p2width = FindNextPower2(patch->width), p2height = OGL_ValidTexHeight2(patch->width, patch->height);// FindNextPower2(patch->height); int flatsize = 4*p2width*p2height; - byte *rgbaflat = _alloca(flatsize); + byte *rgbaflat = (byte *)malloc(flatsize); //printf( "orig: %d x %d => %d x %d\n", patch->width, patch->height, p2width, p2height); @@ -543,6 +549,7 @@ unsigned int OGL_PrepareSprite(int pnum) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); spriteheights[pnum] = patch->height; + free (rgbaflat); } return spritenames[pnum]; } @@ -576,8 +583,8 @@ void OGL_SetRawImage(int lump, int part) // Load the raw texture data (320x200). // We'll create two textures (256x256 and 64x256). byte *raw = W_CacheLumpNum(lump, PU_CACHE); - byte *dat1 = _alloca(3*256*256); // Let's hope there's enough stack! - byte *dat2 = _alloca(3*64*256); + byte *dat1 = (byte*)malloc(3*256*256); + byte *dat2 = (byte*)malloc(3*64*256); byte *palette = W_CacheLumpNum(pallump, PU_CACHE); int i,k; memset(dat1, 0, 3*256*256); // Why must this be done? @@ -624,6 +631,8 @@ void OGL_SetRawImage(int lump, int part) lumptexsizes[lump].w = 256; lumptexsizes[lump].w2 = 64; lumptexsizes[lump].h = 200; + free (dat1); + free (dat2); } // Bind the correct part. if(part <= 1) glBindTexture(GL_TEXTURE_2D, lumptexnames[lump]); @@ -677,8 +686,8 @@ void OGL_SetPatch(int lump) // No mipmaps are generated. int p2width = FindNextPower2(patch->width), p2height = OGL_ValidTexHeight2(patch->width, patch->height);//FindNextPower2(patch->height); int numpels = p2width*p2height; - byte *rgbflat = _alloca(3*numpels), - *rgbaflat = _alloca(4*numpels); + byte *rgbflat = (byte *)malloc(3*numpels), + *rgbaflat = (byte*)malloc(4*numpels); int ptype; memset(rgbaflat, 0, 4*numpels); @@ -692,7 +701,7 @@ void OGL_SetPatch(int lump) // No mipmaps are generated. // applies to both parts. // The width of the first part is maxTexSize. int part2width = FindNextPower2(patch->width - maxTexSize); - byte *tempbuff = _alloca(4*maxTexSize*p2height); + byte *tempbuff = (byte*)malloc(4*maxTexSize*p2height); if(part2width > maxTexSize) I_Error("OGL_SetPatch: Too wide texture (really: %d, pow2: %d).\n", patch->width, p2width); // We'll use a temporary buffer for doing to splitting. @@ -730,6 +739,7 @@ void OGL_SetPatch(int lump) // No mipmaps are generated. lumptexsizes[lump].w = maxTexSize; lumptexsizes[lump].w2 = patch->width - maxTexSize; + free (tempbuff); } else // We can use the normal one-part method. { @@ -749,6 +759,8 @@ void OGL_SetPatch(int lump) // No mipmaps are generated. lumptexsizes[lump].h = patch->height; lumptexsizes[lump].offx = -patch->leftoffset; lumptexsizes[lump].offy = -patch->topoffset; + free (rgbflat); + free (rgbaflat); } else { @@ -851,3 +863,4 @@ void OGL_UpdateRawScreenParams(int smoothing) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glmode); } } + diff --git a/sdl/i_sdl.c b/sdl/i_sdl.c new file mode 100644 index 0000000..36d5744 --- /dev/null +++ b/sdl/i_sdl.c @@ -0,0 +1,517 @@ +//************************************************************************** +//** +//** $Id$ +//** +//************************************************************************** + + +#include +#include +#include +#include "SDL.h" +#include "h2def.h" +#include "r_local.h" +#include "p_local.h" // for P_AproxDistance +#include "sounds.h" +#include "i_sound.h" +#include "soundst.h" +#include "st_start.h" + +// Public Data + +int DisplayTicker = 0; + + +// Code + +void I_StartupNet (void); +void I_ShutdownNet (void); +void I_ReadExternDriver(void); +void GrabScreen (void); + +extern int usemouse, usejoystick; + +extern void **lumpcache; + +int i_Vector; +externdata_t *i_ExternData; +boolean useexterndriver; + +SDL_Surface* sdl_screen; + +boolean mousepresent; + +//=============================== + +int ticcount; + + +boolean novideo; // if true, stay in text mode for debugging + +#define KEY_INS 0x52 +#define KEY_DEL 0x53 +#define KEY_PGUP 0x49 +#define KEY_PGDN 0x51 +#define KEY_HOME 0x47 +#define KEY_END 0x4f + +/* +============================================================================ + + USER INPUT + +============================================================================ +*/ + +//-------------------------------------------------------------------------- +// +// PROC I_WaitVBL +// +//-------------------------------------------------------------------------- + +void I_WaitVBL(int vbls) +{ + if( novideo ) + { + return; + } + while( vbls-- ) + { + SDL_Delay( 16667/1000 ); + } +} + +//-------------------------------------------------------------------------- +// +// PROC I_SetPalette +// +// Palette source must use 8 bit RGB elements. +// +//-------------------------------------------------------------------------- + +void I_SetPalette(byte *palette) +{ + SDL_Color* c; + SDL_Color* cend; + SDL_Color cmap[ 256 ]; + + if(novideo) + { + return; + } + I_WaitVBL(1); + + c = cmap; + cend = c + 256; + for( ; c != cend; c++ ) + { + //_outbyte(PEL_DATA, (gammatable[usegamma][*palette++])>>2); + + c->r = gammatable[usegamma][*palette++]; + c->g = gammatable[usegamma][*palette++]; + c->b = gammatable[usegamma][*palette++]; + } + SDL_SetColors( sdl_screen, cmap, 0, 256 ); +} + +/* +============================================================================ + + 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 + + SDL_UpdateRect( sdl_screen, 0, 0, SCREENWIDTH, SCREENHEIGHT ); + } + 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); + + SDL_UpdateRect( sdl_screen, 0, 0, SCREENWIDTH, + viewwindowy+viewheight ); + } + else + { + for(i = viewwindowy*SCREENWIDTH+viewwindowx; i < + (viewwindowy+viewheight)*SCREENWIDTH; i += SCREENWIDTH) + { + memcpy(pcscreen+i, screen+i, viewwidth); + } + UpdateState &= ~I_FULLVIEW; + + SDL_UpdateRect( sdl_screen, viewwindowx, viewwindowy, viewwidth, + viewheight ); + } + } + if(UpdateState&I_STATBAR) + { + memcpy(pcscreen+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), + screen+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), + SCREENWIDTH*SBARHEIGHT); + UpdateState &= ~I_STATBAR; + + SDL_UpdateRect( sdl_screen, 0, SCREENHEIGHT-SBARHEIGHT, + SCREENWIDTH, SBARHEIGHT ); + } + if(UpdateState&I_MESSAGES) + { + memcpy(pcscreen, screen, SCREENWIDTH*28); + UpdateState &= ~I_MESSAGES; + + SDL_UpdateRect( sdl_screen, 0, 0, SCREENWIDTH, 28 ); + } +} + +//-------------------------------------------------------------------------- +// +// PROC I_InitGraphics +// +//-------------------------------------------------------------------------- + +void I_InitGraphics(void) +{ + char text[20]; + + if( novideo ) + { + return; + } + + // SDL_DOUBLEBUF does not work in full screen mode. Does not seem to + // be necessary anyway. + + sdl_screen = SDL_SetVideoMode(SCREENWIDTH, SCREENHEIGHT, 8, SDL_SWSURFACE); + + if( sdl_screen == NULL ) + { + fprintf( stderr, "Couldn't set video mode %dx%d: %s\n", + SCREENWIDTH, SCREENHEIGHT, SDL_GetError() ); + exit( 3 ); + } + + // Only grab if we want to + if (!M_CheckParm ("--nograb") && !M_CheckParm ("-g")) { + SDL_WM_GrabInput (SDL_GRAB_ON); + } + + SDL_ShowCursor( 0 ); + snprintf (text, 20, "HHexen v%s", HHEXEN_VERSION); + SDL_WM_SetCaption( text, "HHEXEN" ); + + + pcscreen = destscreen = sdl_screen->pixels; + + I_SetPalette( W_CacheLumpName("PLAYPAL", PU_CACHE) ); +} + +//-------------------------------------------------------------------------- +// +// PROC I_ShutdownGraphics +// +//-------------------------------------------------------------------------- + +void I_ShutdownGraphics(void) +{ + SDL_Quit (); +} + +//-------------------------------------------------------------------------- +// +// PROC I_ReadScreen +// +// Reads the screen currently displayed into a linear buffer. +// +//-------------------------------------------------------------------------- + +/* +void I_ReadScreen(byte *scr) +{ + memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); +} +*/ + +//=========================================================================== + + +// +// Translates the key +// + +int xlatekey(SDL_keysym *key) +{ + + int rc; + + switch(key->sym) + { + case SDLK_LEFT: rc = KEY_LEFTARROW; break; + case SDLK_RIGHT: rc = KEY_RIGHTARROW; break; + case SDLK_DOWN: rc = KEY_DOWNARROW; break; + case SDLK_UP: rc = KEY_UPARROW; break; + case SDLK_ESCAPE: rc = KEY_ESCAPE; break; + case SDLK_RETURN: rc = KEY_ENTER; break; + case SDLK_F1: rc = KEY_F1; break; + case SDLK_F2: rc = KEY_F2; break; + case SDLK_F3: rc = KEY_F3; break; + case SDLK_F4: rc = KEY_F4; break; + case SDLK_F5: rc = KEY_F5; break; + case SDLK_F6: rc = KEY_F6; break; + case SDLK_F7: rc = KEY_F7; break; + case SDLK_F8: rc = KEY_F8; break; + case SDLK_F9: rc = KEY_F9; break; + case SDLK_F10: rc = KEY_F10; break; + case SDLK_F11: rc = KEY_F11; break; + case SDLK_F12: rc = KEY_F12; break; + + case SDLK_INSERT: rc = KEY_INS; break; + case SDLK_DELETE: rc = KEY_DEL; break; + case SDLK_PAGEUP: rc = KEY_PGUP; break; + case SDLK_PAGEDOWN: rc = KEY_PGDN; break; + case SDLK_HOME: rc = KEY_HOME; break; + case SDLK_END: rc = KEY_END; break; + + case SDLK_BACKSPACE: rc = KEY_BACKSPACE; break; + + case SDLK_PAUSE: rc = KEY_PAUSE; break; + + case SDLK_EQUALS: rc = KEY_EQUALS; break; + + case SDLK_KP_MINUS: + case SDLK_MINUS: rc = KEY_MINUS; break; + + case SDLK_LSHIFT: + case SDLK_RSHIFT: + rc = KEY_RSHIFT; + break; + + case SDLK_LCTRL: + case SDLK_RCTRL: + rc = KEY_RCTRL; + break; + + case SDLK_LALT: + case SDLK_LMETA: + case SDLK_RALT: + case SDLK_RMETA: + rc = KEY_RALT; + break; + + default: + rc = key->sym; + break; + } + + return rc; + +} + + +/* This processes SDL events */ +void I_GetEvent(SDL_Event *Event) +{ + Uint8 buttonstate; + event_t event; + SDLMod mod; + + switch (Event->type) + { + case SDL_KEYDOWN: + mod = SDL_GetModState (); + if (mod & KMOD_RALT || mod & KMOD_LALT) { + if (Event->key.keysym.sym == 'g') { + if (SDL_WM_GrabInput (SDL_GRAB_QUERY) == SDL_GRAB_OFF) + SDL_WM_GrabInput (SDL_GRAB_ON); + else + SDL_WM_GrabInput (SDL_GRAB_OFF); + } + } else { + event.type = ev_keydown; + event.data1 = xlatekey(&Event->key.keysym); + H2_PostEvent(&event); + } + break; + + case SDL_KEYUP: + event.type = ev_keyup; + event.data1 = xlatekey(&Event->key.keysym); + H2_PostEvent(&event); + break; + + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + buttonstate = SDL_GetMouseState(NULL, NULL); + event.type = ev_mouse; + event.data1 = 0 + | (buttonstate & SDL_BUTTON(1) ? 1 : 0) + | (buttonstate & SDL_BUTTON(2) ? 2 : 0) + | (buttonstate & SDL_BUTTON(3) ? 4 : 0); + event.data2 = event.data3 = 0; + H2_PostEvent(&event); + break; + + case SDL_MOUSEMOTION: + /* Ignore mouse warp events */ + if ( (Event->motion.x != sdl_screen->w/2) || + (Event->motion.y != sdl_screen->h/2) ) + { + /* Warp the mouse back to the center */ + event.type = ev_mouse; + event.data1 = 0 + | (Event->motion.state & SDL_BUTTON(1) ? 1 : 0) + | (Event->motion.state & SDL_BUTTON(2) ? 2 : 0) + | (Event->motion.state & SDL_BUTTON(3) ? 4 : 0); + event.data2 = Event->motion.xrel << 3; + event.data3 = -Event->motion.yrel << 3; + H2_PostEvent(&event); + } + break; + + case SDL_QUIT: + I_Quit(); + } + +} + +// +// I_StartTic +// +void I_StartTic (void) +{ + SDL_Event Event; + + while ( SDL_PollEvent(&Event) ) + I_GetEvent(&Event); +} + + +/* +============================================================================ + + TIMER INTERRUPT + +============================================================================ +*/ + + +/* +================ += += I_TimerISR += +================ +*/ + +int I_TimerISR (void) +{ + ticcount++; + return 0; +} + +/* +============================================================================ + + KEYBOARD + +============================================================================ +*/ + +int lastpress; + + + +/* +============================================================================ + + MOUSE + +============================================================================ +*/ + + +/* +================ += += StartupMouse += +================ +*/ + + +void I_StartupMouse (void) +{ + mousepresent = 1; +} + +void GrabScreen (void) +{ +} diff --git a/sdl/i_sdlgl.c b/sdl/i_sdlgl.c new file mode 100644 index 0000000..fc16330 --- /dev/null +++ b/sdl/i_sdlgl.c @@ -0,0 +1,485 @@ +//************************************************************************** +//** +//** $Id$ +//** +//************************************************************************** + +#include +#include +#include +#include +#include +#include +#include +#include +#include "h2def.h" +#include "r_local.h" +#include "p_local.h" // for P_AproxDistance +#include "sounds.h" +#include "i_sound.h" +#include "soundst.h" +#include "st_start.h" + +// Public Data + +int screenWidth = SCREENWIDTH*2; +int screenHeight = SCREENHEIGHT*2; +int maxTexSize = 256; +int ratioLimit = 0; // Zero if none. +int test3dfx = 0; + +int DisplayTicker = 0; + + +// Code +extern void OGL_InitData(); +extern void OGL_InitRenderer(); +extern void OGL_ResetData(); +extern void OGL_ResetLumpTexData(); + +void I_StartupNet (void); +void I_ShutdownNet (void); +void I_ReadExternDriver(void); +void GrabScreen (void); + +extern int usemouse, usejoystick; + +extern void **lumpcache; + +int i_Vector; +externdata_t *i_ExternData; +boolean useexterndriver; + +boolean mousepresent; + +int ticcount; + +boolean novideo; // if true, stay in text mode for debugging + +#define KEY_INS 0x52 +#define KEY_DEL 0x53 +#define KEY_PGUP 0x49 +#define KEY_PGDN 0x51 +#define KEY_HOME 0x47 +#define KEY_END 0x4f + +//-------------------------------------------------------------------------- +// +// PROC I_WaitVBL +// +//-------------------------------------------------------------------------- + +void I_WaitVBL(int vbls) +{ + if( novideo ) + { + return; + } + while( vbls-- ) + { + SDL_Delay( 16667/1000 ); + } +} + +//-------------------------------------------------------------------------- +// +// PROC I_SetPalette +// +// Palette source must use 8 bit RGB elements. +// +//-------------------------------------------------------------------------- + +void I_SetPalette(byte *palette) +{ +/* + SDL_Color* c; + SDL_Color* cend; + SDL_Color cmap[ 256 ]; + + if(novideo) + { + return; + } + I_WaitVBL(1); + + c = cmap; + cend = c + 256; + for( ; c != cend; c++ ) + { + //_outbyte(PEL_DATA, (gammatable[usegamma][*palette++])>>2); + + c->r = gammatable[usegamma][*palette++]; + c->g = gammatable[usegamma][*palette++]; + c->b = gammatable[usegamma][*palette++]; + } + SDL_SetColors( sdl_screen, cmap, 0, 256 ); +*/ +} + +/* +============================================================================ + + GRAPHICS MODE + +============================================================================ +*/ + +byte *pcscreen, *destscreen, *destview; + +/* +============== += += I_Update += +============== +*/ + +int UpdateState; +extern int screenblocks; + +void I_Update (void) +{ + if(UpdateState == I_NOUPDATE) + return; + + SDL_GL_SwapBuffers(); + UpdateState = I_NOUPDATE; +} + +//-------------------------------------------------------------------------- +// +// PROC I_InitGraphics +// +//-------------------------------------------------------------------------- + +void I_InitGraphics(void) +{ + int p; + char text[20]; + Uint32 flags = SDL_OPENGL; + + if( novideo ) + { + return; + } + + p = M_CheckParm ("-fullscreen"); + if (p) { + flags |= SDL_FULLSCREEN; + setenv ("MESA_GLX_FX","fullscreen", 1); + } else { + setenv ("MESA_GLX_FX","disable",1); + } + p = M_CheckParm ("-height"); + if (p && p < myargc - 1) + { + screenHeight = atoi (myargv[p+1]); + } + p = M_CheckParm ("-width"); + if (p && p < myargc - 1) { + screenWidth = atoi(myargv[p+1]); + } + ST_Message("Screen size: %dx%d\n",screenWidth, screenHeight); + + if(SDL_SetVideoMode(screenWidth, screenHeight, 8, flags) == NULL) + { + fprintf( stderr, "Couldn't set video mode %dx%d: %s\n", + screenWidth, screenHeight, SDL_GetError() ); + exit( 3 ); + } + + OGL_InitRenderer (); + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // Print some OpenGL information. + ST_Message( "I_InitGraphics: OpenGL information:\n" ); + ST_Message( " Vendor: %s\n", glGetString(GL_VENDOR) ); + ST_Message( " Renderer: %s\n", glGetString(GL_RENDERER) ); + ST_Message( " Version: %s\n", glGetString(GL_VERSION) ); + ST_Message( " GLU Version: %s\n", gluGetString((GLenum)GLU_VERSION) ); + + // Check the maximum texture size. + glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTexSize ); + ST_Message(" Maximum texture size: %d\n", maxTexSize); + if( maxTexSize == 256 ) + { + //ST_Message(" Is this Voodoo? Using size ratio limit.\n"); + ratioLimit = 8; + } + + if( M_CheckParm("-3dfxtest") ) + { + test3dfx = 1; + ST_Message(" 3dfx test mode.\n"); + } + + // Only grab if we want to + if (!M_CheckParm ("--nograb") && !M_CheckParm ("-g")) { + SDL_WM_GrabInput (SDL_GRAB_ON); + } + + SDL_ShowCursor( 0 ); + snprintf (text, 20, "HHexen v%s", HHEXEN_VERSION); + SDL_WM_SetCaption( text, "HHEXEN" ); + + + //I_SetPalette( W_CacheLumpName("PLAYPAL", PU_CACHE) ); +} + +//-------------------------------------------------------------------------- +// +// PROC I_ShutdownGraphics +// +//-------------------------------------------------------------------------- + +void I_ShutdownGraphics(void) +{ + OGL_ResetData (); + OGL_ResetLumpTexData (); + SDL_Quit (); +} + +//=========================================================================== + +// +// Translates the key +// + +int xlatekey(SDL_keysym *key) +{ + + int rc; + + switch(key->sym) + { + case SDLK_LEFT: rc = KEY_LEFTARROW; break; + case SDLK_RIGHT: rc = KEY_RIGHTARROW; break; + case SDLK_DOWN: rc = KEY_DOWNARROW; break; + case SDLK_UP: rc = KEY_UPARROW; break; + case SDLK_ESCAPE: rc = KEY_ESCAPE; break; + case SDLK_RETURN: rc = KEY_ENTER; break; + case SDLK_F1: rc = KEY_F1; break; + case SDLK_F2: rc = KEY_F2; break; + case SDLK_F3: rc = KEY_F3; break; + case SDLK_F4: rc = KEY_F4; break; + case SDLK_F5: rc = KEY_F5; break; + case SDLK_F6: rc = KEY_F6; break; + case SDLK_F7: rc = KEY_F7; break; + case SDLK_F8: rc = KEY_F8; break; + case SDLK_F9: rc = KEY_F9; break; + case SDLK_F10: rc = KEY_F10; break; + case SDLK_F11: rc = KEY_F11; break; + case SDLK_F12: rc = KEY_F12; break; + + case SDLK_INSERT: rc = KEY_INS; break; + case SDLK_DELETE: rc = KEY_DEL; break; + case SDLK_PAGEUP: rc = KEY_PGUP; break; + case SDLK_PAGEDOWN: rc = KEY_PGDN; break; + case SDLK_HOME: rc = KEY_HOME; break; + case SDLK_END: rc = KEY_END; break; + + case SDLK_BACKSPACE: rc = KEY_BACKSPACE; break; + + case SDLK_PAUSE: rc = KEY_PAUSE; break; + + case SDLK_EQUALS: rc = KEY_EQUALS; break; + + case SDLK_KP_MINUS: + case SDLK_MINUS: rc = KEY_MINUS; break; + + case SDLK_LSHIFT: + case SDLK_RSHIFT: + rc = KEY_RSHIFT; + break; + + case SDLK_LCTRL: + case SDLK_RCTRL: + rc = KEY_RCTRL; + break; + + case SDLK_LALT: + case SDLK_LMETA: + case SDLK_RALT: + case SDLK_RMETA: + rc = KEY_RALT; + break; + + default: + rc = key->sym; + break; + } + + return rc; + +} + + +/* This processes SDL events */ +void I_GetEvent(SDL_Event *Event) +{ + Uint8 buttonstate; + event_t event; + SDLMod mod; + + switch (Event->type) + { + case SDL_KEYDOWN: + mod = SDL_GetModState (); + if (mod & KMOD_RALT || mod & KMOD_LALT) { + if (Event->key.keysym.sym == 'g') { + if (SDL_WM_GrabInput (SDL_GRAB_QUERY) == SDL_GRAB_OFF) + SDL_WM_GrabInput (SDL_GRAB_ON); + else + SDL_WM_GrabInput (SDL_GRAB_OFF); + } + } else { + event.type = ev_keydown; + event.data1 = xlatekey(&Event->key.keysym); + H2_PostEvent(&event); + } + break; + + case SDL_KEYUP: + event.type = ev_keyup; + event.data1 = xlatekey(&Event->key.keysym); + H2_PostEvent(&event); + break; + + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + buttonstate = SDL_GetMouseState(NULL, NULL); + event.type = ev_mouse; + event.data1 = 0 + | (buttonstate & SDL_BUTTON(1) ? 1 : 0) + | (buttonstate & SDL_BUTTON(2) ? 2 : 0) + | (buttonstate & SDL_BUTTON(3) ? 4 : 0); + event.data2 = event.data3 = 0; + H2_PostEvent(&event); + break; + + case SDL_MOUSEMOTION: + /* Ignore mouse warp events */ + if ( (Event->motion.x != SCREENWIDTH/2) || + (Event->motion.y != SCREENHEIGHT/2) ) + { + /* Warp the mouse back to the center */ + event.type = ev_mouse; + event.data1 = 0 + | (Event->motion.state & SDL_BUTTON(1) ? 1 : 0) + | (Event->motion.state & SDL_BUTTON(2) ? 2 : 0) + | (Event->motion.state & SDL_BUTTON(3) ? 4 : 0); + event.data2 = Event->motion.xrel << 3; + event.data3 = -Event->motion.yrel << 3; + H2_PostEvent(&event); + } + break; + + case SDL_QUIT: + I_Quit(); + } + +} + +// +// I_StartTic +// +void I_StartTic (void) +{ + SDL_Event Event; + + while ( SDL_PollEvent(&Event) ) + I_GetEvent(&Event); +} + + +/* +============================================================================ + + TIMER INTERRUPT + +============================================================================ +*/ + + +/* +================ += += I_TimerISR += +================ +*/ + +int I_TimerISR (void) +{ + ticcount++; + return 0; +} + +/* +============================================================================ + + MOUSE + +============================================================================ +*/ + +/* +================ += += StartupMouse += +================ +*/ + +void I_StartupMouse (void) +{ + mousepresent = 1; +} + +static int makeUniqueFilename( char* filename ) +{ + int i; + + for( i = 0; i < 100; i++ ) + { + sprintf( filename, "hexen%02d.bmp", i ); + + if( access( filename, F_OK ) == -1 ) + { + // It does not exist. + return 1; + } + } + + return 0; +} + +void GrabScreen () +{ + SDL_Surface *image; + SDL_Surface *temp; + int idx; + char filename[80]; + + if (makeUniqueFilename(filename)) { + image = SDL_CreateRGBSurface(SDL_SWSURFACE, screenWidth, screenHeight, + 24, 0x0000FF, 0x00FF00, 0xFF0000,0xFFFFFF); + temp = SDL_CreateRGBSurface(SDL_SWSURFACE, screenWidth, screenHeight, + 24, 0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF); + + glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, + GL_UNSIGNED_BYTE, image->pixels); + for (idx = 0; idx < screenHeight; idx++) + { + memcpy(temp->pixels + 3 * screenWidth * idx, + (char *)image->pixels + 3 + * screenWidth*(screenHeight - idx), + 3*screenWidth); + } + memcpy(image->pixels,temp->pixels,screenWidth * screenHeight * 3); + SDL_SaveBMP(image, filename); + SDL_FreeSurface(image); + } +} + diff --git a/svgalib/i_svgalib.c b/svgalib/i_svgalib.c deleted file mode 100644 index 5980bda..0000000 --- a/svgalib/i_svgalib.c +++ /dev/null @@ -1,632 +0,0 @@ -//************************************************************************** -//** -//** $Id$ -//** -//************************************************************************** - - -#include -#include -#include - -#include // SVGALib includes -#include -#include - -#include /* jim - usleep () */ - -#include /* jim - usleep () */ - -#include "h2def.h" -#include "r_local.h" -#include "p_local.h" // for P_AproxDistance -#include "sounds.h" -#include "i_sound.h" -#include "soundst.h" -#include "st_start.h" - -static enum {F_nomouse, F_mouse} mflag = F_nomouse; - -// Macros - -#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 -#define BITPLANE(p) - -#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) - -// Public Data - -int DisplayTicker = 0; - - -void I_ReadMouse (void); - -extern int usemouse; - - -//================================================== - -#define VBLCOUNTER 34000 // hardware tics to a frame - -#define MOUSEB1 1 -#define MOUSEB2 2 -#define MOUSEB3 4 - -boolean mousepresent; - -//=============================== - -extern int ticcount; - -extern boolean novideo; // if true, stay in text mode for debugging - -#define KBDQUESIZE 32 -byte keyboardque[KBDQUESIZE]; -int kbdtail, kbdhead; - - -#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 - }; - -//========================================================================== - - -/* -============================================================================ - - USER INPUT - -============================================================================ -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_WaitVBL -// -//-------------------------------------------------------------------------- - -void I_WaitVBL(int vbls) -{ - if( novideo ) - { - return; - } - while( vbls-- ) - { - usleep( 16667 ); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_SetPalette -// -// Palette source must use 8 bit RGB elements. -// -//-------------------------------------------------------------------------- -void I_SetPalette(byte *palette) -{ - register int* buf = NULL; - register short count = 256 / 2; - register int* p; - register unsigned char* gtable = gammatable[usegamma]; - - if(novideo) - { - return; - } - I_WaitVBL(1); - - //Code lynched from Collin Phipps' lsdoom - p = buf = Z_Malloc(256 * 3 * sizeof(int),PU_STATIC,NULL); - do { - //One RGB Triple - p[0]=gtable[palette[0]] >> 2; - p[1]=gtable[palette[1]] >> 2; - p[2]=gtable[palette[2]] >> 2; - //And another - p[3]=gtable[palette[3]] >> 2; - p[4]=gtable[palette[4]] >> 2; - p[5]=gtable[palette[5]] >> 2; - - p+=6; palette+=6; - } while (--count); - if(vga_oktowrite()) - vga_setpalvec(0,256,buf); - - Z_Free(buf); -} -/* -============================================================================ - - GRAPHICS MODE - -============================================================================ -*/ - -//byte *pcscreen; -byte *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) //Displays little dots in corner - { - if(screenblocks > 9 || UpdateState&(I_FULLSCRN|I_MESSAGES)) - { - dest = (byte *)screen; - } - else - { - dest = (byte*)graph_mem; - } - 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(graph_mem, 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(graph_mem+i, screen+i, SCREENWIDTH); - } - - UpdateState &= ~(I_FULLVIEW|I_MESSAGES); - } - else - { - for(i = viewwindowy*SCREENWIDTH+viewwindowx; i < - (viewwindowy+viewheight)*SCREENWIDTH; i += SCREENWIDTH) - { - memcpy(graph_mem+i, screen+i, viewwidth); - } - UpdateState &= ~I_FULLVIEW; - } - } - if(UpdateState&I_STATBAR) - { - memcpy(graph_mem+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), - screen+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), - SCREENWIDTH*SBARHEIGHT); - UpdateState &= ~I_STATBAR; - } - if(UpdateState&I_MESSAGES) - { - memcpy(graph_mem, screen, SCREENWIDTH*28); - UpdateState &= ~I_MESSAGES; - } -} - -//----------------------------------------------------------------------------- -// -// PROC I_KeyboardHandler() -// -//----------------------------------------------------------------------------- - -static void I_KeyboardHandler(int scancode, int press) -{ - event_t ev; - - ev.type = (press == KEY_EVENTPRESS) ? ev_keydown : ev_keyup; - switch (scancode) { - case SCANCODE_CURSORBLOCKUP: - case SCANCODE_CURSORUP: ev.data1 = KEY_UPARROW; break; - case SCANCODE_CURSORBLOCKDOWN: - case SCANCODE_CURSORDOWN: ev.data1 = KEY_DOWNARROW; break; - case SCANCODE_CURSORBLOCKLEFT: - case SCANCODE_CURSORLEFT: ev.data1 = KEY_LEFTARROW; break; - case SCANCODE_CURSORBLOCKRIGHT: - case SCANCODE_CURSORRIGHT: ev.data1 = KEY_RIGHTARROW; break; - case SCANCODE_ESCAPE: ev.data1 = KEY_ESCAPE; break; - case SCANCODE_ENTER: - case SCANCODE_KEYPADENTER: ev.data1 = KEY_ENTER; break; - case SCANCODE_F1: ev.data1 = KEY_F1; break; - case SCANCODE_F2: ev.data1 = KEY_F2; break; - case SCANCODE_F3: ev.data1 = KEY_F3; break; - case SCANCODE_F4: ev.data1 = KEY_F4; break; - case SCANCODE_F5: ev.data1 = KEY_F5; break; - case SCANCODE_F6: ev.data1 = KEY_F6; break; - case SCANCODE_F7: ev.data1 = KEY_F7; break; - case SCANCODE_F8: ev.data1 = KEY_F8; break; - case SCANCODE_F9: ev.data1 = KEY_F9; break; - case SCANCODE_F10: ev.data1 = KEY_F10; break; - case SCANCODE_F11: ev.data1 = KEY_F11; break; - case SCANCODE_F12: ev.data1 = KEY_F12; break; - case SCANCODE_INSERT: ev.data1 = KEY_INS; break; - case SCANCODE_REMOVE: ev.data1 = KEY_DEL; break; - case SCANCODE_PAGEUP: ev.data1 = KEY_PGUP; break; - case SCANCODE_PAGEDOWN: ev.data1 = KEY_PGDN; break; - case SCANCODE_HOME: ev.data1 = KEY_HOME; break; - case SCANCODE_END: ev.data1 = KEY_END; break; - case SCANCODE_BACKSPACE: ev.data1 = KEY_BACKSPACE; break; - case SCANCODE_BREAK: - case SCANCODE_BREAK_ALTERNATIVE: ev.data1 = KEY_PAUSE; break; - case SCANCODE_EQUAL: ev.data1 = KEY_EQUALS; break; - case SCANCODE_MINUS: - case SCANCODE_KEYPADMINUS: ev.data1 = KEY_MINUS; break; - case SCANCODE_LEFTSHIFT: - case SCANCODE_RIGHTSHIFT: ev.data1 = KEY_RSHIFT; break; - case SCANCODE_LEFTCONTROL: - case SCANCODE_RIGHTCONTROL: ev.data1 = KEY_RCTRL; break; - case SCANCODE_LEFTALT: - case SCANCODE_RIGHTALT: ev.data1 = KEY_RALT; break; - default: ev.data1 = scantokey[scancode]; break; - } - H2_PostEvent(&ev); -} - -//----------------------------------------------------------------------------- -// -// PROC I_MouseEventHandler() -// -//----------------------------------------------------------------------------- - -static void I_MouseEventHandler(int button, int dx, int dy, int dz, - int rdx, int rdy, int rdz) -{ - event_t ev; - - ev.type = ev_mouse; - ev.data1 = ((button & MOUSE_LEFTBUTTON) ? 1 : 0) | - ((button & MOUSE_MIDDLEBUTTON) ? 2 : 0) | - ((button & MOUSE_LEFTBUTTON) ? 4 : 0); - ev.data2 = dx << 2; ev.data3 = -(dy<<2); - - H2_PostEvent(&ev); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ShutdownGraphics -// -//-------------------------------------------------------------------------- - -void I_ShutdownGraphics(void) -{ - if(mflag != F_nomouse) vga_setmousesupport(0); - keyboard_close(); - vga_setmode(TEXT); - system("stty sane"); -} - -//-------------------------------------------------------------------------- -// -// PROC I_InitGraphics -// -//-------------------------------------------------------------------------- - -void I_InitGraphics(void) -{ - ST_Message("I_InitGraphics: "); - vga_init(); - - atexit(I_ShutdownGraphics); - - keyboard_init(); - keyboard_seteventhandler(I_KeyboardHandler); - - if(!M_CheckParm("-nomouse")) { - vga_setmousesupport(1); - mflag = F_mouse; - } - - if(!vga_hasmode(G320x200x256)) - I_Error("SVGALib reports no mode 13h"); - putc('\n',stderr); - - if(vga_setmode(G320x200x256)) - I_Error("Can't set video mode 13h"); - - I_SetPalette( W_CacheLumpName("PLAYPAL", PU_CACHE) ); - - if(mflag == F_mouse) mouse_seteventhandler(I_MouseEventHandler); -} - - -//-------------------------------------------------------------------------- -// -// PROC I_ReadScreen -// -// Reads the screen currently displayed into a linear buffer. -// -//-------------------------------------------------------------------------- - -/* -void I_ReadScreen(byte *scr) -{ - memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); -} -*/ - -//=========================================================================== - -void I_StartTic (void) -{ - if(mflag != F_nomouse) mouse_update(); - keyboard_update(); -} - - -/* -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 (); - } - } -} -*/ - - -/* -============================================================================ - - KEYBOARD - -============================================================================ -*/ - -int lastpress; - -/* -================ -= -= I_KeyboardISR -= -================ -*/ - -void I_KeyboardISR(void) -{ -// Get the scan code - - keyboardque[kbdhead&(KBDQUESIZE-1)] = lastpress = 0; //TODO - kbdhead++; -} - - - -/* -=============== -= -= I_StartupKeyboard -= -=============== -*/ - -void I_StartupKeyboard (void) -{ - //TODO -} - - -void I_ShutdownKeyboard (void) -{ - //TODO -} - - - -/* -============================================================================ - - MOUSE - -============================================================================ -*/ - - -int I_ResetMouse (void) -{ - // Return 0xffff if mouse reset ok. - return 0; -} - - - -/* -================ -= -= 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) -{ -#if 0 - 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); -#endif -} - - -//========================================================================== -// -// -// I_StartupReadKeys -// -// -//========================================================================== - -void I_StartupReadKeys(void) -{ - int k; - - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; - kbdtail++; - if (k == 1) - I_Quit (); - } -} - - -//EOF diff --git a/x11/i_x11.cpp b/x11/i_x11.cpp deleted file mode 100644 index 549643d..0000000 --- a/x11/i_x11.cpp +++ /dev/null @@ -1,1184 +0,0 @@ -//************************************************************************** -//** -//** $Id$ -//** -//************************************************************************** - - -#include -#include -#include -#include -#include -#include -#include -#include "x11window.h" -#include "xshmext.h" - -extern "C" { -#include "h2def.h" -} - - -/* - Nifty palette cacheing idea taken from Linux Heretic. - - The Hexen palette pointer is used as a palette id, i.e. a palette - with another pointer value is assumed to be a different - palette, and, more important, if the pointer is equal, - the palette is assumed to be the same... -*/ - -#define PAL_CACHE_ON -#define MAX_PAL_CACHE 5 - -#define MOUSE_JUMP_AT 10 - -struct PaletteCache -{ - PaletteCache() : id( 0 ), used( 0 ) {} - - void free( Display* dis, Colormap cmap ) - { - if( id ) - { - XFreeColors( dis, cmap, pixel, 256, 0 ); - id = 0; - used = 0; - } - } - - unsigned char* id; // contains pointer / id of palette. - unsigned int used; - unsigned long pixel[ 256 ]; // xpixel lookup table. -}; - - -class HexenWindow : public X11Window -{ -public: - - HexenWindow(); - - ~HexenWindow(); - - void setPalette( byte* ); - - void blit( unsigned char* buffer, int x, int y, int w, int h ); - - void grabPointer() - { - XGrabPointer( display(), window(), True, - ButtonPressMask | ButtonReleaseMask | PointerMotionMask, - GrabModeAsync, GrabModeAsync, window(), None, CurrentTime ); - hideCursor(); - _grabCursor = true; - } - - void ungrabPointer() - { - XUngrabPointer( display(), CurrentTime ); - showCursor(); - _grabCursor = false; - } - -protected: - - virtual void unknownEvent( XEvent* ); - virtual void configureEvent( XConfigureEvent* ); - virtual void deleteEvent( XEvent* ); - virtual void buttonDown( XButtonEvent* ); - virtual void buttonUp( XButtonEvent* ); - virtual void motionEvent( XMotionEvent* ); - virtual void keyDown( XKeyEvent* ); - virtual void keyUp( XKeyEvent* ); - virtual void exposeEvent( XExposeEvent* ); - -private: - - void waitForShmPut(); - void resizeFramebuffer(); - bool getVisualInfo( XVisualInfo* ); - void postKey( evtype_t type, KeySym key ); - void postMouseEvent( int dx, int dy ); - - XVisualInfo _vinfo; - GC _gc; - - Colormap _colormap; - PaletteCache _palc[ MAX_PAL_CACHE ]; - PaletteCache* _pcurrent; - int _cacheGamma; - int _cacheAge; - - ShmImage* _simage; - int _shmEventType; - bool _usingShm; - - XImage* _ximage; - - int _prevX, _prevY; - int _buttons; - bool _grabCursor; -}; - - -HexenWindow* _win; - - -extern "C" { - - -// Public Data - -int DisplayTicker = 0; - -extern int ticcount; - -extern boolean novideo; // if true, stay in text mode for debugging - - -//================================================== - -#define MOUSEB1 1 -#define MOUSEB2 2 -#define MOUSEB3 4 - -//================================================== - -#define KEY_TAB 9 // From am_map.h - -#define KEY_INS 0x52 -#define KEY_DEL 0x53 -#define KEY_PGUP 0x49 -#define KEY_PGDN 0x51 -#define KEY_HOME 0x47 -#define KEY_END 0x4f - - -/* -============================================================================ - - USER INPUT - -============================================================================ -*/ - -//-------------------------------------------------------------------------- -// -// PROC I_WaitVBL -// -//-------------------------------------------------------------------------- - -void I_WaitVBL(int vbls) -{ - if( novideo ) - { - return; - } - while( vbls-- ) - { - usleep( 16667 ); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_SetPalette -// -// Palette source must use 8 bit RGB elements. -// -//-------------------------------------------------------------------------- - -void I_SetPalette( byte *palette ) -{ - if(novideo) - { - return; - } - - _win->setPalette( palette ); -} - -/* -============================================================================ - - GRAPHICS MODE - -============================================================================ -*/ - - -/* -============== -= -= 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 0 - // Why is it drawing to pcscreen under some conditions? - if(screenblocks > 9 || UpdateState&(I_FULLSCRN|I_MESSAGES)) - { - dest = (byte *)screen; - } - else - { - dest = (byte *)pcscreen; - } -#else - dest = (byte *)screen; -#endif - - 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) - { - UpdateState = I_NOUPDATE; // clear out all draw types - - _win->blit( screen, 0, 0, SCREENWIDTH, SCREENHEIGHT ); - } - if(UpdateState&I_FULLVIEW) - { - if(UpdateState&I_MESSAGES && screenblocks > 7) - { - UpdateState &= ~(I_FULLVIEW|I_MESSAGES); - - _win->blit( screen, 0, 0, SCREENWIDTH, viewwindowy+viewheight ); - } - else - { - UpdateState &= ~I_FULLVIEW; - - _win->blit( screen, viewwindowx, viewwindowy, viewwidth, - viewheight ); - } - } - if(UpdateState&I_STATBAR) - { - UpdateState &= ~I_STATBAR; - - _win->blit( screen, 0, SCREENHEIGHT-SBARHEIGHT, - SCREENWIDTH, SBARHEIGHT ); - } - if(UpdateState&I_MESSAGES) - { - UpdateState &= ~I_MESSAGES; - - _win->blit( screen, 0, 0, SCREENWIDTH, 28 ); - } -} - -//-------------------------------------------------------------------------- -// -// PROC I_InitGraphics -// -//-------------------------------------------------------------------------- - -void I_InitGraphics(void) -{ - if( novideo ) - { - return; - } - - _win = new HexenWindow(); - if( ! _win ) - { - exit( 3 ); - } - - _win->show(); - - I_SetPalette( (byte*) W_CacheLumpName("PLAYPAL", PU_CACHE) ); - _win->grabPointer (); -} - -//-------------------------------------------------------------------------- -// -// PROC I_ShutdownGraphics -// -//-------------------------------------------------------------------------- - -void I_ShutdownGraphics(void) -{ -} - -//-------------------------------------------------------------------------- -// -// PROC I_ReadScreen -// -// Reads the screen currently displayed into a linear buffer. -// -//-------------------------------------------------------------------------- - -/* -void I_ReadScreen(byte *scr) -{ - memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); -} -*/ - -//=========================================================================== - - -void I_StartTic (void) -{ - // Handle keyboard & mouse events. - - while( _win->eventsPending() ) - _win->handleNextEvent(); - - //I_ReadMouse(); -} - - -/* -============================================================================ - - TIMER INTERRUPT - -============================================================================ -*/ - - -/* -================ -= -= I_TimerISR -= -================ -*/ - -int I_TimerISR (void) -{ - ticcount++; - return 0; -} - - -/* -============================================================================ - - MOUSE - -============================================================================ -*/ - - -/* -================ -= -= StartupMouse -= -================ -*/ - -void I_StartupCyberMan(void); - -void I_StartupMouse (void) -{ - I_StartupCyberMan(); -} - - -/* -================ -= -= I_ReadMouse -= -================ -*/ - -void I_ReadMouse (void) -{ -} - - - -//========================================================================== -// -// -// I_StartupReadKeys -// -// -//========================================================================== - -void I_StartupReadKeys(void) -{ - //if( KEY_ESCAPE pressed ) - // I_Quit (); -} - - -} // extern "C" - - -//--------------------------------------------------------------------------- - - -HexenWindow::HexenWindow() - : X11Window( "HEXEN", 0, 0, SCREENWIDTH*2, SCREENHEIGHT*2 ) -{ - _colormap = 0; - _gc = 0; - _simage = 0; - _ximage = 0; - _usingShm = false; - _grabCursor = false; - - _pcurrent = 0; - _cacheGamma = -1; - _cacheAge = 0; - - _buttons = 0; - _prevX = _prevY = 0; - - setTitle( "HHexen v1.3" ); - setSizeHints( SCREENWIDTH, SCREENHEIGHT, SCREENWIDTH*2, SCREENHEIGHT*2 ); - setIconName( "HEXEN" ); - - if( getVisualInfo( &_vinfo ) ) - { - // KR -// printf( "Visual: depth %d, mask %04x %04x %04x\n", _vinfo.depth, -// _vinfo.red_mask, _vinfo.green_mask, _vinfo.blue_mask ); - - if( _vinfo.depth == 8 ) - { - _colormap = XCreateColormap( display(), window(), _vinfo.visual, - AllocAll ); - XSetWindowColormap( display(), window(), _colormap ); - } - else - { - _colormap = DefaultColormapOfScreen( - ScreenOfDisplay( display(), screen() ) ); - } - - XGCValues gcv; - gcv.graphics_exposures = False; - _gc = XCreateGC( display(), window(), GCGraphicsExposures, &gcv ); - if( ! _gc ) - fprintf( stderr, "XCreateGC failed!\n" ); - - _shmEventType = ShmImage::query( display() ); - if( _shmEventType ) - { - printf( "Using X11 MITSHM extension\n" ); - _usingShm = true; // May provide a user disable for Shm later. - } - - resizeFramebuffer(); - } - else - { - fprintf( stderr, "XMatchVisualInfo failed!\n" ); - } -} - - -HexenWindow::~HexenWindow() -{ - if( _vinfo.depth == 8 ) - { - if( _colormap ) - XFreeColormap( display(), _colormap ); - } - else - { - int i; - for( i = 0; i < MAX_PAL_CACHE; i++ ) - _palc[ i ].free( display(), _colormap ); - } - - if( _usingShm ) - { - delete _simage; - } - else if( _ximage ) - { - delete _ximage->data; - XDestroyImage( _ximage ); - } -} - - -void HexenWindow::setPalette( byte* palette ) -{ - int i, c; - - if( _vinfo.c_class == PseudoColor && _vinfo.depth == 8 ) - { - XColor colors[ 256 ]; - - for( i = 0 ; i < 256 ; i++ ) - { - colors[ i ].pixel = i; - colors[ i ].flags = DoRed | DoGreen | DoBlue; - - c = gammatable[usegamma][*palette++]; - colors[ i ].red = (c << 8) + c; - - c = gammatable[usegamma][*palette++]; - colors[ i ].green = (c << 8) + c; - - c = gammatable[usegamma][*palette++]; - colors[ i ].blue = (c << 8) + c; - } - - XStoreColors( display(), _colormap, colors, 256 ); - } - else - { - XColor color; - - // It looks like we could get away with caching as little as - // three palettes to avoid most re-allocations. - - // Must update the entire screen when palette changes in truecolor mode. - UpdateState |= I_FULLSCRN; - -#ifdef PAL_CACHE_ON - if( usegamma != _cacheGamma ) - { - // The gamma has changed so the entire cache must be thrown out. - for( i = 0; i < MAX_PAL_CACHE; i++ ) - _palc[ i ].free( display(), _colormap ); - _cacheAge = 0; - _cacheGamma = usegamma; - //printf( "palette gamma\n" ); - } - - // Search for palette in cache. - for( i = 0; i < MAX_PAL_CACHE; i++ ) - { - if( _palc[ i ].id == palette ) - { - // Found palette. - _pcurrent = &_palc[ i ]; - _pcurrent->used = ++_cacheAge; - - //printf( "palette %d %p - cache\n", i, palette ); - - return; - } - } -#endif - - // Search for unused cache. Otherwise use the oldest cache. - _pcurrent = &_palc[ 0 ]; - -#ifdef PAL_CACHE_ON - for( i = 0; i < MAX_PAL_CACHE; i++ ) - { - if( ! _palc[ i ].id ) - { - // Unused cache. - _pcurrent = &_palc[ i ]; - break; - } - if( _palc[ i ].used < _pcurrent->used ) - _pcurrent = &_palc[ i ]; - } -#endif - - //printf( "palette %d %p - new\n", i, palette ); - - _pcurrent->free( display(), _colormap ); - _pcurrent->used = ++_cacheAge; - _pcurrent->id = palette; - - for( i = 0 ; i < 256 ; i++ ) - { - color.pixel = 0; - color.flags = DoRed | DoGreen | DoBlue; - - c = gammatable[usegamma][*palette++]; - color.red = (c << 8); - - c = gammatable[usegamma][*palette++]; - color.green = (c << 8); - - c = gammatable[usegamma][*palette++]; - color.blue = (c << 8); - - if( ! XAllocColor( display(), _colormap, &color ) ) - { - fprintf( stderr," XAllocColor failed\n" ); - } - - _pcurrent->pixel[ i ] = color.pixel; - } - } -} - - -// Predicate procedure used by waitOnShmPut() - -struct PPArg -{ - PPArg( Window w, int type ) : window( w ), shmCompletionType( type ) {} - - Window window; - int shmCompletionType; -}; - -static Bool _shmPredicateProc( Display* dis, XEvent* event, XPointer arg ) -{ - if( (event->xany.window == ((PPArg*)arg)->window) && - (event->type == ((PPArg*)arg)->shmCompletionType) ) - { - return True; - } - return False; -} - -void HexenWindow::waitForShmPut() -{ - XEvent event; - PPArg arg( window(), _shmEventType ); - XIfEvent( display(), &event, _shmPredicateProc, (XPointer) &arg ); -} - - -typedef unsigned char pixel8; -typedef unsigned short pixel16; -typedef unsigned long pixel32; - -static void blit_8_8( pixel8* source, XImage* img, - int x, int y, int w, int h ) -{ - register pixel8* begin; - - begin = (pixel8*) img->data; - begin += x + (y * img->bytes_per_line); - while( h-- ) - { - memcpy( begin, source, w ); - begin += img->bytes_per_line; - source += w; - } -} - - -static void blit_double_8_8( pixel8* source, XImage* img, - int x, int y, int w, int h ) -{ - pixel8 p; - pixel8* begin; - pixel8* end; - register pixel8* dst; - register pixel8* src; - - begin = (pixel8*) img->data; - begin += (x * 2) + (y * img->bytes_per_line * 2); - src = source; - while( h-- ) - { - dst = begin; - end = dst + (w * 2); - while( dst != end ) - { - p = *src++; - *dst++ = p; - *dst++ = p; - } - - memcpy( begin + img->bytes_per_line, begin, w * 2 ); - - begin += img->bytes_per_line * 2; - } -} - - -static void blit_8_16( pixel8* source, XImage* img, - int x, int y, int w, int h, - unsigned long* pixel ) -{ - pixel16* begin; - pixel16* end; - register pixel16* dst; - register pixel8* src; - - begin = (pixel16*) img->data; - begin += x + (y * img->bytes_per_line / 2); - src = source; - while( h-- ) - { - dst = begin; - end = dst + w; - while( dst != end ) - *dst++ = pixel[ *src++ ]; - begin += img->bytes_per_line / 2; - } -} - - -static void blit_double_8_16( pixel8* source, XImage* img, - int x, int y, int w, int h, - unsigned long* pixel ) -{ - pixel16 p; - pixel16* begin; - pixel16* end; - register pixel16* dst; - register pixel8* src; - - begin = (pixel16*) img->data; - begin += (x * 2) + (y * img->bytes_per_line); - src = source; - while( h-- ) - { - dst = begin; - end = dst + (w * 2); - while( dst != end ) - { - p = pixel[ *src++ ]; - *dst++ = p; - *dst++ = p; - } - - dst = begin + (img->bytes_per_line / 2); - memcpy( dst, begin, w * 4 ); - - begin += img->bytes_per_line; - } -} - - -static void blit_8_32( pixel8* source, XImage* img, - int x, int y, int w, int h, - unsigned long* pixel ) -{ - pixel32* begin; - pixel32* end; - register pixel32* dst; - register unsigned char* src; - - begin = (pixel32*) img->data; - begin += x + (y * img->bytes_per_line / 4); - src = source; - while( h-- ) - { - dst = begin; - end = dst + w; - while( dst != end ) - *dst++ = pixel[ *src++ ]; - begin += img->bytes_per_line / 4; - } -} - - -static void blit_double_8_32( pixel8* source, XImage* img, - int x, int y, int w, int h, - unsigned long* pixel ) -{ - pixel32 p; - pixel32* begin; - pixel32* end; - register pixel32* dst; - register pixel8* src; - - begin = (pixel32*) img->data; - begin += (x * 2) + (y * img->bytes_per_line / 2); - src = source; - while( h-- ) - { - dst = begin; - end = dst + (w * 2); - while( dst != end ) - { - p = pixel[ *src++ ]; - *dst++ = p; - *dst++ = p; - } - - dst = begin + (img->bytes_per_line / 4); - memcpy( dst, begin, w * 8 ); - - begin += img->bytes_per_line / 2; - } -} - - -void HexenWindow::blit( unsigned char* buffer, int x, int y, int w, int h ) -{ - buffer += x + (y * w); - - if( (width() >= SCREENWIDTH*2) && (height() >= SCREENHEIGHT*2) ) - { - if( _vinfo.depth == 8 ) - { - blit_double_8_8( buffer, _ximage, x, y, w, h ); - } - else if( _vinfo.depth <= 16 ) - { - blit_double_8_16( buffer, _ximage, x, y, w, h, _pcurrent->pixel ); - } - else - { - blit_double_8_32( buffer, _ximage, x, y, w, h, _pcurrent->pixel ); - } - x *= 2; - y *= 2; - w *= 2; - h *= 2; - } - else - { - if( _vinfo.depth == 8 ) - { - blit_8_8( buffer, _ximage, x, y, w, h ); - } - else if( _vinfo.depth <= 16 ) - { - blit_8_16( buffer, _ximage, x, y, w, h, _pcurrent->pixel ); - } - else - { - blit_8_32( buffer, _ximage, x, y, w, h, _pcurrent->pixel ); - } - } - - if( _usingShm ) - { - XShmPutImage( display(), window(), _gc, _ximage, x, y, x, y, - w, h, True ); - waitForShmPut(); - } - else - { - XPutImage( display(), window(), _gc, _ximage, x, y, x, y, w, h ); - sync(); - } -} - - -void HexenWindow::resizeFramebuffer() -{ - if(_ximage && (_ximage->width == width()) && (_ximage->height == height())) - { - return; - } - - if( _usingShm ) - { - delete _simage; - _simage = new ShmImage( display(), width(), height(), &_vinfo ); - _ximage = _simage->image(); - } - else - { - if( _ximage ) - { - delete _ximage->data; - XDestroyImage( _ximage ); - } - _ximage = XCreateImage( display(), _vinfo.visual, _vinfo.depth, - ZPixmap, 0, 0, - width(), height(), - (_vinfo.depth == 8) ? 8 : 32, 0 ); - _ximage->data = new char[ _ximage->bytes_per_line * _ximage->height ]; - } - - UpdateState |= I_FULLSCRN; -} - - -bool HexenWindow::getVisualInfo( XVisualInfo* vi ) -{ - if( XMatchVisualInfo( display(), screen(), 8, PseudoColor, vi ) ) - return true; - - if( XMatchVisualInfo( display(), screen(), 16, TrueColor, vi ) ) - return true; - if( XMatchVisualInfo( display(), screen(), 15, TrueColor, vi ) ) - return true; - - if( XMatchVisualInfo( display(), screen(), 32, TrueColor, vi ) ) - return true; - if( XMatchVisualInfo( display(), screen(), 24, TrueColor, vi ) ) - return true; - -#if 0 - if( XMatchVisualInfo( display(), screen(), 8, GrayScale, vi ) ) - return True; -#endif - - return false; -} - - -void HexenWindow::deleteEvent( XEvent* ) -{ - I_Quit(); -} - -void HexenWindow::configureEvent( XConfigureEvent* e ) -{ - resizeFramebuffer(); - //printf( "configure %d %d\n", width(), height() ); -} - -void HexenWindow::unknownEvent( XEvent* e ) -{ - //printf( "Unknown XEvent: %d\n", e->type ); -} - - -void HexenWindow::buttonDown( XButtonEvent* e ) -{ - //printf( "buttonDown: %d %d,%d\n", e->button, e->x, e->y ); - -// if( ! _grabCursor ) -// grabPointer(); - - switch( e->button ) - { - case Button1: _buttons |= MOUSEB1 ; break; - case Button2: _buttons |= MOUSEB2 ; break; - case Button3: _buttons |= MOUSEB3 ; break; - default: - return; - } - postMouseEvent( 0, 0 ); -} - - -void HexenWindow::buttonUp( XButtonEvent* e ) -{ - //printf( "buttonUp: %d %d,%d\n", e->button, e->x, e->y ); - - switch( e->button ) - { - case Button1: _buttons &= ~MOUSEB1 ; break; - case Button2: _buttons &= ~MOUSEB2 ; break; - case Button3: _buttons &= ~MOUSEB3 ; break; - default: - return; - } - postMouseEvent( 0, 0 ); -} - - -void HexenWindow::motionEvent( XMotionEvent* e ) -{ - - int dx,dy; - - if(e->x == width()/2 && e->y == height()/2) - { - _prevX = width()/2; - _prevY = height()/2; - return; - } - dx = (e->x - _prevX); - _prevX = e->x; - dy = (e->y - _prevY); - _prevY = e->y; - - if( dx || dy ) - { - postMouseEvent( dx, dy ); - - if (_grabCursor) - { - - if( (e->x < MOUSE_JUMP_AT) || (e->x > (width() - MOUSE_JUMP_AT)) || - (e->y < MOUSE_JUMP_AT) || (e->y > (height() - MOUSE_JUMP_AT)) ) - { - XWarpPointer( display(), None, window(), 0, 0, 0, 0, - width() / 2, height() / 2 ); - _prevX = width()/2; _prevY = height()/2; - } - else - { - postMouseEvent( dx, dy); - } - } - else - { - postMouseEvent( dx, dy); - } - } -} - - -void HexenWindow::keyDown( XKeyEvent* e ) -{ - KeySym key = keysym( e ); - - //TODO: filter key repeat. - - //printf( "keyDown: %lx %x\n", e->time, key ); - - if( e->state & Mod1Mask ) // Control key defaults to attack. - { - if( key == XK_d ) - { - if( width() == SCREENWIDTH ) - { - resize( SCREENWIDTH * 2, SCREENHEIGHT * 2 ); - } - else - { - resize( SCREENWIDTH, SCREENHEIGHT ); - } - } - else if( key == XK_g ) - { - if( _grabCursor ) - { - ungrabPointer(); - } - else - { - grabPointer(); - } - } - } -#if 0 - else if( key == XK_Escape ) - { - I_Quit(); - } -#endif - else - { - postKey( ev_keydown, key ); - } -} - - -void HexenWindow::keyUp( XKeyEvent* e ) -{ - //printf( "keyUp: %lx %x %x\n", e->time, e->state, e->keycode ); - - postKey( ev_keyup, keysym( e ) ); -} - - -void HexenWindow::exposeEvent( XExposeEvent* ) -{ - //printf( "expose\n" ); - UpdateState |= I_FULLSCRN; -} - - -void HexenWindow::postKey( evtype_t type, KeySym key ) -{ - event_t ev; - - ev.type = type; - - switch( key ) - { - case XK_Up: ev.data1 = KEY_UPARROW; break; - case XK_Down: ev.data1 = KEY_DOWNARROW; break; - case XK_Left: ev.data1 = KEY_LEFTARROW; break; - case XK_Right: ev.data1 = KEY_RIGHTARROW; break; - - case XK_Escape: ev.data1 = KEY_ESCAPE; break; - case XK_Return: ev.data1 = KEY_ENTER; break; - case XK_F1: ev.data1 = KEY_F1; break; - case XK_F2: ev.data1 = KEY_F2; break; - case XK_F3: ev.data1 = KEY_F3; break; - case XK_F4: ev.data1 = KEY_F4; break; - case XK_F5: ev.data1 = KEY_F5; break; - case XK_F6: ev.data1 = KEY_F6; break; - case XK_F7: ev.data1 = KEY_F7; break; - case XK_F8: ev.data1 = KEY_F8; break; - case XK_F9: ev.data1 = KEY_F9; break; - case XK_F10: ev.data1 = KEY_F10; break; - case XK_F11: ev.data1 = KEY_F11; break; - case XK_F12: ev.data1 = KEY_F12; break; - - case XK_Insert: ev.data1 = KEY_INS; break; - case XK_Delete: ev.data1 = KEY_DEL; break; - case XK_Page_Up: ev.data1 = KEY_PGUP; break; - case XK_Page_Down: ev.data1 = KEY_PGDN; break; - case XK_Home: ev.data1 = KEY_HOME; break; - case XK_End: ev.data1 = KEY_END; break; - - case XK_Tab: ev.data1 = KEY_TAB; break; - - case XK_BackSpace: ev.data1 = KEY_BACKSPACE; break; - - case XK_Pause: ev.data1 = KEY_PAUSE; break; - - case XK_equal: ev.data1 = KEY_EQUALS; break; - - case XK_KP_Subtract: - case XK_minus: ev.data1 = KEY_MINUS; break; - - case XK_Shift_L: - case XK_Shift_R: ev.data1 = KEY_RSHIFT; break; - - case XK_Control_L: - case XK_Control_R: ev.data1 = KEY_RCTRL; break; - - case XK_Alt_L: - case XK_Alt_R: - case XK_Meta_L: - case XK_Meta_R: ev.data1 = KEY_RALT; break; - - default: - ev.data1 = key; - break; - } - - H2_PostEvent( &ev ); -} - - -void HexenWindow::postMouseEvent( int dx, int dy ) -{ - event_t ev; - - ev.type = ev_mouse; - ev.data1 = _buttons; - ev.data2 = (short) dx << 2; - ev.data3 = -(short) dy << 2; - - H2_PostEvent( &ev ); -} - - -//EOF diff --git a/x11/x11window.cpp b/x11/x11window.cpp deleted file mode 100644 index 4c24a50..0000000 --- a/x11/x11window.cpp +++ /dev/null @@ -1,604 +0,0 @@ -//============================================================================ -// -// $Id$ -// -//============================================================================ - - -#include "x11window.h" - - -/** - \class X11Window x11window.h - \brief The X11Window class - - Note that most methods will not take effect until a call to XPending, - XNextEvent, or XWindowEvent. If you want to make sure a method takes - effect before your program continues use sync(); -*/ - - -char* X11Window::ErrorMessage[] = -{ - "No error", - "Can't open X display" -}; - - -/** - The specified name is used as the class and window/icon property name. -*/ - -X11Window::X11Window( const char* name, Display* dis, int scr, - int swidth, int sheight, long inputMask ) -{ - _flags = 0; - _err = 0; - _win = 0; - _screen = 0; - _nullCursor = (Cursor) -1; - - if( dis ) - { - _display = dis; - } - else - { - _display = XOpenDisplay( 0 ); - if( ! _display ) - { - _err = kOpenDisplay; - return; - } - _set( kOpenedDisplay ); - } - - if( scr ) - { - _screen = scr; - } - else - { - _screen = DefaultScreen( _display ); - } - - _width = swidth; - _height = sheight; - - unsigned long black = BlackPixel( _display, _screen ); - _win = XCreateSimpleWindow( _display, DefaultRootWindow( _display ), - 0, 0, _width, _height, 0, black, black ); - - - // Enable the delete window protocol. - - _wmDeleteAtom = XInternAtom( _display, "WM_DELETE_WINDOW", False ); - XSetWMProtocols( _display, _win, &_wmDeleteAtom, 1 ); - - -#if 0 - // Set the window manager properties - - XWMHints wmHints; - XClassHint classHints; - XSizeHints sizeHints; - XTextProperty nameProp; - char* argv[ 2 ] = { (char*) name, NULL }; - - wmHints.flags = InputHint | StateHint; - wmHints.input = True; - wmHints.initial_state = NormalState; - - sizeHints.flags = PSize; - sizeHints.width = _width; - sizeHints.height = _height; - - classHints.res_name = (char*) name; - classHints.res_class = (char*) name; - - if( XStringListToTextProperty( (char**) &name, 1, &nameProp ) ) - { - XSetWMProperties( _display, _win, &nameProp, &nameProp, argv, 1, - &sizeHints, &wmHints, &classHints ); - } -#endif - - // Set up the events to wait for. - XSelectInput( _display, _win, inputMask ); -} - - -X11Window::~X11Window() -{ - if( _display ) - { - if( _win ) - { - if( _nullCursor != (Cursor) -1 ) - XFreeCursor( _display, _nullCursor ); - - XDestroyWindow( _display, _win ); - } - - if( _flags & kOpenedDisplay ) - { - XCloseDisplay( _display ); - } - } -} - - -void X11Window::setTitle( const char* title ) -{ - XStoreName( _display, _win, title ); -} - - -void X11Window::setIconName( const char* text ) -{ - XSetIconName( _display, _win, text ); -} - - -void X11Window::move( int x, int y ) -{ - XMoveWindow( _display, _win, x, y ); -} - - -void X11Window::moveResize( int x, int y, unsigned int w, unsigned int h ) -{ - XMoveResizeWindow( _display, _win, x, y, w, h ); -} - - -void X11Window::resize( unsigned int w, unsigned int h ) -{ - XResizeWindow( _display, _win, w, h ); -} - - -void X11Window::setSizeHints( int minW, int minH, int maxW, int maxH ) -{ - XSizeHints* hints = XAllocSizeHints(); - if( hints ) - { - hints->flags = PMinSize | PMaxSize; - hints->min_width = minW; - hints->min_height = minH; - hints->max_width = maxW; - hints->max_height = maxH; - - XSetWMNormalHints( _display, _win, hints ); - XFree( hints ); - } -} - - -void X11Window::raise() -{ - XRaiseWindow( _display, _win ); -} - - -void X11Window::show() -{ - XMapWindow( _display, _win ); - -#if 0 - // Wait for the window to be mapped. - XEvent event; - do - { - XNextEvent( _display, &event ); - } - while( event.type != MapNotify ); -#endif -} - - -void X11Window::hide() -{ - XUnmapWindow( _display, _win ); -} - - -void X11Window::iconify() -{ - /* - XWMHints* hints = XAllocWMHints(); - if( hints ) - { - hints->flags = StateHint; - hints->initial_state = IconicState; - XSetWMHints( _display, _win, hints ); - XFree(hints); - - XIconifyWindow( _display, _win, _screen ); - } - */ - - XIconifyWindow( _display, _win, _screen ); -} - - -void X11Window::unIconify() -{ - /* - XWMHints* hints = XAllocWMHints(); - if( hints ) - { - hints->flags = StateHint; - hints->initial_state = NormalState; - XSetWMHints( _display, _win, hints ); - XFree(hints); - - show(); - } - */ - - show(); -} - - -int X11Window::isIconified() -{ - return 0; -} - - -/** - Calls XNextEvent() and then the appropriate virtual funtion based on event - type. -*/ - -void X11Window::handleNextEvent() -{ - XEvent event; - - XNextEvent( _display, &event ); - - switch( event.type ) - { - case ClientMessage: - if( event.xclient.format == 32 && - event.xclient.data.l[ 0 ] == (int) _wmDeleteAtom ) - { - deleteEvent( &event ); - } - else - { - unknownEvent( &event ); - } - break; - - case ConfigureNotify: - if( event.xconfigure.window == _win ) - { - _width = event.xconfigure.width; - _height = event.xconfigure.height; - configureEvent( &event.xconfigure ); - } - break; - - case ButtonPress: - buttonDown( &event.xbutton ); - break; - - case ButtonRelease: - buttonUp( &event.xbutton ); - break; - - case MotionNotify: - motionEvent( &event.xmotion ); - break; - - case KeyPress: - keyDown( &event.xkey ); - break; - - case KeyRelease: - keyUp( &event.xkey ); - break; - - case FocusIn: - focusIn( &event.xfocus ); - break; - - case FocusOut: - focusOut( &event.xfocus ); - break; - - case Expose: - exposeEvent( &event.xexpose ); - break; - - default: - unknownEvent( &event ); - break; - } -} - - -/** - All events not passed to other virtual event methods are sent here. -*/ - -void X11Window::unknownEvent( XEvent* ) {} - - -void X11Window::deleteEvent( XEvent* ) {} - -void X11Window::focusIn( XFocusChangeEvent* ) {} - -void X11Window::focusOut( XFocusChangeEvent* ) {} - -void X11Window::exposeEvent( XExposeEvent* ) {} - - -/** - Called when the window is moved or resized by the user. - width() and height() can be used to check the new size. -*/ - -void X11Window::configureEvent( XConfigureEvent* ) {} - - -/** - From XButtonEvent structure in Xlib.h: - - \code - int x, y; // pointer x, y coordinates in event window - int x_root, y_root; // coordinates relative to root - unsigned int state; // key or button mask - unsigned int button; // detail - \endcode -*/ - -void X11Window::buttonDown( XButtonEvent* ) {} -void X11Window::buttonUp( XButtonEvent* ) {} - - -void X11Window::motionEvent( XMotionEvent* ) {} - - -void X11Window::keyDown( XKeyEvent* ) {} -void X11Window::keyUp( XKeyEvent* ) {} - - -KeySym X11Window::keysym( XKeyEvent* e ) -{ - return XKeycodeToKeysym( display(), e->keycode, 0 ); - - /* - KeySym sym; - char buf[ 2 ]; - - XLookupString( event, buf, 1, &sym, NULL ); - //printf( "XLookupString %x: %x %x\n", event->keycode, buf[ 0 ], sym ); - return sym; - */ -} - - -void X11Window::hideCursor() -{ - if( _nullCursor == (Cursor) -1 ) - _nullCursor = _createNullCursor(); - - XDefineCursor( _display, _win, _nullCursor ); -} - - -void X11Window::showCursor() -{ - XUndefineCursor( _display, _win ); -} - - -Cursor X11Window::_createNullCursor() -{ - Pixmap cursormask; - XGCValues xgc; - GC gc; - XColor dummycolour; - Cursor cursor; - - cursormask = XCreatePixmap( _display, _win, 1, 1, 1/*depth*/); - xgc.function = GXclear; - gc = XCreateGC( _display, cursormask, GCFunction, &xgc ); - XFillRectangle( _display, cursormask, gc, 0, 0, 1, 1 ); - dummycolour.pixel = 0; - dummycolour.red = 0; - dummycolour.flags = 04; - cursor = XCreatePixmapCursor( _display, cursormask, cursormask, - &dummycolour, &dummycolour, 0, 0 ); - XFreePixmap( _display, cursormask ); - XFreeGC( _display, gc ); - - return cursor; -} - - -#if 0 -void X11Window::enableBackingStore() -{ - if( DoesBackingStore( ScreenOfDisplay( _display, _screen ) ) == Always ) - { - XSetWindowAttributes attr; - winattr.backing_store = Always; - XChangeWindowAttributes( _display, _win, CWBackingStore, &attr ); - } -} -#endif - - -#if 0 -// g++ x11window.cpp -g -L/usr/X11R6/lib -lX11 - -#include -#include -#include - -class TestWindow : public X11Window -{ -public: - - TestWindow( const char* name, Display* dis = 0 ) - : X11Window( name, dis ) - { - setTitle( name ); - } - - void wait() - { - sync(); - - sleep( 1 ); - putchar( '.' ); - fflush( stdout ); - - sleep( 1 ); - putchar( '.' ); - putchar( '\n' ); - fflush( stdout ); - } - - void testHide() - { - wait(); - - printf( "resize\n" ); - resize( 100, 200 ); - wait(); - - printf( "hiding\n" ); - hide(); - wait(); - printf( "showing\n" ); - show(); - wait(); - - printf( "iconifying\n" ); - iconify(); - wait(); - printf( "showing\n" ); - show(); - wait(); - } - - void testEvents() - { - _exit = false; - while( _exit == false ) - { - _ecnt = 0; - - while( eventsPending() ) - handleNextEvent(); - - if( _ecnt ) - printf( " events %d\n", _ecnt ); - - usleep( 16000 ); - } - } - -protected: - - void deleteEvent( XEvent* ) - { - printf( "delete\n" ); - _exit = true; - _ecnt++; - } - - void configureEvent( XConfigureEvent* ) - { - printf( "configure %d %d\n", width(), height() ); - _ecnt++; - } - - void unknownEvent( XEvent* e ) - { - printf( "Unknown XEvent: %d\n", e->type ); - _ecnt++; - } - - void buttonDown( XButtonEvent* e ) - { - printf( "buttonDown: %d %d,%d\n", e->button, e->x, e->y ); - _ecnt++; - } - - void buttonUp( XButtonEvent* e ) - { - printf( "buttonUp: %d %d,%d\n", e->button, e->x, e->y ); - _ecnt++; - } - - void motionEvent( XMotionEvent* e ) - { - printf( "motion: %lx %d %d\n", e->time, e->x, e->y ); - _ecnt++; - } - - void keyDown( XKeyEvent* e ) - { - int a = keysym( e ); - if( isascii( a ) ) - printf( "keyDown: %lx %x %x (%c)\n", e->time, e->state, e->keycode, (char) a ); - else - printf( "keyDown: %lx %x %x %x\n", e->time, e->state, e->keycode, a ); - _ecnt++; - - if( a == 0x1b ) // ASCII ESC - _exit = true; - if( a == 'h' ) - hideCursor(); - if( a == 'u' ) - showCursor(); - } - - void keyUp( XKeyEvent* e ) - { - int a = keysym( e ); - if( isascii( a ) ) - printf( "keyUp: %lx %x %x (%c)\n", e->time, e->state, e->keycode, (char) a ); - else - printf( "keyUp: %lx %x %x %x\n", e->time, e->state, e->keycode, a ); - _ecnt++; - } - -private: - - int _ecnt; - int _exit; -}; - - -int main() -{ - TestWindow win( "X11Window Test" ); - - if( win.error() ) - { - printf( "error %d\n", win.error() ); - return 1; - } - - printf( "sizeof X11Window: %d\n", sizeof( X11Window ) ); - printf( "screen size: %d %d\n", win.displayWidth(), win.displayHeight() ); - - win.show(); - - win.testEvents(); - //win.testHide(); - - printf( "done!\n" ); - return 0; -} -#endif - - -//EOF diff --git a/x11/xshmext.cpp b/x11/xshmext.cpp deleted file mode 100644 index d50ca78..0000000 --- a/x11/xshmext.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//============================================================================ -// -// $Id$ -// -// MIT Shared Memory Extension for X -// -//============================================================================ - - -#include -#include "xshmext.h" -#include - - -//----------------------------------------------------------------------------- - - -// Shared memory error handler routine used temporarily by allocSHM(). - -static int _shmError; - -static int (*_origErrorHandler)(Display*, XErrorEvent*); - -static int _shmErrorHandler( Display* d, XErrorEvent* e ) -{ - _shmError++; - if( e->error_code == BadAccess ) - fprintf( stderr, "ShmImage: failed to attach shared memory\n" ); - else - (*_origErrorHandler)( d, e ); - return 0; -} - - -static void* allocSHM( XShmSegmentInfo* si, Display* dis, int size ) -{ - si->shmaddr = 0; - si->shmid = shmget( IPC_PRIVATE, size, IPC_CREAT | 0777 ); - if( si->shmid != -1 ) - { - si->shmaddr = (char*) shmat( si->shmid, 0, 0 ); - if( si->shmaddr != (char*) -1 ) - { - si->readOnly = False; - - // Attach the memory to the X Server. - - _shmError = 0; - _origErrorHandler = XSetErrorHandler( _shmErrorHandler ); - XShmAttach( dis, si ); - XSync( dis, True ); // wait for error or ok - XSetErrorHandler( _origErrorHandler ); - if( _shmError ) - { - shmdt( si->shmaddr ); - shmctl( si->shmid, IPC_RMID, 0 ); - si->shmaddr = 0; - } - } - else - { - shmctl( si->shmid, IPC_RMID, 0 ); - si->shmaddr = 0; - } - } - - return si->shmaddr; -} - - -static void freeSHM( XShmSegmentInfo* si, Display* dis ) -{ - if( si->shmaddr ) - { - XShmDetach( dis, si ); - //XSync( dis, False );//need server to detach so can remove id? - - shmdt( si->shmaddr ); - shmctl( si->shmid, IPC_RMID, 0 ); - } -} - - -static int bytesPerLine( int width, int depth ) -{ - int bpl; - - // TODO: Find out how to correctly calculate a Pixmap bytesPerLine that is - // guaranteed to be accurate on any X server. - // The important thing is that we don't calculate a value less that what - // is actually used by the server. - - if( depth < 9 ) - { - if( depth == 1 ) - bpl = (width + 7) / 8; - else - bpl = width; - } - else - { - if( depth > 16 ) - bpl = width * 4; - else - bpl = width * 2; - } - - // Pad to 4 byte boundary. - if( bpl & 3 ) - bpl += (4 - (bpl & 3)); - - return bpl; -} - - -//----------------------------------------------------------------------------- - - -/** - \class ShmImage xshmext.h - \brief The ShmImage class is an X11 XImage allocated in shared memory. -*/ - - -/** - \fn XImage* ShmImage::image() - Returns 0 if the constructor failed. -*/ - - -/** - Check to see if the XShm extensions are supported. - Returns the XEvent completion type or zero if XShm is not available to - the display. -*/ - -int ShmImage::query( Display* dis ) -{ - if( ! XShmQueryExtension( dis ) ) - return 0; - - return completionType( dis ); -} - - -ShmImage::ShmImage( Display* dis, int width, int height, XVisualInfo* vis ) -{ - _display = dis; - - // Query here for safety? - - _XImage = XShmCreateImage( _display, vis->visual, vis->depth, ZPixmap, - NULL, &_si, width, height ); - if( _XImage ) - { - _XImage->data = (char*) allocSHM( &_si, _display, - _XImage->bytes_per_line * _XImage->height ); - if( ! _XImage->data ) - { - XDestroyImage( _XImage ); - _XImage = 0; - } - } -} - - -ShmImage::~ShmImage() -{ - if( _si.shmaddr ) - freeSHM( &_si, _display ); - - if( _XImage ) - XDestroyImage( _XImage ); -} - - -//----------------------------------------------------------------------------- - - -/** - \class ShmPixmap xshmext.h - \brief The ShmPixmap class is an X11 Pixmap allocated in shared memory. -*/ - - -/** - \fn Pixmap* ShmPixmap::pixmap() - Returns 0 if the constructor failed. -*/ - - -/** - Check to see if the XShmPixmap extensions are supported. - Returns the XEvent completion type or zero if XShm is not available to - the display. -*/ - -int ShmPixmap::query( Display* dis ) -{ - if( ! XShmPixmapFormat( dis ) ) - return 0; - - return ShmImage::query( dis ); -} - - -ShmPixmap::ShmPixmap( Display* dis, Drawable draw, int width, int height, - int depth ) -{ - _display = dis; - - // Query here for safety? - - if( depth < 1 ) - depth = XDefaultDepth( _display, XDefaultScreen( _display ) ); - - allocSHM( &_si, _display, bytesPerLine( width, depth ) * height ); - if( _si.shmaddr ) - { - _pix = XShmCreatePixmap( _display, draw, _si.shmaddr, &_si, - width, height, depth ); - } -} - - -ShmPixmap::~ShmPixmap() -{ - if( _si.shmaddr ) - freeSHM( &_si, _display ); - - if( _pix ) - XFreePixmap( _display, _pix ); -} - - -// EOF -- 2.39.2