From b6bb97e223e151a238b57756989fad5641af4d6c Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Mon, 16 Apr 2012 06:54:48 +0000 Subject: [PATCH 1/6] - add support for big endian CPUs - enable the build on SPARC64 - add runtime-requirements for SPARC64 - bump version number to 4.10 --- CHANGELOG | 2 ++ Makefile | 2 ++ src/common/header/common.h | 4 +++- src/common/model/cm_areaportals.c | 4 ++-- src/common/model/cm_vis.c | 4 ++-- src/common/shared/shared.c | 7 +++++-- src/game/savegame/savegame.c | 2 ++ src/refresh/r_main.c | 2 +- 8 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ca14fd52..8ef72304 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,8 @@ Quake II 4.03 to 4.10 - Reenable support for gamma via SDL, since the upstream bug was fixed with SDL 1.2.15. Gamma via X11 can be forced by defining X11GAMMA at compile time. +- Add support for big endian architectures and enable + the build on SPARC64 CPUs. (by Kieron Gillespie) Quake II 4.02 to 4.03 - Fix wrong function call in the Quake II file system. diff --git a/Makefile b/Makefile index b4647039..50a0c9e0 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,11 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/) # (You'll need some #ifdef for your unsupported plattform!) ifneq ($(ARCH),i386) ifneq ($(ARCH),x86_64) +ifneq ($(ARCH),sparc64) $(error arch $(ARCH) is currently not supported) endif endif +endif # ---------- diff --git a/src/common/header/common.h b/src/common/header/common.h index f7ad6d18..6da64c1d 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -32,7 +32,7 @@ #include "shared.h" #include "crc.h" -#define VERSION 4.03 +#define VERSION 4.10 #define BASEDIRNAME "baseq2" #if defined __linux__ @@ -47,6 +47,8 @@ #define CPUSTRING "i386" #elif defined __x86_64__ #define CPUSTRING "amd64" +#elif defined __sparc__ +#define CPUSTRING "sparc64" #else #define CPUSTRING "Unknown" #endif diff --git a/src/common/model/cm_areaportals.c b/src/common/model/cm_areaportals.c index d6781771..4e8e3bf5 100644 --- a/src/common/model/cm_areaportals.c +++ b/src/common/model/cm_areaportals.c @@ -48,8 +48,8 @@ void FloodArea_r (carea_t *area, int floodnum) for (i=0 ; inumareaportals ; i++, p++) { - if (portalopen[p->portalnum]) - FloodArea_r (&map_areas[p->otherarea], floodnum); + if (portalopen[LittleLong(p->portalnum)]) + FloodArea_r (&map_areas[LittleLong(p->otherarea)], floodnum); } } diff --git a/src/common/model/cm_vis.c b/src/common/model/cm_vis.c index 6977be1d..47263a04 100644 --- a/src/common/model/cm_vis.c +++ b/src/common/model/cm_vis.c @@ -87,7 +87,7 @@ byte *CM_ClusterPVS (int cluster) memset (pvsrow, 0, (numclusters+7)>>3); else - CM_DecompressVis (map_visibility + map_vis->bitofs[cluster][DVIS_PVS], pvsrow); + CM_DecompressVis (map_visibility + LittleLong(map_vis->bitofs[cluster][DVIS_PVS]), pvsrow); return pvsrow; } @@ -98,7 +98,7 @@ byte *CM_ClusterPHS (int cluster) memset (phsrow, 0, (numclusters+7)>>3); else - CM_DecompressVis (map_visibility + map_vis->bitofs[cluster][DVIS_PHS], phsrow); + CM_DecompressVis (map_visibility + LittleLong(map_vis->bitofs[cluster][DVIS_PHS]), phsrow); return phsrow; } diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index e4f22065..9d1a2974 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -791,8 +791,8 @@ BigShort(short l) short LittleShort(short l) -{return - _LittleShort(l); +{ + return _LittleShort(l); } int @@ -904,6 +904,9 @@ Swap_Init(void) _BigFloat = FloatNoSwap; _LittleFloat = FloatSwap; } + + if (LittleShort(*(short *)swaptest) != 1) + assert("Error in the endian conversion!"); } /* diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index fcc47233..743f5a2d 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -96,6 +96,8 @@ #define ARCH "i386" #elif defined(__x86_64__) #define ARCH "amd64" +#elif defined(__sparc__) + #define ARCH "sparc64" #else #define ARCH "unknown" #endif diff --git a/src/refresh/r_main.c b/src/refresh/r_main.c index c6105b22..3186e413 100644 --- a/src/refresh/r_main.c +++ b/src/refresh/r_main.c @@ -500,7 +500,7 @@ R_DrawParticles ( void ) qglEnable( GL_BLEND ); qglDisable( GL_TEXTURE_2D ); - qglPointSize( gl_particle_size->value ); + qglPointSize( LittleFloat(gl_particle_size->value) ); qglBegin( GL_POINTS ); From 8930dc512f01b0db3d33fde838c7b1a07a5a0b23 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 19 Apr 2012 13:11:00 +0000 Subject: [PATCH 2/6] Enforce "C" locale --- src/unix/misc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/misc.c b/src/unix/misc.c index c425d335..593d6f80 100644 --- a/src/unix/misc.c +++ b/src/unix/misc.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -62,6 +63,9 @@ main ( int argc, char **argv ) saved_euid = geteuid(); seteuid( getuid() ); + /* enforce C locale */ + setlocale(LC_ALL, "C"); + printf( "\nYamagi Quake II v%4.2f\n", VERSION); printf( "=====================\n\n"); From a7aa1e93c01c521dba5f56e75a6f39f8a4c649d6 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 19 Apr 2012 13:14:03 +0000 Subject: [PATCH 3/6] Rename misc.c to main.c --- Makefile | 6 +++--- src/unix/{misc.c => main.c} | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) rename src/unix/{misc.c => main.c} (96%) diff --git a/Makefile b/Makefile index 50a0c9e0..de4baa96 100644 --- a/Makefile +++ b/Makefile @@ -308,7 +308,7 @@ CLIENT_OBJS_ := \ src/server/sv_world.o \ src/unix/glob.o \ src/unix/hunk.o \ - src/unix/misc.o \ + src/unix/main.o \ src/unix/network.o \ src/unix/signalhandler.o \ src/unix/system.o \ @@ -354,7 +354,7 @@ SERVER_OBJS_ := \ src/server/sv_world.o \ src/unix/glob.o \ src/unix/hunk.o \ - src/unix/misc.o \ + src/unix/main.o \ src/unix/network.o \ src/unix/signalhandler.o \ src/unix/system.o @@ -385,7 +385,7 @@ OPENGL_OBJS_ = \ src/common/shared/shared.o \ src/unix/glob.o \ src/unix/hunk.o \ - src/unix/misc.o \ + src/unix/main.o \ src/unix/qgl.o # ---------- diff --git a/src/unix/misc.c b/src/unix/main.c similarity index 96% rename from src/unix/misc.c rename to src/unix/main.c index 593d6f80..52171d0c 100644 --- a/src/unix/misc.c +++ b/src/unix/main.c @@ -19,7 +19,8 @@ * * ======================================================================= * - * This file implements some misc stuff like the main loop + * This file is the starting point of the program and implements + * the main loop * * ======================================================================= */ From 179ec5538e82c89f05bca3cda082a0d9e6d5edf0 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 19 Apr 2012 13:22:50 +0000 Subject: [PATCH 4/6] Move strlwr() into shared.c and don't link main.c into the refresher --- Makefile | 1 - src/common/header/shared.h | 2 ++ src/common/shared/shared.c | 16 ++++++++++++++++ src/unix/main.c | 15 --------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index de4baa96..8065d596 100644 --- a/Makefile +++ b/Makefile @@ -385,7 +385,6 @@ OPENGL_OBJS_ = \ src/common/shared/shared.o \ src/unix/glob.o \ src/unix/hunk.o \ - src/unix/main.o \ src/unix/qgl.o # ---------- diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 7de3eaed..d3b2f59c 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -196,6 +196,8 @@ void Com_sprintf(char *dest, int size, char *fmt, ...); void Com_PageInMemory(byte *buffer, int size); +char *strlwr ( char *s ); + /* ============================================= */ /* portable case insensitive compare */ diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index 9d1a2974..d3c3ead4 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -24,6 +24,8 @@ * ======================================================================= */ +#include + #include "../header/shared.h" #define DEG2RAD(a) (a * M_PI) / 180.0F @@ -1113,6 +1115,20 @@ Com_sprintf(char *dest, int size, char *fmt, ...) strcpy(dest, bigbuffer); } +char * +strlwr ( char *s ) +{ + char *p = s; + + while ( *s ) + { + *s = tolower( *s ); + s++; + } + + return ( p ); +} + /* * ===================================================================== * diff --git a/src/unix/main.c b/src/unix/main.c index 52171d0c..0d846d79 100644 --- a/src/unix/main.c +++ b/src/unix/main.c @@ -25,7 +25,6 @@ * ======================================================================= */ -#include #include #include #include @@ -38,20 +37,6 @@ cvar_t *nostdout; uid_t saved_euid; -char * -strlwr ( char *s ) -{ - char *p = s; - - while ( *s ) - { - *s = tolower( *s ); - s++; - } - - return ( p ); -} - int main ( int argc, char **argv ) { From df0347bde0f2e623d1666511e03ceeedf1666afe Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 19 Apr 2012 13:25:51 +0000 Subject: [PATCH 5/6] Do not link the X11 libs used for setting the gamma --- Makefile | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 8065d596..8c1755ef 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,6 @@ # - libGL # # - libvorbis # # - libogg # -# - X11 (libX11, Xxf86vm) # # - zlib # # # # Platforms: # @@ -69,12 +68,6 @@ SDLCFLAGS := $(shell sdl-config --cflags) # ---------- -# Extra CFLAGS for X11 -X11CFLAGS := $(shell pkg-config x11 --cflags) -X11CFLAGS += $(shell pkg-config xxf86vm --cflags) - -# ---------- - # Base include path. ifeq ($(OSTYPE),Linux) INCLUDE := -I/usr/include @@ -98,12 +91,6 @@ SDLLDFLAGS := $(shell sdl-config --libs) # ---------- -# Extra LDFLAGS for X11 -X11LDFLAGS := $(shell pkg-config x11 --libs) -X11LDFLAGS += $(shell pkg-config xxf86vm --libs) - -# ---------- - # When make is invoked by "make VERBOSE=1" print # the compiler and linker commands. @@ -136,7 +123,7 @@ client: build/client/%.o: %.c @echo '===> CC $<' ${Q}mkdir -p $(@D) - ${Q}$(CC) -c $(CFLAGS) $(X11CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< + ${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $< release/quake2 : LDFLAGS += -lvorbis -lvorbisfile -logg -lz @@ -426,7 +413,7 @@ release/q2ded : $(SERVER_OBJS) # release/ref_gl.so release/ref_gl.so : $(OPENGL_OBJS) @echo '===> LD $@' - ${Q}$(CC) $(OPENGL_OBJS) $(LDFLAGS) $(X11LDFLAGS) -o $@ + ${Q}$(CC) $(OPENGL_OBJS) $(LDFLAGS) -o $@ # release/baseq2/game.so release/baseq2/game.so : $(GAME_OBJS) From fc32d16d423a1a91dc1dc495b43dd26d9ece4ce4 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 19 Apr 2012 13:33:48 +0000 Subject: [PATCH 6/6] Print - OS - CPU - byte ordering at startup --- src/common/shared/shared.c | 2 ++ src/unix/main.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index d3c3ead4..62f06f1b 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -895,6 +895,7 @@ Swap_Init(void) _LittleLong = LongNoSwap; _BigFloat = FloatSwap; _LittleFloat = FloatNoSwap; + Com_Printf("Byte ordering: little endian\n\n"); } else { @@ -905,6 +906,7 @@ Swap_Init(void) _LittleLong = LongSwap; _BigFloat = FloatNoSwap; _LittleFloat = FloatSwap; + Com_Printf("Byte ordering: big endian\n\n"); } if (LittleShort(*(short *)swaptest) != 1) diff --git a/src/unix/main.c b/src/unix/main.c index 0d846d79..457f5a8f 100644 --- a/src/unix/main.c +++ b/src/unix/main.c @@ -55,6 +55,9 @@ main ( int argc, char **argv ) printf( "\nYamagi Quake II v%4.2f\n", VERSION); printf( "=====================\n\n"); + printf("Platform: %s\n", BUILDSTRING); + printf("Architecture: %s\n", CPUSTRING); + Qcommon_Init( argc, argv ); fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );