make quake2 architecture independent. from Jaq (Jamie Wilkinson)

This commit is contained in:
Bill Currie 2002-01-28 05:36:20 +00:00
parent 45955b16f2
commit 8d78a44c1b
14 changed files with 151 additions and 151 deletions

4
.gitignore vendored
View file

@ -3,6 +3,6 @@
*.opt
*.plg
.vimrc
debugi386
debug*
quake2
releasei386
release*

170
Makefile
View file

@ -11,7 +11,7 @@
# Here are your build options, no more will be added!
# (Note: not all options are available for all platforms).
# quake2 (uses OSS for sound, cdrom ioctls for cd audio) is automatically built.
# game{i386,axp,ppc}.so is automatically built.
# game$(ARCH).so is automatically built.
BUILD_SDLQUAKE2=YES # sdlquake2 executable (uses SDL for cdrom and sound)
BUILD_SVGA=YES # SVGAlib driver. Seems to work fine.
BUILD_X11=YES # X11 software driver. Works somewhat ok.
@ -22,48 +22,46 @@ BUILD_SDLGL=YES # SDL OpenGL driver. Works fine for some people.
BUILD_CTFDLL=YES # gamei386.so for ctf
# i can add support for building xatrix and rogue libs if needed
# unportable
# Check OS type.
OSTYPE := $(shell uname -s)
ifneq ($(OSTYPE),Linux)
$(error OS $(OSTYPE) is currently not supported)
endif
#OSTYPE := $(shell uname -s)
#
#ifneq ($(OSTYPE),Linux)
#$(error OS $(OSTYPE) is currently not supported)
#endif
# this nice line comes from the linux kernel makefile
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
#ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
ifneq ($(ARCH),i386)
ifneq ($(ARCH),axp)
ifneq ($(ARCH),ppc)
ifneq ($(ARCH),sparc)
$(error arch $(ARCH) is currently not supported)
endif
endif
endif
endif
# This is preventing builds on sparc and ia64, etc
#ifneq ($(ARCH),i386)
#ifneq ($(ARCH),axp)
#ifneq ($(ARCH),ppc)
#$(error arch $(ARCH) is currently not supported)
#endif
#endif
#endif
CC=gcc
ifeq ($(ARCH),axp)
RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops \
# make this more port friendly
#ifeq ($(ARCH),axp)
RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations
endif
ifeq ($(ARCH),ppc)
RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations
endif
ifeq ($(ARCH),sparc)
RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations
endif
#endif
#
#ifeq ($(ARCH),ppc)
#RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
# -fomit-frame-pointer -fexpensive-optimizations
#endif
ifeq ($(ARCH),i386)
RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops -malign-loops=2 \
-malign-jumps=2 -malign-functions=2
#RELEASE_CFLAGS=$(BASE_CFLAGS) -O2 -ffast-math -funroll-loops -malign-loops=2 \
# -malign-jumps=2 -malign-functions=2 -g
RELEASE_CFLAGS+=-O2 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -g
# compiler bugs with gcc 2.96 and 3.0.1 can cause bad builds with heavy opts.
#RELEASE_CFLAGS=$(BASE_CFLAGS) -O6 -march=i686 -ffast-math -funroll-loops \
#RELEASE_CFLAGS=$(BASE_CFLAGS) -O6 -m486 -ffast-math -funroll-loops \
# -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
# -malign-jumps=2 -malign-functions=2
endif
@ -85,7 +83,11 @@ GAME_DIR=$(MOUNT_DIR)/game
CTF_DIR=$(MOUNT_DIR)/ctf
XATRIX_DIR=$(MOUNT_DIR)/xatrix
BASE_CFLAGS=-Dstricmp=strcasecmp -Wall -Werror
BASE_CFLAGS=-Dstricmp=strcasecmp -Wall -Werror -pipe
ifneq ($(ARCH),i386)
BASE_CFLAGS+=-DC_ONLY
endif
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
@ -114,11 +116,12 @@ SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
DO_GL_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(GLCFLAGS) -o $@ -c $<
DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
DO_SHLIB_AS=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
# added $(ARCH) here as make would munge the quoting in BASE_CFLAGS above
DO_CC=$(CC) -DARCH=\""$(ARCH)"\" $(CFLAGS) -o $@ -c $<
DO_SHLIB_CC=$(CC) -DARCH=\""$(ARCH)"\" $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
DO_GL_SHLIB_CC=$(CC) -DARCH=\""$(ARCH)"\" $(CFLAGS) $(SHLIBCFLAGS) $(GLCFLAGS) -o $@ -c $<
DO_AS=$(CC) -DARCH=\""$(ARCH)"\" $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
DO_SHLIB_AS=$(CC) -DARCH=\""$(ARCH)"\" $(CFLAGS) $(SHLIBCFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
#############################################################################
# SETUP AND BUILD
@ -132,74 +135,16 @@ ifeq ($(strip $(BUILD_CTFDLL)),YES)
TARGETS += $(BUILDDIR)/ctf/game$(ARCH).$(SHLIBEXT)
endif
ifeq ($(ARCH),axp)
ifeq ($(strip $(BUILD_SDLQUAKE2)),YES)
TARGETS += $(BUILDDIR)/sdlquake2
endif
ifeq ($(strip $(BUILD_SVGA)),YES)
$(warning Warning: SVGAlib support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_X11)),YES)
$(warning Warning: X11 support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_GLX)),YES)
$(warning Warning: support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_FXGL)),YES)
$(warning Warning: FXGL support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_SDL)),YES)
$(warning Warning: SDL support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_SDLGL)),YES)
$(warning Warning: SDLGL support not supported for $(ARCH))
endif
endif # ARCH axp
ifeq ($(ARCH),ppc)
ifeq ($(strip $(BUILD_SDLQUAKE2)),YES)
$(warning Warning: SDLQuake2 not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_SVGA)),YES)
$(warning Warning: SVGAlib support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_X11)),YES)
$(warning Warning: X11 support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_GLX)),YES)
$(warning Warning: GLX support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_FXGL)),YES)
$(warning Warning: FXGL support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_SDL)),YES)
$(warning Warning: SDL support not supported for $(ARCH))
endif
ifeq ($(strip $(BUILD_SDLGL)),YES)
TARGETS += $(BUILDDIR)/ref_sdlgl.$(SHLIBEXT)
endif
endif # ARCH ppc
# svgalib just doesn't work with non-i386 at the moment, so don't bother
ifeq ($(ARCH),i386)
ifeq ($(strip $(BUILD_SDLQUAKE2)),YES)
TARGETS += $(BUILDDIR)/sdlquake2
endif
ifeq ($(strip $(BUILD_SVGA)),YES)
TARGETS += $(BUILDDIR)/ref_soft.$(SHLIBEXT)
endif
endif
ifeq ($(strip $(BUILD_X11)),YES)
TARGETS += $(BUILDDIR)/ref_softx.$(SHLIBEXT)
@ -220,7 +165,6 @@ ifeq ($(ARCH),i386)
ifeq ($(strip $(BUILD_SDLGL)),YES)
TARGETS += $(BUILDDIR)/ref_sdlgl.$(SHLIBEXT)
endif
endif # ARCH i386
all: build_debug build_release
@ -307,11 +251,11 @@ QUAKE2_SDL_OBJS = \
$(BUILDDIR)/client/cd_sdl.o \
$(BUILDDIR)/client/snd_sdl.o
ifeq ($(ARCH),axp)
QUAKE2_AS_OBJS = #blank
# more i386 asm
ifeq ($(ARCH),i386)
QUAKE2_AS_OBJS = $(BUILDDIR)/client/snd_mixa.o
else
QUAKE2_AS_OBJS = \
$(BUILDDIR)/client/snd_mixa.o
QUAKE2_AS_OBJS = #blank
endif
$(BUILDDIR)/quake2 : $(QUAKE2_OBJS) $(QUAKE2_LNX_OBJS) $(QUAKE2_AS_OBJS)
@ -401,7 +345,7 @@ $(BUILDDIR)/client/cvar.o : $(COMMON_DIR)/cvar.c
$(BUILDDIR)/client/files.o : $(COMMON_DIR)/files.c
$(DO_CC)
$(BUILDDIR)/client/mdfour.o : $(COMMON_DIR)/mdfour.c
$(BUILDDIR)/client/mdfour.o : $(COMMON_DIR)/mdfour.c
$(DO_CC)
$(BUILDDIR)/client/net_chan.o : $(COMMON_DIR)/net_chan.c
@ -1020,7 +964,12 @@ REF_SOFT_OBJS = \
$(BUILDDIR)/ref_soft/r_scan.o \
$(BUILDDIR)/ref_soft/r_sprite.o \
$(BUILDDIR)/ref_soft/r_surf.o \
\
$(BUILDDIR)/ref_soft/q_shared.o \
$(BUILDDIR)/ref_soft/q_shlinux.o \
$(BUILDDIR)/ref_soft/glob.o
ifeq ($(ARCH),i386)
REF_SOFT_OBJS += \
$(BUILDDIR)/ref_soft/r_aclipa.o \
$(BUILDDIR)/ref_soft/r_draw16.o \
$(BUILDDIR)/ref_soft/r_drawa.o \
@ -1031,11 +980,8 @@ REF_SOFT_OBJS = \
$(BUILDDIR)/ref_soft/math.o \
$(BUILDDIR)/ref_soft/d_polysa.o \
$(BUILDDIR)/ref_soft/r_varsa.o \
$(BUILDDIR)/ref_soft/sys_dosa.o \
\
$(BUILDDIR)/ref_soft/q_shared.o \
$(BUILDDIR)/ref_soft/q_shlinux.o \
$(BUILDDIR)/ref_soft/glob.o
$(BUILDDIR)/ref_soft/sys_dosa.o
endif
REF_SOFT_SVGA_OBJS = \
$(BUILDDIR)/ref_soft/rw_svgalib.o \
@ -1283,6 +1229,6 @@ clean2:
$(REF_GL_OBJS)
distclean:
@-rm -rf $(BUILD_DEBUG_DIR) $(BUILD_RELEASE_DIR)
@-rm -f `find . \( -not -type d \) -and \
-rm -rf $(BUILD_DEBUG_DIR) $(BUILD_RELEASE_DIR)
-rm -f `find . \( -not -type d \) -and \
\( -name '*~' \) -type f -print`

View file

@ -412,7 +412,7 @@ cblock_t Huff1Decompress (cblock_t in)
if (input - in.data != in.count && input - in.data != in.count+1)
{
Com_Printf ("Decompression overread by %i", (input - in.data) - in.count);
Com_Printf ("Decompression overread by %i", (int) (input - in.data) - in.count);
}
out.count = out_p - out.data;

View file

@ -614,11 +614,11 @@ int entitycmpfnc( const entity_t *a, const entity_t *b )
*/
if ( a->model == b->model )
{
return ( ( int ) a->skin - ( int ) b->skin );
return (long int) a->skin - (long int) b->skin;
}
else
{
return ( ( int ) a->model - ( int ) b->model );
return (long int) a->model - (long int) b->model;
}
}

View file

@ -253,7 +253,7 @@ void DumpChunks(void)
memcpy (str, data_p, 4);
data_p += 4;
iff_chunk_len = GetLittleLong();
Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
Com_Printf ("0x%p : %s (%d)\n", data_p - 4, str, iff_chunk_len);
data_p += (iff_chunk_len + 1) & ~1;
} while (data_p < iff_end);
}

View file

@ -175,7 +175,7 @@ void InitGame (void)
//ZOID
//This game.dll only supports deathmatch
if (!deathmatch->value) {
gi.dprintf("Forcing deathmatch.");
gi.dprintf("Forcing deathmatch.\n");
gi.cvar_set("deathmatch", "1");
}
//force coop off

View file

@ -11,14 +11,34 @@ access to other platforms.
Be sure to install SDL 1.2 (http://www.libsdl.org) if you want to use the
softsdl or sdlgl drivers, or the sdlquake2 binary.
You can change what drivers you wish to build by editing the Makefile and
changing the BUILD_ lines at the very top.
'make' will, by default, build both the debug and release files.
To build fully optimized binaries: make build_release
The resulting binaries are then put in releasei386.
Makefile options:
-----------------
(quake2 and gamei386.so are always built, but the following options can be
changed by editing the Makefile)
BUILD_SDLQUAKE2 Build sdlquake2, a quake2 binary that uses SDL for
CD audio and sound access (default = YES).
BUILD_SVGA Build ref_soft.so, a quake2 video driver that uses
SVGAlib (default = NO).
BUILD_X11 Build ref_softx.so, a quake2 video driver that uses
X11 (default = YES).
BUILD_GLX Build ref_glx.so, a quake2 video driver that uses
X11's GLX (default = YES).
BUILD_FXGL Build ref_gl.so [might be renamed to fxgl later],
a quake2 video driver that uses fxMesa (default =
NO). This option is currently untested because I do
not have a Voodoo 1 or 2.
BUILD_SDL Build ref_softsdl.so, a quake2 video driver that
uses SDL (default = YES).
BUILD_SDLGL Build ref_sdlgl.so, a quake2 video driver that uses
OpenGL with SDL (default = YES).
BUILD_CTFDLL Build the Threewave CTF gamei386.so (default = NO).
To install the Quake2 gamedata:
-------------------------------
(installdir is wherever you want to install quake2, and cdromdir is wherever
@ -59,11 +79,20 @@ line).
Configuration files and such are saved in ~/.quake2/, so <installdir> can be
made read-only or whatever.
WARNING: Please do not make quake2 or any of the libraries suid root!
WARNING: Please do not make quake2 or any of the libraries suid root! Doing
so is at your own risk.
NOTE: Save games will most likely not work across different versions or
builds (this is due to how savegames were stored).
NOTE: Save games will not work across different versions or builds, because
of the way they are stored.
Dedicated Server:
-----------------
If there is a demand for it, I can add support for an explicit q2ded binary.
Else, using +set dedicated 1 should be fine.
Joystick Support:
-----------------
None yet.
Commonly used commands:
-----------------------
@ -80,28 +109,63 @@ vid_restart // restart video driver
snd_restart // restart sound driver
basedir <dir> // point quake2 to where the data is
gl_driver <libGL.so> // point quake2 to your libGL
dedicated 1 // run quake2 as a dedicated server
When using these commands on the quake2 command line, use +set to cause the
variables be set before the config files are loaded (important for
gl_driver). e.g.
./quake2 +set vid_ref glx +set gl_driver /usr/lib/libGL.so.1
If quake2 crashes when trying to load an OpenGL based driver (glx, sdlgl),
make sure its not loading the wrong libGL.
Have a NVIDIA card and it _still_ crashes? Try
export LD_PRELOAD=/usr/lib/libGL.so, and run quake2 again.
Is lighting slow in OpenGL (while firing, explosions, etc.)? Disable
multitexturing (gl_ext_multitexture 0; vid_restart).
Website:
--------
I'll post any updates I make at http://www.icculus.org/quake/
I'll post any updates I make at http://www.icculus.org/quake2/
(which currently redirects to http://www.icculus.org/~relnev/)
Mailing List:
-------------
to subscribe: send a blank email to quake2-subscribe@icculus.org
to post: send email to quake2@icculus.org
Anonymous CVS access:
---------------------
cvs -d:pserver:anonymous@icculus.org:/cvs/cvsroot login
(password is "anonymous" without the quotes.)
cvs -z3 -d:pserver:anonymous@icculus.org:/cvs/cvsroot co quake2
Questions:
----------
What's the best way of handling international keyboards with SDL?
Bugzilla:
---------
https://bugzilla.icculus.org
TODO:
-----
Try out RCG's key idea.
Fix save games.
Verify FXGL works.
Joystick support.
Fullscreen/DGA support in X11 driver.
Fully switch to glext.h.
Suggestions, anyone?
v0.0.8: [01/04/02]
-------
+ Fixed C-only ref_soft building.
+ SDL CD audio looping fix (Robert Bäuml)
+ ~/.quake2/<game> added to the search path for mods. (Ludwig Nussel)
+ Minor change to fix compilation with OpenGL 1.3 headers.
+ Fixed changing video drivers using the menu.
+ Fixed autoexec.cfg on startup.
+ Sparc Linux support (Vincent Cojot)
v0.0.7: [12/28/01]
-------
+ Merged in Quake2 3.21 source.
@ -150,7 +214,10 @@ John Allensworth
Stephen Anthony
William Aoki
Robert Bäuml
Vincent Cojot
Michel Dänzer
Ryan C. Gordon
Ludwig Nussel
Peter van Paassen
Zachary 'zakk' Slater
Matti Valtonen

View file

@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <signal.h>
#include <sys/mman.h>
#include <asm/io.h>
#include "vga.h"
#include "vgakeyboard.h"
#include "vgamouse.h"

View file

@ -42,8 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <unistd.h>
#include <sys/mman.h>
#include <asm/io.h>
#include "vga.h"
#include "vgakeyboard.h"
#include "vgamouse.h"

View file

@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <dlfcn.h>
#include "../qcommon/qcommon.h"
#include "../game/game.h"
#include "../linux/rw_linux.h"
cvar_t *nostdout;
@ -214,22 +214,13 @@ Loads the game dll
*/
void *Sys_GetGameAPI (void *parms)
{
void *(*GetGameAPI) (void *);
game_export_t *(*GetGameAPI) (game_import_t *);
char name[MAX_OSPATH];
char *path;
char *str_p;
#if defined __i386__
const char *gamename = "gamei386.so";
#elif defined __alpha__
const char *gamename = "gameaxp.so";
#elif defined __powerpc__
const char *gamename = "gameppc.so";
#elif defined __sparc__
const char *gamename = "gamesparc.so";
#else
#error Unknown arch
#endif
const char *gamename = "game"ARCH".so";
setreuid(getuid(), getuid());
setegid(getgid());
@ -265,7 +256,7 @@ void *Sys_GetGameAPI (void *parms)
}
}
GetGameAPI = (void *)dlsym (game_library, "GetGameAPI");
GetGameAPI = (game_export_t * (*)(game_import_t *)) dlsym(game_library, "GetGameAPI");
if (!GetGameAPI)
{

View file

@ -69,7 +69,7 @@ static char *rd_buffer;
static int rd_buffersize;
static void (*rd_flush)(int target, char *buffer);
void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush))
void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush)(int, char*))
{
if (!target || !buffer || !buffersize || !flush)
return;

View file

@ -735,7 +735,7 @@ MISC
#define PRINT_ALL 0
#define PRINT_DEVELOPER 1 // only print when "developer 1"
void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush));
void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush)(int, char*));
void Com_EndRedirect (void);
void Com_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
void Com_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2)));

View file

@ -1074,7 +1074,7 @@ void D_DrawflatSurfaces (void)
// make a stable color for each surface by taking the low
// bits of the msurface pointer
D_FlatFillSurface (s, (int)s->msurf & 0xFF);
D_FlatFillSurface (s, (long int) s->msurf & 0xFF);
D_DrawZSpans (s->spans);
}
}

View file

@ -450,7 +450,7 @@ surfcache_t *D_SCAlloc (int width, int size)
if ((size <= 0) || (size > 0x10000))
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: bad cache size %d\n", size);
size = (int)&((surfcache_t *)0)->data[size];
size = (long int)&((surfcache_t *)0)->data[size];
size = (size + 3) & ~3;
if (size > sc_size)
ri.Sys_Error (ERR_FATAL,"D_SCAlloc: %i > cache size of %i",size, sc_size);