r1127 - in branches/1.34: . code code/SDL12/include code/botlib code/cgame code/client code/game code/jpeg-6 code/libs code/libs/macosx code/null code/q3_ui code/qcommon code/renderer code/server code/tools/asm code/ui code/unix code/unix/setup code/unix/setup/pkg/ioquake3 code/unix/setup/pkg/ioquake3d code/win32
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Aug 22 17:25:32 EDT 2007
Author: tma
Date: 2007-08-22 17:25:32 -0400 (Wed, 22 Aug 2007)
New Revision: 1127
Added:
branches/1.34/code/SDL12/include/SDL_config.h
branches/1.34/code/SDL12/include/SDL_config_amiga.h
branches/1.34/code/SDL12/include/SDL_config_dreamcast.h
branches/1.34/code/SDL12/include/SDL_config_macos.h
branches/1.34/code/SDL12/include/SDL_config_macosx.h
branches/1.34/code/SDL12/include/SDL_config_minimal.h
branches/1.34/code/SDL12/include/SDL_config_os2.h
branches/1.34/code/SDL12/include/SDL_config_win32.h
branches/1.34/code/SDL12/include/SDL_platform.h
branches/1.34/code/SDL12/include/SDL_stdinc.h
branches/1.34/code/client/cl_curl.c
branches/1.34/code/client/cl_curl.h
branches/1.34/code/libcurl/
branches/1.34/code/libs/win32/
branches/1.34/code/qcommon/vm_ppc.c
branches/1.34/code/qcommon/vm_x86_64_assembler.c
branches/1.34/code/win32/win_resource.rc
Removed:
branches/1.34/code/qcommon/vm_ppc.c
branches/1.34/code/qcommon/vm_ppc_new.c
branches/1.34/code/win32/winquake.rc
Modified:
branches/1.34/
branches/1.34/Makefile
branches/1.34/NOTTODO
branches/1.34/README
branches/1.34/TODO
branches/1.34/code/SDL12/include/SDL.h
branches/1.34/code/SDL12/include/SDL_active.h
branches/1.34/code/SDL12/include/SDL_audio.h
branches/1.34/code/SDL12/include/SDL_byteorder.h
branches/1.34/code/SDL12/include/SDL_cdrom.h
branches/1.34/code/SDL12/include/SDL_copying.h
branches/1.34/code/SDL12/include/SDL_cpuinfo.h
branches/1.34/code/SDL12/include/SDL_endian.h
branches/1.34/code/SDL12/include/SDL_error.h
branches/1.34/code/SDL12/include/SDL_events.h
branches/1.34/code/SDL12/include/SDL_getenv.h
branches/1.34/code/SDL12/include/SDL_joystick.h
branches/1.34/code/SDL12/include/SDL_keyboard.h
branches/1.34/code/SDL12/include/SDL_keysym.h
branches/1.34/code/SDL12/include/SDL_loadso.h
branches/1.34/code/SDL12/include/SDL_main.h
branches/1.34/code/SDL12/include/SDL_mouse.h
branches/1.34/code/SDL12/include/SDL_mutex.h
branches/1.34/code/SDL12/include/SDL_opengl.h
branches/1.34/code/SDL12/include/SDL_quit.h
branches/1.34/code/SDL12/include/SDL_rwops.h
branches/1.34/code/SDL12/include/SDL_syswm.h
branches/1.34/code/SDL12/include/SDL_thread.h
branches/1.34/code/SDL12/include/SDL_timer.h
branches/1.34/code/SDL12/include/SDL_types.h
branches/1.34/code/SDL12/include/SDL_version.h
branches/1.34/code/SDL12/include/SDL_video.h
branches/1.34/code/SDL12/include/begin_code.h
branches/1.34/code/SDL12/include/close_code.h
branches/1.34/code/botlib/be_ai_chat.c
branches/1.34/code/botlib/be_ai_goal.c
branches/1.34/code/botlib/be_ai_weap.c
branches/1.34/code/cgame/cg_main.c
branches/1.34/code/client/cl_cgame.c
branches/1.34/code/client/cl_keys.c
branches/1.34/code/client/cl_main.c
branches/1.34/code/client/cl_parse.c
branches/1.34/code/client/cl_ui.c
branches/1.34/code/client/client.h
branches/1.34/code/client/keycodes.h
branches/1.34/code/client/keys.h
branches/1.34/code/client/qal.c
branches/1.34/code/client/snd_dma.c
branches/1.34/code/client/snd_openal.c
branches/1.34/code/game/ai_cmd.c
branches/1.34/code/game/ai_dmq3.c
branches/1.34/code/game/ai_team.c
branches/1.34/code/game/bg_lib.h
branches/1.34/code/game/g_bot.c
branches/1.34/code/game/g_local.h
branches/1.34/code/game/g_session.c
branches/1.34/code/jpeg-6/jerror.c
branches/1.34/code/jpeg-6/jmemnobs.c
branches/1.34/code/jpeg-6/jmorecfg.h
branches/1.34/code/libs/macosx/libSDL-1.2.0.dylib
branches/1.34/code/null/null_client.c
branches/1.34/code/q3_ui/ui_teamorders.c
branches/1.34/code/qcommon/cm_patch.c
branches/1.34/code/qcommon/cm_test.c
branches/1.34/code/qcommon/cm_trace.c
branches/1.34/code/qcommon/common.c
branches/1.34/code/qcommon/cvar.c
branches/1.34/code/qcommon/files.c
branches/1.34/code/qcommon/md5.c
branches/1.34/code/qcommon/msg.c
branches/1.34/code/qcommon/net_chan.c
branches/1.34/code/qcommon/q_math.c
branches/1.34/code/qcommon/q_platform.h
branches/1.34/code/qcommon/q_shared.c
branches/1.34/code/qcommon/q_shared.h
branches/1.34/code/qcommon/qcommon.h
branches/1.34/code/qcommon/vm.c
branches/1.34/code/qcommon/vm_interpreted.c
branches/1.34/code/qcommon/vm_x86.c
branches/1.34/code/qcommon/vm_x86_64.c
branches/1.34/code/renderer/tr_init.c
branches/1.34/code/renderer/tr_shader.c
branches/1.34/code/server/sv_client.c
branches/1.34/code/server/sv_game.c
branches/1.34/code/server/sv_init.c
branches/1.34/code/server/sv_main.c
branches/1.34/code/tools/asm/Makefile
branches/1.34/code/tools/asm/cmdlib.c
branches/1.34/code/ui/ui_main.c
branches/1.34/code/ui/ui_players.c
branches/1.34/code/unix/linux_glimp.c
branches/1.34/code/unix/linux_signals.c
branches/1.34/code/unix/sdl_glimp.c
branches/1.34/code/unix/sdl_snd.c
branches/1.34/code/unix/setup/Makefile
branches/1.34/code/unix/setup/Solaris_pkg.sh
branches/1.34/code/unix/setup/pkg/ioquake3/pkginfo.template
branches/1.34/code/unix/setup/pkg/ioquake3d/pkginfo.template
branches/1.34/code/unix/setup/setup.xml
branches/1.34/code/unix/unix_main.c
branches/1.34/code/unix/unix_net.c
branches/1.34/code/unix/unix_shared.c
branches/1.34/code/win32/win_gamma.c
branches/1.34/code/win32/win_input.c
branches/1.34/code/win32/win_shared.c
branches/1.34/code/win32/win_wndproc.c
branches/1.34/cross-make-mingw.sh
branches/1.34/make-macosx-ub.sh
Log:
* Merge trunk to 1.34 branch
+ HTTP download support -- this has enough testing now
+ OpenAL still disabled by default
Property changes on: branches/1.34
___________________________________________________________________
Name: svn:ignore
+ *.d
Modified: branches/1.34/Makefile
===================================================================
--- branches/1.34/Makefile 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/Makefile 2007-08-22 21:25:32 UTC (rev 1127)
@@ -100,6 +100,18 @@
USE_OPENAL_DLOPEN=0
endif
+ifndef USE_CURL
+USE_CURL=1
+endif
+
+ifndef USE_CURL_DLOPEN
+ ifeq ($(PLATFORM),mingw32)
+ USE_CURL_DLOPEN=0
+ else
+ USE_CURL_DLOPEN=1
+ endif
+endif
+
ifndef USE_CODEC_VORBIS
USE_CODEC_VORBIS=0
endif
@@ -145,8 +157,6 @@
#############################################################################
## Defaults
-VM_PPC=
-
LIB=lib
INSTALL=install
@@ -154,8 +164,6 @@
ifeq ($(PLATFORM),linux)
- CC=gcc
-
ifeq ($(ARCH),alpha)
ARCH=axp
else
@@ -181,15 +189,21 @@
endif
endif
+ ifeq ($(USE_CURL),1)
+ BASE_CFLAGS += -DUSE_CURL=1
+ ifeq ($(USE_CURL_DLOPEN),1)
+ BASE_CFLAGS += -DUSE_CURL_DLOPEN=1
+ endif
+ endif
+
ifeq ($(USE_CODEC_VORBIS),1)
BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
endif
ifeq ($(USE_SDL),1)
BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags)
- GL_CFLAGS =
else
- GL_CFLAGS = -I/usr/X11R6/include
+ BASE_CFLAGS += -I/usr/X11R6/include
endif
OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
@@ -209,9 +223,7 @@
else
ifeq ($(ARCH),ppc)
BASE_CFLAGS += -maltivec
- ifneq ($(VM_PPC),)
- HAVE_VM_COMPILED=true
- endif
+ HAVE_VM_COMPILED=false
endif
endif
endif
@@ -242,6 +254,12 @@
CLIENT_LDFLAGS += -lopenal
endif
endif
+
+ ifeq ($(USE_CURL),1)
+ ifneq ($(USE_CURL_DLOPEN),1)
+ CLIENT_LDFLAGS += -lcurl
+ endif
+ endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
@@ -260,8 +278,6 @@
#############################################################################
ifeq ($(PLATFORM),darwin)
- CC=gcc
- VM_PPC=vm_ppc_new
HAVE_VM_COMPILED=true
BASE_CFLAGS=
CLIENT_LDFLAGS=
@@ -281,7 +297,7 @@
LDFLAGS += -arch ppc \
-L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
- -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk,-m
+ -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk,-m
ARCH=ppc
# OS X 10.2 sdk lacks dlopen() so ded would need libSDL anyway
@@ -289,7 +305,7 @@
# because of a problem with linking on 10.2 this will generate multiply
# defined symbol errors. The errors can be turned into warnings with
- # the -m linker flag, but you can't shut up the warnings
+ # the -m linker flag, but you can't shut up the warnings
USE_OPENAL_DLOPEN=1
else
ifeq ($(BUILD_MACOSX_UB),i386)
@@ -307,7 +323,7 @@
ARCH=i386
BUILD_SERVER=0
else
- # for whatever reason using the headers in the MacOSX SDKs tend to throw
+ # for whatever reason using the headers in the MacOSX SDKs tend to throw
# errors even though they are identical to the system ones which don't
# therefore we shut up warning flags when running the universal build
# script as much as possible.
@@ -317,9 +333,6 @@
ifeq ($(ARCH),ppc)
OPTIMIZE += -faltivec -O3
- # Carbon is required on PPC only to make a call to MakeDataExecutable
- # in the PPC vm (should be a better non-Carbon way).
- LDFLAGS += -framework Carbon
endif
ifeq ($(ARCH),i386)
OPTIMIZE += -march=prescott -mfpmath=sse
@@ -342,6 +355,15 @@
endif
endif
+ ifeq ($(USE_CURL),1)
+ BASE_CFLAGS += -DUSE_CURL=1
+ ifneq ($(USE_CURL_DLOPEN),1)
+ CLIENT_LDFLAGS += -lcurl
+ else
+ BASE_CFLAGS += -DUSE_CURL_DLOPEN=1
+ endif
+ endif
+
ifeq ($(USE_CODEC_VORBIS),1)
BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
@@ -350,12 +372,11 @@
ifeq ($(USE_SDL),1)
BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 -D_THREAD_SAFE=1 \
-I$(SDLHDIR)/include
- GL_CFLAGS =
# We copy sdlmain before ranlib'ing it so that subversion doesn't think
# the file has been modified by each build.
LIBSDLMAIN=$(B)/libSDLmain.a
LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a
- CLIENT_LDFLAGS += -framework Cocoa -framework OpenGL \
+ CLIENT_LDFLAGS += -framework Cocoa -framework IOKit -framework OpenGL \
$(LIBSDIR)/macosx/libSDL-1.2.0.dylib
else
# !!! FIXME: frameworks: OpenGL, Carbon, etc...
@@ -387,8 +408,9 @@
ifeq ($(PLATFORM),mingw32)
- CC=gcc
- WINDRES=windres
+ifndef WINDRES
+WINDRES=windres
+endif
ARCH=x86
@@ -398,13 +420,17 @@
BASE_CFLAGS += -DUSE_OPENAL=1 -DUSE_OPENAL_DLOPEN=1
endif
+ ifeq ($(USE_CURL),1)
+ BASE_CFLAGS += -DUSE_CURL=1
+ ifneq ($(USE_CURL_DLOPEN),1)
+ BASE_CFLAGS += -DCURL_STATICLIB
+ endif
+ endif
+
ifeq ($(USE_CODEC_VORBIS),1)
BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
endif
- GL_CFLAGS =
- MINGW_CFLAGS = -DDONT_TYPEDEF_INT32
-
OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math -falign-loops=2 \
-funroll-loops -falign-jumps=2 -falign-functions=2 -fstrength-reduce
@@ -423,6 +449,12 @@
LDFLAGS= -mwindows -lwsock32 -lgdi32 -lwinmm -lole32
CLIENT_LDFLAGS=
+ ifeq ($(USE_CURL),1)
+ ifneq ($(USE_CURL_DLOPEN),1)
+ CLIENT_LDFLAGS += $(LIBSDIR)/win32/libcurl.a
+ endif
+ endif
+
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
endif
@@ -451,10 +483,9 @@
endif #alpha test
- BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
+ BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+ -I/usr/X11R6/include
- GL_CFLAGS = -I/usr/X11R6/include
-
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
ifeq ($(USE_OPENAL),1)
@@ -473,13 +504,11 @@
endif
ifeq ($(ARCH),axp)
- CC=gcc
BASE_CFLAGS += -DNO_VM_COMPILED
RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations
else
ifeq ($(ARCH),i386)
- CC=gcc
RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
-march=pentium -fomit-frame-pointer -pipe -ffast-math \
-falign-loops=2 -falign-jumps=2 -falign-functions=2 \
@@ -529,7 +558,6 @@
ARCH=i386
endif
- CC=gcc
LDFLAGS=-lm
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
@@ -556,7 +584,6 @@
ARCH=mips #default to MIPS
- CC=cc
BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 -mips3 \
-nostdinc -I. -I$(ROOT)/usr/include -DNO_VM_COMPILED
RELEASE_CFLAGS=$(BASE_CFLAGS) -O3
@@ -599,9 +626,8 @@
ifeq ($(USE_SDL),1)
BASE_CFLAGS += -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags)
- GL_CFLAGS =
else
- GL_CFLAGS = -I/usr/openwin/include
+ BASE_CFLAGS += -I/usr/openwin/include
endif
OPTIMIZE = -O3 -ffast-math -funroll-loops
@@ -611,15 +637,22 @@
-falign-jumps=2 -falign-functions=2 -fstrength-reduce \
-mtune=ultrasparc -mv8plus -mno-faster-structs \
-funroll-loops
- BASE_CFLAGS += -DNO_VM_COMPILED
else
ifeq ($(ARCH),i386)
- OPTIMIZE = -O3 -march=i586 -ffast-math \
- -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
- -funroll-loops -fstrength-reduce
+ OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
+ -funroll-loops -falign-loops=2 -falign-jumps=2 \
+ -falign-functions=2 -fstrength-reduce
+ HAVE_VM_COMPILED=true
+ BASE_CFLAGS += -m32
+ LDFLAGS += -m32
+ BASE_CFLAGS += -I/usr/X11/include/NVIDIA
endif
endif
+ ifneq ($(HAVE_VM_COMPILED),true)
+ BASE_CFLAGS += -DNO_VM_COMPILED
+ endif
+
DEBUG_CFLAGS = $(BASE_CFLAGS) -ggdb -O0
RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
@@ -639,18 +672,11 @@
CLIENT_LDFLAGS=-L/usr/openwin/$(LIB) -L/usr/X11/lib -lGLU -lX11 -lXext
endif
- ifeq ($(ARCH),i386)
- # Solarix x86 make ...
- BASE_CFLAGS += -m32
- LDFLAGS+=-m32
- endif
-
else # ifeq sunos
#############################################################################
# SETUP AND BUILD -- GENERIC
#############################################################################
- CC=cc
BASE_CFLAGS=-DNO_VM_COMPILED
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3
@@ -698,8 +724,7 @@
$(B)/baseq3/vm/ui.qvm \
$(B)/missionpack/vm/qagame.qvm \
$(B)/missionpack/vm/cgame.qvm \
- $(B)/missionpack/vm/ui.qvm \
- qvmdeps
+ $(B)/missionpack/vm/ui.qvm
endif
endif
@@ -716,51 +741,99 @@
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
- ifeq ($(CC),gcc)
- DEPEND_CFLAGS=-MMD
- endif
+ BASE_CFLAGS += -MMD
endif
ifeq ($(USE_SVN),1)
BASE_CFLAGS += -DSVN_VERSION=\\\"$(SVN_VERSION)\\\"
endif
-DO_CC=$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $<
-DO_SMP_CC=$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $<
-DO_BOT_CC=$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $< # $(SHLIBCFLAGS) # bk001212
-DO_DEBUG_CC=$(CC) $(NOTSHLIBCFLAGS) $(DEBUG_CFLAGS) -o $@ -c $<
-DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
-DO_SHLIB_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
-DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
-DO_DED_CC=$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $<
-DO_WINDRES=$(WINDRES) -i $< -o $@
+define DO_CC
+ at echo "CC $<"
+@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $<
+endef
+define DO_SMP_CC
+ at echo "SMP_CC $<"
+@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $<
+endef
+
+define DO_BOT_CC
+ at echo "BOT_CC $<"
+@$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $<
+endef
+
+ifeq ($(GENERATE_DEPENDENCIES),1)
+ DO_QVM_DEP=cat $(@:%.o=%.d) | sed -e 's/\.o/\.asm/g' >> $(@:%.o=%.d)
+endif
+
+define DO_SHLIB_CC
+ at echo "SHLIB_CC $<"
+@$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
+@$(DO_QVM_DEP)
+endef
+
+define DO_SHLIB_CC_MISSIONPACK
+ at echo "SHLIB_CC_MISSIONPACK $<"
+@$(CC) -DMISSIONPACK $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
+@$(DO_QVM_DEP)
+endef
+
+define DO_AS
+ at echo "AS $<"
+@$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
+endef
+
+define DO_DED_CC
+ at echo "DED_CC $<"
+@$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $<
+endef
+
+define DO_WINDRES
+ at echo "WINDRES $<"
+@$(WINDRES) -i $< -o $@
+endef
+
+
#############################################################################
# MAIN TARGETS
#############################################################################
-default:build_release
+default: release
+all: debug release
-debug: build_debug
-release: build_release
+debug:
+ @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS)"
-build_debug: B=$(BD)
-build_debug: makedirs tools
- $(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS) $(DEPEND_CFLAGS)"
+release:
+ @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS)"
-build_release: B=$(BR)
-build_release: makedirs tools
- $(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS) $(DEPEND_CFLAGS)"
+# Create the build directories and tools, print out
+# an informational message, then start building
+targets: makedirs tools
+ @echo ""
+ @echo "Building ioquake3 in $(B):"
+ @echo " CC: $(CC)"
+ @echo ""
+ @echo " CFLAGS:"
+ @for i in $(CFLAGS); \
+ do \
+ echo " $$i"; \
+ done
+ @echo ""
+ @echo " Output:"
+ @for i in $(TARGETS); \
+ do \
+ echo " $$i"; \
+ done
+ @echo ""
+ @$(MAKE) $(TARGETS)
-#Build both debug and release builds
-all:build_debug build_release
-
-targets: $(TARGETS)
-
makedirs:
@if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi
@if [ ! -d $(B) ];then $(MKDIR) $(B);fi
@if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi
+ @if [ ! -d $(B)/clientsmp ];then $(MKDIR) $(B)/clientsmp;fi
@if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi
@if [ ! -d $(B)/baseq3 ];then $(MKDIR) $(B)/baseq3;fi
@if [ ! -d $(B)/baseq3/cgame ];then $(MKDIR) $(B)/baseq3/cgame;fi
@@ -784,15 +857,24 @@
ifeq ($(CROSS_COMPILING),1)
tools:
- echo QVM tools not built when cross-compiling
+ @echo QVM tools not built when cross-compiling
else
tools:
$(MAKE) -C $(TOOLSDIR)/lcc install
$(MAKE) -C $(TOOLSDIR)/asm install
endif
-DO_Q3LCC=$(Q3LCC) -o $@ $<
+define DO_Q3LCC
+ at echo "Q3LCC $<"
+@$(Q3LCC) -o $@ $<
+endef
+define DO_Q3LCC_MISSIONPACK
+ at echo "Q3LCC_MISSIONPACK $<"
+@$(Q3LCC) -DMISSIONPACK -o $@ $<
+endef
+
+
#############################################################################
# CLIENT/SERVER
#############################################################################
@@ -840,6 +922,8 @@
$(B)/client/qal.o \
$(B)/client/snd_openal.o \
\
+ $(B)/client/cl_curl.o \
+ \
$(B)/client/sv_bot.o \
$(B)/client/sv_ccmds.o \
$(B)/client/sv_client.o \
@@ -968,10 +1052,10 @@
Q3OBJ += $(B)/client/vm_x86.o
endif
ifeq ($(ARCH),x86_64)
- Q3OBJ += $(B)/client/vm_x86_64.o
+ Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
endif
ifeq ($(ARCH),ppc)
- Q3OBJ += $(B)/client/$(VM_PPC).o
+ Q3OBJ += $(B)/client/vm_ppc.o
endif
endif
@@ -1013,15 +1097,18 @@
$(B)/client/sdl_glimp.o
Q3POBJ_SMP = \
- $(B)/client/linux_glimp_smp.o \
- $(B)/client/sdl_glimp_smp.o
+ $(B)/clientsmp/linux_glimp.o \
+ $(B)/clientsmp/sdl_glimp.o
endif
$(B)/ioquake3.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
- $(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
+ @echo "LD $@"
+ @$(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) \
+ $(LDFLAGS) $(LIBSDLMAIN)
$(B)/ioquake3-smp.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN)
- $(CC) -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(CLIENT_LDFLAGS) \
+ @echo "LD $@"
+ @$(CC) -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(CLIENT_LDFLAGS) \
$(THREAD_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
ifneq ($(strip $(LIBSDLMAIN)),)
@@ -1032,200 +1119,8 @@
endif
endif
-$(B)/client/cl_cgame.o : $(CDIR)/cl_cgame.c; $(DO_CC)
-$(B)/client/cl_cin.o : $(CDIR)/cl_cin.c; $(DO_CC)
-$(B)/client/cl_console.o : $(CDIR)/cl_console.c; $(DO_CC)
-ifeq ($(USE_SVN),1)
- $(B)/client/cl_console.o : .svn/entries
-endif
-$(B)/client/cl_input.o : $(CDIR)/cl_input.c; $(DO_CC)
-$(B)/client/cl_keys.o : $(CDIR)/cl_keys.c; $(DO_CC)
-$(B)/client/cl_main.o : $(CDIR)/cl_main.c; $(DO_CC)
-$(B)/client/cl_net_chan.o : $(CDIR)/cl_net_chan.c; $(DO_CC)
-$(B)/client/cl_parse.o : $(CDIR)/cl_parse.c; $(DO_CC)
-$(B)/client/cl_scrn.o : $(CDIR)/cl_scrn.c; $(DO_CC)
-$(B)/client/cl_ui.o : $(CDIR)/cl_ui.c; $(DO_CC)
-$(B)/client/cl_avi.o : $(CDIR)/cl_avi.c; $(DO_CC)
-$(B)/client/snd_adpcm.o : $(CDIR)/snd_adpcm.c; $(DO_CC)
-$(B)/client/snd_dma.o : $(CDIR)/snd_dma.c; $(DO_CC)
-$(B)/client/snd_mem.o : $(CDIR)/snd_mem.c; $(DO_CC)
-$(B)/client/snd_mix.o : $(CDIR)/snd_mix.c; $(DO_CC)
-$(B)/client/snd_wavelet.o : $(CDIR)/snd_wavelet.c; $(DO_CC)
-$(B)/client/snd_main.o : $(CDIR)/snd_main.c; $(DO_CC)
-$(B)/client/snd_codec.o : $(CDIR)/snd_codec.c; $(DO_CC)
-$(B)/client/snd_codec_wav.o : $(CDIR)/snd_codec_wav.c; $(DO_CC)
-$(B)/client/snd_codec_ogg.o : $(CDIR)/snd_codec_ogg.c; $(DO_CC)
-$(B)/client/qal.o : $(CDIR)/qal.c; $(DO_CC)
-$(B)/client/snd_openal.o : $(CDIR)/snd_openal.c; $(DO_CC)
-
-$(B)/client/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_CC)
-$(B)/client/sv_client.o : $(SDIR)/sv_client.c; $(DO_CC)
-$(B)/client/sv_ccmds.o : $(SDIR)/sv_ccmds.c; $(DO_CC)
-$(B)/client/sv_game.o : $(SDIR)/sv_game.c; $(DO_CC)
-$(B)/client/sv_init.o : $(SDIR)/sv_init.c; $(DO_CC)
-$(B)/client/sv_main.o : $(SDIR)/sv_main.c; $(DO_CC)
-$(B)/client/sv_net_chan.o : $(SDIR)/sv_net_chan.c; $(DO_CC)
-$(B)/client/sv_snapshot.o : $(SDIR)/sv_snapshot.c; $(DO_CC)
-$(B)/client/sv_world.o : $(SDIR)/sv_world.c; $(DO_CC)
-$(B)/client/cm_trace.o : $(CMDIR)/cm_trace.c; $(DO_CC)
-$(B)/client/cm_load.o : $(CMDIR)/cm_load.c; $(DO_CC)
-$(B)/client/cm_test.o : $(CMDIR)/cm_test.c; $(DO_CC)
-$(B)/client/cm_patch.o : $(CMDIR)/cm_patch.c; $(DO_CC)
-$(B)/client/cm_polylib.o : $(CMDIR)/cm_polylib.c; $(DO_CC)
-$(B)/client/cmd.o : $(CMDIR)/cmd.c; $(DO_CC)
-$(B)/client/common.o : $(CMDIR)/common.c; $(DO_CC)
-ifeq ($(USE_SVN),1)
- $(B)/client/common.o : .svn/entries
-endif
-$(B)/client/cvar.o : $(CMDIR)/cvar.c; $(DO_CC)
-$(B)/client/files.o : $(CMDIR)/files.c; $(DO_CC)
-$(B)/client/md4.o : $(CMDIR)/md4.c; $(DO_CC)
-$(B)/client/md5.o : $(CMDIR)/md5.c; $(DO_CC)
-$(B)/client/msg.o : $(CMDIR)/msg.c; $(DO_CC)
-$(B)/client/net_chan.o : $(CMDIR)/net_chan.c; $(DO_CC)
-$(B)/client/huffman.o : $(CMDIR)/huffman.c; $(DO_CC)
-$(B)/client/q_shared.o : $(CMDIR)/q_shared.c; $(DO_CC)
-$(B)/client/q_math.o : $(CMDIR)/q_math.c; $(DO_CC)
-
-$(B)/client/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC)
-$(B)/client/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC)
-$(B)/client/be_aas_debug.o : $(BLIBDIR)/be_aas_debug.c; $(DO_BOT_CC)
-$(B)/client/be_aas_entity.o : $(BLIBDIR)/be_aas_entity.c; $(DO_BOT_CC)
-$(B)/client/be_aas_file.o : $(BLIBDIR)/be_aas_file.c; $(DO_BOT_CC)
-$(B)/client/be_aas_main.o : $(BLIBDIR)/be_aas_main.c; $(DO_BOT_CC)
-$(B)/client/be_aas_move.o : $(BLIBDIR)/be_aas_move.c; $(DO_BOT_CC)
-$(B)/client/be_aas_optimize.o : $(BLIBDIR)/be_aas_optimize.c; $(DO_BOT_CC)
-$(B)/client/be_aas_reach.o : $(BLIBDIR)/be_aas_reach.c; $(DO_BOT_CC)
-$(B)/client/be_aas_route.o : $(BLIBDIR)/be_aas_route.c; $(DO_BOT_CC)
-$(B)/client/be_aas_routealt.o : $(BLIBDIR)/be_aas_routealt.c; $(DO_BOT_CC)
-$(B)/client/be_aas_sample.o : $(BLIBDIR)/be_aas_sample.c; $(DO_BOT_CC)
-$(B)/client/be_ai_char.o : $(BLIBDIR)/be_ai_char.c; $(DO_BOT_CC)
-$(B)/client/be_ai_chat.o : $(BLIBDIR)/be_ai_chat.c; $(DO_BOT_CC)
-$(B)/client/be_ai_gen.o : $(BLIBDIR)/be_ai_gen.c; $(DO_BOT_CC)
-$(B)/client/be_ai_goal.o : $(BLIBDIR)/be_ai_goal.c; $(DO_BOT_CC)
-$(B)/client/be_ai_move.o : $(BLIBDIR)/be_ai_move.c; $(DO_BOT_CC)
-$(B)/client/be_ai_weap.o : $(BLIBDIR)/be_ai_weap.c; $(DO_BOT_CC)
-$(B)/client/be_ai_weight.o : $(BLIBDIR)/be_ai_weight.c; $(DO_BOT_CC)
-$(B)/client/be_ea.o : $(BLIBDIR)/be_ea.c; $(DO_BOT_CC)
-$(B)/client/be_interface.o : $(BLIBDIR)/be_interface.c; $(DO_BOT_CC)
-$(B)/client/l_crc.o : $(BLIBDIR)/l_crc.c; $(DO_BOT_CC)
-$(B)/client/l_libvar.o : $(BLIBDIR)/l_libvar.c; $(DO_BOT_CC)
-$(B)/client/l_log.o : $(BLIBDIR)/l_log.c; $(DO_BOT_CC)
-$(B)/client/l_memory.o : $(BLIBDIR)/l_memory.c; $(DO_BOT_CC)
-$(B)/client/l_precomp.o : $(BLIBDIR)/l_precomp.c; $(DO_BOT_CC)
-$(B)/client/l_script.o : $(BLIBDIR)/l_script.c; $(DO_BOT_CC)
-$(B)/client/l_struct.o : $(BLIBDIR)/l_struct.c; $(DO_BOT_CC)
-
-$(B)/client/jcapimin.o : $(JPDIR)/jcapimin.c; $(DO_CC)
-$(B)/client/jchuff.o : $(JPDIR)/jchuff.c; $(DO_CC)
-$(B)/client/jcinit.o : $(JPDIR)/jcinit.c; $(DO_CC)
-$(B)/client/jccoefct.o : $(JPDIR)/jccoefct.c; $(DO_CC)
-$(B)/client/jccolor.o : $(JPDIR)/jccolor.c; $(DO_CC)
-$(B)/client/jfdctflt.o : $(JPDIR)/jfdctflt.c; $(DO_CC)
-$(B)/client/jcdctmgr.o : $(JPDIR)/jcdctmgr.c; $(DO_CC)
-$(B)/client/jcmainct.o : $(JPDIR)/jcmainct.c; $(DO_CC)
-$(B)/client/jcmarker.o : $(JPDIR)/jcmarker.c; $(DO_CC)
-$(B)/client/jcmaster.o : $(JPDIR)/jcmaster.c; $(DO_CC)
-$(B)/client/jcomapi.o : $(JPDIR)/jcomapi.c; $(DO_CC)
-$(B)/client/jcparam.o : $(JPDIR)/jcparam.c; $(DO_CC)
-$(B)/client/jcprepct.o : $(JPDIR)/jcprepct.c; $(DO_CC)
-$(B)/client/jcsample.o : $(JPDIR)/jcsample.c; $(DO_CC)
-
-$(B)/client/jdapimin.o : $(JPDIR)/jdapimin.c; $(DO_CC)
-$(B)/client/jdapistd.o : $(JPDIR)/jdapistd.c; $(DO_CC)
-$(B)/client/jdatasrc.o : $(JPDIR)/jdatasrc.c; $(DO_CC)
-$(B)/client/jdcoefct.o : $(JPDIR)/jdcoefct.c; $(DO_CC)
-$(B)/client/jdcolor.o : $(JPDIR)/jdcolor.c; $(DO_CC)
-$(B)/client/jcphuff.o : $(JPDIR)/jcphuff.c; $(DO_CC)
-$(B)/client/jddctmgr.o : $(JPDIR)/jddctmgr.c; $(DO_CC)
-$(B)/client/jdhuff.o : $(JPDIR)/jdhuff.c; $(DO_CC)
-$(B)/client/jdinput.o : $(JPDIR)/jdinput.c; $(DO_CC)
-$(B)/client/jdmainct.o : $(JPDIR)/jdmainct.c; $(DO_CC)
-$(B)/client/jdmarker.o : $(JPDIR)/jdmarker.c; $(DO_CC)
-$(B)/client/jdmaster.o : $(JPDIR)/jdmaster.c; $(DO_CC)
-$(B)/client/jdpostct.o : $(JPDIR)/jdpostct.c; $(DO_CC)
-$(B)/client/jdsample.o : $(JPDIR)/jdsample.c; $(DO_CC)
-$(B)/client/jdtrans.o : $(JPDIR)/jdtrans.c; $(DO_CC)
-$(B)/client/jerror.o : $(JPDIR)/jerror.c; $(DO_CC) $(GL_CFLAGS) $(MINGW_CFLAGS)
-$(B)/client/jidctflt.o : $(JPDIR)/jidctflt.c; $(DO_CC)
-$(B)/client/jmemmgr.o : $(JPDIR)/jmemmgr.c; $(DO_CC)
-$(B)/client/jmemnobs.o : $(JPDIR)/jmemnobs.c; $(DO_CC) $(GL_CFLAGS) $(MINGW_CFLAGS)
-$(B)/client/jutils.o : $(JPDIR)/jutils.c; $(DO_CC)
-
-$(B)/client/tr_bsp.o : $(RDIR)/tr_bsp.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_animation.o : $(RDIR)/tr_animation.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_backend.o : $(RDIR)/tr_backend.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_cmds.o : $(RDIR)/tr_cmds.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_curve.o : $(RDIR)/tr_curve.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_flares.o : $(RDIR)/tr_flares.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_font.o : $(RDIR)/tr_font.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_image.o : $(RDIR)/tr_image.c; $(DO_CC) $(GL_CFLAGS) $(MINGW_CFLAGS)
-$(B)/client/tr_init.o : $(RDIR)/tr_init.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_light.o : $(RDIR)/tr_light.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_main.o : $(RDIR)/tr_main.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_marks.o : $(RDIR)/tr_marks.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_mesh.o : $(RDIR)/tr_mesh.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_model.o : $(RDIR)/tr_model.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_noise.o : $(RDIR)/tr_noise.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_scene.o : $(RDIR)/tr_scene.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_shade.o : $(RDIR)/tr_shade.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_shader.o : $(RDIR)/tr_shader.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_shade_calc.o : $(RDIR)/tr_shade_calc.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_shadows.o : $(RDIR)/tr_shadows.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_sky.o : $(RDIR)/tr_sky.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_smp.o : $(RDIR)/tr_smp.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_stripify.o : $(RDIR)/tr_stripify.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_subdivide.o : $(RDIR)/tr_subdivide.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_surface.o : $(RDIR)/tr_surface.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/tr_world.o : $(RDIR)/tr_world.c; $(DO_CC) $(GL_CFLAGS)
-
-$(B)/client/unix_qgl.o : $(UDIR)/unix_qgl.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/unix_main.o : $(UDIR)/unix_main.c; $(DO_CC)
-$(B)/client/unix_net.o : $(UDIR)/unix_net.c; $(DO_CC)
-$(B)/client/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_CC)
-$(B)/client/irix_glimp.o : $(UDIR)/irix_glimp.c; $(DO_CC)
-$(B)/client/irix_glimp_smp.o : $(UDIR)/irix_glimp.c; $(DO_SMP_CC)
-$(B)/client/irix_snd.o : $(UDIR)/irix_snd.c; $(DO_CC)
-$(B)/client/irix_input.o : $(UDIR)/irix_input.c; $(DO_CC)
-$(B)/client/linux_signals.o : $(UDIR)/linux_signals.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/linux_glimp.o : $(UDIR)/linux_glimp.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/sdl_glimp.o : $(UDIR)/sdl_glimp.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/linux_glimp_smp.o : $(UDIR)/linux_glimp.c; $(DO_SMP_CC) $(GL_CFLAGS)
-$(B)/client/sdl_glimp_smp.o : $(UDIR)/sdl_glimp.c; $(DO_SMP_CC) $(GL_CFLAGS)
-$(B)/client/linux_joystick.o : $(UDIR)/linux_joystick.c; $(DO_CC)
-$(B)/client/linux_qgl.o : $(UDIR)/linux_qgl.c; $(DO_CC) $(GL_CFLAGS)
-$(B)/client/linux_input.o : $(UDIR)/linux_input.c; $(DO_CC)
-$(B)/client/linux_snd.o : $(UDIR)/linux_snd.c; $(DO_CC)
-$(B)/client/sdl_snd.o : $(UDIR)/sdl_snd.c; $(DO_CC)
-$(B)/client/snd_mixa.o : $(UDIR)/snd_mixa.s; $(DO_AS)
-$(B)/client/matha.o : $(UDIR)/matha.s; $(DO_AS)
-$(B)/client/ftola.o : $(UDIR)/ftola.s; $(DO_AS)
-$(B)/client/snapvectora.o : $(UDIR)/snapvectora.s; $(DO_AS)
-
-$(B)/client/win_gamma.o : $(W32DIR)/win_gamma.c; $(DO_CC)
-$(B)/client/win_glimp.o : $(W32DIR)/win_glimp.c; $(DO_CC)
-$(B)/client/win_input.o : $(W32DIR)/win_input.c; $(DO_CC)
-$(B)/client/win_main.o : $(W32DIR)/win_main.c; $(DO_CC)
-$(B)/client/win_net.o : $(W32DIR)/win_net.c; $(DO_CC)
-$(B)/client/win_qgl.o : $(W32DIR)/win_qgl.c; $(DO_CC)
-$(B)/client/win_shared.o : $(W32DIR)/win_shared.c; $(DO_CC)
-$(B)/client/win_snd.o : $(W32DIR)/win_snd.c; $(DO_CC)
-$(B)/client/win_syscon.o : $(W32DIR)/win_syscon.c; $(DO_CC)
-$(B)/client/win_wndproc.o : $(W32DIR)/win_wndproc.c; $(DO_CC)
-$(B)/client/win_resource.o : $(W32DIR)/winquake.rc; $(DO_WINDRES)
-
-$(B)/client/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_CC)
-$(B)/client/vm_x86_64.o : $(CMDIR)/vm_x86_64.c; $(DO_CC)
-ifneq ($(VM_PPC),)
-$(B)/client/$(VM_PPC).o : $(CMDIR)/$(VM_PPC).c; $(DO_CC)
-endif
-
-$(B)/client/unzip.o : $(CMDIR)/unzip.c; $(DO_CC)
-$(B)/client/vm.o : $(CMDIR)/vm.c; $(DO_CC)
-$(B)/client/vm_interpreted.o : $(CMDIR)/vm_interpreted.c; $(DO_CC)
-
#############################################################################
# DEDICATED SERVER
#############################################################################
@@ -1321,97 +1216,19 @@
Q3DOBJ += $(B)/ded/vm_x86.o
endif
ifeq ($(ARCH),x86_64)
- Q3DOBJ += $(B)/ded/vm_x86_64.o
+ Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
endif
ifeq ($(ARCH),ppc)
- Q3DOBJ += $(B)/ded/$(VM_PPC).o
+ Q3DOBJ += $(B)/ded/vm_ppc.o
endif
endif
$(B)/ioq3ded.$(ARCH)$(BINEXT): $(Q3DOBJ)
- $(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
+ @echo "LD $@"
+ @$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
-$(B)/ded/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_DED_CC)
-$(B)/ded/sv_client.o : $(SDIR)/sv_client.c; $(DO_DED_CC)
-$(B)/ded/sv_ccmds.o : $(SDIR)/sv_ccmds.c; $(DO_DED_CC)
-$(B)/ded/sv_game.o : $(SDIR)/sv_game.c; $(DO_DED_CC)
-$(B)/ded/sv_init.o : $(SDIR)/sv_init.c; $(DO_DED_CC)
-$(B)/ded/sv_main.o : $(SDIR)/sv_main.c; $(DO_DED_CC)
-$(B)/ded/sv_net_chan.o : $(SDIR)/sv_net_chan.c; $(DO_DED_CC)
-$(B)/ded/sv_snapshot.o : $(SDIR)/sv_snapshot.c; $(DO_DED_CC)
-$(B)/ded/sv_world.o : $(SDIR)/sv_world.c; $(DO_DED_CC)
-$(B)/ded/cm_load.o : $(CMDIR)/cm_load.c; $(DO_DED_CC)
-$(B)/ded/cm_polylib.o : $(CMDIR)/cm_polylib.c; $(DO_DED_CC)
-$(B)/ded/cm_test.o : $(CMDIR)/cm_test.c; $(DO_DED_CC)
-$(B)/ded/cm_trace.o : $(CMDIR)/cm_trace.c; $(DO_DED_CC)
-$(B)/ded/cm_patch.o : $(CMDIR)/cm_patch.c; $(DO_DED_CC)
-$(B)/ded/cmd.o : $(CMDIR)/cmd.c; $(DO_DED_CC)
-$(B)/ded/common.o : $(CMDIR)/common.c; $(DO_DED_CC)
-ifeq ($(USE_SVN),1)
- $(B)/ded/common.o : .svn/entries
-endif
-$(B)/ded/cvar.o : $(CMDIR)/cvar.c; $(DO_DED_CC)
-$(B)/ded/files.o : $(CMDIR)/files.c; $(DO_DED_CC)
-$(B)/ded/md4.o : $(CMDIR)/md4.c; $(DO_DED_CC)
-$(B)/ded/msg.o : $(CMDIR)/msg.c; $(DO_DED_CC)
-$(B)/ded/net_chan.o : $(CMDIR)/net_chan.c; $(DO_DED_CC)
-$(B)/ded/huffman.o : $(CMDIR)/huffman.c; $(DO_DED_CC)
-$(B)/ded/q_shared.o : $(CMDIR)/q_shared.c; $(DO_DED_CC)
-$(B)/ded/q_math.o : $(CMDIR)/q_math.c; $(DO_DED_CC)
-$(B)/ded/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_debug.o : $(BLIBDIR)/be_aas_debug.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_entity.o : $(BLIBDIR)/be_aas_entity.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_file.o : $(BLIBDIR)/be_aas_file.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_main.o : $(BLIBDIR)/be_aas_main.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_move.o : $(BLIBDIR)/be_aas_move.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_optimize.o : $(BLIBDIR)/be_aas_optimize.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_reach.o : $(BLIBDIR)/be_aas_reach.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_route.o : $(BLIBDIR)/be_aas_route.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_routealt.o : $(BLIBDIR)/be_aas_routealt.c; $(DO_BOT_CC)
-$(B)/ded/be_aas_sample.o : $(BLIBDIR)/be_aas_sample.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_char.o : $(BLIBDIR)/be_ai_char.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_chat.o : $(BLIBDIR)/be_ai_chat.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_gen.o : $(BLIBDIR)/be_ai_gen.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_goal.o : $(BLIBDIR)/be_ai_goal.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_move.o : $(BLIBDIR)/be_ai_move.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_weap.o : $(BLIBDIR)/be_ai_weap.c; $(DO_BOT_CC)
-$(B)/ded/be_ai_weight.o : $(BLIBDIR)/be_ai_weight.c; $(DO_BOT_CC)
-$(B)/ded/be_ea.o : $(BLIBDIR)/be_ea.c; $(DO_BOT_CC)
-$(B)/ded/be_interface.o : $(BLIBDIR)/be_interface.c; $(DO_BOT_CC)
-$(B)/ded/l_crc.o : $(BLIBDIR)/l_crc.c; $(DO_BOT_CC)
-$(B)/ded/l_libvar.o : $(BLIBDIR)/l_libvar.c; $(DO_BOT_CC)
-$(B)/ded/l_log.o : $(BLIBDIR)/l_log.c; $(DO_BOT_CC)
-$(B)/ded/l_memory.o : $(BLIBDIR)/l_memory.c; $(DO_BOT_CC)
-$(B)/ded/l_precomp.o : $(BLIBDIR)/l_precomp.c; $(DO_BOT_CC)
-$(B)/ded/l_script.o : $(BLIBDIR)/l_script.c; $(DO_BOT_CC)
-$(B)/ded/l_struct.o : $(BLIBDIR)/l_struct.c; $(DO_BOT_CC)
-$(B)/ded/linux_signals.o : $(UDIR)/linux_signals.c; $(DO_DED_CC)
-$(B)/ded/unix_main.o : $(UDIR)/unix_main.c; $(DO_DED_CC)
-$(B)/ded/unix_net.o : $(UDIR)/unix_net.c; $(DO_DED_CC)
-$(B)/ded/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_DED_CC)
-
-$(B)/ded/null_client.o : $(NDIR)/null_client.c; $(DO_DED_CC)
-$(B)/ded/null_input.o : $(NDIR)/null_input.c; $(DO_DED_CC)
-$(B)/ded/null_snddma.o : $(NDIR)/null_snddma.c; $(DO_DED_CC)
-$(B)/ded/unzip.o : $(CMDIR)/unzip.c; $(DO_DED_CC)
-$(B)/ded/vm.o : $(CMDIR)/vm.c; $(DO_DED_CC)
-$(B)/ded/vm_interpreted.o : $(CMDIR)/vm_interpreted.c; $(DO_DED_CC)
-
-$(B)/ded/ftola.o : $(UDIR)/ftola.s; $(DO_AS)
-$(B)/ded/snapvectora.o : $(UDIR)/snapvectora.s; $(DO_AS)
-$(B)/ded/matha.o : $(UDIR)/matha.s; $(DO_AS)
-
-$(B)/ded/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_DED_CC)
-$(B)/ded/vm_x86_64.o : $(CMDIR)/vm_x86_64.c; $(DO_DED_CC)
-ifneq ($(VM_PPC),)
-$(B)/ded/$(VM_PPC).o : $(CMDIR)/$(VM_PPC).c; $(DO_DED_CC)
-endif
-
-
-
#############################################################################
## BASEQ3 CGAME
#############################################################################
@@ -1446,10 +1263,12 @@
Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) : $(Q3CGOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ)
$(B)/baseq3/vm/cgame.qvm: $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm
- $(Q3ASM) -o $@ $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm
#############################################################################
## MISSIONPACK CGAME
@@ -1487,10 +1306,12 @@
MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) : $(MPCGOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ)
$(B)/missionpack/vm/cgame.qvm: $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm
- $(Q3ASM) -o $@ $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm
@@ -1537,10 +1358,12 @@
Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) : $(Q3GOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ)
$(B)/baseq3/vm/qagame.qvm: $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm
- $(Q3ASM) -o $@ $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm
#############################################################################
## MISSIONPACK GAME
@@ -1585,10 +1408,12 @@
MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) : $(MPGOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ)
$(B)/missionpack/vm/qagame.qvm: $(MPGVMOBJ) $(GDIR)/g_syscalls.asm
- $(Q3ASM) -o $@ $(MPGVMOBJ) $(GDIR)/g_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(MPGVMOBJ) $(GDIR)/g_syscalls.asm
@@ -1645,10 +1470,12 @@
Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
$(B)/baseq3/ui$(ARCH).$(SHLIBEXT) : $(Q3UIOBJ)
- $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ)
+ @echo "LD $@"
+ @$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ)
$(B)/baseq3/vm/ui.qvm: $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm
- $(Q3ASM) -o $@ $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm
#############################################################################
## MISSIONPACK UI
@@ -1670,14 +1497,80 @@
MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
$(B)/missionpack/ui$(ARCH).$(SHLIBEXT) : $(MPUIOBJ)
- $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ)
+ @echo "LD $@"
+ @$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ)
$(B)/missionpack/vm/ui.qvm: $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm
- $(Q3ASM) -o $@ $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm
#############################################################################
+## CLIENT/SERVER RULES
+#############################################################################
+
+$(B)/client/%.o: $(UDIR)/%.s
+ $(DO_AS)
+
+$(B)/client/%.o: $(CDIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(SDIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(CMDIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(BLIBDIR)/%.c
+ $(DO_BOT_CC)
+
+$(B)/client/%.o: $(JPDIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(RDIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(UDIR)/%.c
+ $(DO_CC)
+
+$(B)/clientsmp/%.o: $(UDIR)/%.c
+ $(DO_SMP_CC)
+
+$(B)/client/%.o: $(W32DIR)/%.c
+ $(DO_CC)
+
+$(B)/client/%.o: $(W32DIR)/%.rc
+ $(DO_WINDRES)
+
+
+$(B)/ded/%.o: $(UDIR)/%.s
+ $(DO_AS)
+
+$(B)/ded/%.o: $(SDIR)/%.c
+ $(DO_DED_CC)
+
+$(B)/ded/%.o: $(CMDIR)/%.c
+ $(DO_DED_CC)
+
+$(B)/ded/%.o: $(BLIBDIR)/%.c
+ $(DO_BOT_CC)
+
+$(B)/ded/%.o: $(UDIR)/%.c
+ $(DO_DED_CC)
+
+$(B)/ded/%.o: $(NDIR)/%.c
+ $(DO_DED_CC)
+
+# Extra dependencies to ensure the SVN version is incorporated
+ifeq ($(USE_SVN),1)
+ $(B)/client/cl_console.o : .svn/entries
+ $(B)/client/common.o : .svn/entries
+ $(B)/ded/common.o : .svn/entries
+endif
+
+
+#############################################################################
## GAME MODULE RULES
#############################################################################
@@ -1688,10 +1581,10 @@
$(DO_Q3LCC)
$(B)/missionpack/cgame/%.o: $(CGDIR)/%.c
- $(DO_SHLIB_CC) -DMISSIONPACK
+ $(DO_SHLIB_CC_MISSIONPACK)
$(B)/missionpack/cgame/%.asm: $(CGDIR)/%.c
- $(DO_Q3LCC) -DMISSIONPACK
+ $(DO_Q3LCC_MISSIONPACK)
$(B)/baseq3/game/%.o: $(GDIR)/%.c
@@ -1701,10 +1594,10 @@
$(DO_Q3LCC)
$(B)/missionpack/game/%.o: $(GDIR)/%.c
- $(DO_SHLIB_CC) -DMISSIONPACK
+ $(DO_SHLIB_CC_MISSIONPACK)
$(B)/missionpack/game/%.asm: $(GDIR)/%.c
- $(DO_Q3LCC) -DMISSIONPACK
+ $(DO_Q3LCC_MISSIONPACK)
$(B)/baseq3/ui/%.o: $(Q3UIDIR)/%.c
@@ -1714,10 +1607,10 @@
$(DO_Q3LCC)
$(B)/missionpack/ui/%.o: $(UIDIR)/%.c
- $(DO_SHLIB_CC) -DMISSIONPACK
+ $(DO_SHLIB_CC_MISSIONPACK)
$(B)/missionpack/ui/%.asm: $(UIDIR)/%.c
- $(DO_Q3LCC) -DMISSIONPACK
+ $(DO_Q3LCC_MISSIONPACK)
$(B)/baseq3/qcommon/%.o: $(CMDIR)/%.c
@@ -1727,17 +1620,17 @@
$(DO_Q3LCC)
$(B)/missionpack/qcommon/%.o: $(CMDIR)/%.c
- $(DO_SHLIB_CC) -DMISSIONPACK
+ $(DO_SHLIB_CC_MISSIONPACK)
$(B)/missionpack/qcommon/%.asm: $(CMDIR)/%.c
- $(DO_Q3LCC) -DMISSIONPACK
+ $(DO_Q3LCC_MISSIONPACK)
#############################################################################
# MISC
#############################################################################
-copyfiles: build_release
+copyfiles: release
@if [ ! -d $(COPYDIR)/baseq3 ]; then echo "You need to set COPYDIR to where your Quake3 data is!"; fi
-$(MKDIR) -p -m 0755 $(COPYDIR)/baseq3
-$(MKDIR) -p -m 0755 $(COPYDIR)/missionpack
@@ -1757,7 +1650,7 @@
fi
endif
-ifneq ($(BUILD_GAME_SO),0)
+ifneq ($(BUILD_GAME_SO),0)
$(INSTALL) -s -m 0755 $(BR)/baseq3/cgame$(ARCH).$(SHLIBEXT) \
$(COPYDIR)/baseq3/.
$(INSTALL) -s -m 0755 $(BR)/baseq3/qagame$(ARCH).$(SHLIBEXT) \
@@ -1774,36 +1667,37 @@
endif
clean: clean-debug clean-release
- $(MAKE) -C $(LOKISETUPDIR) clean
+ @$(MAKE) -C $(LOKISETUPDIR) clean
clean2:
- if [ -d $(B) ];then (find $(B) -name '*.d' -exec rm {} \;)fi
- rm -f $(Q3OBJ) $(Q3POBJ) $(Q3POBJ_SMP) $(Q3DOBJ) \
+ @echo "CLEAN $(B)"
+ @if [ -d $(B) ];then (find $(B) -name '*.d' -exec rm {} \;)fi
+ @rm -f $(Q3OBJ) $(Q3POBJ) $(Q3POBJ_SMP) $(Q3DOBJ) \
$(MPGOBJ) $(Q3GOBJ) $(Q3CGOBJ) $(MPCGOBJ) $(Q3UIOBJ) $(MPUIOBJ) \
$(MPGVMOBJ) $(Q3GVMOBJ) $(Q3CGVMOBJ) $(MPCGVMOBJ) $(Q3UIVMOBJ) $(MPUIVMOBJ)
- rm -f $(TARGETS)
+ @rm -f $(TARGETS)
clean-debug:
- $(MAKE) clean2 B=$(BD) CFLAGS="$(DEBUG_CFLAGS)"
+ @$(MAKE) clean2 B=$(BD)
clean-release:
- $(MAKE) clean2 B=$(BR) CFLAGS="$(RELEASE_CFLAGS)"
+ @$(MAKE) clean2 B=$(BR)
toolsclean:
- $(MAKE) -C $(TOOLSDIR)/asm clean uninstall
- $(MAKE) -C $(TOOLSDIR)/lcc clean uninstall
+ @$(MAKE) -C $(TOOLSDIR)/asm clean uninstall
+ @$(MAKE) -C $(TOOLSDIR)/lcc clean uninstall
distclean: clean toolsclean
- rm -rf $(BUILD_DIR)
+ @rm -rf $(BUILD_DIR)
-installer: build_release
- $(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR)
+installer: release
+ @$(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR)
dist:
- rm -rf quake3-$(SVN_VERSION)
- svn export . quake3-$(SVN_VERSION)
- tar --owner=root --group=root --force-local -cjf quake3-$(SVN_VERSION).tar.bz2 quake3-$(SVN_VERSION)
- rm -rf quake3-$(SVN_VERSION)
+ rm -rf ioquake3-$(SVN_VERSION)
+ svn export . ioquake3-$(SVN_VERSION)
+ tar --owner=root --group=root --force-local -cjf ioquake3-$(SVN_VERSION).tar.bz2 ioquake3-$(SVN_VERSION)
+ rm -rf ioquake3-$(SVN_VERSION)
#############################################################################
# DEPENDENCIES
@@ -1811,16 +1705,10 @@
D_FILES=$(shell find . -name '*.d')
-$(B)/baseq3/vm/vm.d: $(Q3GOBJ) $(Q3CGOBJ) $(Q3UIOBJ)
- cat $(^:%.o=%.d) | sed -e 's/\.o/\.asm/g' > $@
-
-$(B)/missionpack/vm/vm.d: $(MPGOBJ) $(MPCGOBJ) $(MPUIOBJ)
- cat $(^:%.o=%.d) | sed -e 's/\.o/\.asm/g' > $@
-
-qvmdeps: $(B)/baseq3/vm/vm.d $(B)/missionpack/vm/vm.d
-
ifneq ($(strip $(D_FILES)),)
include $(D_FILES)
endif
-.PHONY: release debug clean distclean copyfiles installer dist
+.PHONY: all clean clean2 clean-debug clean-release copyfiles \
+ debug default dist distclean installer makedirs release \
+ targets tools toolsclean
Modified: branches/1.34/NOTTODO
===================================================================
--- branches/1.34/NOTTODO 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/NOTTODO 2007-08-22 21:25:32 UTC (rev 1127)
@@ -18,4 +18,15 @@
Removing the SDL/OpenAL header files from SVN. Having them in SVN makes it easier
for non-Linux platforms to compile the game. This isn't changing.
-MP3 support. It is already done, see: http://icculus.org/quake3/?page=patches
+MP3 support. It is already done, see: http://ioquake3.org/?page=patches
+
+All development should take place on the trunk. This includes bug
+fixes, new features and experimental stuff.
+
+Release branches should not receive any commits that aren't also made
+to the trunk. Normally you /shouldn't/ commit to release branches as
+such commits are periodically merged from the trunk. These merges are
+harder to perform if there are sporadic commits made in the interim.
+
+Under NO CIRCUMSTANCES ever commit to a tag. A tag is a static
+snapshot which is intended to be unchanging.
Modified: branches/1.34/README
===================================================================
--- branches/1.34/README 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/README 2007-08-22 21:25:32 UTC (rev 1127)
@@ -23,6 +23,8 @@
* Much improved QVM tools
* Support for various esoteric operating systems (see
http://ioquake3.org/?page=status)
+ * cl_guid support
+ * HTTP/FTP download redirection (using cURL)
* Multiuser support on Windows systems (user specific game data
is stored in "%APPDATA%\Quake3")
* Many, many bug fixes
@@ -73,9 +75,12 @@
It is also possible to cross compile for Windows under *nix using MinGW. A
script is available to build a cross compilation environment from
http://www.libsdl.org/extras/win32/cross/build-cross.sh. The gcc/binutils
-version numbers that the script downloads may need to be altered. After you
-have successfully run this script cross compiling is simply a case of using
-'./cross-make-mingw.sh' in place of 'make'.
+version numbers that the script downloads may need to be altered.
+Alternatively, your distribution may have mingw32 packages available. On
+debian/Ubuntu, these are mingw32, mingw32-runtime and mingw32-binutils. Cross
+compiling is simply a case of using './cross-make-mingw.sh' in place of 'make',
+though you may find you need to change the value of the variables in this
+script to match your environment.
If the make based build system is being used (i.e. *nix or MinGW), the
following variables may be set, either on the command line or in
@@ -91,6 +96,8 @@
USE_SDL - use the SDL backend where available
USE_OPENAL - use OpenAL where available
USE_OPENAL_DLOPEN - link with OpenAL at runtime
+ USE_CURL - use libcurl for http/ftp download support
+ USE_CURL_DLOPEN - link with libcurl at runtime
USE_CODEC_VORBIS - enable Ogg Vorbis support
USE_LOCAL_HEADERS - use headers local to ioq3 instead of system ones
USE_CCACHE - use ccache compiler caching tool
@@ -121,8 +128,6 @@
source
s_alGraceDistance - after having passed MaxDistance, length
until sounds are completely inaudible.
- s_alMaxSpeakerDistance - ET_SPEAKERS beyond this distance are
- culled
s_alDriver - which OpenAL library to use
s_alDevice - which OpenAL device to use
s_alAvailableDevices - list of available OpenAL devices
@@ -146,6 +151,10 @@
cl_platformSensitivity - read only, indicates the mouse input
scaling
r_ext_texture_filter_anisotropic - anisotropic texture filtering
+ cl_guidServerUniq - makes cl_guid unique for each server
+ cl_cURLLib - filename of cURL library to load
+ sv_dlURL - the base of the HTTP or FTP site that
+ holds custom pk3 files for your server
New commands
video [filename] - start video capture (use with demo command)
@@ -198,6 +207,62 @@
compiler. See http://www.quakesrc.org/forums/viewtopic.php?t=5665 (if it
still exists when you read this) for more details.
+cl_guid Support
+ cl_guid is a cvar which is part of the client's USERINFO string. Its value
+ is a 32 character string made up of [a-f] and [0-9] characters. This
+ value is pseudo-unique for every player. Id's Quake 3 Arena client also
+ sets cl_guid, but only if Punkbuster is enabled on the client.
+
+ If cl_guidServerUniq is non-zero (the default), then this value is also
+ pseudo-unique for each server a client connects to (based on IP:PORT of
+ the server).
+
+ The purpose of cl_guid is to add an identifier for each player on
+ a server. This value can be reset by the client at any time so it's not
+ useful for blocking access. However, it can have at least two uses in
+ your mod's game code:
+ 1) improve logging to allow statistical tools to index players by more
+ than just name
+ 2) granting some weak admin rights to players without requiring passwords
+
+Using HTTP/FTP Download Support (Server)
+ You can enable redirected downloads on your server even if it's not
+ an ioquake3 server. You simply need to use the 'sets' command to put
+ the sv_dlURL cvar into your SERVERINFO string and ensure sv_allowDownloads
+ is set to 1
+
+ sv_dlURL is the base of the URL that contains your custom .pk3 files
+ the client will append both fs_game and the filename to the end of
+ this value. For example, if you have sv_dlURL set to
+ "http://ioquake3.org", fs_game is "baseq3", and the client is
+ missing "test.pk3", it will attempt to download from the URL
+ "http://ioquake3.org/baseq3/test.pk3"
+
+ sv_allowDownload's value is now a bitmask made up of the following
+ flags:
+ 1 - ENABLE
+ 2 - do not use HTTP/FTP downloads
+ 4 - do not use UDP downloads
+ 8 - do not ask the client to disconnect when using HTTP/FTP
+
+ Server operators who are concerned about potential "leeching" from their
+ HTTP servers from other ioquake3 servers can make use of the HTTP_REFERER
+ that ioquake3 sets which is "ioQ3://{SERVER_IP}:{SERVER_PORT}". For,
+ example, Apache's mod_rewrite can restrict access based on HTTP_REFERER.
+
+Using HTTP/FTP Download Support (Client)
+ Simply setting cl_allowDownload to 1 will enable HTTP/FTP downloads
+ assuming ioquake3 was compiled with USE_CURL=1 (the default).
+ like sv_allowDownload, cl_allowDownload also uses a bitmask value
+ supporting the following flags:
+ 1 - ENABLE
+ 2 - do not use HTTP/FTP downloads
+ 4 - do not use UDP downloads
+
+ When ioquake3 is built with USE_CURL_DLOPEN=1 (default on some platforms),
+ it will use the value of the cvar cl_cURLLib as the filename of the cURL
+ library to dynamically load.
+
Multiuser Support on Windows systems
On Windows, all user specific files such as autogenerated configuration,
demos, videos, screenshots, and autodownloaded pk3s are now saved in a
@@ -224,6 +289,28 @@
ioquake3.exe +set fs_homepath "c:\ioquake3"
Note that this cvar MUST be set as a command line parameter.
+SDL Keyboard Differences
+ ioquake3 clients built againt SDL (e.g. Linux and Mac OS X) have different
+ keyboard behaviour than the original Quake3 clients.
+
+ * "Caps Lock" and "Num Lock" can not be used as normal binds since they
+ do not send a KEYUP event until the key is pressed again.
+
+ * SDL > 1.2.9 does not support disabling "Dead Key" recognition.
+ In order to send "Dead Key" characters (e.g. ~, ', `, and ^), you
+ must key a Space (or sometimes the same character again) after the
+ character to send it on many international keyboard layouts.
+
+ * The SDL client supports many more keys than the original Quake3 client.
+ For example the keys: "Windows", "SysReq", "ScrollLock", and "Break".
+ For non-US keyboards, all of the so called "World" keys are now
+ supported as well as F13, F14, F15, and the country-specific
+ mode/meta keys.
+
+ SDL's "Dead Key" behaviour makes the hard-coded toggleConsole binds ~ and `
+ annoying to use on many non-US keyboards. In response, an additional
+ toggleConsole bind has been added on the key combination Shift-Esc.
+
------------------------------------------------------------- Contributing -----
Please send all patches to bugzilla (https://bugzilla.icculus.org), or join the
Modified: branches/1.34/TODO
===================================================================
--- branches/1.34/TODO 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/TODO 2007-08-22 21:25:32 UTC (rev 1127)
@@ -23,6 +23,8 @@
* Replace windows DirectX backend with SDL
* Graphical "ioquake3" watermark in videos, optional, on by default
* Gamma stuff while recording videos.
+* Application for OS X at least to launch mods with appropriate hunkmegs, etc.
-For 1.99:
+For 2.0:
* Four player split-screen
+* Multi-platform application to launch and download mods.
Modified: branches/1.34/code/SDL12/include/SDL.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,47 +1,44 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL.h,v 1.8 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
/* Main include header for the SDL library */
#ifndef _SDL_H
#define _SDL_H
#include "SDL_main.h"
-#include "SDL_types.h"
-#include "SDL_getenv.h"
-#include "SDL_error.h"
-#include "SDL_rwops.h"
-#include "SDL_timer.h"
+#include "SDL_stdinc.h"
#include "SDL_audio.h"
#include "SDL_cdrom.h"
-#include "SDL_joystick.h"
+#include "SDL_cpuinfo.h"
+#include "SDL_endian.h"
+#include "SDL_error.h"
#include "SDL_events.h"
+#include "SDL_loadso.h"
+#include "SDL_mutex.h"
+#include "SDL_rwops.h"
+#include "SDL_thread.h"
+#include "SDL_timer.h"
#include "SDL_video.h"
-#include "SDL_byteorder.h"
#include "SDL_version.h"
#include "begin_code.h"
Modified: branches/1.34/code/SDL12/include/SDL_active.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_active.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_active.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,35 +1,33 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_active.h,v 1.6 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
/* Include file for SDL application focus event handling */
#ifndef _SDL_active_h
#define _SDL_active_h
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
+
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Modified: branches/1.34/code/SDL12/include/SDL_audio.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_audio.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_audio.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,42 +1,36 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_audio.h,v 1.9 2004/08/20 18:57:01 slouken Exp $";
-#endif
-
/* Access to the raw audio mixing buffer for the SDL library */
#ifndef _SDL_audio_h
#define _SDL_audio_h
-#include <stdio.h>
-
-#include "SDL_main.h"
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
#include "SDL_rwops.h"
-#include "SDL_byteorder.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Modified: branches/1.34/code/SDL12/include/SDL_byteorder.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_byteorder.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_byteorder.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,68 +1,24 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_byteorder.h,v 1.10 2005/09/08 06:49:20 icculus Exp $";
-#endif
-
-/* Macros for determining the byte-order of this platform */
-
-#ifndef _SDL_byteorder_h
-#define _SDL_byteorder_h
-
-/* The two types of endianness */
-#define SDL_LIL_ENDIAN 1234
-#define SDL_BIG_ENDIAN 4321
-
-#ifdef __linux__
-# include <endian.h>
-# if BYTE_ORDER == LITTLE_ENDIAN
-# define SDL_BYTEORDER SDL_LIL_ENDIAN
-# else
-# define SDL_BYTEORDER SDL_BIG_ENDIAN
-# endif
-
-#else
-
-/* Pardon the mess, I'm trying to determine the endianness of this host.
- I'm doing it by preprocessor defines rather than some sort of configure
- script so that application code can use this too. The "right" way would
- be to dynamically generate this file on install, but that's a lot of work.
- */
-#if (defined(__i386__) || defined(__i386)) || \
- defined(__ia64__) || defined(WIN32) || \
- (defined(__alpha__) || defined(__alpha)) || \
- (defined(__arm__) || defined(__thumb__)) || \
- (defined(__sh__) || defined(__sh64__)) || \
- (defined(__mips__) && defined(__MIPSEL__)) || \
- defined(__SYMBIAN32__) || \
- defined(__x86_64__) || \
- defined(__LITTLE_ENDIAN__)
-#define SDL_BYTEORDER SDL_LIL_ENDIAN
-#else
-#define SDL_BYTEORDER SDL_BIG_ENDIAN
-#endif
-
-#endif /* __linux__ */
-
-#endif /* _SDL_byteorder_h */
+/* DEPRECATED */
+#include "SDL_endian.h"
Modified: branches/1.34/code/SDL12/include/SDL_cdrom.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_cdrom.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_cdrom.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_cdrom.h,v 1.8 2005/04/17 10:16:30 icculus Exp $";
-#endif
-
/* This is the CD-audio control API for Simple DirectMedia Layer */
#ifndef _SDL_cdrom_h
#define _SDL_cdrom_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Copied: branches/1.34/code/SDL12/include/SDL_config.h (from rev 1126, trunk/code/SDL12/include/SDL_config.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,45 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_h
+#define _SDL_config_h
+
+#include "SDL_platform.h"
+
+/* Add any platform that doesn't build using the configure system */
+#if defined(__AMIGA__)
+#include "SDL_config_amiga.h"
+#elif defined(__DREAMCAST__)
+#include "SDL_config_dreamcast.h"
+#elif defined(__MACOS__)
+#include "SDL_config_macos.h"
+#elif defined(__MACOSX__)
+#include "SDL_config_macosx.h"
+#elif defined(__WIN32__)
+#include "SDL_config_win32.h"
+#elif defined(__OS2__)
+#include "SDL_config_os2.h"
+#else
+#include "SDL_config_minimal.h"
+#endif /* platform config */
+
+#endif /* _SDL_config_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_amiga.h (from rev 1126, trunk/code/SDL12/include/SDL_config_amiga.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_amiga.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_amiga.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,80 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_amiga_h
+#define _SDL_config_amiga_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Useful headers */
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_AHI 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#define SDL_CDROM_DUMMY 1
+
+/* Enable various input drivers */
+#define SDL_JOYSTICK_AMIGA 1
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_DUMMY 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_AMIGA 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_AMIGA 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+/* Enable OpenGL support */
+#define SDL_VIDEO_OPENGL 1
+
+#endif /* _SDL_config_amiga_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_dreamcast.h (from rev 1126, trunk/code/SDL12/include/SDL_config_dreamcast.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_dreamcast.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_dreamcast.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,106 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_dreamcast_h
+#define _SDL_config_dreamcast_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+typedef unsigned long uintptr_t;
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Useful headers */
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRDUP 1
+#define HAVE_INDEX 1
+#define HAVE_RINDEX 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_STRICMP 1
+#define HAVE_STRCASECMP 1
+#define HAVE_SSCANF 1
+#define HAVE_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_DC 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#define SDL_CDROM_DC 1
+
+/* Enable various input drivers */
+#define SDL_JOYSTICK_DC 1
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_DUMMY 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_DC 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_DC 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_DC 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+#endif /* _SDL_config_dreamcast_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_macos.h (from rev 1126, trunk/code/SDL12/include/SDL_config_macos.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_macos.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_macos.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,112 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_macos_h
+#define _SDL_config_macos_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#include <MacTypes.h>
+
+typedef SInt8 int8_t;
+typedef UInt8 uint8_t;
+typedef SInt16 int16_t;
+typedef UInt16 uint16_t;
+typedef SInt32 int32_t;
+typedef UInt32 uint32_t;
+typedef SInt64 int64_t;
+typedef UInt64 uint64_t;
+typedef unsigned long uintptr_t;
+
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Useful headers */
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_ABS 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_ITOA 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_SSCANF 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_SNDMGR 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#if TARGET_API_MAC_CARBON
+#define SDL_CDROM_DUMMY 1
+#else
+#define SDL_CDROM_MACOS 1
+#endif
+
+/* Enable various input drivers */
+#if TARGET_API_MAC_CARBON
+#define SDL_JOYSTICK_DUMMY 1
+#else
+#define SDL_JOYSTICK_MACOS 1
+#endif
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_MACOS 1
+
+/* Enable various threading systems */
+#define SDL_THREADS_DISABLED 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_MACOS 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_DUMMY 1
+#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1
+#define SDL_VIDEO_DRIVER_TOOLBOX 1
+
+/* Enable OpenGL support */
+#define SDL_VIDEO_OPENGL 1
+
+#endif /* _SDL_config_macos_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_macosx.h (from rev 1126, trunk/code/SDL12/include/SDL_config_macosx.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_macosx.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_macosx.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,132 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_macosx_h
+#define _SDL_config_macosx_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Useful headers */
+/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */
+#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) )
+#define HAVE_ALLOCA_H 1
+#endif
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_UNSETENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRLCAT 1
+#define HAVE_STRDUP 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOULL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_SSCANF 1
+#define HAVE_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_SIGACTION 1
+#define HAVE_SETJMP 1
+#define HAVE_NANOSLEEP 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_COREAUDIO 1
+#define SDL_AUDIO_DRIVER_SNDMGR 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#define SDL_CDROM_MACOSX 1
+
+/* Enable various input drivers */
+#define SDL_JOYSTICK_IOKIT 1
+
+/* Enable various shared object loading systems */
+#ifdef __ppc__
+/* For Mac OS X 10.2 compatibility */
+#define SDL_LOADSO_DLCOMPAT 1
+#else
+#define SDL_LOADSO_DLOPEN 1
+#endif
+
+/* Enable various threading systems */
+#define SDL_THREAD_PTHREAD 1
+#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_UNIX 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_DUMMY 1
+#if TARGET_API_MAC_CARBON
+#define SDL_VIDEO_DRIVER_TOOLBOX 1
+#else
+#define SDL_VIDEO_DRIVER_QUARTZ 1
+#endif
+
+/* Enable OpenGL support */
+#define SDL_VIDEO_OPENGL 1
+
+/* Enable assembly routines */
+#define SDL_ASSEMBLY_ROUTINES 1
+#ifdef __ppc__
+#define SDL_ALTIVEC_BLITTERS 1
+#endif
+
+#endif /* _SDL_config_macosx_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_minimal.h (from rev 1126, trunk/code/SDL12/include/SDL_config_minimal.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_minimal.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_minimal.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,62 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_minimal_h
+#define _SDL_config_minimal_h
+
+#include "SDL_platform.h"
+
+/* This is the minimal configuration that can be used to build SDL */
+
+#include <stdarg.h>
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef unsigned int size_t;
+typedef unsigned long uintptr_t;
+
+/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
+#define SDL_CDROM_DISABLED 1
+
+/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
+#define SDL_JOYSTICK_DISABLED 1
+
+/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
+#define SDL_LOADSO_DISABLED 1
+
+/* Enable the stub thread support (src/thread/generic/\*.c) */
+#define SDL_THREADS_DISABLED 1
+
+/* Enable the stub timer support (src/timer/dummy/\*.c) */
+#define SDL_TIMERS_DISABLED 1
+
+/* Enable the dummy video driver (src/video/dummy/\*.c) */
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+#endif /* _SDL_config_minimal_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_os2.h (from rev 1126, trunk/code/SDL12/include/SDL_config_os2.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_os2.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_os2.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,141 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_os2_h
+#define _SDL_config_os2_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef unsigned int size_t;
+typedef unsigned long uintptr_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Use Watcom's LIBC */
+#define HAVE_LIBC 1
+
+/* Useful headers */
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_UNSETENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRLCAT 1
+#define HAVE_STRDUP 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+#define HAVE__STRLWR 1
+#define HAVE_INDEX 1
+#define HAVE_RINDEX 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_ITOA 1
+#define HAVE__LTOA 1
+#define HAVE__UITOA 1
+#define HAVE__ULTOA 1
+#define HAVE_STRTOL 1
+#define HAVE__I64TOA 1
+#define HAVE__UI64TOA 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_STRICMP 1
+#define HAVE_STRCASECMP 1
+#define HAVE_SSCANF 1
+#define HAVE_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_SETJMP 1
+#define HAVE_CLOCK_GETTIME 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_DART 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#define SDL_CDROM_OS2 1
+
+/* Enable various input drivers */
+#define SDL_JOYSTICK_OS2 1
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_OS2 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_OS2 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_OS2 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_DUMMY 1
+#define SDL_VIDEO_DRIVER_OS2FS 1
+
+/* Enable OpenGL support */
+/* Nothing here yet for OS/2... :( */
+
+/* Enable assembly routines where available */
+#define SDL_ASSEMBLY_ROUTINES 1
+
+#endif /* _SDL_config_os2_h */
Copied: branches/1.34/code/SDL12/include/SDL_config_win32.h (from rev 1126, trunk/code/SDL12/include/SDL_config_win32.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_config_win32.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_config_win32.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,173 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+#ifndef _SDL_config_win32_h
+#define _SDL_config_win32_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#ifdef __GNUC__
+#define HAVE_STDINT_H 1
+#elif defined(_MSC_VER)
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#ifndef _UINTPTR_T_DEFINED
+#ifdef _WIN64
+typedef unsigned __int64 uintptr_t;
+#else
+typedef unsigned int uintptr_t;
+#endif
+#define _UINTPTR_T_DEFINED
+#endif
+#else /* !__GNUC__ && !_MSC_VER */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef unsigned int size_t;
+#endif
+typedef unsigned int uintptr_t;
+#endif /* __GNUC__ || _MSC_VER */
+#define SDL_HAS_64BIT_TYPE 1
+
+/* Enabled for SDL 1.2 (binary compatibility) */
+#define HAVE_LIBC 1
+#ifdef HAVE_LIBC
+/* Useful headers */
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#ifndef _WIN32_WCE
+#define HAVE_SIGNAL_H 1
+#endif
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+#define HAVE__STRLWR 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_ITOA 1
+#define HAVE__LTOA 1
+#define HAVE__ULTOA 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE__STRICMP 1
+#define HAVE__STRNICMP 1
+#define HAVE_SSCANF 1
+#else
+#define HAVE_STDARG_H 1
+#define HAVE_STDDEF_H 1
+#endif
+
+/* Enable various audio drivers */
+#ifndef _WIN32_WCE
+#define SDL_AUDIO_DRIVER_DSOUND 1
+#endif
+#define SDL_AUDIO_DRIVER_WAVEOUT 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various cdrom drivers */
+#ifdef _WIN32_WCE
+#define SDL_CDROM_DISABLED 1
+#else
+#define SDL_CDROM_WIN32 1
+#endif
+
+/* Enable various input drivers */
+#ifdef _WIN32_WCE
+#define SDL_JOYSTICK_DISABLED 1
+#else
+#define SDL_JOYSTICK_WINMM 1
+#endif
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_WIN32 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_WIN32 1
+
+/* Enable various timer systems */
+#ifdef _WIN32_WCE
+#define SDL_TIMER_WINCE 1
+#else
+#define SDL_TIMER_WIN32 1
+#endif
+
+/* Enable various video drivers */
+#ifdef _WIN32_WCE
+#define SDL_VIDEO_DRIVER_GAPI 1
+#endif
+#ifndef _WIN32_WCE
+#define SDL_VIDEO_DRIVER_DDRAW 1
+#endif
+#define SDL_VIDEO_DRIVER_DUMMY 1
+#define SDL_VIDEO_DRIVER_WINDIB 1
+
+/* Enable OpenGL support */
+#ifndef _WIN32_WCE
+#define SDL_VIDEO_OPENGL 1
+#define SDL_VIDEO_OPENGL_WGL 1
+#endif
+
+/* Enable assembly routines (Win64 doesn't have inline asm) */
+#ifndef _WIN64
+#define SDL_ASSEMBLY_ROUTINES 1
+#endif
+
+#endif /* _SDL_config_win32_h */
Modified: branches/1.34/code/SDL12/include/SDL_copying.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_copying.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_copying.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,27 +1,22 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_copying.h,v 1.5 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
Modified: branches/1.34/code/SDL12/include/SDL_cpuinfo.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_cpuinfo.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_cpuinfo.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,33 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_cpuinfo.h,v 1.5 2004/01/24 05:47:18 slouken Exp $";
-#endif
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* CPU feature detection for SDL */
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
+#include "SDL_stdinc.h"
+
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@@ -39,35 +36,35 @@
/* This function returns true if the CPU has the RDTSC instruction
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
/* This function returns true if the CPU has MMX features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
/* This function returns true if the CPU has MMX Ext. features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void);
/* This function returns true if the CPU has 3DNow features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow();
+extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
/* This function returns true if the CPU has 3DNow! Ext. features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt();
+extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void);
/* This function returns true if the CPU has SSE features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
/* This function returns true if the CPU has SSE2 features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
/* This function returns true if the CPU has AltiVec features
*/
-extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec();
+extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
Modified: branches/1.34/code/SDL12/include/SDL_endian.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_endian.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_endian.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,52 +1,48 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_endian.h,v 1.15 2005/03/30 12:38:03 pmandin Exp $";
-#endif
-
/* Functions for reading and writing endian-specific values */
#ifndef _SDL_endian_h
#define _SDL_endian_h
-/* These functions read and write data of the specified endianness,
- dynamically translating to the host machine endianness.
+#include "SDL_stdinc.h"
- e.g.: If you want to read a 16 bit value on big-endian machine from
- an open file containing little endian values, you would use:
- value = SDL_ReadLE16(rp);
- Note that the read/write functions use SDL_RWops pointers
- instead of FILE pointers. This allows you to read and write
- endian values from large chunks of memory as well as files
- and other data sources.
-*/
+/* The two types of endianness */
+#define SDL_LIL_ENDIAN 1234
+#define SDL_BIG_ENDIAN 4321
-#include <stdio.h>
+#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
+#if defined(__hppa__) || \
+ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
+ (defined(__MIPS__) && defined(__MISPEB__)) || \
+ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
+ defined(__sparc__)
+#define SDL_BYTEORDER SDL_BIG_ENDIAN
+#else
+#define SDL_BYTEORDER SDL_LIL_ENDIAN
+#endif
+#endif /* !SDL_BYTEORDER */
-#include "SDL_types.h"
-#include "SDL_rwops.h"
-#include "SDL_byteorder.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -59,7 +55,8 @@
static for compilers that do not support inline functions, this
header should only be included in files that actually use them.
*/
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && defined(__i386__) && \
+ !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
__asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x));
@@ -186,23 +183,6 @@
#define SDL_SwapBE64(X) (X)
#endif
-/* Read an item of the specified endianness and return in native format */
-extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
-extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
-extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
-extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
-extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
-extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
-
-/* Write an item of native format to the specified endianness */
-extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
-extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
-extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
-extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
-extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
-extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
-
-
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
Modified: branches/1.34/code/SDL12/include/SDL_error.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_error.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_error.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,35 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_error.h,v 1.8 2004/11/15 23:30:07 slouken Exp $";
-#endif
-
/* Simple error message routines for SDL */
#ifndef _SDL_error_h
#define _SDL_error_h
+#include "SDL_stdinc.h"
+
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@@ -43,11 +40,13 @@
/* Private error message function - used internally */
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
+#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
typedef enum {
SDL_ENOMEM,
SDL_EFREAD,
SDL_EFWRITE,
SDL_EFSEEK,
+ SDL_UNSUPPORTED,
SDL_LASTERROR
} SDL_errorcode;
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
Modified: branches/1.34/code/SDL12/include/SDL_events.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_events.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_events.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_events.h,v 1.11 2004/08/20 18:57:01 slouken Exp $";
-#endif
-
/* Include file for SDL event handling */
#ifndef _SDL_events_h
#define _SDL_events_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "SDL_active.h"
#include "SDL_keyboard.h"
#include "SDL_mouse.h"
@@ -43,8 +39,13 @@
extern "C" {
#endif
+/* General keyboard/mouse state definitions */
+#define SDL_RELEASED 0
+#define SDL_PRESSED 1
+
/* Event enumerations */
-enum { SDL_NOEVENT = 0, /* Unused (do not remove) */
+typedef enum {
+ SDL_NOEVENT = 0, /* Unused (do not remove) */
SDL_ACTIVEEVENT, /* Application loses/gains visibility */
SDL_KEYDOWN, /* Keys pressed */
SDL_KEYUP, /* Keys released */
@@ -74,14 +75,16 @@
It is the number of bits in the event mask datatype -- Uint32
*/
SDL_NUMEVENTS = 32
-};
+} SDL_EventType;
/* Predefined event masks */
#define SDL_EVENTMASK(X) (1<<(X))
-enum {
+typedef enum {
SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT),
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
+ SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)|
+ SDL_EVENTMASK(SDL_KEYUP),
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
@@ -102,7 +105,7 @@
SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE),
SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
-};
+} SDL_EventMask ;
#define SDL_ALLEVENTS 0xFFFFFFFF
/* Application visibility event structure */
@@ -214,7 +217,7 @@
} SDL_SysWMEvent;
/* General event structure */
-typedef union {
+typedef union SDL_Event {
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
Modified: branches/1.34/code/SDL12/include/SDL_getenv.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_getenv.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_getenv.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,30 +1,24 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
-/* Not all environments have a working getenv()/putenv() */
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(macintosh) || defined(_WIN32_WCE)
-#define NEED_SDL_GETENV
-#endif
+ This library 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
+ Lesser General Public License for more details.
-#ifdef NEED_SDL_GETENV
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#include "begin_code.h"
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C" {
-#endif
+ Sam Lantinga
+ slouken at libsdl.org
+*/
-/* Put a variable of the form "name=value" into the environment */
-extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
-#define putenv(X) SDL_putenv(X)
-
-/* Retrieve a variable named "name" from the environment */
-extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
-#define getenv(X) SDL_getenv(X)
-
-/* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-}
-#endif
-#include "close_code.h"
-
-#endif /* NEED_GETENV */
+/* DEPRECATED */
+#include "SDL_stdinc.h"
Modified: branches/1.34/code/SDL12/include/SDL_joystick.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_joystick.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_joystick.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_joystick.h,v 1.7 2004/07/18 19:05:06 slouken Exp $";
-#endif
-
/* Include file for SDL joystick event handling */
#ifndef _SDL_joystick_h
#define _SDL_joystick_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Modified: branches/1.34/code/SDL12/include/SDL_keyboard.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_keyboard.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_keyboard.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_keyboard.h,v 1.7 2004/07/18 22:57:40 slouken Exp $";
-#endif
-
/* Include file for SDL keyboard event handling */
#ifndef _SDL_keyboard_h
#define _SDL_keyboard_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "SDL_keysym.h"
#include "begin_code.h"
@@ -88,6 +84,7 @@
* If 'delay' is set to 0, keyboard repeat is disabled.
*/
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
+extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
/*
* Get a snapshot of the current state of the keyboard.
Modified: branches/1.34/code/SDL12/include/SDL_keysym.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_keysym.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_keysym.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,30 +1,25 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_keysym.h,v 1.6 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
#ifndef _SDL_keysym_h
#define _SDL_keysym_h
Modified: branches/1.34/code/SDL12/include/SDL_loadso.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_loadso.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_loadso.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,30 +1,25 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_loadso.h,v 1.5 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
@@ -46,6 +41,9 @@
#ifndef _SDL_loadso_h
#define _SDL_loadso_h
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
+
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Modified: branches/1.34/code/SDL12/include/SDL_main.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_main.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_main.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,38 +1,35 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_main.h,v 1.13 2005/09/27 09:00:42 icculus Exp $";
-#endif
-
#ifndef _SDL_main_h
#define _SDL_main_h
+#include "SDL_stdinc.h"
+
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
-#if defined(WIN32) || defined(_WIN32) || \
+#if defined(__WIN32__) || \
(defined(__MWERKS__) && !defined(__BEOS__)) || \
- defined(macintosh) || defined(__APPLE__) || \
+ defined(__MACOS__) || defined(__MACOSX__) || \
defined(__SYMBIAN32__) || defined(QWS)
#ifdef __cplusplus
@@ -57,10 +54,9 @@
/* From the SDL library code -- needed for registering the app on Win32 */
-#if defined(WIN32)
-#include "SDL_types.h"
-#include "begin_code.h"
+#ifdef __WIN32__
+#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -70,7 +66,7 @@
/* This can also be called, but is no longer necessary */
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
/* This can also be called, but is no longer necessary (SDL_Quit calls it) */
-extern DECLSPEC void SDLCALL SDL_UnregisterApp();
+extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#ifdef __cplusplus
}
#endif
@@ -78,9 +74,9 @@
#endif
/* From the SDL library code -- needed for registering QuickDraw on MacOS */
-#if defined(macintosh)
-#include "begin_code.h"
+#if defined(__MACOS__)
+#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
Modified: branches/1.34/code/SDL12/include/SDL_mouse.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_mouse.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_mouse.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_mouse.h,v 1.9 2005/04/17 10:16:30 icculus Exp $";
-#endif
-
/* Include file for SDL mouse event handling */
#ifndef _SDL_mouse_h
#define _SDL_mouse_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "SDL_video.h"
#include "begin_code.h"
@@ -120,7 +116,7 @@
Button 4: Mouse wheel up (may also be a real button)
Button 5: Mouse wheel down (may also be a real button)
*/
-#define SDL_BUTTON(X) (SDL_PRESSED << ((X)-1))
+#define SDL_BUTTON(X) (1 << ((X)-1))
#define SDL_BUTTON_LEFT 1
#define SDL_BUTTON_MIDDLE 2
#define SDL_BUTTON_RIGHT 3
Modified: branches/1.34/code/SDL12/include/SDL_mutex.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_mutex.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_mutex.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,30 +1,25 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_mutex.h,v 1.7 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
#ifndef _SDL_mutex_h
#define _SDL_mutex_h
@@ -33,8 +28,8 @@
These are independent of the other SDL routines.
*/
-#include "SDL_main.h"
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -145,6 +140,7 @@
/* Wait on the condition variable, unlocking the provided mutex.
The mutex must be locked before entering this function!
+ The mutex is re-locked once the condition variable is signaled.
Returns 0 when it is signaled, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
Modified: branches/1.34/code/SDL12/include/SDL_opengl.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_opengl.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_opengl.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,33 +1,30 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_opengl.h,v 1.10 2004/08/20 22:32:05 slouken Exp $";
-#endif
-
/* This is a simple file to encapsulate the OpenGL API headers */
-#ifdef WIN32
+#include "SDL_config.h"
+
+#ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
#define NOMINMAX /* Don't defined min() and max() */
@@ -37,9 +34,12 @@
#ifndef NO_SDL_GLEXT
#define __glext_h_ /* Don't let gl.h include glext.h */
#endif
-#if defined(__APPLE__) && defined(__MACH__)
+#if defined(__MACOSX__)
#include <OpenGL/gl.h> /* Header File For The OpenGL Library */
#include <OpenGL/glu.h> /* Header File For The GLU Library */
+#elif defined(__MACOS__)
+#include <gl.h> /* Header File For The OpenGL Library */
+#include <glu.h> /* Header File For The GLU Library */
#else
#include <GL/gl.h> /* Header File For The OpenGL Library */
#include <GL/glu.h> /* Header File For The GLU Library */
@@ -79,7 +79,7 @@
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc.
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
@@ -107,9 +107,9 @@
/*************************************************************/
/* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated 2003/1/12 */
+/* glext.h last updated 2005/06/20 */
/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
-#define GL_GLEXT_VERSION 21
+#define GL_GLEXT_VERSION 29
#ifndef GL_VERSION_1_2
#define GL_UNSIGNED_BYTE_3_3_2 0x8032
@@ -306,7 +306,6 @@
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_CLAMP_TO_BORDER_SGIS 0x812D
#define GL_COMBINE 0x8570
#define GL_COMBINE_RGB 0x8571
#define GL_COMBINE_ALPHA 0x8572
@@ -412,7 +411,7 @@
#define GL_DYNAMIC_READ 0x88E9
#define GL_DYNAMIC_COPY 0x88EA
#define GL_SAMPLES_PASSED 0x8914
-#define GL_FOG_COORD_SOURCE GL_FOG_COORDINATE_SOURCE
+#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
#define GL_FOG_COORD GL_FOG_COORDINATE
#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
@@ -428,6 +427,93 @@
#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA
#endif
+#ifndef GL_VERSION_2_0
+#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_POINT_SPRITE 0x8861
+#define GL_COORD_REPLACE 0x8862
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_COORDS 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#endif
+
#ifndef GL_ARB_multitexture
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
@@ -804,6 +890,14 @@
#define GL_FLOAT_MAT2_ARB 0x8B5A
#define GL_FLOAT_MAT3_ARB 0x8B5B
#define GL_FLOAT_MAT4_ARB 0x8B5C
+#define GL_SAMPLER_1D_ARB 0x8B5D
+#define GL_SAMPLER_2D_ARB 0x8B5E
+#define GL_SAMPLER_3D_ARB 0x8B5F
+#define GL_SAMPLER_CUBE_ARB 0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
@@ -828,9 +922,11 @@
#ifndef GL_ARB_fragment_shader
#define GL_FRAGMENT_SHADER_ARB 0x8B30
#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
#endif
#ifndef GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
#endif
#ifndef GL_ARB_texture_non_power_of_two
@@ -841,6 +937,78 @@
#define GL_COORD_REPLACE_ARB 0x8862
#endif
+#ifndef GL_ARB_fragment_program_shadow
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#define GL_DRAW_BUFFER0_ARB 0x8825
+#define GL_DRAW_BUFFER1_ARB 0x8826
+#define GL_DRAW_BUFFER2_ARB 0x8827
+#define GL_DRAW_BUFFER3_ARB 0x8828
+#define GL_DRAW_BUFFER4_ARB 0x8829
+#define GL_DRAW_BUFFER5_ARB 0x882A
+#define GL_DRAW_BUFFER6_ARB 0x882B
+#define GL_DRAW_BUFFER7_ARB 0x882C
+#define GL_DRAW_BUFFER8_ARB 0x882D
+#define GL_DRAW_BUFFER9_ARB 0x882E
+#define GL_DRAW_BUFFER10_ARB 0x882F
+#define GL_DRAW_BUFFER11_ARB 0x8830
+#define GL_DRAW_BUFFER12_ARB 0x8831
+#define GL_DRAW_BUFFER13_ARB 0x8832
+#define GL_DRAW_BUFFER14_ARB 0x8833
+#define GL_DRAW_BUFFER15_ARB 0x8834
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_RGBA_FLOAT_MODE_ARB 0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
+#define GL_CLAMP_READ_COLOR_ARB 0x891C
+#define GL_FIXED_ONLY_ARB 0x891D
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB 0x140B
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#endif
+
#ifndef GL_EXT_abgr
#define GL_ABGR_EXT 0x8000
#endif
@@ -1171,6 +1339,10 @@
#define GL_CLAMP_TO_EDGE_SGIS 0x812F
#endif
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#endif
+
#ifndef GL_EXT_blend_minmax
#define GL_FUNC_ADD_EXT 0x8006
#define GL_MIN_EXT 0x8007
@@ -2714,6 +2886,11 @@
#define GL_DRAW_BUFFER15_ATI 0x8834
#endif
+#ifndef GL_ATI_pixel_format_float
+#define GL_TYPE_RGBA_FLOAT_ATI 0x8820
+#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
+#endif
+
#ifndef GL_ATI_texture_env_combine3
#define GL_MODULATE_ADD_ATI 0x8744
#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
@@ -2800,6 +2977,11 @@
#ifndef GL_ATI_vertex_attrib_array_object
#endif
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#endif
+
#ifndef GL_EXT_depth_bounds_test
#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
#define GL_DEPTH_BOUNDS_EXT 0x8891
@@ -2826,10 +3008,100 @@
#define GL_YCBCR_MESA 0x8757
#endif
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
+#endif
+#ifndef GL_NV_fragment_program_option
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
+#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
+#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
+#endif
+
+#ifndef GL_NV_vertex_program3
+/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#endif
+
+
/*************************************************************/
#include <stddef.h>
+#ifndef GL_VERSION_2_0
+/* GL type for program/shader text */
+typedef char GLchar; /* native character */
+#endif
+
#ifndef GL_VERSION_1_5
/* GL types for handling large vertex buffer objects */
typedef ptrdiff_t GLintptr;
@@ -2843,13 +3115,17 @@
#endif
#ifndef GL_ARB_shader_objects
-/* GL types for handling shader object handles and characters */
+/* GL types for handling shader object handles and program/shader text */
typedef char GLcharARB; /* native character */
typedef unsigned int GLhandleARB; /* shader object handle */
#endif
+/* GL types for "half" precision (s10e5) float data in host memory */
+#ifndef GL_ARB_half_float_pixel
+typedef unsigned short GLhalfARB;
+#endif
+
#ifndef GL_NV_half_float
-/* GL type for representing NVIDIA "half" floating point type in host memory */
typedef unsigned short GLhalfNV;
#endif
@@ -3173,6 +3449,198 @@
typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
#endif
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum);
+GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *);
+GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint);
+GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint);
+GLAPI void APIENTRY glAttachShader (GLuint, GLuint);
+GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *);
+GLAPI void APIENTRY glCompileShader (GLuint);
+GLAPI GLuint APIENTRY glCreateProgram (void);
+GLAPI GLuint APIENTRY glCreateShader (GLenum);
+GLAPI void APIENTRY glDeleteProgram (GLuint);
+GLAPI void APIENTRY glDeleteShader (GLuint);
+GLAPI void APIENTRY glDetachShader (GLuint, GLuint);
+GLAPI void APIENTRY glDisableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glEnableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *);
+GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *);
+GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgram (GLuint);
+GLAPI GLboolean APIENTRY glIsShader (GLuint);
+GLAPI void APIENTRY glLinkProgram (GLuint);
+GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *);
+GLAPI void APIENTRY glUseProgram (GLuint);
+GLAPI void APIENTRY glUniform1f (GLint, GLfloat);
+GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform1i (GLint, GLint);
+GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glValidateProgram (GLuint);
+GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif
+
#ifndef GL_ARB_multitexture
#define GL_ARB_multitexture 1
#ifdef GL_GLEXT_PROTOTYPES
@@ -3365,8 +3833,8 @@
#define GL_ARB_texture_env_dot3 1
#endif
-#ifndef GL_ARB_texture_mirror_repeat
-#define GL_ARB_texture_mirror_repeat 1
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
#endif
#ifndef GL_ARB_depth_texture
@@ -3716,6 +4184,42 @@
#define GL_ARB_point_sprite 1
#endif
+#ifndef GL_ARB_fragment_program_shadow
+#define GL_ARB_fragment_program_shadow 1
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_ARB_color_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClampColorARB (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+
#ifndef GL_EXT_abgr
#define GL_EXT_abgr 1
#endif
@@ -5742,6 +6246,13 @@
typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
#endif
+#ifndef GL_ATI_pixel_format_float
+#define GL_ATI_pixel_format_float 1
+/* This is really a WGL extension, but defines some associated GL enums.
+ * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
+ */
+#endif
+
#ifndef GL_ATI_texture_env_combine3
#define GL_ATI_texture_env_combine3 1
#endif
@@ -5931,6 +6442,10 @@
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
#endif
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
#ifndef GL_EXT_depth_bounds_test
#define GL_EXT_depth_bounds_test 1
#ifdef GL_GLEXT_PROTOTYPES
@@ -5959,7 +6474,75 @@
#define GL_MESA_ycbcr_texture 1
#endif
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_EXT_pixel_buffer_object 1
+#endif
+#ifndef GL_NV_fragment_program_option
+#define GL_NV_fragment_program_option 1
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_NV_fragment_program2 1
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#endif
+
+#ifndef GL_NV_vertex_program3
+#define GL_NV_vertex_program3 1
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint);
+GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *);
+GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint);
+GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *);
+GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum);
+GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGenerateMipmapEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#define GL_GREMEDY_string_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
+#endif
+
+
#ifdef __cplusplus
}
#endif
Copied: branches/1.34/code/SDL12/include/SDL_platform.h (from rev 1126, trunk/code/SDL12/include/SDL_platform.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_platform.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_platform.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,104 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+/* Try to get a standard set of platform defines */
+
+#ifndef _SDL_platform_h
+#define _SDL_platform_h
+
+#if defined(_AIX)
+#undef __AIX__
+#define __AIX__ 1
+#endif
+#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__)
+#undef __AMIGA__
+#define __AMIGA__ 1
+#endif
+#if defined(__BEOS__)
+#undef __BEOS__
+#define __BEOS__ 1
+#endif
+#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
+#undef __BSDI__
+#define __BSDI__ 1
+#endif
+#if defined(_arch_dreamcast)
+#undef __DREAMCAST__
+#define __DREAMCAST__ 1
+#endif
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#undef __FREEBSD__
+#define __FREEBSD__ 1
+#endif
+#if defined(hpux) || defined(__hpux) || defined(__hpux__)
+#undef __HPUX__
+#define __HPUX__ 1
+#endif
+#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
+#undef __IRIX__
+#define __IRIX__ 1
+#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+#undef __LINUX__
+#define __LINUX__ 1
+#endif
+#if defined(__APPLE__)
+#undef __MACOSX__
+#define __MACOSX__ 1
+#elif defined(macintosh)
+#undef __MACOS__
+#define __MACOS__ 1
+#endif
+#if defined(__NetBSD__)
+#undef __NETBSD__
+#define __NETBSD__ 1
+#endif
+#if defined(__OpenBSD__)
+#undef __OPENBSD__
+#define __OPENBSD__ 1
+#endif
+#if defined(__OS2__)
+#undef __OS2__
+#define __OS2__ 1
+#endif
+#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
+#undef __OSF__
+#define __OSF__ 1
+#endif
+#if defined(__QNXNTO__)
+#undef __QNXNTO__
+#define __QNXNTO__ 1
+#endif
+#if defined(riscos) || defined(__riscos) || defined(__riscos__)
+#undef __RISCOS__
+#define __RISCOS__ 1
+#endif
+#if defined(__SVR4)
+#undef __SOLARIS__
+#define __SOLARIS__ 1
+#endif
+#if defined(WIN32) || defined(_WIN32)
+#undef __WIN32__
+#define __WIN32__ 1
+#endif
+
+#endif /* _SDL_platform_h */
Modified: branches/1.34/code/SDL12/include/SDL_quit.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_quit.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_quit.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,35 +1,33 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_quit.h,v 1.5 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
/* Include file for SDL quit event handling */
#ifndef _SDL_quit_h
#define _SDL_quit_h
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
+
/*
An SDL_QUITEVENT is generated when the user tries to close the application
window. If it is ignored or filtered out, the window will remain open.
Modified: branches/1.34/code/SDL12/include/SDL_rwops.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_rwops.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_rwops.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,41 +1,35 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_rwops.h,v 1.8 2004/08/20 18:57:01 slouken Exp $";
-#endif
-
/* This file provides a general interface for SDL to read and write
data sources. It can easily be extended to files, memory, etc.
*/
-#ifndef _SDL_RWops_h
-#define _SDL_RWops_h
+#ifndef _SDL_rwops_h
+#define _SDL_rwops_h
-#include <stdio.h>
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
-#include "SDL_types.h"
-
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@@ -68,10 +62,18 @@
Uint32 type;
union {
+#ifdef __WIN32__
struct {
+ int append;
+ void* h;
+ } win32io;
+#endif
+#ifdef HAVE_STDIO_H
+ struct {
int autoclose;
FILE *fp;
} stdio;
+#endif
struct {
Uint8 *base;
Uint8 *here;
@@ -89,7 +91,9 @@
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
+#ifdef HAVE_STDIO_H
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
+#endif
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
@@ -97,18 +101,39 @@
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
+#define RW_SEEK_SET 0 /* Seek from the beginning of data */
+#define RW_SEEK_CUR 1 /* Seek relative to current read point */
+#define RW_SEEK_END 2 /* Seek relative to the end of data */
+
/* Macros to easily read and write from an SDL_RWops structure */
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
-#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR)
+#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
#define SDL_RWclose(ctx) (ctx)->close(ctx)
+/* Read an item of the specified endianness and return in native format */
+extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
+extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
+extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
+extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
+extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
+extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
+
+/* Write an item of native format to the specified endianness */
+extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
+extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
+extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
+extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
+extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
+extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
+
+
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
-#endif /* _SDL_RWops_h */
+#endif /* _SDL_rwops_h */
Copied: branches/1.34/code/SDL12/include/SDL_stdinc.h (from rev 1126, trunk/code/SDL12/include/SDL_stdinc.h)
===================================================================
--- branches/1.34/code/SDL12/include/SDL_stdinc.h (rev 0)
+++ branches/1.34/code/SDL12/include/SDL_stdinc.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,586 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken at libsdl.org
+*/
+
+/* This is a general header that includes C language support */
+
+#ifndef _SDL_stdinc_h
+#define _SDL_stdinc_h
+
+#include "SDL_config.h"
+
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if defined(STDC_HEADERS)
+# include <stdlib.h>
+# include <stddef.h>
+# include <stdarg.h>
+#else
+# if defined(HAVE_STDLIB_H)
+# include <stdlib.h>
+# elif defined(HAVE_MALLOC_H)
+# include <malloc.h>
+# endif
+# if defined(HAVE_STDDEF_H)
+# include <stddef.h>
+# endif
+# if defined(HAVE_STDARG_H)
+# include <stdarg.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+# include <stdint.h>
+#endif
+#ifdef HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+#ifdef HAVE_ICONV_H
+# include <iconv.h>
+#endif
+
+/* The number of elements in an array */
+#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
+#define SDL_TABLESIZE(table) SDL_arraysize(table)
+
+/* Basic data types */
+typedef enum SDL_bool {
+ SDL_FALSE = 0,
+ SDL_TRUE = 1
+} SDL_bool;
+
+typedef int8_t Sint8;
+typedef uint8_t Uint8;
+typedef int16_t Sint16;
+typedef uint16_t Uint16;
+typedef int32_t Sint32;
+typedef uint32_t Uint32;
+
+#ifdef SDL_HAS_64BIT_TYPE
+typedef int64_t Sint64;
+typedef uint64_t Uint64;
+#else
+/* This is really just a hack to prevent the compiler from complaining */
+typedef struct {
+ Uint32 hi;
+ Uint32 lo;
+} Uint64, Sint64;
+#endif
+
+/* Make sure the types really have the right sizes */
+#define SDL_COMPILE_TIME_ASSERT(name, x) \
+ typedef int SDL_dummy_ ## name[(x) * 2 - 1]
+
+SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
+SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
+SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
+SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
+SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
+SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
+SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
+SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
+
+/* Check to make sure enums are the size of ints, for structure packing.
+ For both Watcom C/C++ and Borland C/C++ the compiler option that makes
+ enums having the size of an int must be enabled.
+ This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
+*/
+/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
+#ifdef __MWERKS__
+#pragma enumsalwaysint on
+#endif
+
+typedef enum {
+ DUMMY_ENUM_VALUE
+} SDL_DUMMY_ENUM;
+
+SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
+
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_MALLOC
+#define SDL_malloc malloc
+#else
+extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
+#endif
+
+#ifdef HAVE_CALLOC
+#define SDL_calloc calloc
+#else
+extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
+#endif
+
+#ifdef HAVE_REALLOC
+#define SDL_realloc realloc
+#else
+extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
+#endif
+
+#ifdef HAVE_FREE
+#define SDL_free free
+#else
+extern DECLSPEC void SDLCALL SDL_free(void *mem);
+#endif
+
+#if defined(HAVE_ALLOCA) && !defined(alloca)
+# if defined(HAVE_ALLOCA_H)
+# include <alloca.h>
+# elif defined(__GNUC__)
+# define alloca __builtin_alloca
+# elif defined(_MSC_VER)
+# include <malloc.h>
+# define alloca _alloca
+# elif defined(__WATCOMC__)
+# include <malloc.h>
+# elif defined(__DMC__)
+# include <stdlib.h>
+# elif defined(__AIX__)
+ #pragma alloca
+# elif defined(__MRC__)
+ void *alloca (unsigned);
+# else
+ char *alloca ();
+# endif
+#endif
+#ifdef HAVE_ALLOCA
+#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
+#define SDL_stack_free(data)
+#else
+#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count)
+#define SDL_stack_free(data) SDL_free(data)
+#endif
+
+#ifdef HAVE_GETENV
+#define SDL_getenv getenv
+#else
+extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
+#endif
+
+#ifdef HAVE_PUTENV
+#define SDL_putenv putenv
+#else
+extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
+#endif
+
+#ifdef HAVE_QSORT
+#define SDL_qsort qsort
+#else
+extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
+ int (*compare)(const void *, const void *));
+#endif
+
+#ifdef HAVE_ABS
+#define SDL_abs abs
+#else
+#define SDL_abs(X) ((X) < 0 ? -(X) : (X))
+#endif
+
+#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
+#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
+
+#ifdef HAVE_CTYPE_H
+#define SDL_isdigit(X) isdigit(X)
+#define SDL_isspace(X) isspace(X)
+#define SDL_toupper(X) toupper(X)
+#define SDL_tolower(X) tolower(X)
+#else
+#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9'))
+#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
+#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
+#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
+#endif
+
+#ifdef HAVE_MEMSET
+#define SDL_memset memset
+#else
+extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
+#endif
+
+#if defined(__GNUC__) && defined(i386)
+#define SDL_memset4(dst, val, len) \
+do { \
+ int u0, u1, u2; \
+ __asm__ __volatile__ ( \
+ "cld\n\t" \
+ "rep ; stosl\n\t" \
+ : "=&D" (u0), "=&a" (u1), "=&c" (u2) \
+ : "0" (dst), "1" (val), "2" ((Uint32)(len)) \
+ : "memory" ); \
+} while(0)
+#endif
+#ifndef SDL_memset4
+#define SDL_memset4(dst, val, len) \
+do { \
+ unsigned _count = (len); \
+ unsigned _n = (_count + 3) / 4; \
+ Uint32 *_p = (Uint32 *)(dst); \
+ Uint32 _val = (val); \
+ switch (_count % 4) { \
+ case 0: do { *_p++ = _val; \
+ case 3: *_p++ = _val; \
+ case 2: *_p++ = _val; \
+ case 1: *_p++ = _val; \
+ } while ( --_n ); \
+ } \
+} while(0)
+#endif
+
+#if defined(__GNUC__) && defined(i386)
+#define SDL_memcpy(dst, src, len) \
+do { \
+ int u0, u1, u2; \
+ __asm__ __volatile__ ( \
+ "cld\n\t" \
+ "rep ; movsl\n\t" \
+ "testb $2,%b4\n\t" \
+ "je 1f\n\t" \
+ "movsw\n" \
+ "1:\ttestb $1,%b4\n\t" \
+ "je 2f\n\t" \
+ "movsb\n" \
+ "2:" \
+ : "=&c" (u0), "=&D" (u1), "=&S" (u2) \
+ : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
+ : "memory" ); \
+} while(0)
+#endif
+#ifndef SDL_memcpy
+#ifdef HAVE_MEMCPY
+#define SDL_memcpy memcpy
+#elif defined(HAVE_BCOPY)
+#define SDL_memcpy(d, s, n) bcopy((s), (d), (n))
+#else
+extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
+#endif
+#endif
+
+#if defined(__GNUC__) && defined(i386)
+#define SDL_memcpy4(dst, src, len) \
+do { \
+ int ecx, edi, esi; \
+ __asm__ __volatile__ ( \
+ "cld\n\t" \
+ "rep ; movsl" \
+ : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
+ : "0" ((unsigned)(len)), "1" (dst), "2" (src) \
+ : "memory" ); \
+} while(0)
+#endif
+#ifndef SDL_memcpy4
+#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2)
+#endif
+
+#if defined(__GNUC__) && defined(i386)
+#define SDL_revcpy(dst, src, len) \
+do { \
+ int u0, u1, u2; \
+ char *dstp = (char *)(dst); \
+ char *srcp = (char *)(src); \
+ int n = (len); \
+ if ( n >= 4 ) { \
+ __asm__ __volatile__ ( \
+ "std\n\t" \
+ "rep ; movsl\n\t" \
+ : "=&c" (u0), "=&D" (u1), "=&S" (u2) \
+ : "0" (n >> 2), \
+ "1" (dstp+(n-4)), "2" (srcp+(n-4)) \
+ : "memory" ); \
+ } \
+ switch (n & 3) { \
+ case 3: dstp[2] = srcp[2]; \
+ case 2: dstp[1] = srcp[1]; \
+ case 1: dstp[0] = srcp[0]; \
+ break; \
+ default: \
+ break; \
+ } \
+} while(0)
+#endif
+#ifndef SDL_revcpy
+extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
+#endif
+
+#ifdef HAVE_MEMMOVE
+#define SDL_memmove memmove
+#elif defined(HAVE_BCOPY)
+#define SDL_memmove(d, s, n) bcopy((s), (d), (n))
+#else
+#define SDL_memmove(dst, src, len) \
+do { \
+ if ( dst < src ) { \
+ SDL_memcpy(dst, src, len); \
+ } else { \
+ SDL_revcpy(dst, src, len); \
+ } \
+} while(0)
+#endif
+
+#ifdef HAVE_MEMCMP
+#define SDL_memcmp memcmp
+#else
+extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
+#endif
+
+#ifdef HAVE_STRLEN
+#define SDL_strlen strlen
+#else
+extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
+#endif
+
+#ifdef HAVE_STRLCPY
+#define SDL_strlcpy strlcpy
+#else
+extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
+#endif
+
+#ifdef HAVE_STRLCAT
+#define SDL_strlcat strlcat
+#else
+extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
+#endif
+
+#ifdef HAVE_STRDUP
+#define SDL_strdup strdup
+#else
+extern DECLSPEC char * SDLCALL SDL_strdup(const char *string);
+#endif
+
+#ifdef HAVE__STRREV
+#define SDL_strrev _strrev
+#else
+extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
+#endif
+
+#ifdef HAVE__STRUPR
+#define SDL_strupr _strupr
+#else
+extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
+#endif
+
+#ifdef HAVE__STRLWR
+#define SDL_strlwr _strlwr
+#else
+extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
+#endif
+
+#ifdef HAVE_STRCHR
+#define SDL_strchr strchr
+#elif defined(HAVE_INDEX)
+#define SDL_strchr index
+#else
+extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
+#endif
+
+#ifdef HAVE_STRRCHR
+#define SDL_strrchr strrchr
+#elif defined(HAVE_RINDEX)
+#define SDL_strrchr rindex
+#else
+extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
+#endif
+
+#ifdef HAVE_STRSTR
+#define SDL_strstr strstr
+#else
+extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
+#endif
+
+#ifdef HAVE_ITOA
+#define SDL_itoa itoa
+#else
+#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
+#endif
+
+#ifdef HAVE__LTOA
+#define SDL_ltoa _ltoa
+#else
+extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
+#endif
+
+#ifdef HAVE__UITOA
+#define SDL_uitoa _uitoa
+#else
+#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
+#endif
+
+#ifdef HAVE__ULTOA
+#define SDL_ultoa _ultoa
+#else
+extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
+#endif
+
+#ifdef HAVE_STRTOL
+#define SDL_strtol strtol
+#else
+extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
+#endif
+
+#ifdef HAVE_STRTOUL
+#define SDL_strtoul strtoul
+#else
+extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
+#endif
+
+#ifdef SDL_HAS_64BIT_TYPE
+
+#ifdef HAVE__I64TOA
+#define SDL_lltoa _i64toa
+#else
+extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
+#endif
+
+#ifdef HAVE__UI64TOA
+#define SDL_ulltoa _ui64toa
+#else
+extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
+#endif
+
+#ifdef HAVE_STRTOLL
+#define SDL_strtoll strtoll
+#else
+extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
+#endif
+
+#ifdef HAVE_STRTOULL
+#define SDL_strtoull strtoull
+#else
+extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
+#endif
+
+#endif /* SDL_HAS_64BIT_TYPE */
+
+#ifdef HAVE_STRTOD
+#define SDL_strtod strtod
+#else
+extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
+#endif
+
+#ifdef HAVE_ATOI
+#define SDL_atoi atoi
+#else
+#define SDL_atoi(X) SDL_strtol(X, NULL, 0)
+#endif
+
+#ifdef HAVE_ATOF
+#define SDL_atof atof
+#else
+#define SDL_atof(X) SDL_strtod(X, NULL)
+#endif
+
+#ifdef HAVE_STRCMP
+#define SDL_strcmp strcmp
+#else
+extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
+#endif
+
+#ifdef HAVE_STRNCMP
+#define SDL_strncmp strncmp
+#else
+extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
+#endif
+
+#ifdef HAVE_STRCASECMP
+#define SDL_strcasecmp strcasecmp
+#elif defined(HAVE__STRICMP)
+#define SDL_strcasecmp _stricmp
+#else
+extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
+#endif
+
+#ifdef HAVE_STRNCASECMP
+#define SDL_strncasecmp strncasecmp
+#elif defined(HAVE__STRNICMP)
+#define SDL_strncasecmp _strnicmp
+#else
+extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
+#endif
+
+#ifdef HAVE_SSCANF
+#define SDL_sscanf sscanf
+#else
+extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
+#endif
+
+#ifdef HAVE_SNPRINTF
+#define SDL_snprintf snprintf
+#else
+extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
+#endif
+
+#ifdef HAVE_VSNPRINTF
+#define SDL_vsnprintf vsnprintf
+#else
+extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
+#endif
+
+/* The SDL implementation of iconv() returns these error codes */
+#define SDL_ICONV_ERROR (size_t)-1
+#define SDL_ICONV_E2BIG (size_t)-2
+#define SDL_ICONV_EILSEQ (size_t)-3
+#define SDL_ICONV_EINVAL (size_t)-4
+
+#ifdef HAVE_ICONV
+#define SDL_iconv_t iconv_t
+#define SDL_iconv_open iconv_open
+#define SDL_iconv_close iconv_close
+extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
+#else
+typedef struct _SDL_iconv_t *SDL_iconv_t;
+extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
+extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
+extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
+#endif
+/* This function converts a string between encodings in one pass, returning a
+ string that must be freed with SDL_free() or NULL on error.
+*/
+extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
+#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
+#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
+#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
+#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_stdinc_h */
Modified: branches/1.34/code/SDL12/include/SDL_syswm.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_syswm.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_syswm.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,35 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_syswm.h,v 1.18 2005/09/08 06:16:13 icculus Exp $";
-#endif
-
/* Include file for SDL custom system window manager hooks */
#ifndef _SDL_syswm_h
#define _SDL_syswm_h
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "SDL_version.h"
#include "begin_code.h"
@@ -48,23 +45,18 @@
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#else
+/* This is the structure for custom window manager events */
+#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(__APPLE__) && defined(__MACH__)
-// conflicts with Quickdraw.h
+/* conflicts with Quickdraw.h */
#define Cursor X11Cursor
#endif
-/* This is the structure for custom window manager events */
-#if (defined(unix) || defined(__unix__) || defined(_AIX) || \
- defined(__OpenBSD__) || defined(__NetBSD__) || \
- (defined(__APPLE__) && defined(__MACH__))) && \
- (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX) && \
- !defined(__QNXNTO__))
- /* AIX is unix, of course, but the native compiler CSet doesn't define unix */
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#if defined(__APPLE__) && defined(__MACH__)
-// matches the re-define above
+/* matches the re-define above */
#undef Cursor
#endif
@@ -108,7 +100,7 @@
} info;
} SDL_SysWMinfo;
-#elif defined(ENABLE_NANOX)
+#elif defined(SDL_VIDEO_DRIVER_NANOX)
#include <microwin/nano-X.h>
/* The generic custom event structure */
@@ -123,7 +115,7 @@
GR_WINDOW_ID window ; /* The display window */
} SDL_SysWMinfo;
-#elif defined(WIN32)
+#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -143,7 +135,7 @@
HGLRC hglrc; /* The OpenGL context, if any */
} SDL_SysWMinfo;
-#elif defined(__riscos__)
+#elif defined(SDL_VIDEO_DRIVER_RISCOS)
/* RISC OS custom event structure */
struct SDL_SysWMmsg {
@@ -160,7 +152,7 @@
int window; /* The RISC OS display window */
} SDL_SysWMinfo;
-#elif defined(__QNXNTO__)
+#elif defined(SDL_VIDEO_DRIVER_PHOTON)
#include <sys/neutrino.h>
#include <Ph.h>
@@ -190,7 +182,7 @@
int data;
} SDL_SysWMinfo;
-#endif /* OS type */
+#endif /* video driver type */
#endif /* SDL_PROTOTYPES_ONLY */
Modified: branches/1.34/code/SDL12/include/SDL_thread.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_thread.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_thread.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,30 +1,25 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_thread.h,v 1.7 2004/08/20 18:57:01 slouken Exp $";
-#endif
-
#ifndef _SDL_thread_h
#define _SDL_thread_h
@@ -33,8 +28,8 @@
These are independent of the other SDL routines.
*/
-#include "SDL_main.h"
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
/* Thread synchronization primitives */
#include "SDL_mutex.h"
@@ -50,7 +45,52 @@
typedef struct SDL_Thread SDL_Thread;
/* Create a thread */
+#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)
+/*
+ We compile SDL into a DLL on OS/2. This means, that it's the DLL which
+ creates a new thread for the calling process with the SDL_CreateThread()
+ API. There is a problem with this, that only the RTL of the SDL.DLL will
+ be initialized for those threads, and not the RTL of the calling application!
+ To solve this, we make a little hack here.
+ We'll always use the caller's _beginthread() and _endthread() APIs to
+ start a new thread. This way, if it's the SDL.DLL which uses this API,
+ then the RTL of SDL.DLL will be used to create the new thread, and if it's
+ the application, then the RTL of the application will be used.
+ So, in short:
+ Always use the _beginthread() and _endthread() of the calling runtime library!
+*/
+#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
+#ifndef _WIN32_WCE
+#include <process.h> /* This has _beginthread() and _endthread() defined! */
+#endif
+
+#ifdef __OS2__
+typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg);
+typedef void (*pfnSDL_CurrentEndThread)(void);
+#elif __GNUC__
+typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
+ unsigned (__stdcall *func)(void *), void *arg,
+ unsigned, unsigned *threadID);
+typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
+#else
+typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
+ unsigned (__stdcall *func)(void *), void *arg,
+ unsigned, unsigned *threadID);
+typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
+#endif
+
+extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
+
+#ifdef __OS2__
+#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
+#elif defined(_WIN32_WCE)
+#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
+#else
+#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
+#endif
+#else
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
+#endif
/* Get the 32-bit thread identifier for the current thread */
extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
Modified: branches/1.34/code/SDL12/include/SDL_timer.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_timer.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_timer.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,37 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_timer.h,v 1.7 2005/01/13 23:24:56 slouken Exp $";
-#endif
-
#ifndef _SDL_timer_h
#define _SDL_timer_h
/* Header for the SDL time management routines */
-#include "SDL_main.h"
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Modified: branches/1.34/code/SDL12/include/SDL_types.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_types.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_types.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,120 +1,24 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_types.h,v 1.13 2004/07/21 04:53:26 slouken Exp $";
-#endif
-
-/* General data types used by the SDL library */
-
-#ifndef _SDL_types_h
-#define _SDL_types_h
-
-/* The number of elements in a table */
-#define SDL_TABLESIZE(table) (sizeof(table)/sizeof(table[0]))
-
-/* Basic data types */
-typedef enum {
- SDL_FALSE = 0,
- SDL_TRUE = 1
-} SDL_bool;
-
-#ifdef H_MMBASIC /* mmbasic.h (Tru64 MME) */
-/* Some of the basic types are already defined in mmbasic.h */
-typedef signed char Sint8;
-typedef signed short Sint16;
-typedef signed int Sint32;
-#else
-typedef unsigned char Uint8;
-typedef signed char Sint8;
-typedef unsigned short Uint16;
-typedef signed short Sint16;
-typedef unsigned int Uint32;
-typedef signed int Sint32;
-#endif
-
-/* Figure out how to support 64-bit datatypes */
-#if !defined(__STRICT_ANSI__)
-#ifdef __osf__ /* Tru64 */
-#define SDL_HAS_64BIT_TYPE long
-#elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DECC)
-#define SDL_HAS_64BIT_TYPE long long
-#elif defined(_MSC_VER) /* VC++ */
-#define SDL_HAS_64BIT_TYPE __int64
-#endif
-#endif /* !__STRICT_ANSI__ */
-
-/* The 64-bit type isn't available on EPOC/Symbian OS */
-#ifdef __SYMBIAN32__
-#undef SDL_HAS_64BIT_TYPE
-#endif
-
-/* The 64-bit datatype isn't supported on all platforms */
-#ifdef SDL_HAS_64BIT_TYPE
-#ifndef H_MMBASIC
-typedef unsigned SDL_HAS_64BIT_TYPE Uint64;
-#endif
-typedef SDL_HAS_64BIT_TYPE Sint64;
-#else
-/* This is really just a hack to prevent the compiler from complaining */
-typedef struct {
- Uint32 hi;
- Uint32 lo;
-} Uint64, Sint64;
-#endif
-
-/* Make sure the types really have the right sizes */
-#define SDL_COMPILE_TIME_ASSERT(name, x) \
- typedef int SDL_dummy_ ## name[(x) * 2 - 1]
-
-SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
-SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
-SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
-SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
-SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
-SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
-SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
-SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
-
-/* Check to make sure enums are the size of ints, for structure packing.
- For both Watcom C/C++ and Borland C/C++ the compiler option that makes
- enums having the size of an int must be enabled.
- This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
-*/
-/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
-#ifdef __MWERKS__
-#pragma enumsalwaysint on
-#endif
-
-typedef enum {
- DUMMY_ENUM_VALUE
-} SDL_DUMMY_ENUM;
-
-SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
-
-#undef SDL_COMPILE_TIME_ASSERT
-
-/* General keyboard/mouse state definitions */
-enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 };
-
-#endif
+/* DEPRECATED */
+#include "SDL_stdinc.h"
Modified: branches/1.34/code/SDL12/include/SDL_version.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_version.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_version.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,36 +1,31 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_version.h,v 1.16 2005/04/17 10:16:30 icculus Exp $";
-#endif
-
/* This header defines the current SDL version */
#ifndef _SDL_version_h
#define _SDL_version_h
-#include "SDL_types.h"
+#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -42,7 +37,7 @@
*/
#define SDL_MAJOR_VERSION 1
#define SDL_MINOR_VERSION 2
-#define SDL_PATCHLEVEL 9
+#define SDL_PATCHLEVEL 11
typedef struct SDL_version {
Uint8 major;
Modified: branches/1.34/code/SDL12/include/SDL_video.h
===================================================================
--- branches/1.34/code/SDL12/include/SDL_video.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/SDL_video.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,39 +1,32 @@
/*
SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2004 Sam Lantinga
+ Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
This library 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
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken at libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_video.h,v 1.19 2005/01/02 05:11:16 slouken Exp $";
-#endif
-
/* Header file for access to the SDL raw framebuffer window */
#ifndef _SDL_video_h
#define _SDL_video_h
-#include <stdio.h>
-
-#include "SDL_types.h"
-#include "SDL_mutex.h"
+#include "SDL_stdinc.h"
+#include "SDL_error.h"
#include "SDL_rwops.h"
#include "begin_code.h"
@@ -168,6 +161,8 @@
Uint32 UnusedBits3 :16;
Uint32 video_mem; /* The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
+ int current_w; /* Value: The current video mode width */
+ int current_h; /* Value: The current video mode height */
} SDL_VideoInfo;
@@ -218,7 +213,9 @@
SDL_GL_ACCUM_ALPHA_SIZE,
SDL_GL_STEREO,
SDL_GL_MULTISAMPLEBUFFERS,
- SDL_GL_MULTISAMPLESAMPLES
+ SDL_GL_MULTISAMPLESAMPLES,
+ SDL_GL_ACCELERATED_VISUAL,
+ SDL_GL_SWAP_CONTROL
} SDL_GLattr;
/* flags for SDL_SetPalette() */
@@ -779,19 +776,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Dynamically load a GL driver, if SDL is built with dynamic GL.
+ * Dynamically load an OpenGL library, or the default one if path is NULL
*
- * SDL links normally with the OpenGL library on your system by default,
- * but you can compile it to dynamically load the GL driver at runtime.
* If you do this, you need to retrieve all of the GL functions used in
* your program from the dynamic library using SDL_GL_GetProcAddress().
- *
- * This is disabled in default builds of SDL.
*/
extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
/*
- * Get the address of a GL function (for extension functions)
+ * Get the address of a GL function
*/
extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc);
@@ -829,7 +822,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Sets/Gets the title and icon text of the display window
+ * Sets/Gets the title and icon text of the display window (UTF-8 encoded)
*/
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
Modified: branches/1.34/code/SDL12/include/begin_code.h
===================================================================
--- branches/1.34/code/SDL12/include/begin_code.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/begin_code.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -31,43 +31,56 @@
#endif
#define _begin_code_h
-/* Make sure the correct platform symbols are defined */
-#if !defined(WIN32) && defined(_WIN32)
-#define WIN32
-#endif /* Windows */
-
/* Some compilers use a special export keyword */
#ifndef DECLSPEC
-# ifdef __BEOS__
+# if defined(__BEOS__)
# if defined(__GNUC__)
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC __declspec(export)
# endif
-# else
-# ifdef WIN32
+# elif defined(__WIN32__)
# ifdef __BORLANDC__
# ifdef BUILD_SDL
# define DECLSPEC
# else
-# define DECLSPEC __declspec(dllimport)
+# define DECLSPEC __declspec(dllimport)
# endif
# else
# define DECLSPEC __declspec(dllexport)
# endif
+# elif defined(__OS2__)
+# ifdef __WATCOMC__
+# ifdef BUILD_SDL
+# define DECLSPEC __declspec(dllexport)
+# else
+# define DECLSPEC
+# endif
+# else
+# define DECLSPEC
+# endif
# else
-# define DECLSPEC
+# if defined(__GNUC__) && __GNUC__ >= 4
+# define DECLSPEC __attribute__ ((visibility("default")))
+# else
+# define DECLSPEC
+# endif
# endif
-# endif
#endif
/* By default SDL uses the C calling convention */
#ifndef SDLCALL
-#if defined(WIN32) && !defined(__GNUC__)
+#if defined(__WIN32__) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
+#ifdef __OS2__
+/* But on OS/2, we use the _System calling convention */
+/* to be compatible with every compiler */
+#define SDLCALL _System
+#else
#define SDLCALL
#endif
+#endif
#endif /* SDLCALL */
/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
@@ -89,7 +102,7 @@
#pragma nopackwarning
#endif
#pragma pack(push,4)
-#elif (defined(__MWERKS__) && defined(macintosh))
+#elif (defined(__MWERKS__) && defined(__MACOS__))
#pragma options align=mac68k4byte
#pragma enumsalwaysint on
#endif /* Compiler needs structure packing set */
@@ -134,4 +147,4 @@
#define NULL ((void *)0)
#endif
#endif /* NULL */
-#endif /* ! MacOS X - breaks precompiled headers */
+#endif /* ! Mac OS X - breaks precompiled headers */
Modified: branches/1.34/code/SDL12/include/close_code.h
===================================================================
--- branches/1.34/code/SDL12/include/close_code.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/SDL12/include/close_code.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -31,7 +31,7 @@
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
-#if (defined(__MWERKS__) && defined(macintosh))
+#if (defined(__MWERKS__) && defined(__MACOS__))
#pragma options align=reset
#pragma enumsalwaysint reset
#else
Modified: branches/1.34/code/botlib/be_ai_chat.c
===================================================================
--- branches/1.34/code/botlib/be_ai_chat.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/botlib/be_ai_chat.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -367,13 +367,26 @@
int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm)
{
bot_chatstate_t *cs;
+ bot_consolemessage_t *firstmsg;
cs = BotChatStateFromHandle(chatstate);
if (!cs) return 0;
- if (cs->firstmessage)
+ if ((firstmsg = cs->firstmessage))
{
- Com_Memcpy(cm, cs->firstmessage, sizeof(bot_consolemessage_t));
- cm->next = cm->prev = NULL;
+ cm->handle = firstmsg->handle;
+ cm->time = firstmsg->time;
+ cm->type = firstmsg->type;
+ Q_strncpyz(cm->message, firstmsg->message,
+ sizeof(cm->message));
+
+ /* We omit setting the two pointers in cm because pointer
+ * size in the VM differs between the size in the engine on
+ * 64 bit machines, which would lead to a buffer overflow if
+ * this functions is called from the VM. The pointers are
+ * of no interest to functions calling
+ * BotNextConsoleMessage anyways.
+ */
+
return cm->handle;
} //end if
return 0;
Modified: branches/1.34/code/botlib/be_ai_goal.c
===================================================================
--- branches/1.34/code/botlib/be_ai_goal.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/botlib/be_ai_goal.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -134,7 +134,7 @@
int number; //number of the item info
} iteminfo_t;
-#define ITEMINFO_OFS(x) (int)&(((iteminfo_t *)0)->x)
+#define ITEMINFO_OFS(x) (size_t)&(((iteminfo_t *)0)->x)
fielddef_t iteminfo_fields[] =
{
Modified: branches/1.34/code/botlib/be_ai_weap.c
===================================================================
--- branches/1.34/code/botlib/be_ai_weap.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/botlib/be_ai_weap.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -48,8 +48,8 @@
//#define DEBUG_AI_WEAP
//structure field offsets
-#define WEAPON_OFS(x) (int)&(((weaponinfo_t *)0)->x)
-#define PROJECTILE_OFS(x) (int)&(((projectileinfo_t *)0)->x)
+#define WEAPON_OFS(x) (size_t)&(((weaponinfo_t *)0)->x)
+#define PROJECTILE_OFS(x) (size_t)&(((projectileinfo_t *)0)->x)
//weapon definition // bk001212 - static
static fielddef_t weaponinfo_fields[] =
Modified: branches/1.34/code/cgame/cg_main.c
===================================================================
--- branches/1.34/code/cgame/cg_main.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/cgame/cg_main.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1448,7 +1448,7 @@
trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ );
if (!f) {
- trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n", menuFile ) );
+ trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n") );
}
}
Modified: branches/1.34/code/client/cl_cgame.c
===================================================================
--- branches/1.34/code/client/cl_cgame.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/cl_cgame.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -415,10 +415,10 @@
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case CG_PRINT:
- Com_Printf( "%s", VMA(1) );
+ Com_Printf( "%s", (const char*)VMA(1) );
return 0;
case CG_ERROR:
- Com_Error( ERR_DROP, "%s", VMA(1) );
+ Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
@@ -698,7 +698,7 @@
default:
assert(0); // bk010102
- Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] );
+ Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] );
}
return 0;
}
@@ -746,6 +746,10 @@
// otherwise server commands sent just before a gamestate are dropped
VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum );
+ // reset any CVAR_CHEAT cvars registered by cgame
+ if ( !clc.demoplaying && !cl_connectedToCheatServer )
+ Cvar_SetCheatState();
+
// we will send a usercmd this frame, which
// will cause the server to send us the first snapshot
cls.state = CA_PRIMED;
Copied: branches/1.34/code/client/cl_curl.c (from rev 898, trunk/code/client/cl_curl.c)
===================================================================
--- branches/1.34/code/client/cl_curl.c (rev 0)
+++ branches/1.34/code/client/cl_curl.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,360 @@
+/*
+===========================================================================
+Copyright (C) 2006 Tony J. White (tjw at tjw.org)
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code 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.
+
+Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#if USE_CURL
+#include "client.h"
+cvar_t *cl_cURLLib;
+
+#if USE_CURL_DLOPEN
+
+#if USE_SDL_VIDEO
+#include "SDL.h"
+#include "SDL_loadso.h"
+#define OBJTYPE void *
+#define OBJLOAD(x) SDL_LoadObject(x)
+#define SYMLOAD(x,y) SDL_LoadFunction(x,y)
+#define OBJFREE(x) SDL_UnloadObject(x)
+
+#elif defined _WIN32
+#include <windows.h>
+#define OBJTYPE HMODULE
+#define OBJLOAD(x) LoadLibrary(x)
+#define SYMLOAD(x,y) GetProcAddress(x,y)
+#define OBJFREE(x) FreeLibrary(x)
+
+#elif defined __linux__ || defined __FreeBSD__ || defined MACOS_X || defined __sun
+#include <dlfcn.h>
+#define OBJTYPE void *
+#define OBJLOAD(x) dlopen(x, RTLD_LAZY | RTLD_GLOBAL)
+#define SYMLOAD(x,y) dlsym(x,y)
+#define OBJFREE(x) dlclose(x)
+#else
+
+#error "Your platform has no lib loading code or it is disabled"
+#endif
+
+#if defined __linux__ || defined __FreeBSD__ || defined MACOS_X
+#include <unistd.h>
+#include <sys/types.h>
+#endif
+
+char* (*qcurl_version)(void);
+
+CURL* (*qcurl_easy_init)(void);
+CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
+CURLcode (*qcurl_easy_perform)(CURL *curl);
+void (*qcurl_easy_cleanup)(CURL *curl);
+CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
+CURL* (*qcurl_easy_duphandle)(CURL *curl);
+void (*qcurl_easy_reset)(CURL *curl);
+const char *(*qcurl_easy_strerror)(CURLcode);
+
+CURLM* (*qcurl_multi_init)(void);
+CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
+ CURL *curl_handle);
+CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
+ CURL *curl_handle);
+CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
+ fd_set *read_fd_set,
+ fd_set *write_fd_set,
+ fd_set *exc_fd_set,
+ int *max_fd);
+CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
+ int *running_handles);
+CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
+CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
+ int *msgs_in_queue);
+const char *(*qcurl_multi_strerror)(CURLMcode);
+
+static OBJTYPE cURLLib = NULL;
+
+/*
+=================
+GPA
+=================
+*/
+static void *GPA(char *str)
+{
+ void *rv;
+
+ rv = SYMLOAD(cURLLib, str);
+ if(!rv)
+ {
+ Com_Printf("Can't load symbol %s\n", str);
+ clc.cURLEnabled = qfalse;
+ return NULL;
+ }
+ else
+ {
+ Com_DPrintf("Loaded symbol %s (0x%p)\n", str, rv);
+ return rv;
+ }
+}
+#endif /* USE_CURL_DLOPEN */
+
+/*
+=================
+CL_cURL_Init
+=================
+*/
+qboolean CL_cURL_Init()
+{
+#if USE_CURL_DLOPEN
+ if(cURLLib)
+ return qtrue;
+
+
+ Com_Printf("Loading \"%s\"...", cl_cURLLib->string);
+ if( (cURLLib = OBJLOAD(cl_cURLLib->string)) == 0 )
+ {
+#ifdef _WIN32
+ return qfalse;
+#else
+ char fn[1024];
+ getcwd(fn, sizeof(fn));
+ strncat(fn, "/", sizeof(fn)-strlen(fn)-1);
+ strncat(fn, cl_cURLLib->string, sizeof(fn)-strlen(fn)-1);
+
+ if( (cURLLib = OBJLOAD(fn)) == 0 )
+ {
+ return qfalse;
+ }
+#endif /* _WIN32 */
+ }
+
+ clc.cURLEnabled = qtrue;
+
+ qcurl_version = GPA("curl_version");
+
+ qcurl_easy_init = GPA("curl_easy_init");
+ qcurl_easy_setopt = GPA("curl_easy_setopt");
+ qcurl_easy_perform = GPA("curl_easy_perform");
+ qcurl_easy_cleanup = GPA("curl_easy_cleanup");
+ qcurl_easy_getinfo = GPA("curl_easy_getinfo");
+ qcurl_easy_duphandle = GPA("curl_easy_duphandle");
+ qcurl_easy_reset = GPA("curl_easy_reset");
+ qcurl_easy_strerror = GPA("curl_easy_strerror");
+
+ qcurl_multi_init = GPA("curl_multi_init");
+ qcurl_multi_add_handle = GPA("curl_multi_add_handle");
+ qcurl_multi_remove_handle = GPA("curl_multi_remove_handle");
+ qcurl_multi_fdset = GPA("curl_multi_fdset");
+ qcurl_multi_perform = GPA("curl_multi_perform");
+ qcurl_multi_cleanup = GPA("curl_multi_cleanup");
+ qcurl_multi_info_read = GPA("curl_multi_info_read");
+ qcurl_multi_strerror = GPA("curl_multi_strerror");
+
+ if(!clc.cURLEnabled)
+ {
+ CL_cURL_Shutdown();
+ Com_Printf("FAIL One or more symbols not found\n");
+ return qfalse;
+ }
+ Com_Printf("OK\n");
+
+ return qtrue;
+#else
+ clc.cURLEnabled = qtrue;
+ return qtrue;
+#endif /* USE_CURL_DLOPEN */
+}
+
+/*
+=================
+CL_cURL_Shutdown
+=================
+*/
+void CL_cURL_Shutdown( void )
+{
+ CL_cURL_Cleanup();
+#if USE_CURL_DLOPEN
+ if(cURLLib)
+ {
+ OBJFREE(cURLLib);
+ cURLLib = NULL;
+ }
+ qcurl_easy_init = NULL;
+ qcurl_easy_setopt = NULL;
+ qcurl_easy_perform = NULL;
+ qcurl_easy_cleanup = NULL;
+ qcurl_easy_getinfo = NULL;
+ qcurl_easy_duphandle = NULL;
+ qcurl_easy_reset = NULL;
+
+ qcurl_multi_init = NULL;
+ qcurl_multi_add_handle = NULL;
+ qcurl_multi_remove_handle = NULL;
+ qcurl_multi_fdset = NULL;
+ qcurl_multi_perform = NULL;
+ qcurl_multi_cleanup = NULL;
+ qcurl_multi_info_read = NULL;
+ qcurl_multi_strerror = NULL;
+#endif /* USE_CURL_DLOPEN */
+}
+
+void CL_cURL_Cleanup(void)
+{
+ if(clc.downloadCURLM) {
+ if(clc.downloadCURL) {
+ qcurl_multi_remove_handle(clc.downloadCURLM,
+ clc.downloadCURL);
+ qcurl_easy_cleanup(clc.downloadCURL);
+ }
+ qcurl_multi_cleanup(clc.downloadCURLM);
+ clc.downloadCURLM = NULL;
+ clc.downloadCURL = NULL;
+ }
+ else if(clc.downloadCURL) {
+ qcurl_easy_cleanup(clc.downloadCURL);
+ clc.downloadCURL = NULL;
+ }
+}
+
+static int CL_cURL_CallbackProgress( void *dummy, double dltotal, double dlnow,
+ double ultotal, double ulnow )
+{
+ clc.downloadSize = (int)dltotal;
+ Cvar_SetValue( "cl_downloadSize", clc.downloadSize );
+ clc.downloadCount = (int)dlnow;
+ Cvar_SetValue( "cl_downloadCount", clc.downloadCount );
+ return 0;
+}
+
+static int CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb,
+ void *stream)
+{
+ FS_Write( buffer, size*nmemb, ((fileHandle_t*)stream)[0] );
+ return size*nmemb;
+}
+
+void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
+{
+ clc.cURLUsed = qtrue;
+ Com_Printf("URL: %s\n", remoteURL);
+ Com_DPrintf("***** CL_cURL_BeginDownload *****\n"
+ "Localname: %s\n"
+ "RemoteURL: %s\n"
+ "****************************\n", localName, remoteURL);
+ CL_cURL_Cleanup();
+ Q_strncpyz(clc.downloadURL, remoteURL, sizeof(clc.downloadURL));
+ Q_strncpyz(clc.downloadName, localName, sizeof(clc.downloadName));
+ Com_sprintf(clc.downloadTempName, sizeof(clc.downloadTempName),
+ "%s.tmp", localName);
+
+ // Set so UI gets access to it
+ Cvar_Set("cl_downloadName", localName);
+ Cvar_Set("cl_downloadSize", "0");
+ Cvar_Set("cl_downloadCount", "0");
+ Cvar_SetValue("cl_downloadTime", cls.realtime);
+
+ clc.downloadBlock = 0; // Starting new file
+ clc.downloadCount = 0;
+
+ clc.downloadCURL = qcurl_easy_init();
+ if(!clc.downloadCURL) {
+ Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() "
+ "failed\n");
+ return;
+ }
+ clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName);
+ if(!clc.download) {
+ Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open "
+ "%s for writing\n", clc.downloadTempName);
+ return;
+ }
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, clc.download);
+ if(com_developer->integer)
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_VERBOSE, 1);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_URL, clc.downloadURL);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s",
+ NET_AdrToString(clc.serverAddress)));
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s",
+ Q3_VERSION, qcurl_version()));
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEFUNCTION,
+ CL_cURL_CallbackWrite);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_NOPROGRESS, 0);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSFUNCTION,
+ CL_cURL_CallbackProgress);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FAILONERROR, 1);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1);
+ qcurl_easy_setopt(clc.downloadCURL, CURLOPT_MAXREDIRS, 5);
+ clc.downloadCURLM = qcurl_multi_init();
+ if(!clc.downloadCURLM) {
+ qcurl_easy_cleanup(clc.downloadCURL);
+ clc.downloadCURL = NULL;
+ Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() "
+ "failed\n");
+ return;
+ }
+ qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL);
+
+ if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) &&
+ !clc.cURLDisconnected) {
+
+ CL_AddReliableCommand("disconnect");
+ CL_WritePacket();
+ CL_WritePacket();
+ CL_WritePacket();
+ clc.cURLDisconnected = qtrue;
+ }
+}
+
+void CL_cURL_PerformDownload(void)
+{
+ CURLMcode res;
+ CURLMsg *msg;
+ int c;
+ int i = 0;
+
+ res = qcurl_multi_perform(clc.downloadCURLM, &c);
+ while(res == CURLM_CALL_MULTI_PERFORM && i < 100) {
+ res = qcurl_multi_perform(clc.downloadCURLM, &c);
+ i++;
+ }
+ if(res == CURLM_CALL_MULTI_PERFORM)
+ return;
+ msg = qcurl_multi_info_read(clc.downloadCURLM, &c);
+ if(msg == NULL) {
+ return;
+ }
+ FS_FCloseFile(clc.download);
+ if(msg->msg == CURLMSG_DONE && msg->data.result == CURLE_OK) {
+ FS_SV_Rename(clc.downloadTempName, clc.downloadName);
+ clc.downloadRestart = qtrue;
+ }
+ else {
+ long code;
+
+ qcurl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE,
+ &code);
+ Com_Error(ERR_DROP, "Download Error: %s Code: %ld URL: %s",
+ qcurl_easy_strerror(msg->data.result),
+ code, clc.downloadURL);
+ }
+ *clc.downloadTempName = *clc.downloadName = 0;
+ Cvar_Set( "cl_downloadName", "" );
+ CL_NextDownload();
+}
+#endif /* USE_CURL */
Copied: branches/1.34/code/client/cl_curl.h (from rev 898, trunk/code/client/cl_curl.h)
===================================================================
--- branches/1.34/code/client/cl_curl.h (rev 0)
+++ branches/1.34/code/client/cl_curl.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,101 @@
+/*
+===========================================================================
+Copyright (C) 2006 Tony J. White (tjw at tjw.org)
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code 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.
+
+Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+
+#ifndef __QCURL_H__
+#define __QCURL_H__
+
+extern cvar_t *cl_cURLLib;
+
+#include "../qcommon/q_shared.h"
+#include "../qcommon/qcommon.h"
+
+#ifdef WIN32
+#define DEFAULT_CURL_LIB "libcurl-3.dll"
+#elif defined(MACOS_X)
+#define DEFAULT_CURL_LIB "libcurl.dylib"
+#else
+#define DEFAULT_CURL_LIB "libcurl.so.3"
+#endif
+
+#if USE_LOCAL_HEADERS
+ #include "../libcurl/curl/curl.h"
+#else
+ #include <curl/curl.h>
+#endif
+
+
+#if USE_CURL_DLOPEN
+extern char* (*qcurl_version)(void);
+
+extern CURL* (*qcurl_easy_init)(void);
+extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
+extern CURLcode (*qcurl_easy_perform)(CURL *curl);
+extern void (*qcurl_easy_cleanup)(CURL *curl);
+extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
+extern void (*qcurl_easy_reset)(CURL *curl);
+extern const char *(*qcurl_easy_strerror)(CURLcode);
+
+extern CURLM* (*qcurl_multi_init)(void);
+extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
+ CURL *curl_handle);
+extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
+ CURL *curl_handle);
+extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
+ fd_set *read_fd_set,
+ fd_set *write_fd_set,
+ fd_set *exc_fd_set,
+ int *max_fd);
+extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
+ int *running_handles);
+extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
+extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
+ int *msgs_in_queue);
+extern const char *(*qcurl_multi_strerror)(CURLMcode);
+#else
+#define qcurl_version curl_version
+
+#define qcurl_easy_init curl_easy_init
+#define qcurl_easy_setopt curl_easy_setopt
+#define qcurl_easy_perform curl_easy_perform
+#define qcurl_easy_cleanup curl_easy_cleanup
+#define qcurl_easy_getinfo curl_easy_getinfo
+#define qcurl_easy_duphandle curl_easy_duphandle
+#define qcurl_easy_reset curl_easy_reset
+#define qcurl_easy_strerror curl_easy_strerror
+
+#define qcurl_multi_init curl_multi_init
+#define qcurl_multi_add_handle curl_multi_add_handle
+#define qcurl_multi_remove_handle curl_multi_remove_handle
+#define qcurl_multi_fdset curl_multi_fdset
+#define qcurl_multi_perform curl_multi_perform
+#define qcurl_multi_cleanup curl_multi_cleanup
+#define qcurl_multi_info_read curl_multi_info_read
+#define qcurl_multi_strerror curl_multi_strerror
+#endif
+
+qboolean CL_cURL_Init( void );
+void CL_cURL_Shutdown( void );
+void CL_cURL_BeginDownload( const char *localName, const char *remoteURL );
+void CL_cURL_PerformDownload( void );
+void CL_cURL_Cleanup( void );
+#endif // __QCURL_H__
Modified: branches/1.34/code/client/cl_keys.c
===================================================================
--- branches/1.34/code/client/cl_keys.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/cl_keys.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -86,6 +86,9 @@
{"F10", K_F10},
{"F11", K_F11},
{"F12", K_F12},
+ {"F13", K_F13},
+ {"F14", K_F14},
+ {"F15", K_F15},
{"INS", K_INS},
{"DEL", K_DEL},
@@ -176,6 +179,116 @@
{"SEMICOLON", ';'}, // because a raw semicolon seperates commands
+ {"WORLD_0", K_WORLD_0},
+ {"WORLD_1", K_WORLD_1},
+ {"WORLD_2", K_WORLD_2},
+ {"WORLD_3", K_WORLD_3},
+ {"WORLD_4", K_WORLD_4},
+ {"WORLD_5", K_WORLD_5},
+ {"WORLD_6", K_WORLD_6},
+ {"WORLD_7", K_WORLD_7},
+ {"WORLD_8", K_WORLD_8},
+ {"WORLD_9", K_WORLD_9},
+ {"WORLD_10", K_WORLD_10},
+ {"WORLD_11", K_WORLD_11},
+ {"WORLD_12", K_WORLD_12},
+ {"WORLD_13", K_WORLD_13},
+ {"WORLD_14", K_WORLD_14},
+ {"WORLD_15", K_WORLD_15},
+ {"WORLD_16", K_WORLD_16},
+ {"WORLD_17", K_WORLD_17},
+ {"WORLD_18", K_WORLD_18},
+ {"WORLD_19", K_WORLD_19},
+ {"WORLD_20", K_WORLD_20},
+ {"WORLD_21", K_WORLD_21},
+ {"WORLD_22", K_WORLD_22},
+ {"WORLD_23", K_WORLD_23},
+ {"WORLD_24", K_WORLD_24},
+ {"WORLD_25", K_WORLD_25},
+ {"WORLD_26", K_WORLD_26},
+ {"WORLD_27", K_WORLD_27},
+ {"WORLD_28", K_WORLD_28},
+ {"WORLD_29", K_WORLD_29},
+ {"WORLD_30", K_WORLD_30},
+ {"WORLD_31", K_WORLD_31},
+ {"WORLD_32", K_WORLD_32},
+ {"WORLD_33", K_WORLD_33},
+ {"WORLD_34", K_WORLD_34},
+ {"WORLD_35", K_WORLD_35},
+ {"WORLD_36", K_WORLD_36},
+ {"WORLD_37", K_WORLD_37},
+ {"WORLD_38", K_WORLD_38},
+ {"WORLD_39", K_WORLD_39},
+ {"WORLD_40", K_WORLD_40},
+ {"WORLD_41", K_WORLD_41},
+ {"WORLD_42", K_WORLD_42},
+ {"WORLD_43", K_WORLD_43},
+ {"WORLD_44", K_WORLD_44},
+ {"WORLD_45", K_WORLD_45},
+ {"WORLD_46", K_WORLD_46},
+ {"WORLD_47", K_WORLD_47},
+ {"WORLD_48", K_WORLD_48},
+ {"WORLD_49", K_WORLD_49},
+ {"WORLD_50", K_WORLD_50},
+ {"WORLD_51", K_WORLD_51},
+ {"WORLD_52", K_WORLD_52},
+ {"WORLD_53", K_WORLD_53},
+ {"WORLD_54", K_WORLD_54},
+ {"WORLD_55", K_WORLD_55},
+ {"WORLD_56", K_WORLD_56},
+ {"WORLD_57", K_WORLD_57},
+ {"WORLD_58", K_WORLD_58},
+ {"WORLD_59", K_WORLD_59},
+ {"WORLD_60", K_WORLD_60},
+ {"WORLD_61", K_WORLD_61},
+ {"WORLD_62", K_WORLD_62},
+ {"WORLD_63", K_WORLD_63},
+ {"WORLD_64", K_WORLD_64},
+ {"WORLD_65", K_WORLD_65},
+ {"WORLD_66", K_WORLD_66},
+ {"WORLD_67", K_WORLD_67},
+ {"WORLD_68", K_WORLD_68},
+ {"WORLD_69", K_WORLD_69},
+ {"WORLD_70", K_WORLD_70},
+ {"WORLD_71", K_WORLD_71},
+ {"WORLD_72", K_WORLD_72},
+ {"WORLD_73", K_WORLD_73},
+ {"WORLD_74", K_WORLD_74},
+ {"WORLD_75", K_WORLD_75},
+ {"WORLD_76", K_WORLD_76},
+ {"WORLD_77", K_WORLD_77},
+ {"WORLD_78", K_WORLD_78},
+ {"WORLD_79", K_WORLD_79},
+ {"WORLD_80", K_WORLD_80},
+ {"WORLD_81", K_WORLD_81},
+ {"WORLD_82", K_WORLD_82},
+ {"WORLD_83", K_WORLD_83},
+ {"WORLD_84", K_WORLD_84},
+ {"WORLD_85", K_WORLD_85},
+ {"WORLD_86", K_WORLD_86},
+ {"WORLD_87", K_WORLD_87},
+ {"WORLD_88", K_WORLD_88},
+ {"WORLD_89", K_WORLD_89},
+ {"WORLD_90", K_WORLD_90},
+ {"WORLD_91", K_WORLD_91},
+ {"WORLD_92", K_WORLD_92},
+ {"WORLD_93", K_WORLD_93},
+ {"WORLD_94", K_WORLD_94},
+ {"WORLD_95", K_WORLD_95},
+
+ {"WINDOWS", K_SUPER},
+ {"COMPOSE", K_COMPOSE},
+ {"MODE", K_MODE},
+ {"HELP", K_HELP},
+ {"PRINT", K_PRINT},
+ {"SYSREQ", K_SYSREQ},
+ {"SCROLLOCK", K_SCROLLOCK },
+ {"BREAK", K_BREAK},
+ {"MENU", K_MENU},
+ {"POWER", K_POWER},
+ {"EURO", K_EURO},
+ {"UNDO", K_UNDO},
+
{NULL,0}
};
@@ -669,7 +782,7 @@
===================
*/
qboolean Key_IsDown( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return qfalse;
}
@@ -751,7 +864,7 @@
return "<KEY NOT FOUND>";
}
- if ( keynum < 0 || keynum > 255 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return "<OUT OF RANGE>";
}
@@ -789,7 +902,7 @@
===================
*/
void Key_SetBinding( int keynum, const char *binding ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return;
}
@@ -813,7 +926,7 @@
===================
*/
char *Key_GetBinding( int keynum ) {
- if ( keynum == -1 ) {
+ if ( keynum < 0 || keynum >= MAX_KEYS ) {
return "";
}
@@ -830,7 +943,7 @@
int i;
if (binding) {
- for (i=0 ; i<256 ; i++) {
+ for (i=0 ; i < MAX_KEYS ; i++) {
if (keys[i].binding && Q_stricmp(binding, keys[i].binding) == 0) {
return i;
}
@@ -873,7 +986,7 @@
{
int i;
- for (i=0 ; i<256 ; i++)
+ for (i=0 ; i < MAX_KEYS; i++)
if (keys[i].binding)
Key_SetBinding (i, "");
}
@@ -936,7 +1049,7 @@
FS_Printf (f, "unbindall\n" );
- for (i=0 ; i<256 ; i++) {
+ for (i=0 ; i<MAX_KEYS ; i++) {
if (keys[i].binding && keys[i].binding[0] ) {
FS_Printf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keys[i].binding);
@@ -955,7 +1068,7 @@
void Key_Bindlist_f( void ) {
int i;
- for ( i = 0 ; i < 256 ; i++ ) {
+ for ( i = 0 ; i < MAX_KEYS ; i++ ) {
if ( keys[i].binding && keys[i].binding[0] ) {
Com_Printf( "%s \"%s\"\n", Key_KeynumToString(i), keys[i].binding );
}
@@ -980,7 +1093,7 @@
CL_AddKeyUpCommands
===================
*/
-void CL_AddKeyUpCommands( int key, char *kb ) {
+void CL_AddKeyUpCommands( int key, char *kb, unsigned time) {
int i;
char button[1024], *buttonPtr;
char cmd[1024];
@@ -1066,7 +1179,8 @@
#endif
// console key is hardcoded, so the user can never unbind it
- if (key == '`' || key == '~') {
+ if (key == '`' || key == '~' ||
+ ( key == K_ESCAPE && keys[K_SHIFT].down ) ) {
if (!down) {
return;
}
@@ -1126,7 +1240,7 @@
if (!down) {
kb = keys[key].binding;
- CL_AddKeyUpCommands( key, kb );
+ CL_AddKeyUpCommands( key, kb, time );
if ( cls.keyCatchers & KEYCATCH_UI && uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, down );
@@ -1258,8 +1372,10 @@
}
// This must not exceed MAX_CMD_LINE
-#define MAX_CONSOLE_SAVE_BUFFER 1024
-static char consoleSaveBuffer[ MAX_CONSOLE_SAVE_BUFFER ];
+#define MAX_CONSOLE_SAVE_BUFFER 1024
+#define CONSOLE_HISTORY_FILE "q3history"
+static char consoleSaveBuffer[ MAX_CONSOLE_SAVE_BUFFER ];
+static int consoleSaveBufferSize = 0;
/*
================
@@ -1270,51 +1386,63 @@
*/
void CL_LoadConsoleHistory( void )
{
- char *token, *text_p;
- int i, numChars, numLines = 0;
- cvar_t *cv;
+ char *token, *text_p;
+ int i, numChars, numLines = 0;
+ fileHandle_t f;
- cv = Cvar_Get( "cl_consoleHistory", "", CVAR_ARCHIVE|CVAR_ROM );
- Q_strncpyz( consoleSaveBuffer, cv->string, MAX_CONSOLE_SAVE_BUFFER );
+ consoleSaveBufferSize = FS_FOpenFileRead( CONSOLE_HISTORY_FILE, &f, qfalse );
+ if( !f )
+ {
+ Com_Printf( "Couldn't read %s.\n", CONSOLE_HISTORY_FILE );
+ return;
+ }
- text_p = consoleSaveBuffer;
-
- for( i = COMMAND_HISTORY - 1; i >= 0; i-- )
+ if( consoleSaveBufferSize <= MAX_CONSOLE_SAVE_BUFFER &&
+ FS_Read( consoleSaveBuffer, consoleSaveBufferSize, f ) == consoleSaveBufferSize )
{
- if( !*( token = COM_Parse( &text_p ) ) )
- break;
+ text_p = consoleSaveBuffer;
- historyEditLines[ i ].cursor = atoi( token );
+ for( i = COMMAND_HISTORY - 1; i >= 0; i-- )
+ {
+ if( !*( token = COM_Parse( &text_p ) ) )
+ break;
- if( !*( token = COM_Parse( &text_p ) ) )
- break;
+ historyEditLines[ i ].cursor = atoi( token );
- historyEditLines[ i ].scroll = atoi( token );
+ if( !*( token = COM_Parse( &text_p ) ) )
+ break;
- if( !*( token = COM_Parse( &text_p ) ) )
- break;
+ historyEditLines[ i ].scroll = atoi( token );
- numChars = atoi( token );
- text_p++;
- if( numChars > ( strlen( consoleSaveBuffer ) - ( text_p - consoleSaveBuffer ) ) )
- {
- Com_DPrintf( S_COLOR_YELLOW "WARNING: probable corrupt history\n" );
- break;
+ if( !*( token = COM_Parse( &text_p ) ) )
+ break;
+
+ numChars = atoi( token );
+ text_p++;
+ if( numChars > ( strlen( consoleSaveBuffer ) - ( text_p - consoleSaveBuffer ) ) )
+ {
+ Com_DPrintf( S_COLOR_YELLOW "WARNING: probable corrupt history\n" );
+ break;
+ }
+ Com_Memcpy( historyEditLines[ i ].buffer,
+ text_p, numChars );
+ historyEditLines[ i ].buffer[ numChars ] = '\0';
+ text_p += numChars;
+
+ numLines++;
}
- Com_Memcpy( historyEditLines[ i ].buffer,
- text_p, numChars );
- historyEditLines[ i ].buffer[ numChars ] = '\0';
- text_p += numChars;
- numLines++;
+ memmove( &historyEditLines[ 0 ], &historyEditLines[ i + 1 ],
+ numLines * sizeof( field_t ) );
+ for( i = numLines; i < COMMAND_HISTORY; i++ )
+ Field_Clear( &historyEditLines[ i ] );
+
+ historyLine = nextHistoryLine = numLines;
}
+ else
+ Com_Printf( "Couldn't read %s.\n", CONSOLE_HISTORY_FILE );
- memmove( &historyEditLines[ 0 ], &historyEditLines[ i + 1 ],
- numLines * sizeof( field_t ) );
- for( i = numLines; i < COMMAND_HISTORY; i++ )
- Field_Clear( &historyEditLines[ i ] );
-
- historyLine = nextHistoryLine = numLines;
+ FS_FCloseFile( f );
}
/*
@@ -1327,8 +1455,9 @@
*/
void CL_SaveConsoleHistory( void )
{
- int i;
- int lineLength, saveBufferLength, additionalLength;
+ int i;
+ int lineLength, saveBufferLength, additionalLength;
+ fileHandle_t f;
consoleSaveBuffer[ 0 ] = '\0';
@@ -1340,8 +1469,8 @@
lineLength = strlen( historyEditLines[ i ].buffer );
saveBufferLength = strlen( consoleSaveBuffer );
- //ICK "seta cl_consoleHistory " + "%d %d %d " = 23 + 13 = 36
- additionalLength = lineLength + 36;
+ //ICK
+ additionalLength = lineLength + strlen( "999 999 999 " );
if( saveBufferLength + additionalLength < MAX_CONSOLE_SAVE_BUFFER )
{
@@ -1359,5 +1488,17 @@
}
while( i != ( nextHistoryLine - 1 ) % COMMAND_HISTORY );
- Cvar_Set( "cl_consoleHistory", consoleSaveBuffer );
+ consoleSaveBufferSize = strlen( consoleSaveBuffer );
+
+ f = FS_FOpenFileWrite( CONSOLE_HISTORY_FILE );
+ if( !f )
+ {
+ Com_Printf( "Couldn't write %s.\n", CONSOLE_HISTORY_FILE );
+ return;
+ }
+
+ if( FS_Write( consoleSaveBuffer, consoleSaveBufferSize, f ) < consoleSaveBufferSize )
+ Com_Printf( "Couldn't write %s.\n", CONSOLE_HISTORY_FILE );
+
+ FS_FCloseFile( f );
}
Modified: branches/1.34/code/client/cl_main.c
===================================================================
--- branches/1.34/code/client/cl_main.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/cl_main.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -74,6 +74,8 @@
cvar_t *cl_lanForcePackets;
+cvar_t *cl_guidServerUniq;
+
clientActive_t cl;
clientConnection_t clc;
clientStatic_t cls;
@@ -506,7 +508,8 @@
}
// make sure a local server is killed
- Cvar_Set( "sv_killserver", "1" );
+ // 2 means don't force disconnect of local client
+ Cvar_Set( "sv_killserver", "2" );
CL_Disconnect( qtrue );
@@ -608,6 +611,9 @@
*/
void CL_ShutdownAll(void) {
+#if USE_CURL
+ CL_cURL_Shutdown();
+#endif
// clear sounds
S_DisableSounds();
// shutdown CGame
@@ -710,7 +716,29 @@
Com_Memset( &cl, 0, sizeof( cl ) );
}
+/*
+====================
+CL_UpdateGUID
+update cl_guid using QKEY_FILE and optional prefix
+====================
+*/
+static void CL_UpdateGUID( char *prefix, int prefix_len )
+{
+ fileHandle_t f;
+ int len;
+
+ len = FS_SV_FOpenFileRead( QKEY_FILE, &f );
+ FS_FCloseFile( f );
+
+ if( len != QKEY_SIZE )
+ Cvar_Set( "cl_guid", "" );
+ else
+ Cvar_Set( "cl_guid", Com_MD5File( QKEY_FILE, QKEY_SIZE,
+ prefix, prefix_len ) );
+}
+
+
/*
=====================
CL_Disconnect
@@ -778,6 +806,7 @@
if( CL_VideoRecording( ) ) {
CL_CloseAVI( );
}
+ CL_UpdateGUID( NULL, 0 );
}
@@ -990,7 +1019,7 @@
if ( env ) {
Com_Printf( "%s=%s\n", Cmd_Argv(1), env );
} else {
- Com_Printf( "%s undefined\n", Cmd_Argv(1), env );
+ Com_Printf( "%s undefined\n", Cmd_Argv(1));
}
}
}
@@ -1033,6 +1062,7 @@
*/
void CL_Connect_f( void ) {
char *server;
+ char serverString[ 22 ];
if ( Cmd_Argc() != 2 ) {
Com_Printf( "usage: connect [server]\n");
@@ -1075,11 +1105,18 @@
if (clc.serverAddress.port == 0) {
clc.serverAddress.port = BigShort( PORT_SERVER );
}
- Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", cls.servername,
- clc.serverAddress.ip[0], clc.serverAddress.ip[1],
- clc.serverAddress.ip[2], clc.serverAddress.ip[3],
- BigShort( clc.serverAddress.port ) );
+ Com_sprintf( serverString, sizeof( serverString ), "%i.%i.%i.%i:%i",
+ clc.serverAddress.ip[0], clc.serverAddress.ip[1],
+ clc.serverAddress.ip[2], clc.serverAddress.ip[3],
+ BigShort( clc.serverAddress.port ) );
+
+ Com_Printf( "%s resolved to %s\n", cls.servername, serverString );
+ if( cl_guidServerUniq->integer )
+ CL_UpdateGUID( serverString, strlen( serverString ) );
+ else
+ CL_UpdateGUID( NULL, 0 );
+
// if we aren't playing on a lan, we need to authenticate
// with the cd key
if ( NET_IsLocalAddress( clc.serverAddress ) ) {
@@ -1334,6 +1371,23 @@
*/
void CL_DownloadsComplete( void ) {
+#if USE_CURL
+ // if we downloaded with cURL
+ if(clc.cURLUsed) {
+ clc.cURLUsed = qfalse;
+ CL_cURL_Shutdown();
+ if( clc.cURLDisconnected ) {
+ if(clc.downloadRestart) {
+ FS_Restart(clc.checksumFeed);
+ clc.downloadRestart = qfalse;
+ }
+ clc.cURLDisconnected = qfalse;
+ CL_Reconnect_f();
+ return;
+ }
+ }
+#endif
+
// if we downloaded files we need to restart the file system
if (clc.downloadRestart) {
clc.downloadRestart = qfalse;
@@ -1421,6 +1475,7 @@
void CL_NextDownload(void) {
char *s;
char *remoteName, *localName;
+ qboolean useCURL = qfalse;
// We are looking to start a download here
if (*clc.downloadList) {
@@ -1444,9 +1499,48 @@
*s++ = 0;
else
s = localName + strlen(localName); // point at the nul byte
-
- CL_BeginDownload( localName, remoteName );
-
+#if USE_CURL
+ if(!(cl_allowDownload->integer & DLF_NO_REDIRECT)) {
+ if(clc.sv_allowDownload & DLF_NO_REDIRECT) {
+ Com_Printf("WARNING: server does not "
+ "allow download redirection "
+ "(sv_allowDownload is %d)\n",
+ clc.sv_allowDownload);
+ }
+ else if(!*clc.sv_dlURL) {
+ Com_Printf("WARNING: server allows "
+ "download redirection, but does not "
+ "have sv_dlURL set\n");
+ }
+ else if(!CL_cURL_Init()) {
+ Com_Printf("WARNING: could not load "
+ "cURL library\n");
+ }
+ else {
+ CL_cURL_BeginDownload(localName, va("%s/%s",
+ clc.sv_dlURL, remoteName));
+ useCURL = qtrue;
+ }
+ }
+ else if(!(clc.sv_allowDownload & DLF_NO_REDIRECT)) {
+ Com_Printf("WARNING: server allows download "
+ "redirection, but it disabled by client "
+ "configuration (cl_allowDownload is %d)\n",
+ cl_allowDownload->integer);
+ }
+#endif /* USE_CURL */
+ if(!useCURL) {
+ if((cl_allowDownload->integer & DLF_NO_UDP)) {
+ Com_Error(ERR_DROP, "UDP Downloads are "
+ "disabled on your client. "
+ "(cl_allowDownload is %d)",
+ cl_allowDownload->integer);
+ return;
+ }
+ else {
+ CL_BeginDownload( localName, remoteName );
+ }
+ }
clc.downloadRestart = qtrue;
// move over the rest
@@ -1469,7 +1563,7 @@
void CL_InitDownloads(void) {
char missingfiles[1024];
- if ( !cl_allowDownload->integer )
+ if ( !(cl_allowDownload->integer & DLF_ENABLE) )
{
// autodownload is disabled on the client
// but it's possible that some referenced files on the server are missing
@@ -2031,6 +2125,25 @@
return;
}
+#if USE_CURL
+ if(clc.downloadCURLM) {
+ CL_cURL_PerformDownload();
+ // we can't process frames normally when in disconnected
+ // download mode since the ui vm expects cls.state to be
+ // CA_CONNECTED
+ if(clc.cURLDisconnected) {
+ cls.realFrametime = msec;
+ cls.frametime = msec;
+ cls.realtime += cls.frametime;
+ SCR_UpdateScreen();
+ S_Update();
+ Con_RunConsole();
+ cls.framecount++;
+ return;
+ }
+ }
+#endif
+
if ( cls.cddialog ) {
// bring up the cd error dialog if needed
cls.cddialog = qfalse;
@@ -2401,25 +2514,44 @@
CL_CloseAVI( );
}
+/*
+===============
+CL_GenerateQKey
+
+test to see if a valid QKEY_FILE exists. If one does not, try to generate
+it by filling it with 2048 bytes of random data.
+===============
+*/
static void CL_GenerateQKey(void)
{
int len = 0;
- unsigned char buff[2048];
+ unsigned char buff[ QKEY_SIZE ];
+ fileHandle_t f;
- len = FS_ReadFile(QKEY_FILE, NULL);
- if(len >= (int)sizeof(buff)) {
- Com_Printf("QKEY found.\n");
+ len = FS_SV_FOpenFileRead( QKEY_FILE, &f );
+ FS_FCloseFile( f );
+ if( len == QKEY_SIZE ) {
+ Com_Printf( "QKEY found.\n" );
return;
}
else {
- int i;
- srand(time(0));
- for(i = 0; i < sizeof(buff) - 1; i++) {
- buff[i] = (unsigned char)(rand() % 255);
+ if( len > 0 ) {
+ Com_Printf( "QKEY file size != %d, regenerating\n",
+ QKEY_SIZE );
}
- buff[i] = 0;
- Com_Printf("QKEY generated\n");
- FS_WriteFile(QKEY_FILE, buff, sizeof(buff));
+
+ Com_Printf( "QKEY building random string\n" );
+ Com_RandomBytes( buff, sizeof(buff) );
+
+ f = FS_SV_FOpenFileWrite( QKEY_FILE );
+ if( !f ) {
+ Com_Printf( "QKEY could not open %s for write\n",
+ QKEY_FILE );
+ return;
+ }
+ FS_Write( buff, sizeof(buff), f );
+ FS_FCloseFile( f );
+ Com_Printf( "QKEY generated\n" );
}
}
@@ -2481,6 +2613,9 @@
cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE);
+#if USE_CURL
+ cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE);
+#endif
cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0);
#ifdef MACOS_X
@@ -2513,6 +2648,8 @@
cl_lanForcePackets = Cvar_Get ("cl_lanForcePackets", "1", CVAR_ARCHIVE);
+ cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE);
+
// userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "3000", CVAR_USERINFO | CVAR_ARCHIVE );
@@ -2573,7 +2710,8 @@
Cvar_Set( "cl_running", "1" );
CL_GenerateQKey();
- Cvar_Get("cl_guid", Com_MD5File(QKEY_FILE, 0), CVAR_USERINFO | CVAR_ROM);
+ Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM );
+ CL_UpdateGUID( NULL, 0 );
Com_Printf( "----- Client Initialization Complete -----\n" );
}
Modified: branches/1.34/code/client/cl_parse.c
===================================================================
--- branches/1.34/code/client/cl_parse.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/cl_parse.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -325,6 +325,7 @@
//=====================================================================
int cl_connectedToPureServer;
+int cl_connectedToCheatServer;
/*
==================
@@ -355,7 +356,8 @@
}
s = Info_ValueForKey( systemInfo, "sv_cheats" );
- if ( atoi(s) == 0 ) {
+ cl_connectedToCheatServer = atoi( s );
+ if ( !cl_connectedToCheatServer ) {
Cvar_SetCheatState();
}
@@ -414,6 +416,25 @@
/*
==================
+CL_ParseServerInfo
+==================
+*/
+static void CL_ParseServerInfo(void)
+{
+ const char *serverInfo;
+
+ serverInfo = cl.gameState.stringData
+ + cl.gameState.stringOffsets[ CS_SERVERINFO ];
+
+ clc.sv_allowDownload = atoi(Info_ValueForKey(serverInfo,
+ "sv_allowDownload"));
+ Q_strncpyz(clc.sv_dlURL,
+ Info_ValueForKey(serverInfo, "sv_dlURL"),
+ sizeof(clc.sv_dlURL));
+}
+
+/*
+==================
CL_ParseGamestate
==================
*/
@@ -479,6 +500,9 @@
// read the checksum feed
clc.checksumFeed = MSG_ReadLong( msg );
+ // parse useful values out of CS_SERVERINFO
+ CL_ParseServerInfo();
+
// parse serverId and other cvars
CL_SystemInfoChanged();
Modified: branches/1.34/code/client/cl_ui.c
===================================================================
--- branches/1.34/code/client/cl_ui.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/cl_ui.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -767,11 +767,11 @@
intptr_t CL_UISystemCalls( intptr_t *args ) {
switch( args[0] ) {
case UI_ERROR:
- Com_Error( ERR_DROP, "%s", VMA(1) );
+ Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
return 0;
case UI_PRINT:
- Com_Printf( "%s", VMA(1) );
+ Com_Printf( "%s", (const char*)VMA(1) );
return 0;
case UI_MILLISECONDS:
@@ -1109,7 +1109,7 @@
default:
- Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] );
+ Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );
}
@@ -1171,6 +1171,10 @@
// init for this gamestate
VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) );
}
+
+ // reset any CVAR_CHEAT cvars registered by ui
+ if ( !clc.demoplaying && !cl_connectedToCheatServer )
+ Cvar_SetCheatState();
}
qboolean UI_usesUniqueCDKey( void ) {
Modified: branches/1.34/code/client/client.h
===================================================================
--- branches/1.34/code/client/client.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/client.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -30,8 +30,13 @@
#include "../cgame/cg_public.h"
#include "../game/bg_public.h"
-// tjw: file full of random crap that gets used to create cl_guid
+#if USE_CURL
+#include "cl_curl.h"
+#endif /* USE_CURL */
+
+// file full of random crap that gets used to create cl_guid
#define QKEY_FILE "qkey"
+#define QKEY_SIZE 2048
#define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits
@@ -185,6 +190,16 @@
fileHandle_t download;
char downloadTempName[MAX_OSPATH];
char downloadName[MAX_OSPATH];
+#ifdef USE_CURL
+ qboolean cURLEnabled;
+ qboolean cURLUsed;
+ qboolean cURLDisconnected;
+ char downloadURL[MAX_OSPATH];
+ CURL *downloadCURL;
+ CURLM *downloadCURLM;
+#endif /* USE_CURL */
+ int sv_allowDownload;
+ char sv_dlURL[MAX_CVAR_VALUE_STRING];
int downloadNumber;
int downloadBlock; // block we are waiting for
int downloadCount; // how many bytes we got
@@ -351,6 +366,7 @@
extern cvar_t *cl_activeAction;
extern cvar_t *cl_allowDownload;
+extern cvar_t *cl_downloadMethod;
extern cvar_t *cl_conXOffset;
extern cvar_t *cl_inGameVideo;
@@ -426,6 +442,7 @@
// cl_parse.c
//
extern int cl_connectedToPureServer;
+extern int cl_connectedToCheatServer;
void CL_SystemInfoChanged( void );
void CL_ParseServerMessage( msg_t *msg );
Modified: branches/1.34/code/client/keycodes.h
===================================================================
--- branches/1.34/code/client/keycodes.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/keycodes.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -151,9 +151,122 @@
K_AUX15,
K_AUX16,
- K_LAST_KEY // this had better be <256!
+ K_WORLD_0,
+ K_WORLD_1,
+ K_WORLD_2,
+ K_WORLD_3,
+ K_WORLD_4,
+ K_WORLD_5,
+ K_WORLD_6,
+ K_WORLD_7,
+ K_WORLD_8,
+ K_WORLD_9,
+ K_WORLD_10,
+ K_WORLD_11,
+ K_WORLD_12,
+ K_WORLD_13,
+ K_WORLD_14,
+ K_WORLD_15,
+ K_WORLD_16,
+ K_WORLD_17,
+ K_WORLD_18,
+ K_WORLD_19,
+ K_WORLD_20,
+ K_WORLD_21,
+ K_WORLD_22,
+ K_WORLD_23,
+ K_WORLD_24,
+ K_WORLD_25,
+ K_WORLD_26,
+ K_WORLD_27,
+ K_WORLD_28,
+ K_WORLD_29,
+ K_WORLD_30,
+ K_WORLD_31,
+ K_WORLD_32,
+ K_WORLD_33,
+ K_WORLD_34,
+ K_WORLD_35,
+ K_WORLD_36,
+ K_WORLD_37,
+ K_WORLD_38,
+ K_WORLD_39,
+ K_WORLD_40,
+ K_WORLD_41,
+ K_WORLD_42,
+ K_WORLD_43,
+ K_WORLD_44,
+ K_WORLD_45,
+ K_WORLD_46,
+ K_WORLD_47,
+ K_WORLD_48,
+ K_WORLD_49,
+ K_WORLD_50,
+ K_WORLD_51,
+ K_WORLD_52,
+ K_WORLD_53,
+ K_WORLD_54,
+ K_WORLD_55,
+ K_WORLD_56,
+ K_WORLD_57,
+ K_WORLD_58,
+ K_WORLD_59,
+ K_WORLD_60,
+ K_WORLD_61,
+ K_WORLD_62,
+ K_WORLD_63,
+ K_WORLD_64,
+ K_WORLD_65,
+ K_WORLD_66,
+ K_WORLD_67,
+ K_WORLD_68,
+ K_WORLD_69,
+ K_WORLD_70,
+ K_WORLD_71,
+ K_WORLD_72,
+ K_WORLD_73,
+ K_WORLD_74,
+ K_WORLD_75,
+ K_WORLD_76,
+ K_WORLD_77,
+ K_WORLD_78,
+ K_WORLD_79,
+ K_WORLD_80,
+ K_WORLD_81,
+ K_WORLD_82,
+ K_WORLD_83,
+ K_WORLD_84,
+ K_WORLD_85,
+ K_WORLD_86,
+ K_WORLD_87,
+ K_WORLD_88,
+ K_WORLD_89,
+ K_WORLD_90,
+ K_WORLD_91,
+ K_WORLD_92,
+ K_WORLD_93,
+ K_WORLD_94,
+ K_WORLD_95,
+
+ K_SUPER,
+ K_COMPOSE,
+ K_MODE,
+ K_HELP,
+ K_PRINT,
+ K_SYSREQ,
+ K_SCROLLOCK,
+ K_BREAK,
+ K_MENU,
+ K_EURO,
+ K_UNDO,
+
+ MAX_KEYS
} keyNum_t;
+// MAX_KEYS replaces K_LAST_KEY, however some mods may have used K_LAST_KEY
+// in detecting binds, so we leave it defined to the old hardcoded value
+// of maxiumum keys to prevent mods from crashing older versions of the engine
+#define K_LAST_KEY 256
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
Modified: branches/1.34/code/client/keys.h
===================================================================
--- branches/1.34/code/client/keys.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/keys.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -21,8 +21,6 @@
*/
#include "keycodes.h"
-#define MAX_KEYS 256
-
typedef struct {
qboolean down;
int repeats; // if > 1, it is autorepeating
Modified: branches/1.34/code/client/qal.c
===================================================================
--- branches/1.34/code/client/qal.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/qal.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -153,7 +153,7 @@
}
else
{
- Com_DPrintf( " Loaded symbol %s (0x%08X)\n", str, rv);
+ Com_DPrintf( " Loaded symbol %s (%p)\n", str, rv);
return rv;
}
}
Modified: branches/1.34/code/client/snd_dma.c
===================================================================
--- branches/1.34/code/client/snd_dma.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/snd_dma.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -109,7 +109,7 @@
Com_Printf("%5d samplebits\n", dma.samplebits);
Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
Com_Printf("%5d speed\n", dma.speed);
- Com_Printf("0x%x dma buffer\n", dma.buffer);
+ Com_Printf("%p dma buffer\n", dma.buffer);
if ( s_backgroundStream ) {
Com_Printf("Background file: %s\n", s_backgroundLoop );
} else {
@@ -466,7 +466,7 @@
}
if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Printf( S_COLOR_YELLOW, "S_StartSound: handle %i out of range\n", sfxHandle );
+ Com_Printf( S_COLOR_YELLOW "S_StartSound: handle %i out of range\n", sfxHandle );
return;
}
@@ -578,7 +578,7 @@
}
if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Printf( S_COLOR_YELLOW, "S_StartLocalSound: handle %i out of range\n", sfxHandle );
+ Com_Printf( S_COLOR_YELLOW "S_StartLocalSound: handle %i out of range\n", sfxHandle );
return;
}
@@ -687,7 +687,7 @@
}
if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Printf( S_COLOR_YELLOW, "S_AddLoopingSound: handle %i out of range\n", sfxHandle );
+ Com_Printf( S_COLOR_YELLOW "S_AddLoopingSound: handle %i out of range\n", sfxHandle );
return;
}
@@ -750,7 +750,7 @@
}
if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
- Com_Printf( S_COLOR_YELLOW, "S_AddRealLoopingSound: handle %i out of range\n", sfxHandle );
+ Com_Printf( S_COLOR_YELLOW "S_AddRealLoopingSound: handle %i out of range\n", sfxHandle );
return;
}
@@ -1115,7 +1115,7 @@
ch = s_channels;
for (i=0 ; i<MAX_CHANNELS; i++, ch++) {
if (ch->thesfx && (ch->leftvol || ch->rightvol) ) {
- Com_Printf ("%f %f %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName);
+ Com_Printf ("%d %d %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName);
total++;
}
}
Modified: branches/1.34/code/client/snd_openal.c
===================================================================
--- branches/1.34/code/client/snd_openal.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/client/snd_openal.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -42,7 +42,6 @@
cvar_t *s_alDriver;
cvar_t *s_alDevice;
cvar_t *s_alAvailableDevices;
-cvar_t *s_alMaxSpeakerDistance;
/*
=================
@@ -530,15 +529,13 @@
static void S_AL_ScaleGain(src_t *chksrc, vec3_t origin)
{
float distance;
-
- if(chksrc->local)
- distance = VectorLength(origin);
- else
+
+ if(!chksrc->local)
distance = Distance(origin, lastListenerOrigin);
-
+
// If we exceed a certain distance, scale the gain linearly until the sound
// vanishes into nothingness.
- if((distance -= s_alMaxDistance->value) > 0)
+ if(!chksrc->local && (distance -= s_alMaxDistance->value) > 0)
{
float scaleFactor;
@@ -896,7 +893,7 @@
if (sfx < 0 || sfx >= numSfx)
{
- Com_Printf(S_COLOR_RED, "ERROR: S_AL_CheckInput: handle %i out of range\n", sfx);
+ Com_Printf(S_COLOR_RED "ERROR: S_AL_CheckInput: handle %i out of range\n", sfx);
return qtrue;
}
@@ -913,11 +910,14 @@
static
void S_AL_StartLocalSound(sfxHandle_t sfx, int channel)
{
+ srcHandle_t src;
+
if(S_AL_CheckInput(0, sfx))
return;
// Try to grab a source
- srcHandle_t src = S_AL_SrcAlloc(SRCPRI_LOCAL, -1, channel);
+ src = S_AL_SrcAlloc(SRCPRI_LOCAL, -1, channel);
+
if(src == -1)
return;
@@ -939,12 +939,13 @@
void S_AL_StartSound( vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx )
{
vec3_t sorigin;
+ srcHandle_t src;
if(S_AL_CheckInput(origin ? 0 : entnum, sfx))
return;
// Try to grab a source
- srcHandle_t src = S_AL_SrcAlloc(SRCPRI_ONESHOT, entnum, entchannel);
+ src = S_AL_SrcAlloc(SRCPRI_ONESHOT, entnum, entchannel);
if(src == -1)
return;
@@ -1094,8 +1095,8 @@
// There are certain maps (*cough* Q3:TA mpterra*) that have large quantities
// of ET_SPEAKERS in the PVS at any given time. OpenAL can't cope with mixing
// large numbers of sounds, so this culls them by distance
- if( DistanceSquared( origin, lastListenerOrigin ) >
- s_alMaxSpeakerDistance->value * s_alMaxSpeakerDistance->value )
+ if( DistanceSquared( origin, lastListenerOrigin ) > (s_alMaxDistance->value + s_alGraceDistance->value) *
+ (s_alMaxDistance->value + s_alGraceDistance->value) )
return;
S_AL_SrcLoop(SRCPRI_AMBIENT, sfx, origin, velocity, entityNum);
@@ -1881,7 +1882,6 @@
s_alMaxDistance = Cvar_Get("s_alMaxDistance", "1024", CVAR_CHEAT);
s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT);
s_alGraceDistance = Cvar_Get("s_alGraceDistance", "512", CVAR_CHEAT);
- s_alMaxSpeakerDistance = Cvar_Get( "s_alMaxSpeakerDistance", "1024", CVAR_ARCHIVE );
s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE );
Modified: branches/1.34/code/game/ai_cmd.c
===================================================================
--- branches/1.34/code/game/ai_cmd.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/ai_cmd.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1308,7 +1308,7 @@
//get the team mate that will be the team leader
trap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));
strncpy(bs->teamleader, teammate, sizeof(bs->teamleader));
- bs->teamleader[sizeof(bs->teamleader)] = '\0';
+ bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
}
//chats for someone else
else {
Modified: branches/1.34/code/game/ai_dmq3.c
===================================================================
--- branches/1.34/code/game/ai_dmq3.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/ai_dmq3.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -4176,7 +4176,7 @@
return 0;
}
trap_AAS_ValueForBSPEpairKey(ent, "classname", classname, sizeof(classname));
- if (!classname) {
+ if (!*classname) {
BotAI_Print(PRT_ERROR, "BotGetActivateGoal: entity with model %s has no classname\n", model);
return 0;
}
Modified: branches/1.34/code/game/ai_team.c
===================================================================
--- branches/1.34/code/game/ai_team.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/ai_team.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1960,7 +1960,7 @@
BotSayVoiceTeamOrder(bs, -1, VOICECHAT_STARTLEADER);
ClientName(bs->client, netname, sizeof(netname));
strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
- bs->teamleader[sizeof(bs->teamleader)] = '\0';
+ bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
bs->becometeamleader_time = 0;
}
return;
Modified: branches/1.34/code/game/bg_lib.h
===================================================================
--- branches/1.34/code/game/bg_lib.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/bg_lib.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -26,6 +26,13 @@
#ifndef BG_LIB_H
#define BG_LIB_H
+//Ignore __attribute__ on non-gcc platforms
+#ifndef __GNUC__
+#ifndef __attribute__
+#define __attribute__(x)
+#endif
+#endif
+
#ifndef NULL
#define NULL ((void *)0)
#endif
@@ -76,7 +83,7 @@
int _atoi( const char **stringPtr );
int vsprintf( char *buffer, const char *fmt, va_list argptr );
-int sscanf( const char *buffer, const char *fmt, ... );
+int sscanf( const char *buffer, const char *fmt, ... ) __attribute__ ((format (scanf, 2, 3)));
// Memory functions
void *memmove( void *dest, const void *src, size_t count );
Modified: branches/1.34/code/game/g_bot.c
===================================================================
--- branches/1.34/code/game/g_bot.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/g_bot.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -306,7 +306,6 @@
*/
int G_RemoveRandomBot( int team ) {
int i;
- char netname[36];
gclient_t *cl;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
@@ -320,9 +319,7 @@
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
- strcpy(netname, cl->pers.netname);
- Q_CleanStr(netname);
- trap_SendConsoleCommand( EXEC_INSERT, va("kick %s\n", netname) );
+ trap_SendConsoleCommand( EXEC_INSERT, va("clientkick %d\n", cl->ps.clientNum) );
return qtrue;
}
return qfalse;
Modified: branches/1.34/code/game/g_local.h
===================================================================
--- branches/1.34/code/game/g_local.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/g_local.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -712,7 +712,7 @@
extern level_locals_t level;
extern gentity_t g_entities[MAX_GENTITIES];
-#define FOFS(x) ((int)&(((gentity_t *)0)->x))
+#define FOFS(x) ((size_t)&(((gentity_t *)0)->x))
extern vmCvar_t g_gametype;
extern vmCvar_t g_dedicated;
Modified: branches/1.34/code/game/g_session.c
===================================================================
--- branches/1.34/code/game/g_session.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/game/g_session.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -54,7 +54,7 @@
client->sess.teamLeader
);
- var = va( "session%i", client - level.clients );
+ var = va( "session%i", (int)(client - level.clients) );
trap_Cvar_Set( var, s );
}
@@ -75,7 +75,7 @@
int spectatorState;
int sessionTeam;
- var = va( "session%i", client - level.clients );
+ var = va( "session%i", (int)(client - level.clients) );
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) );
sscanf( s, "%i %i %i %i %i %i %i",
Modified: branches/1.34/code/jpeg-6/jerror.c
===================================================================
--- branches/1.34/code/jpeg-6/jerror.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/jpeg-6/jerror.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -13,14 +13,14 @@
* These routines are used by both the compression and decompression code.
*/
+#include "../renderer/tr_local.h"
+
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
#include "jinclude.h"
#include "jpeglib.h"
#include "jversion.h"
#include "jerror.h"
-#include "../renderer/tr_local.h"
-
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1
#endif
Modified: branches/1.34/code/jpeg-6/jmemnobs.c
===================================================================
--- branches/1.34/code/jpeg-6/jmemnobs.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/jpeg-6/jmemnobs.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -15,13 +15,13 @@
* Note that the max_memory_to_use option is ignored by this implementation.
*/
+#include "../renderer/tr_local.h"
+
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h" /* import the system-dependent declarations */
-#include "../renderer/tr_local.h"
-
/*
* Memory allocation and ri.Freeing are controlled by the regular library
* routines ri.Malloc() and ri.Free().
Modified: branches/1.34/code/jpeg-6/jmorecfg.h
===================================================================
--- branches/1.34/code/jpeg-6/jmorecfg.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/jpeg-6/jmorecfg.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -149,7 +149,10 @@
typedef unsigned int UINT16;
#endif /* HAVE_UNSIGNED_SHORT */
-#ifndef DONT_TYPEDEF_INT32
+/* INT32 must hold at least signed 32-bit values. */
+
+/* MinGW basetsd.h defines INT32 - don't redefine it */
+#if !(defined __MINGW32__ && defined _BASETSD_H)
typedef long INT32;
#endif
@@ -159,12 +162,6 @@
typedef short INT16;
#endif
-/* INT32 must hold at least signed 32-bit values. */
-
-//#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
-//typedef long INT32;
-//#endif
-
/* Datatype used for image dimensions. The JPEG standard only supports
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
* "unsigned int" is sufficient on all machines. However, if you need to
Copied: branches/1.34/code/libcurl (from rev 898, trunk/code/libcurl)
Modified: branches/1.34/code/libs/macosx/libSDL-1.2.0.dylib
===================================================================
(Binary files differ)
Copied: branches/1.34/code/libs/win32 (from rev 898, trunk/code/libs/win32)
Modified: branches/1.34/code/null/null_client.c
===================================================================
--- branches/1.34/code/null/null_client.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/null/null_client.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -85,7 +85,7 @@
}
// bk001119 - added new dummy for sv_init.c
-void CL_ShutdownAll(void) {};
+void CL_ShutdownAll(void) {}
// bk001208 - added new dummy (RC4)
qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { return qtrue; }
Modified: branches/1.34/code/q3_ui/ui_teamorders.c
===================================================================
--- branches/1.34/code/q3_ui/ui_teamorders.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/q3_ui/ui_teamorders.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -295,7 +295,7 @@
int numPlayers;
int isBot;
int n;
- char playerTeam;
+ char playerTeam = '3';
char botTeam;
char info[MAX_INFO_STRING];
@@ -315,8 +315,6 @@
for( n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++ ) {
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );
- playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use
-
if( n == cs.clientNum ) {
playerTeam = *Info_ValueForKey( info, "t" );
continue;
Modified: branches/1.34/code/qcommon/cm_patch.c
===================================================================
--- branches/1.34/code/qcommon/cm_patch.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/cm_patch.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1153,7 +1153,7 @@
if ( width <= 2 || height <= 2 || !points ) {
Com_Error( ERR_DROP, "CM_GeneratePatchFacets: bad parameters: (%i, %i, %p)",
- width, height, points );
+ width, height, (void *)points );
}
if ( !(width & 1) || !(height & 1) ) {
@@ -1386,6 +1386,11 @@
static cvar_t *cv;
#endif //BSPC
+ if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
+ pc->bounds[0], pc->bounds[1] ) ) {
+ return;
+ }
+
if (tw->isPoint) {
CM_TracePointThroughPatchCollide( tw, pc );
return;
Modified: branches/1.34/code/qcommon/cm_test.c
===================================================================
--- branches/1.34/code/qcommon/cm_test.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/cm_test.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -250,6 +250,10 @@
brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
b = &cm.brushes[brushnum];
+ if ( !BoundsIntersectPoint( b->bounds[0], b->bounds[1], p ) ) {
+ continue;
+ }
+
// see if the point is in the brush
for ( i = 0 ; i < b->numsides ; i++ ) {
d = DotProduct( p, b->sides[i].plane->normal );
Modified: branches/1.34/code/qcommon/cm_trace.c
===================================================================
--- branches/1.34/code/qcommon/cm_trace.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/cm_trace.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -685,6 +685,11 @@
continue;
}
+ if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1],
+ b->bounds[0], b->bounds[1] ) ) {
+ continue;
+ }
+
CM_TraceThroughBrush( tw, b );
if ( !tw->trace.fraction ) {
return;
Modified: branches/1.34/code/qcommon/common.c
===================================================================
--- branches/1.34/code/qcommon/common.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/common.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1256,7 +1256,7 @@
for (block = mainzone->blocklist.next ; ; block = block->next) {
if ( Cmd_Argc() != 1 ) {
Com_Printf ("block:%p size:%7i tag:%3i\n",
- block, block->size, block->tag);
+ (void *)block, block->size, block->tag);
}
if ( block->tag ) {
zoneBytes += block->size;
@@ -3217,3 +3217,24 @@
Field_CompleteCommand( completionField->buffer, qtrue, qtrue );
}
+
+/*
+==================
+Com_RandomBytes
+
+fills string array with len radom bytes, peferably from the OS randomizer
+==================
+*/
+void Com_RandomBytes( byte *string, int len )
+{
+ int i;
+
+ if( Sys_RandomBytes( string, len ) )
+ return;
+
+ Com_Printf( "Com_RandomBytes: using weak randomization\n" );
+ srand( time( 0 ) );
+ for( i = 0; i < len; i++ )
+ string[i] = (unsigned char)( rand() % 255 );
+}
+
Modified: branches/1.34/code/qcommon/cvar.c
===================================================================
--- branches/1.34/code/qcommon/cvar.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/cvar.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -913,10 +913,9 @@
vmCvar->modificationCount = cv->modificationCount;
// bk001129 - mismatches.
if ( strlen(cv->string)+1 > MAX_CVAR_VALUE_STRING )
- Com_Error( ERR_DROP, "Cvar_Update: src %s length %d exceeds MAX_CVAR_VALUE_STRING",
+ Com_Error( ERR_DROP, "Cvar_Update: src %s length %zd exceeds MAX_CVAR_VALUE_STRING",
cv->string,
- strlen(cv->string),
- sizeof(vmCvar->string) );
+ strlen(cv->string));
// bk001212 - Q_strncpyz guarantees zero padding and dest[MAX_CVAR_VALUE_STRING-1]==0
// bk001129 - paranoia. Never trust the destination string.
// bk001129 - beware, sizeof(char*) is always 4 (for cv->string).
Modified: branches/1.34/code/qcommon/files.c
===================================================================
--- branches/1.34/code/qcommon/files.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/files.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -196,12 +196,20 @@
*/
-#define DEMOGAME "demota"
-
// every time a new demo pk3 file is built, this checksum must be updated.
// the easiest way to get it is to just run the game and see what it spits out
#define DEMO_PAK0_CHECKSUM 2985612116u
-#define PAK0_CHECKSUM 1566731103u
+static const unsigned pak_checksums[] = {
+ 1566731103u,
+ 298122907u,
+ 412165236u,
+ 2991495316u,
+ 1197932710u,
+ 4087071573u,
+ 3709064859u,
+ 908855077u,
+ 977125798u
+};
// if this is defined, the executable positively won't work with any paks other
// than the demo pak, even if productid is present. This is only used for our
@@ -2483,7 +2491,6 @@
then loads the zip headers
================
*/
-#define MAX_PAKFILES 1024
static void FS_AddGameDirectory( const char *path, const char *dir ) {
searchpath_t *sp;
int i;
@@ -2492,7 +2499,6 @@
char *pakfile;
int numfiles;
char **pakfiles;
- char *sorted[MAX_PAKFILES];
// this fixes the case where fs_basepath is the same as fs_cdpath
// which happens on full installs
@@ -2521,20 +2527,11 @@
pakfiles = Sys_ListFiles( pakfile, ".pk3", NULL, &numfiles, qfalse );
- // sort them so that later alphabetic matches override
- // earlier ones. This makes pak1.pk3 override pak0.pk3
- if ( numfiles > MAX_PAKFILES ) {
- numfiles = MAX_PAKFILES;
- }
- for ( i = 0 ; i < numfiles ; i++ ) {
- sorted[i] = pakfiles[i];
- }
+ qsort( pakfiles, numfiles, sizeof(char*), paksort );
- qsort( sorted, numfiles, sizeof(char*), paksort );
-
for ( i = 0 ; i < numfiles ; i++ ) {
- pakfile = FS_BuildOSPath( path, dir, sorted[i] );
- if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 )
+ pakfile = FS_BuildOSPath( path, dir, pakfiles[i] );
+ if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 )
continue;
// store the game name for downloading
strcpy(pak->pakGamename, dir);
@@ -2904,15 +2901,19 @@
static void FS_CheckPak0( void )
{
searchpath_t *path;
- qboolean foundPak0 = qfalse;
+ qboolean founddemo = qfalse;
+ unsigned foundPak = 0;
for( path = fs_searchpaths; path; path = path->next ) {
- if( path->pack &&
- !Q_stricmpn( path->pack->pakBasename, "pak0", MAX_OSPATH ) &&
- (!Q_stricmpn( path->pack->pakGamename, BASEGAME, MAX_OSPATH ) ||
- !Q_stricmpn( path->pack->pakGamename, "demoq3", MAX_OSPATH ))) {
- foundPak0 = qtrue;
+ const char* pakBasename = path->pack->pakBasename;
+ if(!path->pack)
+ continue;
+
+ if(!Q_stricmpn( path->pack->pakGamename, "demoq3", MAX_OSPATH )
+ && !Q_stricmpn( pakBasename, "pak0", MAX_OSPATH )) {
+ founddemo = qtrue;
+
if( path->pack->checksum == DEMO_PAK0_CHECKSUM ) {
Com_Printf( "\n\n"
"**************************************************\n"
@@ -2920,22 +2921,56 @@
"from the demo. This may work fine, but it is not\n"
"guaranteed or supported.\n"
"**************************************************\n\n\n" );
- } else if( path->pack->checksum != PAK0_CHECKSUM ) {
- Com_Printf( "\n\n"
+ }
+ } else if(!Q_stricmpn( path->pack->pakGamename, BASEGAME, MAX_OSPATH )
+ && strlen(pakBasename) == 4 && !Q_stricmpn( pakBasename, "pak", 3 )
+ && pakBasename[3] >= '0' && pakBasename[3] <= '8') {
+
+ if( path->pack->checksum != pak_checksums[pakBasename[3]-'0'] ) {
+ if(pakBasename[0] == '0') {
+ Com_Printf("\n\n"
"**************************************************\n"
"WARNING: pak0.pk3 is present but its checksum (%u)\n"
"is not correct. Please re-copy pak0.pk3 from your\n"
"legitimate Q3 CDROM.\n"
"**************************************************\n\n\n",
path->pack->checksum );
+ } else {
+ Com_Printf("\n\n"
+ "**************************************************\n"
+ "WARNING: pak%d.pk3 is present but its checksum (%u)\n"
+ "is not correct. Please re-install the point release\n"
+ "**************************************************\n\n\n",
+ pakBasename[3]-'0', path->pack->checksum );
+ }
}
+
+ foundPak |= 1<<(pakBasename[3]-'0');
}
}
- if( !foundPak0 ) {
- Com_Error( ERR_FATAL, "Couldn't find pak0.pk3. Check that your Q3\n"
- "executable is in the correct place and that every file\n"
- "in the %s directory is present and readable.", BASEGAME);
+ if( !founddemo && foundPak != 0x1ff ) {
+ if((foundPak&1) != 1 ) {
+ Com_Printf("\n\n"
+ "pak0.pk3 is missing. Please copy it\n"
+ "from your legitimate Q3 CDROM.\n");
+ }
+
+ if((foundPak&0x1fe) != 0x1fe ) {
+ Com_Printf("\n\n"
+ "Point Release files are missing. Please\n"
+ "re-install the 1.32 point release.\n");
+ }
+
+ Com_Printf("\n\n"
+ "Also check that your Q3 executable is in\n"
+ "the correct place and that every file\n"
+ "in the %s directory is present and readable.\n", BASEGAME);
+
+ if(!fs_gamedirvar->string[0]
+ || !Q_stricmp( fs_gamedirvar->string, BASEGAME )
+ || !Q_stricmp( fs_gamedirvar->string, "missionpack" ))
+ Com_Error(ERR_FATAL, "\n*** you need to install Quake III Arena in order to play ***");
}
}
Modified: branches/1.34/code/qcommon/md5.c
===================================================================
--- branches/1.34/code/qcommon/md5.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/md5.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -257,27 +257,38 @@
}
-char *Com_MD5File(const char *fn, int length)
+char *Com_MD5File( const char *fn, int length, const char *prefix, int prefix_len )
{
- static char final[33] = {"unknown"};
+ static char final[33] = {""};
unsigned char digest[16] = {""};
fileHandle_t f;
MD5_CTX md5;
- char buffer[2048];
+ byte buffer[2048];
int i;
int filelen = 0;
int r = 0;
int total = 0;
- filelen = FS_FOpenFileRead(fn, &f, qtrue);
- if(filelen < 1) {
+ Q_strncpyz( final, "", sizeof( final ) );
+
+ filelen = FS_SV_FOpenFileRead( fn, &f );
+
+ if( !f ) {
return final;
}
+ if( filelen < 1 ) {
+ FS_FCloseFile( f );
+ return final;
+ }
if(filelen < length || !length) {
length = filelen;
}
MD5Init(&md5);
+
+ if( prefix_len && *prefix )
+ MD5Update(&md5 , (unsigned char *)prefix, prefix_len);
+
for(;;) {
r = FS_Read2(buffer, sizeof(buffer), f);
if(r < 1)
@@ -285,7 +296,7 @@
if(r + total > length)
r = length - total;
total += r;
- MD5Update(&md5 , (unsigned char *)buffer, r);
+ MD5Update(&md5 , buffer, r);
if(r < sizeof(buffer) || total >= length)
break;
}
Modified: branches/1.34/code/qcommon/msg.c
===================================================================
--- branches/1.34/code/qcommon/msg.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/msg.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -790,7 +790,7 @@
} netField_t;
// using the stringizing operator to save typing...
-#define NETF(x) #x,(int)&((entityState_t*)0)->x
+#define NETF(x) #x,(size_t)&((entityState_t*)0)->x
netField_t entityStateFields[] =
{
@@ -1105,7 +1105,7 @@
*/
// using the stringizing operator to save typing...
-#define PSF(x) #x,(int)&((playerState_t*)0)->x
+#define PSF(x) #x,(size_t)&((playerState_t*)0)->x
netField_t playerStateFields[] =
{
Modified: branches/1.34/code/qcommon/net_chan.c
===================================================================
--- branches/1.34/code/qcommon/net_chan.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/net_chan.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -397,8 +397,7 @@
if ( fragmentStart != chan->fragmentLength ) {
if ( showdrop->integer || showpackets->integer ) {
Com_Printf( "%s:Dropped a message fragment\n"
- , NET_AdrToString( chan->remoteAddress )
- , sequence);
+ , NET_AdrToString( chan->remoteAddress ));
}
// we can still keep the part that we have so far,
// so we don't need to clear chan->fragmentLength
@@ -720,7 +719,7 @@
string[3] = -1;
va_start( argptr, format );
- vsprintf( string+4, format, argptr );
+ Q_vsnprintf( string+4, sizeof(string)-4, format, argptr );
va_end( argptr );
// send the datagram
Modified: branches/1.34/code/qcommon/q_math.c
===================================================================
--- branches/1.34/code/qcommon/q_math.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/q_math.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1037,7 +1037,54 @@
}
}
+qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs,
+ const vec3_t mins2, const vec3_t maxs2)
+{
+ if ( maxs[0] < mins2[0] ||
+ maxs[1] < mins2[1] ||
+ maxs[2] < mins2[2] ||
+ mins[0] > maxs2[0] ||
+ mins[1] > maxs2[1] ||
+ mins[2] > maxs2[2])
+ {
+ return qfalse;
+ }
+ return qtrue;
+}
+
+qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs,
+ const vec3_t origin, vec_t radius)
+{
+ if ( origin[0] - radius > maxs[0] ||
+ origin[0] + radius < mins[0] ||
+ origin[1] - radius > maxs[1] ||
+ origin[1] + radius < mins[1] ||
+ origin[2] - radius > maxs[2] ||
+ origin[2] + radius < mins[2])
+ {
+ return qfalse;
+ }
+
+ return qtrue;
+}
+
+qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs,
+ const vec3_t origin)
+{
+ if ( origin[0] > maxs[0] ||
+ origin[0] < mins[0] ||
+ origin[1] > maxs[1] ||
+ origin[1] < mins[1] ||
+ origin[2] > maxs[2] ||
+ origin[2] < mins[2])
+ {
+ return qfalse;
+ }
+
+ return qtrue;
+}
+
vec_t VectorNormalize( vec3_t v ) {
// NOTE: TTimo - Apple G4 altivec source uses double?
float length, ilength;
Modified: branches/1.34/code/qcommon/q_platform.h
===================================================================
--- branches/1.34/code/qcommon/q_platform.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/q_platform.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -222,7 +222,7 @@
#ifdef __sun
-#include <sys/isa_defs.h>
+#include <stdint.h>
#include <sys/byteorder.h>
#define OS_STRING "solaris"
Modified: branches/1.34/code/qcommon/q_shared.c
===================================================================
--- branches/1.34/code/qcommon/q_shared.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/q_shared.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1187,29 +1187,21 @@
*/
void Info_SetValueForKey( char *s, const char *key, const char *value ) {
char newi[MAX_INFO_STRING];
+ const char* blacklist = "\\;\"";
if ( strlen( s ) >= MAX_INFO_STRING ) {
Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
}
- if (strchr (key, '\\') || strchr (value, '\\'))
+ for(; *blacklist; ++blacklist)
{
- Com_Printf ("Can't use keys or values with a \\\n");
- return;
+ if (strchr (key, *blacklist) || strchr (value, *blacklist))
+ {
+ Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value);
+ return;
+ }
}
-
- if (strchr (key, ';') || strchr (value, ';'))
- {
- Com_Printf ("Can't use keys or values with a semicolon\n");
- return;
- }
-
- if (strchr (key, '\"') || strchr (value, '\"'))
- {
- Com_Printf ("Can't use keys or values with a \"\n");
- return;
- }
-
+
Info_RemoveKey (s, key);
if (!value || !strlen(value))
return;
@@ -1235,29 +1227,21 @@
*/
void Info_SetValueForKey_Big( char *s, const char *key, const char *value ) {
char newi[BIG_INFO_STRING];
+ const char* blacklist = "\\;\"";
if ( strlen( s ) >= BIG_INFO_STRING ) {
Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
}
- if (strchr (key, '\\') || strchr (value, '\\'))
+ for(; *blacklist; ++blacklist)
{
- Com_Printf ("Can't use keys or values with a \\\n");
- return;
+ if (strchr (key, *blacklist) || strchr (value, *blacklist))
+ {
+ Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value);
+ return;
+ }
}
- if (strchr (key, ';') || strchr (value, ';'))
- {
- Com_Printf ("Can't use keys or values with a semicolon\n");
- return;
- }
-
- if (strchr (key, '\"') || strchr (value, '\"'))
- {
- Com_Printf ("Can't use keys or values with a \"\n");
- return;
- }
-
Info_RemoveKey_Big (s, key);
if (!value || !strlen(value))
return;
Modified: branches/1.34/code/qcommon/q_shared.h
===================================================================
--- branches/1.34/code/qcommon/q_shared.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/q_shared.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -26,13 +26,13 @@
// q_shared.h -- included first by ALL program modules.
// A user mod should never modify this file
-#define Q3_VERSION "ioQ3 1.34-rc3"
+#define Q3_VERSION "ioQ3 1.34-rc4"
#ifndef SVN_VERSION
#define SVN_VERSION Q3_VERSION
#endif
-#define CLIENT_WINDOW_TITLE "icculus.org/quake3"
+#define CLIENT_WINDOW_TITLE "ioquake3"
#define CLIENT_WINDOW_ICON "ioq3"
-#define CONSOLE_WINDOW_TITLE "icculus.org/quake3 console"
+#define CONSOLE_WINDOW_TITLE "ioquake3 console"
#define CONSOLE_WINDOW_ICON "ioq3 console"
// 1.32 released 7-10-2002
@@ -114,18 +114,19 @@
#ifdef Q3_VM
typedef int intptr_t;
#else
-# ifndef _MSC_VER
-# include <stdint.h>
-# else
- typedef __int64 int64_t;
- typedef __int32 int32_t;
- typedef __int16 int16_t;
- typedef __int8 int8_t;
- typedef unsigned __int64 uint64_t;
- typedef unsigned __int32 uint32_t;
- typedef unsigned __int16 uint16_t;
- typedef unsigned __int8 uint8_t;
-# endif
+ #ifndef _MSC_VER
+ #include <stdint.h>
+ #else
+ #include <io.h>
+ typedef __int64 int64_t;
+ typedef __int32 int32_t;
+ typedef __int16 int16_t;
+ typedef __int8 int8_t;
+ typedef unsigned __int64 uint64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int8 uint8_t;
+ #endif
#endif
typedef unsigned char byte;
@@ -529,7 +530,7 @@
vec_t Distance( const vec3_t p1, const vec3_t p2 );
vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
-
+
void VectorNormalizeFast( vec3_t v );
void VectorInverse( vec3_t v );
@@ -562,6 +563,13 @@
void SetPlaneSignbits( struct cplane_s *out );
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
+qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs,
+ const vec3_t mins2, const vec3_t maxs2);
+qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs,
+ const vec3_t origin, vec_t radius);
+qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs,
+ const vec3_t origin);
+
float AngleMod(float a);
float LerpAngle (float from, float to, float frac);
float AngleSubtract( float a1, float a2 );
@@ -599,8 +607,8 @@
char *COM_Parse( char **data_p );
char *COM_ParseExt( char **data_p, qboolean allowLineBreak );
int COM_Compress( char *data_p );
-void COM_ParseError( char *format, ... );
-void COM_ParseWarning( char *format, ... );
+void COM_ParseError( char *format, ... ) __attribute__ ((format (printf, 1, 2)));
+void COM_ParseWarning( char *format, ... ) __attribute__ ((format (printf, 1, 2)));
//int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
#define MAX_TOKENLENGTH 1024
@@ -634,11 +642,13 @@
void Parse2DMatrix (char **buf_p, int y, int x, float *m);
void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);
-void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
+void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
char *Com_SkipTokens( char *s, int numTokens, char *sep );
char *Com_SkipCharset( char *s, char *sep );
+void Com_RandomBytes( byte *string, int len );
+
// mode parm for FS_FOpenFile
typedef enum {
FS_READ,
@@ -706,7 +716,7 @@
void Swap_Init (void);
*/
-char * QDECL va(char *format, ...);
+char * QDECL va(char *format, ...) __attribute__ ((format (printf, 1, 2)));
#define TRUNCATE_LENGTH 64
void Com_TruncateLongString( char *buffer, const char *s );
@@ -725,8 +735,8 @@
void Info_NextPair( const char **s, char *key, char *value );
// this is only here so the functions in q_shared.c and bg_*.c can link
-void QDECL Com_Error( int level, const char *error, ... );
-void QDECL Com_Printf( const char *msg, ... );
+void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((format (printf, 2, 3)));
+void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));
/*
Modified: branches/1.34/code/qcommon/qcommon.h
===================================================================
--- branches/1.34/code/qcommon/qcommon.h 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/qcommon.h 2007-08-22 21:25:32 UTC (rev 1127)
@@ -161,7 +161,7 @@
void NET_Config( qboolean enableNetworking );
void NET_FlushPacketQueue(void);
void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to);
-void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...);
+void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len );
qboolean NET_CompareAdr (netadr_t a, netadr_t b);
@@ -725,14 +725,14 @@
void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *));
void Com_EndRedirect( void );
-void QDECL Com_Printf( const char *fmt, ... );
-void QDECL Com_DPrintf( const char *fmt, ... );
-void QDECL Com_Error( int code, const char *fmt, ... );
+void QDECL Com_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
+void QDECL Com_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
+void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
void Com_Quit_f( void );
int Com_EventLoop( void );
int Com_Milliseconds( void ); // will be journaled properly
unsigned Com_BlockChecksum( const void *buffer, int length );
-char *Com_MD5File(const char *filename, int length);
+char *Com_MD5File(const char *filename, int length, const char *prefix, int prefix_len);
int Com_HashKey(char *string, int maxlen);
int Com_Filter(char *filter, char *name, int casesensitive);
int Com_FilterPath(char *filter, char *name, int casesensitive);
@@ -989,7 +989,7 @@
char *Sys_GetCurrentUser( void );
-void QDECL Sys_Error( const char *error, ...);
+void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2)));
void Sys_Quit (void);
char *Sys_GetClipboardData( void ); // note that this isn't journaled...
@@ -1001,6 +1001,8 @@
void Sys_SnapVector( float *v );
+qboolean Sys_RandomBytes( byte *string, int len );
+
// the system console is shown when a dedicated server is running
void Sys_DisplaySystemConsole( qboolean show );
@@ -1100,4 +1102,10 @@
#define CL_ENCODE_START 12
#define CL_DECODE_START 4
+// flags for sv_allowDownload and cl_allowDownload
+#define DLF_ENABLE 1
+#define DLF_NO_REDIRECT 2
+#define DLF_NO_UDP 4
+#define DLF_NO_DISCONNECT 8
+
#endif // _QCOMMON_H_
Modified: branches/1.34/code/qcommon/vm.c
===================================================================
--- branches/1.34/code/qcommon/vm.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -726,7 +726,7 @@
lastVM = vm;
if ( vm_debugLevel ) {
- Com_Printf( "VM_Call( %ld )\n", callnum );
+ Com_Printf( "VM_Call( %d )\n", callnum );
}
// if we have a dll loaded, call it directly
Modified: branches/1.34/code/qcommon/vm_interpreted.c
===================================================================
--- branches/1.34/code/qcommon/vm_interpreted.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm_interpreted.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -394,9 +394,8 @@
r0 = ((int *)opStack)[0];
r1 = ((int *)opStack)[-1];
nextInstruction2:
- opcode = codeImage[ programCounter++ ];
#ifdef DEBUG_VM
- if ( (unsigned)programCounter > vm->codeLength ) {
+ if ( (unsigned)programCounter >= vm->codeLength ) {
Com_Error( ERR_DROP, "VM pc out of range" );
}
@@ -420,6 +419,7 @@
}
profileSymbol->profileCount++;
#endif
+ opcode = codeImage[ programCounter++ ];
switch ( opcode ) {
#ifdef DEBUG_VM
@@ -564,6 +564,8 @@
Com_Printf( "%s<--- %s\n", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) );
}
#endif
+ } else if ( (unsigned)programCounter >= vm->codeLength ) {
+ Com_Error( ERR_DROP, "VM program counter out of range in OP_CALL" );
} else {
programCounter = vm->instructionPointers[ programCounter ];
}
@@ -619,6 +621,8 @@
// check for leaving the VM
if ( programCounter == -1 ) {
goto done;
+ } else if ( (unsigned)programCounter >= vm->codeLength ) {
+ Com_Error( ERR_DROP, "VM program counter out of range in OP_LEAVE" );
}
goto nextInstruction;
@@ -907,7 +911,7 @@
vm->currentlyInterpreting = qfalse;
if ( opStack != &stack[1] ) {
- Com_Error( ERR_DROP, "Interpreter error: opStack = %i", opStack - stack );
+ Com_Error( ERR_DROP, "Interpreter error: opStack = %ld", (long int) (opStack - stack) );
}
vm->programStack = stackOnEntry;
Deleted: branches/1.34/code/qcommon/vm_ppc.c
===================================================================
--- branches/1.34/code/qcommon/vm_ppc.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm_ppc.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,1479 +0,0 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code 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.
-
-Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-// vm_ppc.c
-// ppc dynamic compiler
-
-#include "vm_local.h"
-
-#pragma opt_pointer_analysis off
-
-
-typedef enum {
- R_REAL_STACK = 1,
- // registers 3-11 are the parameter passing registers
-
- // state
- R_STACK = 3, // local
- R_OPSTACK, // global
-
- // constants
- R_MEMBASE, // global
- R_MEMMASK,
- R_ASMCALL, // global
- R_INSTRUCTIONS, // global
- R_NUM_INSTRUCTIONS, // global
- R_CVM, // currentVM
-
- // temps
- R_TOP = 11,
- R_SECOND = 12,
- R_EA = 2 // effective address calculation
-
-} regNums_t;
-
-#define RG_REAL_STACK r1
-#define RG_STACK r3
-#define RG_OPSTACK r4
-#define RG_MEMBASE r5
-#define RG_MEMMASK r6
-#define RG_ASMCALL r7
-#define RG_INSTRUCTIONS r8
-#define RG_NUM_INSTRUCTIONS r9
-#define RG_CVM r10
-#define RG_TOP r12
-#define RG_SECOND r13
-#define RG_EA r14
-
-// this doesn't have the low order bits set for instructions i'm not using...
-typedef enum {
- PPC_TDI = 0x08000000,
- PPC_TWI = 0x0c000000,
- PPC_MULLI = 0x1c000000,
- PPC_SUBFIC = 0x20000000,
- PPC_CMPI = 0x28000000,
- PPC_CMPLI = 0x2c000000,
- PPC_ADDIC = 0x30000000,
- PPC_ADDIC_ = 0x34000000,
- PPC_ADDI = 0x38000000,
- PPC_ADDIS = 0x3c000000,
- PPC_BC = 0x40000000,
- PPC_SC = 0x44000000,
- PPC_B = 0x48000000,
-
- PPC_MCRF = 0x4c000000,
- PPC_BCLR = 0x4c000020,
- PPC_RFID = 0x4c000000,
- PPC_CRNOR = 0x4c000000,
- PPC_RFI = 0x4c000000,
- PPC_CRANDC = 0x4c000000,
- PPC_ISYNC = 0x4c000000,
- PPC_CRXOR = 0x4c000000,
- PPC_CRNAND = 0x4c000000,
- PPC_CREQV = 0x4c000000,
- PPC_CRORC = 0x4c000000,
- PPC_CROR = 0x4c000000,
-//------------
- PPC_BCCTR = 0x4c000420,
- PPC_RLWIMI = 0x50000000,
- PPC_RLWINM = 0x54000000,
- PPC_RLWNM = 0x5c000000,
- PPC_ORI = 0x60000000,
- PPC_ORIS = 0x64000000,
- PPC_XORI = 0x68000000,
- PPC_XORIS = 0x6c000000,
- PPC_ANDI_ = 0x70000000,
- PPC_ANDIS_ = 0x74000000,
- PPC_RLDICL = 0x78000000,
- PPC_RLDICR = 0x78000000,
- PPC_RLDIC = 0x78000000,
- PPC_RLDIMI = 0x78000000,
- PPC_RLDCL = 0x78000000,
- PPC_RLDCR = 0x78000000,
- PPC_CMP = 0x7c000000,
- PPC_TW = 0x7c000000,
- PPC_SUBFC = 0x7c000010,
- PPC_MULHDU = 0x7c000000,
- PPC_ADDC = 0x7c000014,
- PPC_MULHWU = 0x7c000000,
- PPC_MFCR = 0x7c000000,
- PPC_LWAR = 0x7c000000,
- PPC_LDX = 0x7c000000,
- PPC_LWZX = 0x7c00002e,
- PPC_SLW = 0x7c000030,
- PPC_CNTLZW = 0x7c000000,
- PPC_SLD = 0x7c000000,
- PPC_AND = 0x7c000038,
- PPC_CMPL = 0x7c000040,
- PPC_SUBF = 0x7c000050,
- PPC_LDUX = 0x7c000000,
-//------------
- PPC_DCBST = 0x7c000000,
- PPC_LWZUX = 0x7c00006c,
- PPC_CNTLZD = 0x7c000000,
- PPC_ANDC = 0x7c000000,
- PPC_TD = 0x7c000000,
- PPC_MULHD = 0x7c000000,
- PPC_MULHW = 0x7c000000,
- PPC_MTSRD = 0x7c000000,
- PPC_MFMSR = 0x7c000000,
- PPC_LDARX = 0x7c000000,
- PPC_DCBF = 0x7c000000,
- PPC_LBZX = 0x7c0000ae,
- PPC_NEG = 0x7c000000,
- PPC_MTSRDIN = 0x7c000000,
- PPC_LBZUX = 0x7c000000,
- PPC_NOR = 0x7c0000f8,
- PPC_SUBFE = 0x7c000000,
- PPC_ADDE = 0x7c000000,
- PPC_MTCRF = 0x7c000000,
- PPC_MTMSR = 0x7c000000,
- PPC_STDX = 0x7c000000,
- PPC_STWCX_ = 0x7c000000,
- PPC_STWX = 0x7c00012e,
- PPC_MTMSRD = 0x7c000000,
- PPC_STDUX = 0x7c000000,
- PPC_STWUX = 0x7c00016e,
- PPC_SUBFZE = 0x7c000000,
- PPC_ADDZE = 0x7c000000,
- PPC_MTSR = 0x7c000000,
- PPC_STDCX_ = 0x7c000000,
- PPC_STBX = 0x7c0001ae,
- PPC_SUBFME = 0x7c000000,
- PPC_MULLD = 0x7c000000,
-//------------
- PPC_ADDME = 0x7c000000,
- PPC_MULLW = 0x7c0001d6,
- PPC_MTSRIN = 0x7c000000,
- PPC_DCBTST = 0x7c000000,
- PPC_STBUX = 0x7c000000,
- PPC_ADD = 0x7c000214,
- PPC_DCBT = 0x7c000000,
- PPC_LHZX = 0x7c00022e,
- PPC_EQV = 0x7c000000,
- PPC_TLBIE = 0x7c000000,
- PPC_ECIWX = 0x7c000000,
- PPC_LHZUX = 0x7c000000,
- PPC_XOR = 0x7c000278,
- PPC_MFSPR = 0x7c0002a6,
- PPC_LWAX = 0x7c000000,
- PPC_LHAX = 0x7c000000,
- PPC_TLBIA = 0x7c000000,
- PPC_MFTB = 0x7c000000,
- PPC_LWAUX = 0x7c000000,
- PPC_LHAUX = 0x7c000000,
- PPC_STHX = 0x7c00032e,
- PPC_ORC = 0x7c000338,
- PPC_SRADI = 0x7c000000,
- PPC_SLBIE = 0x7c000000,
- PPC_ECOWX = 0x7c000000,
- PPC_STHUX = 0x7c000000,
- PPC_OR = 0x7c000378,
- PPC_DIVDU = 0x7c000000,
- PPC_DIVWU = 0x7c000396,
- PPC_MTSPR = 0x7c0003a6,
- PPC_DCBI = 0x7c000000,
- PPC_NAND = 0x7c000000,
- PPC_DIVD = 0x7c000000,
-//------------
- PPC_DIVW = 0x7c0003d6,
- PPC_SLBIA = 0x7c000000,
- PPC_MCRXR = 0x7c000000,
- PPC_LSWX = 0x7c000000,
- PPC_LWBRX = 0x7c000000,
- PPC_LFSX = 0x7c000000,
- PPC_SRW = 0x7c000430,
- PPC_SRD = 0x7c000000,
- PPC_TLBSYNC = 0x7c000000,
- PPC_LFSUX = 0x7c000000,
- PPC_MFSR = 0x7c000000,
- PPC_LSWI = 0x7c000000,
- PPC_SYNC = 0x7c000000,
- PPC_LFDX = 0x7c000000,
- PPC_LFDUX = 0x7c000000,
- PPC_MFSRIN = 0x7c000000,
- PPC_STSWX = 0x7c000000,
- PPC_STWBRX = 0x7c000000,
- PPC_STFSX = 0x7c000000,
- PPC_STFSUX = 0x7c000000,
- PPC_STSWI = 0x7c000000,
- PPC_STFDX = 0x7c000000,
- PPC_DCBA = 0x7c000000,
- PPC_STFDUX = 0x7c000000,
- PPC_LHBRX = 0x7c000000,
- PPC_SRAW = 0x7c000630,
- PPC_SRAD = 0x7c000000,
- PPC_SRAWI = 0x7c000000,
- PPC_EIEIO = 0x7c000000,
- PPC_STHBRX = 0x7c000000,
- PPC_EXTSH = 0x7c000734,
- PPC_EXTSB = 0x7c000774,
- PPC_ICBI = 0x7c000000,
-//------------
- PPC_STFIWX = 0x7c0007ae,
- PPC_EXTSW = 0x7c000000,
- PPC_DCBZ = 0x7c000000,
- PPC_LWZ = 0x80000000,
- PPC_LWZU = 0x84000000,
- PPC_LBZ = 0x88000000,
- PPC_LBZU = 0x8c000000,
- PPC_STW = 0x90000000,
- PPC_STWU = 0x94000000,
- PPC_STB = 0x98000000,
- PPC_STBU = 0x9c000000,
- PPC_LHZ = 0xa0000000,
- PPC_LHZU = 0xa4000000,
- PPC_LHA = 0xa8000000,
- PPC_LHAU = 0xac000000,
- PPC_STH = 0xb0000000,
- PPC_STHU = 0xb4000000,
- PPC_LMW = 0xb8000000,
- PPC_STMW = 0xbc000000,
- PPC_LFS = 0xc0000000,
- PPC_LFSU = 0xc4000000,
- PPC_LFD = 0xc8000000,
- PPC_LFDU = 0xcc000000,
- PPC_STFS = 0xd0000000,
- PPC_STFSU = 0xd4000000,
- PPC_STFD = 0xd8000000,
- PPC_STFDU = 0xdc000000,
- PPC_LD = 0xe8000000,
- PPC_LDU = 0xe8000001,
- PPC_LWA = 0xe8000002,
- PPC_FDIVS = 0xec000024,
- PPC_FSUBS = 0xec000028,
- PPC_FADDS = 0xec00002a,
-//------------
- PPC_FSQRTS = 0xec000000,
- PPC_FRES = 0xec000000,
- PPC_FMULS = 0xec000032,
- PPC_FMSUBS = 0xec000000,
- PPC_FMADDS = 0xec000000,
- PPC_FNMSUBS = 0xec000000,
- PPC_FNMADDS = 0xec000000,
- PPC_STD = 0xf8000000,
- PPC_STDU = 0xf8000001,
- PPC_FCMPU = 0xfc000000,
- PPC_FRSP = 0xfc000018,
- PPC_FCTIW = 0xfc000000,
- PPC_FCTIWZ = 0xfc00001e,
- PPC_FDIV = 0xfc000000,
- PPC_FSUB = 0xfc000028,
- PPC_FADD = 0xfc000000,
- PPC_FSQRT = 0xfc000000,
- PPC_FSEL = 0xfc000000,
- PPC_FMUL = 0xfc000000,
- PPC_FRSQRTE = 0xfc000000,
- PPC_FMSUB = 0xfc000000,
- PPC_FMADD = 0xfc000000,
- PPC_FNMSUB = 0xfc000000,
- PPC_FNMADD = 0xfc000000,
- PPC_FCMPO = 0xfc000000,
- PPC_MTFSB1 = 0xfc000000,
- PPC_FNEG = 0xfc000050,
- PPC_MCRFS = 0xfc000000,
- PPC_MTFSB0 = 0xfc000000,
- PPC_FMR = 0xfc000000,
- PPC_MTFSFI = 0xfc000000,
- PPC_FNABS = 0xfc000000,
- PPC_FABS = 0xfc000000,
-//------------
- PPC_MFFS = 0xfc000000,
- PPC_MTFSF = 0xfc000000,
- PPC_FCTID = 0xfc000000,
- PPC_FCTIDZ = 0xfc000000,
- PPC_FCFID = 0xfc000000
-
-} ppcOpcodes_t;
-
-
-// the newly generated code
-static unsigned *buf;
-static int compiledOfs; // in dwords
-
-// fromt the original bytecode
-static byte *code;
-static int pc;
-
-void AsmCall( void );
-
-double itofConvert[2];
-
-static int Constant4( void ) {
- int v;
-
- v = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);
- pc += 4;
- return v;
-}
-
-static int Constant1( void ) {
- int v;
-
- v = code[pc];
- pc += 1;
- return v;
-}
-
-static void Emit4( int i ) {
- buf[ compiledOfs ] = i;
- compiledOfs++;
-}
-
-static void Inst( int opcode, int destReg, int aReg, int bReg ) {
- unsigned r;
-
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void Inst4( int opcode, int destReg, int aReg, int bReg, int cReg ) {
- unsigned r;
-
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void InstImm( int opcode, int destReg, int aReg, int immediate ) {
- unsigned r;
-
- if ( immediate > 32767 || immediate < -32768 ) {
- Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range, opcode %x,%d,%d", immediate, opcode, destReg, aReg );
- }
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void InstImmU( int opcode, int destReg, int aReg, int immediate ) {
- unsigned r;
-
- if ( immediate > 0xffff || immediate < 0 ) {
- Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range", immediate );
- }
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static qboolean rtopped;
-static int pop0, pop1, oc0, oc1;
-static vm_t *tvm;
-static int instruction;
-static byte *jused;
-static int pass;
-
-static void ltop() {
- if (rtopped == qfalse) {
- InstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- }
-}
-
-static void ltopandsecond() {
- if (pass>=0 && buf[compiledOfs-1] == (PPC_STWU | R_TOP<<21 | R_OPSTACK<<16 | 4 ) && jused[instruction]==0 ) {
- compiledOfs--;
- if (!pass) {
- tvm->instructionPointers[instruction] = compiledOfs * 4;
- }
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- } else if (pass>=0 && buf[compiledOfs-1] == (PPC_STW | R_TOP<<21 | R_OPSTACK<<16 | 0 ) && jused[instruction]==0 ) {
- compiledOfs--;
- if (!pass) {
- tvm->instructionPointers[instruction] = compiledOfs * 4;
- }
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
- } else {
- ltop(); // get value from opstack
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
- }
- rtopped = qfalse;
-}
-
-// TJW: Unused
-#if 0
-static void fltop() {
- if (rtopped == qfalse) {
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- }
-}
-#endif
-
-static void fltopandsecond() {
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFS, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
- rtopped = qfalse;
- return;
-}
-
-/*
-=================
-VM_Compile
-=================
-*/
-void VM_Compile( vm_t *vm, vmHeader_t *header ) {
- int op;
- int maxLength;
- int v;
- int i;
-
- // set up the into-to-float variables
- ((int *)itofConvert)[0] = 0x43300000;
- ((int *)itofConvert)[1] = 0x80000000;
- ((int *)itofConvert)[2] = 0x43300000;
-
- // allocate a very large temp buffer, we will shrink it later
- maxLength = header->codeLength * 8;
- buf = Z_Malloc( maxLength );
- jused = Z_Malloc(header->instructionCount + 2);
- Com_Memset(jused, 0, header->instructionCount+2);
-
- // compile everything twice, so the second pass will have valid instruction
- // pointers for branches
- for ( pass = -1 ; pass < 2 ; pass++ ) {
-
- rtopped = qfalse;
- // translate all instructions
- pc = 0;
-
- pop0 = 343545;
- pop1 = 2443545;
- oc0 = -2343535;
- oc1 = 24353454;
- tvm = vm;
- code = (byte *)header + header->codeOffset;
- compiledOfs = 0;
-#ifndef __GNUC__
- // metrowerks seems to require this header in front of functions
- Emit4( (int)(buf+2) );
- Emit4( 0 );
-#endif
-
- for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
- if ( compiledOfs*4 > maxLength - 16 ) {
- Com_Error( ERR_DROP, "VM_Compile: maxLength exceeded" );
- }
-
- op = code[ pc ];
- if ( !pass ) {
- vm->instructionPointers[ instruction ] = compiledOfs * 4;
- }
- pc++;
- switch ( op ) {
- case 0:
- break;
- case OP_BREAK:
- InstImmU( PPC_ADDI, R_TOP, 0, 0 );
- InstImm( PPC_LWZ, R_TOP, R_TOP, 0 ); // *(int *)0 to crash to debugger
- rtopped = qfalse;
- break;
- case OP_ENTER:
- InstImm( PPC_ADDI, R_STACK, R_STACK, -Constant4() ); // sub R_STACK, R_STACK, imm
- rtopped = qfalse;
- break;
- case OP_CONST:
- v = Constant4();
- if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
- v &= vm->dataMask;
- }
- if ( v < 32768 && v >= -32768 ) {
- InstImmU( PPC_ADDI, R_TOP, 0, v & 0xffff );
- } else {
- InstImmU( PPC_ADDIS, R_TOP, 0, (v >> 16)&0xffff );
- if ( v & 0xffff ) {
- InstImmU( PPC_ORI, R_TOP, R_TOP, v & 0xffff );
- }
- }
- if (code[pc] == OP_LOAD4) {
- Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- } else if (code[pc] == OP_LOAD2) {
- Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- } else if (code[pc] == OP_LOAD1) {
- Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- }
- if (code[pc] == OP_STORE4) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- } else if (code[pc] == OP_STORE2) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- } else if (code[pc] == OP_STORE1) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- }
- if (code[pc] == OP_JUMP) {
- jused[v] = 1;
- }
- InstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );
- rtopped = qtrue;
- break;
- case OP_LOCAL:
- oc0 = oc1;
- oc1 = Constant4();
- if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
- oc1 &= vm->dataMask;
- }
- InstImm( PPC_ADDI, R_TOP, R_STACK, oc1 );
- if (code[pc] == OP_LOAD4) {
- Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- } else if (code[pc] == OP_LOAD2) {
- Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- } else if (code[pc] == OP_LOAD1) {
- Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- pc++;
- instruction++;
- }
- if (code[pc] == OP_STORE4) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- } else if (code[pc] == OP_STORE2) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- } else if (code[pc] == OP_STORE1) {
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- pc++;
- instruction++;
- rtopped = qfalse;
- break;
- }
- InstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );
- rtopped = qtrue;
- break;
- case OP_ARG:
- ltop(); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- InstImm( PPC_ADDI, R_EA, R_STACK, Constant1() ); // location to put it
- Inst( PPC_STWX, R_TOP, R_EA, R_MEMBASE );
- rtopped = qfalse;
- break;
- case OP_CALL:
- Inst( PPC_MFSPR, R_SECOND, 8, 0 ); // move from link register
- InstImm( PPC_STWU, R_SECOND, R_REAL_STACK, -16 ); // save off the old return address
-
- Inst( PPC_MTSPR, R_ASMCALL, 9, 0 ); // move to count register
- Inst( PPC_BCCTR | 1, 20, 0, 0 ); // jump and link to the count register
-
- InstImm( PPC_LWZ, R_SECOND, R_REAL_STACK, 0 ); // fetch the old return address
- InstImm( PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );
- Inst( PPC_MTSPR, R_SECOND, 8, 0 ); // move to link register
- rtopped = qfalse;
- break;
- case OP_PUSH:
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, 4 );
- rtopped = qfalse;
- break;
- case OP_POP:
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- rtopped = qfalse;
- break;
- case OP_LEAVE:
- InstImm( PPC_ADDI, R_STACK, R_STACK, Constant4() ); // add R_STACK, R_STACK, imm
- Inst( PPC_BCLR, 20, 0, 0 ); // branch unconditionally to link register
- rtopped = qfalse;
- break;
- case OP_LOAD4:
- ltop(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP ); // mask it
- Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
- break;
- case OP_LOAD2:
- ltop(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP ); // mask it
- Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
- break;
- case OP_LOAD1:
- ltop(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP ); // mask it
- Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE ); // load from memory base
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
- break;
- case OP_STORE4:
- ltopandsecond(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- rtopped = qfalse;
- break;
- case OP_STORE2:
- ltopandsecond(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- rtopped = qfalse;
- break;
- case OP_STORE1:
- ltopandsecond(); // get value from opstack
- //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND ); // mask it
- Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE ); // store from memory base
- rtopped = qfalse;
- break;
-
- case OP_EQ:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (v&0x3ffffff) );
- rtopped = qfalse;
- break;
- case OP_NE:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 2, v );
-
- rtopped = qfalse;
- break;
- case OP_LTI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 0, v );
- rtopped = qfalse;
- break;
- case OP_LEI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 1, v );
- rtopped = qfalse;
- break;
- case OP_GTI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 1, v );
- rtopped = qfalse;
- break;
- case OP_GEI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 0, v );
- rtopped = qfalse;
- break;
- case OP_LTU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 0, v );
- rtopped = qfalse;
- break;
- case OP_LEU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 1, v );
- rtopped = qfalse;
- break;
- case OP_GTU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 1, v );
- rtopped = qfalse;
- break;
- case OP_GEU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 0, v );
- rtopped = qfalse;
- break;
-
- case OP_EQF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 2, v );
- rtopped = qfalse;
- break;
- case OP_NEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 2, v );
- rtopped = qfalse;
- break;
- case OP_LTF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 0, v );
- rtopped = qfalse;
- break;
- case OP_LEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 1, v );
- rtopped = qfalse;
- break;
- case OP_GTF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 12, 1, v );
- rtopped = qfalse;
- break;
- case OP_GEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
- i = Constant4();
- jused[i] = 1;
- InstImm( PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( PPC_BC, 4, 0, v );
- rtopped = qfalse;
- break;
-
- case OP_NEGI:
- ltop(); // get value from opstack
- InstImm( PPC_SUBFIC, R_TOP, R_TOP, 0 );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_ADD:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_ADD, R_TOP, R_TOP, R_SECOND );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_SUB:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_SUBF, R_TOP, R_TOP, R_SECOND );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_DIVI:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_DIVW, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_DIVU:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_DIVWU, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_MODI:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_DIVW, R_EA, R_SECOND, R_TOP );
- Inst( PPC_MULLW, R_EA, R_TOP, R_EA );
- Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_MODU:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_DIVWU, R_EA, R_SECOND, R_TOP );
- Inst( PPC_MULLW, R_EA, R_TOP, R_EA );
- Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_MULI:
- case OP_MULU:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_MULLW, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_BAND:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_AND, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_BOR:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_OR, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_BXOR:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_XOR, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_BCOM:
- ltop(); // get value from opstack
- Inst( PPC_NOR, R_TOP, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_LSH:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_SLW, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_RSHI:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_SRAW, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
- case OP_RSHU:
- ltop(); // get value from opstack
- InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_SRW, R_SECOND, R_TOP, R_TOP );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qtrue;
- break;
-
- case OP_NEGF:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- Inst( PPC_FNEG, R_TOP, 0, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_ADDF:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_FADDS, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_SUBF:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_FSUBS, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_DIVF:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst( PPC_FDIVS, R_TOP, R_SECOND, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_MULF:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- Inst4( PPC_FMULS, R_TOP, R_SECOND, 0, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
-
- case OP_CVIF:
- v = (int)&itofConvert;
- InstImmU( PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );
- InstImmU( PPC_ORI, R_EA, R_EA, v & 0xffff );
- InstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImmU( PPC_XORIS, R_TOP, R_TOP, 0x8000 );
- InstImm( PPC_STW, R_TOP, R_EA, 12 );
- InstImm( PPC_LFD, R_TOP, R_EA, 0 );
- InstImm( PPC_LFD, R_SECOND, R_EA, 8 );
- Inst( PPC_FSUB, R_TOP, R_SECOND, R_TOP );
- // Inst( PPC_FRSP, R_TOP, 0, R_TOP );
- InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_CVFI:
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- Inst( PPC_FCTIWZ, R_TOP, 0, R_TOP );
- Inst( PPC_STFIWX, R_TOP, 0, R_OPSTACK ); // save value to opstack
- rtopped = qfalse;
- break;
- case OP_SEX8:
- ltop(); // get value from opstack
- Inst( PPC_EXTSB, R_TOP, R_TOP, 0 );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
- break;
- case OP_SEX16:
- ltop(); // get value from opstack
- Inst( PPC_EXTSH, R_TOP, R_TOP, 0 );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
- break;
-
- case OP_BLOCK_COPY:
- v = Constant4() >> 2;
- ltop(); // source
- InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 ); // dest
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
- InstImmU( PPC_ADDI, R_EA, 0, v ); // count
- // FIXME: range check
- Inst( PPC_MTSPR, R_EA, 9, 0 ); // move to count register
-
- Inst( PPC_ADD, R_TOP, R_TOP, R_MEMBASE );
- InstImm( PPC_ADDI, R_TOP, R_TOP, -4 );
- Inst( PPC_ADD, R_SECOND, R_SECOND, R_MEMBASE );
- InstImm( PPC_ADDI, R_SECOND, R_SECOND, -4 );
-
- InstImm( PPC_LWZU, R_EA, R_TOP, 4 ); // source
- InstImm( PPC_STWU, R_EA, R_SECOND, 4 ); // dest
- Inst( PPC_BC | 0xfff8 , 16, 0, 0 ); // loop
- rtopped = qfalse;
- break;
-
- case OP_JUMP:
- ltop(); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- Inst( PPC_RLWINM | ( 29 << 1 ), R_TOP, R_TOP, 2 );
- // FIXME: range check
- Inst( PPC_LWZX, R_TOP, R_TOP, R_INSTRUCTIONS );
- Inst( PPC_MTSPR, R_TOP, 9, 0 ); // move to count register
- Inst( PPC_BCCTR, 20, 0, 0 ); // jump to the count register
- rtopped = qfalse;
- break;
- default:
- Com_Error( ERR_DROP, "VM_CompilePPC: bad opcode %i at instruction %i, offset %i", op, instruction, pc );
- }
- pop0 = pop1;
- pop1 = op;
- }
-
- Com_Printf( "VM file %s pass %d compiled to %i bytes of code\n", vm->name, (pass+1), compiledOfs*4 );
-
- if ( pass == 0 ) {
- // copy to an exact size buffer on the hunk
- vm->codeLength = compiledOfs * 4;
- vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );
- Com_Memcpy( vm->codeBase, buf, vm->codeLength );
- Z_Free( buf );
-
- // offset all the instruction pointers for the new location
- for ( i = 0 ; i < header->instructionCount ; i++ ) {
- vm->instructionPointers[i] += (int)vm->codeBase;
- }
-
- // go back over it in place now to fixup reletive jump targets
- buf = (unsigned *)vm->codeBase;
- }
- }
- Z_Free( jused );
-}
-
-/*
-==============
-VM_CallCompiled
-
-This function is called directly by the generated code
-==============
-*/
-int VM_CallCompiled( vm_t *vm, int *args ) {
- int stack[1024];
- int programStack;
- int stackOnEntry;
- byte *image;
-
- currentVM = vm;
-
- // interpret the code
- vm->currentlyInterpreting = qtrue;
-
- // we might be called recursively, so this might not be the very top
- programStack = vm->programStack;
- stackOnEntry = programStack;
- image = vm->dataBase;
-
- // set up the stack frame
- programStack -= 48;
-
- *(int *)&image[ programStack + 44] = args[9];
- *(int *)&image[ programStack + 40] = args[8];
- *(int *)&image[ programStack + 36] = args[7];
- *(int *)&image[ programStack + 32] = args[6];
- *(int *)&image[ programStack + 28] = args[5];
- *(int *)&image[ programStack + 24] = args[4];
- *(int *)&image[ programStack + 20] = args[3];
- *(int *)&image[ programStack + 16] = args[2];
- *(int *)&image[ programStack + 12] = args[1];
- *(int *)&image[ programStack + 8 ] = args[0];
- *(int *)&image[ programStack + 4 ] = 0; // return stack
- *(int *)&image[ programStack ] = -1; // will terminate the loop on return
-
- // off we go into generated code...
- // the PPC calling standard says the parms will all go into R3 - R11, so
- // no special asm code is needed here
-#ifdef __GNUC__
- ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
- programStack, (int)&stack,
- (int)image, vm->dataMask, (int)&AsmCall,
- (int)vm->instructionPointers, vm->instructionPointersLength,
- (int)vm );
-#else
- ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
- programStack, (int)&stack,
- (int)image, vm->dataMask, *(int *)&AsmCall /* skip function pointer header */,
- (int)vm->instructionPointers, vm->instructionPointersLength,
- (int)vm );
-#endif
- vm->programStack = stackOnEntry;
-
- vm->currentlyInterpreting = qfalse;
-
- return stack[1];
-}
-
-
-/*
-==================
-AsmCall
-
-Put this at end of file because gcc messes up debug line numbers
-==================
-*/
-#ifdef __GNUC__
-
-void AsmCall( void ) {
-asm (
- // pop off the destination instruction
-" lwz r12,0(r4) \n" // RG_TOP, 0(RG_OPSTACK)
-" addi r4,r4,-4 \n" // RG_OPSTACK, RG_OPSTACK, -4 \n"
-
- // see if it is a system trap
-" cmpwi r12,0 \n" // RG_TOP, 0 \n"
-" bc 12,0, systemTrap \n"
-
- // calling another VM function, so lookup in instructionPointers
-" slwi r12,r12,2 \n" // RG_TOP,RG_TOP,2
- // FIXME: range check
-" lwzx r12, r8, r12 \n" // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
-" mtctr r12 \n" // RG_TOP
-);
-
-#if defined(MACOS_X) && defined(__OPTIMIZE__)
- // On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.
-#warning Mac OS X optimization on, not popping GCC AsmCall frame
-#else
- // Mac OS X Server and unoptimized compiles include a GCC AsmCall frame
- asm (
-" lwz r1,0(r1) \n" // pop off the GCC AsmCall frame
-" lmw r30,-8(r1) \n"
-);
-#endif
-
-asm (
-" bcctr 20,0 \n" // when it hits a leave, it will branch to the current link register
-
- // calling a system trap
-"systemTrap: \n"
- // convert to positive system call number
-" subfic r12,r12,-1 \n"
-
- // save all our registers, including the current link register
-" mflr r13 \n" // RG_SECOND // copy off our link register
-" addi r1,r1,-92 \n" // required 24 byets of linkage, 32 bytes of parameter, plus our saves
-" stw r3,56(r1) \n" // RG_STACK, -36(REAL_STACK)
-" stw r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
-" stw r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
-" stw r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
-" stw r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
-" stw r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-" stw r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-" stw r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
-" stw r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK) // link register
-
- // save the vm stack position to allow recursive VM entry
-" addi r13,r3,-4 \n" // RG_TOP, RG_STACK, -4
-" stw r13,0(r10) \n" //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
-
- // save the system call number as the 0th parameter
-" add r3,r3,r5 \n" // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
-" stwu r12,4(r3) \n" // RG_TOP, 4(r3)
-
- // make the system call with the address of all the VM parms as a parameter
- // vm->systemCalls( &parms )
-" lwz r12,4(r10) \n" // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
-" mtctr r12 \n" // RG_TOP
-" bcctrl 20,0 \n"
-" mr r12,r3 \n" // RG_TOP, r3
-
- // pop our saved registers
-" lwz r3,56(r1) \n" // RG_STACK, 0(RG_REAL_STACK)
-" lwz r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
-" lwz r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
-" lwz r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
-" lwz r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
-" lwz r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-" lwz r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-" lwz r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
-" lwz r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK)
-" addi r1,r1,92 \n" // RG_REAL_STACK, RG_REAL_STACK, 36
-
- // restore the old link register
-" mtlr r13 \n" // RG_SECOND
-
- // save off the return value
-" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
-
- // GCC adds its own prolog / epilog code
- );
-}
-#else
-
-// codewarrior version
-
-void asm AsmCall( void ) {
-
- // pop off the destination instruction
-
- lwz r12,0(r4) // RG_TOP, 0(RG_OPSTACK)
-
- addi r4,r4,-4 // RG_OPSTACK, RG_OPSTACK, -4
-
-
-
- // see if it is a system trap
-
- cmpwi r12,0 // RG_TOP, 0
-
- bc 12,0, systemTrap
-
-
-
- // calling another VM function, so lookup in instructionPointers
-
- slwi r12,r12,2 // RG_TOP,RG_TOP,2
-
- // FIXME: range check
-
- lwzx r12, r8, r12 // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
-
- mtctr r12 // RG_TOP
-
-
-
- bcctr 20,0 // when it hits a leave, it will branch to the current link register
-
-
-
- // calling a system trap
-
-systemTrap:
-
- // convert to positive system call number
-
- subfic r12,r12,-1
-
-
-
- // save all our registers, including the current link register
-
- mflr r13 // RG_SECOND // copy off our link register
-
- addi r1,r1,-92 // required 24 byets of linkage, 32 bytes of parameter, plus our saves
-
- stw r3,56(r1) // RG_STACK, -36(REAL_STACK)
-
- stw r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
-
- stw r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
-
- stw r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
-
- stw r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
-
- stw r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-
- stw r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-
- stw r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
-
- stw r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK) // link register
-
-
-
- // save the vm stack position to allow recursive VM entry
-
- addi r13,r3,-4 // RG_TOP, RG_STACK, -4
-
- stw r13,0(r10) //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
-
-
-
- // save the system call number as the 0th parameter
-
- add r3,r3,r5 // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
-
- stwu r12,4(r3) // RG_TOP, 4(r3)
-
-
-
- // make the system call with the address of all the VM parms as a parameter
-
- // vm->systemCalls( &parms )
-
- lwz r12,4(r10) // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
-
-
-
- // perform macos cross fragment fixup crap
-
- lwz r9,0(r12)
-
- stw r2,52(r1) // save old TOC
-
- lwz r2,4(r12)
-
-
-
- mtctr r9 // RG_TOP
-
- bcctrl 20,0
-
-
-
- lwz r2,52(r1) // restore TOC
-
-
-
- mr r12,r3 // RG_TOP, r3
-
-
-
- // pop our saved registers
-
- lwz r3,56(r1) // RG_STACK, 0(RG_REAL_STACK)
-
- lwz r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
-
- lwz r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
-
- lwz r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
-
- lwz r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
-
- lwz r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-
- lwz r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-
- lwz r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
-
- lwz r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK)
-
- addi r1,r1,92 // RG_REAL_STACK, RG_REAL_STACK, 36
-
-
-
- // restore the old link register
-
- mtlr r13 // RG_SECOND
-
-
-
- // save off the return value
-
- stwu r12,4(r4) // RG_TOP, 0(RG_OPSTACK)
-
-
-
- blr
-
-}
-
-
-
-
-#endif
Copied: branches/1.34/code/qcommon/vm_ppc.c (from rev 1126, trunk/code/qcommon/vm_ppc.c)
===================================================================
--- branches/1.34/code/qcommon/vm_ppc.c (rev 0)
+++ branches/1.34/code/qcommon/vm_ppc.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,2064 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code 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.
+
+Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+// vm_ppc.c
+// ppc dynamic compiler
+
+#include "vm_local.h"
+#include <sys/mman.h>
+
+#define DEBUG_VM 0
+
+#if DEBUG_VM
+static char *opnames[256] = {
+ "OP_UNDEF",
+
+ "OP_IGNORE",
+
+ "OP_BREAK",
+
+ "OP_ENTER",
+ "OP_LEAVE",
+ "OP_CALL",
+ "OP_PUSH",
+ "OP_POP",
+
+ "OP_CONST",
+
+ "OP_LOCAL",
+
+ "OP_JUMP",
+
+ //-------------------
+
+ "OP_EQ",
+ "OP_NE",
+
+ "OP_LTI",
+ "OP_LEI",
+ "OP_GTI",
+ "OP_GEI",
+
+ "OP_LTU",
+ "OP_LEU",
+ "OP_GTU",
+ "OP_GEU",
+
+ "OP_EQF",
+ "OP_NEF",
+
+ "OP_LTF",
+ "OP_LEF",
+ "OP_GTF",
+ "OP_GEF",
+
+ //-------------------
+
+ "OP_LOAD1",
+ "OP_LOAD2",
+ "OP_LOAD4",
+ "OP_STORE1",
+ "OP_STORE2",
+ "OP_STORE4",
+ "OP_ARG",
+
+ "OP_BLOCK_COPY",
+
+ //-------------------
+
+ "OP_SEX8",
+ "OP_SEX16",
+
+ "OP_NEGI",
+ "OP_ADD",
+ "OP_SUB",
+ "OP_DIVI",
+ "OP_DIVU",
+ "OP_MODI",
+ "OP_MODU",
+ "OP_MULI",
+ "OP_MULU",
+
+ "OP_BAND",
+ "OP_BOR",
+ "OP_BXOR",
+ "OP_BCOM",
+
+ "OP_LSH",
+ "OP_RSHI",
+ "OP_RSHU",
+
+ "OP_NEGF",
+ "OP_ADDF",
+ "OP_SUBF",
+ "OP_DIVF",
+ "OP_MULF",
+
+ "OP_CVIF",
+ "OP_CVFI"
+};
+#endif
+
+typedef enum {
+ R_REAL_STACK = 1,
+ // registers 3-11 are the parameter passing registers
+
+ // state
+ R_STACK = 3, // local
+ R_OPSTACK, // global
+
+ // constants
+ R_MEMBASE, // global
+ R_MEMMASK,
+ R_ASMCALL, // global
+ R_INSTRUCTIONS, // global
+ R_NUM_INSTRUCTIONS, // global
+ R_CVM, // currentVM
+
+ // temps
+ R_TOP = 11,
+ R_SECOND = 12,
+ R_EA = 2 // effective address calculation
+
+} regNums_t;
+
+#define RG_REAL_STACK r1
+#define RG_STACK r3
+#define RG_OPSTACK r4
+#define RG_MEMBASE r5
+#define RG_MEMMASK r6
+#define RG_ASMCALL r7
+#define RG_INSTRUCTIONS r8
+#define RG_NUM_INSTRUCTIONS r9
+#define RG_CVM r10
+#define RG_TOP r12
+#define RG_SECOND r13
+#define RG_EA r14
+
+// The deepest value I saw in the Quake3 games was 9.
+#define OP_STACK_MAX_DEPTH 16
+
+// These are all volatile and thus must be saved upon entry to the VM code.
+// NOTE: These are General Purpose Registers (GPR) numbers like the
+// R_ definitions in the regNums_t enum above (31 is the max)
+static int opStackIntRegisters[OP_STACK_MAX_DEPTH] =
+{
+ 16, 17, 18, 19,
+ 20, 21, 22, 23,
+ 24, 25, 26, 27,
+ 28, 29, 30, 31
+};
+
+static unsigned int *opStackLoadInstructionAddr[OP_STACK_MAX_DEPTH];
+
+// We use different registers for the floating point
+// operand stack (these are volatile in the PPC ABI)
+// NOTE: these are Floating Point Register (FPR) numbers, not
+// General Purpose Register (GPR) numbers
+static int opStackFloatRegisters[OP_STACK_MAX_DEPTH] =
+{
+ 0, 1, 2, 3,
+ 4, 5, 6, 7,
+ 8, 9, 10, 11,
+ 12, 13, 14, 15
+};
+
+static int opStackRegType[OP_STACK_MAX_DEPTH] =
+{
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0
+};
+
+// this doesn't have the low order bits set for instructions i'm not using...
+typedef enum {
+ PPC_TDI = 0x08000000,
+ PPC_TWI = 0x0c000000,
+ PPC_MULLI = 0x1c000000,
+ PPC_SUBFIC = 0x20000000,
+ PPC_CMPI = 0x28000000,
+ PPC_CMPLI = 0x2c000000,
+ PPC_ADDIC = 0x30000000,
+ PPC_ADDIC_ = 0x34000000,
+ PPC_ADDI = 0x38000000,
+ PPC_ADDIS = 0x3c000000,
+ PPC_BC = 0x40000000,
+ PPC_SC = 0x44000000,
+ PPC_B = 0x48000000,
+
+ PPC_MCRF = 0x4c000000,
+ PPC_BCLR = 0x4c000020,
+ PPC_RFID = 0x4c000000,
+ PPC_CRNOR = 0x4c000000,
+ PPC_RFI = 0x4c000000,
+ PPC_CRANDC = 0x4c000000,
+ PPC_ISYNC = 0x4c000000,
+ PPC_CRXOR = 0x4c000000,
+ PPC_CRNAND = 0x4c000000,
+ PPC_CREQV = 0x4c000000,
+ PPC_CRORC = 0x4c000000,
+ PPC_CROR = 0x4c000000,
+//------------
+ PPC_BCCTR = 0x4c000420,
+ PPC_RLWIMI = 0x50000000,
+ PPC_RLWINM = 0x54000000,
+ PPC_RLWNM = 0x5c000000,
+ PPC_ORI = 0x60000000,
+ PPC_ORIS = 0x64000000,
+ PPC_XORI = 0x68000000,
+ PPC_XORIS = 0x6c000000,
+ PPC_ANDI_ = 0x70000000,
+ PPC_ANDIS_ = 0x74000000,
+ PPC_RLDICL = 0x78000000,
+ PPC_RLDICR = 0x78000000,
+ PPC_RLDIC = 0x78000000,
+ PPC_RLDIMI = 0x78000000,
+ PPC_RLDCL = 0x78000000,
+ PPC_RLDCR = 0x78000000,
+ PPC_CMP = 0x7c000000,
+ PPC_TW = 0x7c000000,
+ PPC_SUBFC = 0x7c000010,
+ PPC_MULHDU = 0x7c000000,
+ PPC_ADDC = 0x7c000014,
+ PPC_MULHWU = 0x7c000000,
+ PPC_MFCR = 0x7c000000,
+ PPC_LWAR = 0x7c000000,
+ PPC_LDX = 0x7c000000,
+ PPC_LWZX = 0x7c00002e,
+ PPC_SLW = 0x7c000030,
+ PPC_CNTLZW = 0x7c000000,
+ PPC_SLD = 0x7c000000,
+ PPC_AND = 0x7c000038,
+ PPC_CMPL = 0x7c000040,
+ PPC_SUBF = 0x7c000050,
+ PPC_LDUX = 0x7c000000,
+//------------
+ PPC_DCBST = 0x7c000000,
+ PPC_LWZUX = 0x7c00006c,
+ PPC_CNTLZD = 0x7c000000,
+ PPC_ANDC = 0x7c000000,
+ PPC_TD = 0x7c000000,
+ PPC_MULHD = 0x7c000000,
+ PPC_MULHW = 0x7c000000,
+ PPC_MTSRD = 0x7c000000,
+ PPC_MFMSR = 0x7c000000,
+ PPC_LDARX = 0x7c000000,
+ PPC_DCBF = 0x7c000000,
+ PPC_LBZX = 0x7c0000ae,
+ PPC_NEG = 0x7c000000,
+ PPC_MTSRDIN = 0x7c000000,
+ PPC_LBZUX = 0x7c000000,
+ PPC_NOR = 0x7c0000f8,
+ PPC_SUBFE = 0x7c000000,
+ PPC_ADDE = 0x7c000000,
+ PPC_MTCRF = 0x7c000000,
+ PPC_MTMSR = 0x7c000000,
+ PPC_STDX = 0x7c000000,
+ PPC_STWCX_ = 0x7c000000,
+ PPC_STWX = 0x7c00012e,
+ PPC_MTMSRD = 0x7c000000,
+ PPC_STDUX = 0x7c000000,
+ PPC_STWUX = 0x7c00016e,
+ PPC_SUBFZE = 0x7c000000,
+ PPC_ADDZE = 0x7c000000,
+ PPC_MTSR = 0x7c000000,
+ PPC_STDCX_ = 0x7c000000,
+ PPC_STBX = 0x7c0001ae,
+ PPC_SUBFME = 0x7c000000,
+ PPC_MULLD = 0x7c000000,
+//------------
+ PPC_ADDME = 0x7c000000,
+ PPC_MULLW = 0x7c0001d6,
+ PPC_MTSRIN = 0x7c000000,
+ PPC_DCBTST = 0x7c000000,
+ PPC_STBUX = 0x7c000000,
+ PPC_ADD = 0x7c000214,
+ PPC_DCBT = 0x7c000000,
+ PPC_LHZX = 0x7c00022e,
+ PPC_EQV = 0x7c000000,
+ PPC_TLBIE = 0x7c000000,
+ PPC_ECIWX = 0x7c000000,
+ PPC_LHZUX = 0x7c000000,
+ PPC_XOR = 0x7c000278,
+ PPC_MFSPR = 0x7c0002a6,
+ PPC_LWAX = 0x7c000000,
+ PPC_LHAX = 0x7c000000,
+ PPC_TLBIA = 0x7c000000,
+ PPC_MFTB = 0x7c000000,
+ PPC_LWAUX = 0x7c000000,
+ PPC_LHAUX = 0x7c000000,
+ PPC_STHX = 0x7c00032e,
+ PPC_ORC = 0x7c000338,
+ PPC_SRADI = 0x7c000000,
+ PPC_SLBIE = 0x7c000000,
+ PPC_ECOWX = 0x7c000000,
+ PPC_STHUX = 0x7c000000,
+ PPC_OR = 0x7c000378,
+ PPC_DIVDU = 0x7c000000,
+ PPC_DIVWU = 0x7c000396,
+ PPC_MTSPR = 0x7c0003a6,
+ PPC_DCBI = 0x7c000000,
+ PPC_NAND = 0x7c000000,
+ PPC_DIVD = 0x7c000000,
+//------------
+ PPC_DIVW = 0x7c0003d6,
+ PPC_SLBIA = 0x7c000000,
+ PPC_MCRXR = 0x7c000000,
+ PPC_LSWX = 0x7c000000,
+ PPC_LWBRX = 0x7c000000,
+ PPC_LFSX = 0x7c00042e,
+ PPC_SRW = 0x7c000430,
+ PPC_SRD = 0x7c000000,
+ PPC_TLBSYNC = 0x7c000000,
+ PPC_LFSUX = 0x7c000000,
+ PPC_MFSR = 0x7c000000,
+ PPC_LSWI = 0x7c000000,
+ PPC_SYNC = 0x7c000000,
+ PPC_LFDX = 0x7c000000,
+ PPC_LFDUX = 0x7c000000,
+ PPC_MFSRIN = 0x7c000000,
+ PPC_STSWX = 0x7c000000,
+ PPC_STWBRX = 0x7c000000,
+ PPC_STFSX = 0x7c00052e,
+ PPC_STFSUX = 0x7c000000,
+ PPC_STSWI = 0x7c000000,
+ PPC_STFDX = 0x7c000000,
+ PPC_DCBA = 0x7c000000,
+ PPC_STFDUX = 0x7c000000,
+ PPC_LHBRX = 0x7c000000,
+ PPC_SRAW = 0x7c000630,
+ PPC_SRAD = 0x7c000000,
+ PPC_SRAWI = 0x7c000000,
+ PPC_EIEIO = 0x7c000000,
+ PPC_STHBRX = 0x7c000000,
+ PPC_EXTSH = 0x7c000734,
+ PPC_EXTSB = 0x7c000774,
+ PPC_ICBI = 0x7c000000,
+//------------
+ PPC_STFIWX = 0x7c0007ae,
+ PPC_EXTSW = 0x7c000000,
+ PPC_DCBZ = 0x7c000000,
+ PPC_LWZ = 0x80000000,
+ PPC_LWZU = 0x84000000,
+ PPC_LBZ = 0x88000000,
+ PPC_LBZU = 0x8c000000,
+ PPC_STW = 0x90000000,
+ PPC_STWU = 0x94000000,
+ PPC_STB = 0x98000000,
+ PPC_STBU = 0x9c000000,
+ PPC_LHZ = 0xa0000000,
+ PPC_LHZU = 0xa4000000,
+ PPC_LHA = 0xa8000000,
+ PPC_LHAU = 0xac000000,
+ PPC_STH = 0xb0000000,
+ PPC_STHU = 0xb4000000,
+ PPC_LMW = 0xb8000000,
+ PPC_STMW = 0xbc000000,
+ PPC_LFS = 0xc0000000,
+ PPC_LFSU = 0xc4000000,
+ PPC_LFD = 0xc8000000,
+ PPC_LFDU = 0xcc000000,
+ PPC_STFS = 0xd0000000,
+ PPC_STFSU = 0xd4000000,
+ PPC_STFD = 0xd8000000,
+ PPC_STFDU = 0xdc000000,
+ PPC_LD = 0xe8000000,
+ PPC_LDU = 0xe8000001,
+ PPC_LWA = 0xe8000002,
+ PPC_FDIVS = 0xec000024,
+ PPC_FSUBS = 0xec000028,
+ PPC_FADDS = 0xec00002a,
+//------------
+ PPC_FSQRTS = 0xec000000,
+ PPC_FRES = 0xec000000,
+ PPC_FMULS = 0xec000032,
+ PPC_FMSUBS = 0xec000000,
+ PPC_FMADDS = 0xec000000,
+ PPC_FNMSUBS = 0xec000000,
+ PPC_FNMADDS = 0xec000000,
+ PPC_STD = 0xf8000000,
+ PPC_STDU = 0xf8000001,
+ PPC_FCMPU = 0xfc000000,
+ PPC_FRSP = 0xfc000018,
+ PPC_FCTIW = 0xfc000000,
+ PPC_FCTIWZ = 0xfc00001e,
+ PPC_FDIV = 0xfc000000,
+ PPC_FSUB = 0xfc000028,
+ PPC_FADD = 0xfc000000,
+ PPC_FSQRT = 0xfc000000,
+ PPC_FSEL = 0xfc000000,
+ PPC_FMUL = 0xfc000000,
+ PPC_FRSQRTE = 0xfc000000,
+ PPC_FMSUB = 0xfc000000,
+ PPC_FMADD = 0xfc000000,
+ PPC_FNMSUB = 0xfc000000,
+ PPC_FNMADD = 0xfc000000,
+ PPC_FCMPO = 0xfc000000,
+ PPC_MTFSB1 = 0xfc000000,
+ PPC_FNEG = 0xfc000050,
+ PPC_MCRFS = 0xfc000000,
+ PPC_MTFSB0 = 0xfc000000,
+ PPC_FMR = 0xfc000000,
+ PPC_MTFSFI = 0xfc000000,
+ PPC_FNABS = 0xfc000000,
+ PPC_FABS = 0xfc000000,
+//------------
+ PPC_MFFS = 0xfc000000,
+ PPC_MTFSF = 0xfc000000,
+ PPC_FCTID = 0xfc000000,
+ PPC_FCTIDZ = 0xfc000000,
+ PPC_FCFID = 0xfc000000
+
+} ppcOpcodes_t;
+
+
+// the newly generated code
+static unsigned *buf;
+static int compiledOfs; // in dwords
+static int pass;
+
+// fromt the original bytecode
+static byte *code;
+static int pc;
+
+void AsmCall( void );
+
+double itofConvert[2];
+
+static int Constant4( void ) {
+ int v;
+
+ v = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);
+ pc += 4;
+ return v;
+}
+
+static int Constant1( void ) {
+ int v;
+
+ v = code[pc];
+ pc += 1;
+ return v;
+}
+
+static void Emit4( char *opname, int i ) {
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("\t\t\t%p %s\t%08lx\n",&buf[compiledOfs],opname,i&0x3ffffff);
+ #endif
+ buf[ compiledOfs ] = i;
+ compiledOfs++;
+}
+
+static void Inst( char *opname, int opcode, int destReg, int aReg, int bReg ) {
+ unsigned r;
+
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("\t\t\t%p %s\tr%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg);
+ #endif
+ r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
+ buf[ compiledOfs ] = r;
+ compiledOfs++;
+}
+
+static void Inst4( char *opname, int opcode, int destReg, int aReg, int bReg, int cReg ) {
+ unsigned r;
+
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("\t\t\t%p %s\tr%d,r%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg,cReg);
+ #endif
+ r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );
+ buf[ compiledOfs ] = r;
+ compiledOfs++;
+}
+
+static void InstImm( char *opname, int opcode, int destReg, int aReg, int immediate ) {
+ unsigned r;
+
+ if ( immediate > 32767 || immediate < -32768 ) {
+ Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range, opcode %x,%d,%d", immediate, opcode, destReg, aReg );
+ }
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
+ #endif
+ r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
+ buf[ compiledOfs ] = r;
+ compiledOfs++;
+}
+
+static void InstImmU( char *opname, int opcode, int destReg, int aReg, int immediate ) {
+ unsigned r;
+
+ if ( immediate > 0xffff || immediate < 0 ) {
+ Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range", immediate );
+ }
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
+ #endif
+ r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
+ buf[ compiledOfs ] = r;
+ compiledOfs++;
+}
+
+static int pop0, pop1, oc0, oc1;
+static vm_t *tvm;
+static int instruction;
+static byte *jused;
+
+static void spillOpStack(int depth)
+{
+ // Store out each register on the operand stack to it's correct location.
+ int i;
+
+ for(i = 0; i < depth; i++)
+ {
+ assert(opStackRegType[i]);
+ assert(opStackRegType[i] == 1);
+ switch(opStackRegType[i])
+ {
+ case 1: // Integer register
+ InstImm( "stw", PPC_STW, opStackIntRegisters[i], R_OPSTACK, i*4+4);
+ break;
+ case 2: // Float register
+ InstImm( "stfs", PPC_STFS, opStackFloatRegisters[i], R_OPSTACK, i*4+4);
+ break;
+ }
+ opStackRegType[i] = 0;
+ }
+}
+
+static void loadOpStack(int depth)
+{
+ // Back off operand stack pointer and reload all operands.
+// InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -(depth)*4 );
+
+ int i;
+
+ for(i = 0; i < depth; i++)
+ {
+ assert(opStackRegType[i] == 0);
+ // For now we're stuck reloading everything as an integer.
+ opStackLoadInstructionAddr[i] = &buf[compiledOfs];
+ InstImm( "lwz", PPC_LWZ, opStackIntRegisters[i], R_OPSTACK, i*4+4);
+ opStackRegType[i] = 1;
+ }
+}
+
+static void makeFloat(int depth)
+{
+ //assert(opStackRegType[depth] == 1);
+ if(opStackRegType[depth] == 1)
+ {
+ unsigned instruction;
+ unsigned destReg, aReg, bReg, imm;
+
+ if(opStackLoadInstructionAddr[depth])
+ {
+ // Repatch load instruction to use LFS instead of LWZ
+ instruction = *opStackLoadInstructionAddr[depth];
+ // Figure out if it's LWZ or LWZX
+ if((instruction & 0xfc000000) == PPC_LWZ)
+ {
+ //printf("patching LWZ at %p to LFS at depth %ld\n",opStackLoadInstructionAddr[depth],depth);
+ //printf("old instruction: %08lx\n",instruction);
+ // Extract registers
+ destReg = (instruction >> 21) & 31;
+ aReg = (instruction >> 16) & 31;
+ imm = instruction & 0xffff;
+
+ // Calculate correct FP register to use.
+ // THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!
+ //printf("old dest: %ld\n",destReg);
+ destReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];
+ instruction = PPC_LFS | ( destReg << 21 ) | ( aReg << 16 ) | imm ;
+ //printf("new dest: %ld\n",destReg);
+ //printf("new instruction: %08lx\n",instruction);
+ }
+ else
+ {
+ //printf("patching LWZX at %p to LFSX at depth %ld\n",opStackLoadInstructionAddr[depth],depth);
+ //printf("old instruction: %08lx\n",instruction);
+ // Extract registers
+ destReg = (instruction >> 21) & 31;
+ aReg = (instruction >> 16) & 31;
+ bReg = (instruction >> 11) & 31;
+ // Calculate correct FP register to use.
+ // THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!
+ //printf("old dest: %ld\n",destReg);
+ destReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];
+ instruction = PPC_LFSX | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
+ //printf("new dest: %ld\n",destReg);
+ //printf("new instruction: %08lx\n",instruction);
+ }
+ *opStackLoadInstructionAddr[depth] = instruction;
+ opStackLoadInstructionAddr[depth] = 0;
+ }
+ else
+ {
+ //printf("doing float constant load at %p for depth %ld\n",&buf[compiledOfs],depth);
+ // It was likely loaded as a constant so we have to save/load it. A more
+ // interesting implementation might be to generate code to do a "PC relative"
+ // load from the VM code region.
+ InstImm( "stw", PPC_STW, opStackIntRegisters[depth], R_OPSTACK, depth*4+4);
+ // For XXX make sure we force enough NOPs to get the load into
+ // another dispatch group to avoid pipeline flush.
+ Inst( "ori", PPC_ORI, 0, 0, 0 );
+ Inst( "ori", PPC_ORI, 0, 0, 0 );
+ Inst( "ori", PPC_ORI, 0, 0, 0 );
+ Inst( "ori", PPC_ORI, 0, 0, 0 );
+ InstImm( "lfs", PPC_LFS, opStackFloatRegisters[depth], R_OPSTACK, depth*4+4);
+ }
+ opStackRegType[depth] = 2;
+ }
+}
+
+// TJW: Unused
+#if 0
+static void fltop() {
+ if (rtopped == qfalse) {
+ InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
+ }
+}
+#endif
+
+#if 0
+static void fltopandsecond() {
+ InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
+ InstImm( PPC_LFS, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
+ InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
+ rtopped = qfalse;
+ return;
+}
+#endif
+
+#define assertInteger(depth) assert(opStackRegType[depth] == 1)
+
+/*
+=================
+VM_Compile
+=================
+*/
+void VM_Compile( vm_t *vm, vmHeader_t *header ) {
+ int op;
+ int maxLength;
+ int v;
+ int i;
+ int opStackDepth;
+
+ int mainFunction;
+
+ // set up the into-to-float variables
+ ((int *)itofConvert)[0] = 0x43300000;
+ ((int *)itofConvert)[1] = 0x80000000;
+ ((int *)itofConvert)[2] = 0x43300000;
+
+ // allocate a very large temp buffer, we will shrink it later
+ maxLength = header->codeLength * 8;
+ buf = Z_Malloc( maxLength );
+ jused = Z_Malloc(header->instructionCount + 2);
+ Com_Memset(jused, 0, header->instructionCount+2);
+
+ // compile everything twice, so the second pass will have valid instruction
+ // pointers for branches
+ for ( pass = -1 ; pass < 2 ; pass++ ) {
+
+ // translate all instructions
+ pc = 0;
+ mainFunction = 0;
+ opStackDepth = 0;
+
+ pop0 = 343545;
+ pop1 = 2443545;
+ oc0 = -2343535;
+ oc1 = 24353454;
+ tvm = vm;
+ code = (byte *)header + header->codeOffset;
+ compiledOfs = 0;
+#ifndef __GNUC__
+ // metrowerks seems to require this header in front of functions
+ Emit4( (int)(buf+2) );
+ Emit4( 0 );
+#endif
+
+ for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
+ if ( compiledOfs*4 > maxLength - 16 ) {
+ Com_Error( ERR_DROP, "VM_Compile: maxLength exceeded" );
+ }
+
+ op = code[ pc ];
+ if ( !pass ) {
+ vm->instructionPointers[ instruction ] = compiledOfs * 4;
+ }
+ pc++;
+ switch ( op ) {
+ case 0:
+ break;
+ case OP_BREAK:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08lx BREAK\n",instruction);
+ #endif
+ InstImmU( "addi", PPC_ADDI, R_TOP, 0, 0 );
+ InstImm( "lwz", PPC_LWZ, R_TOP, R_TOP, 0 ); // *(int *)0 to crash to debugger
+ break;
+ case OP_ENTER:
+ opStackDepth = 0;
+ v = Constant4();
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x ENTER\t%04x\n",instruction,v);
+ #endif
+ opStackRegType[opStackDepth] = 0;
+ mainFunction++;
+ if(mainFunction == 1)
+ {
+ // Main VM entry point is the first thing we compile, so save off operand stack
+ // registers here. This avoids issues with trying to trick the native compiler
+ // into doing it, and properly matches the PowerPC ABI
+ InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, -OP_STACK_MAX_DEPTH*4 ); // sub R_STACK, R_STACK, imm
+ for(i = 0; i < OP_STACK_MAX_DEPTH; i++)
+ InstImm( "stw", PPC_STW, opStackIntRegisters[i], R_REAL_STACK, i*4);
+ }
+ InstImm( "addi", PPC_ADDI, R_STACK, R_STACK, -v ); // sub R_STACK, R_STACK, imm
+ break;
+ case OP_CONST:
+ v = Constant4();
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x CONST\t%08x\n",instruction,v);
+ #endif
+ opStackLoadInstructionAddr[opStackDepth] = 0;
+ if ( v < 32768 && v >= -32768 ) {
+ InstImmU( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], 0, v & 0xffff );
+ } else {
+ InstImmU( "addis", PPC_ADDIS, opStackIntRegisters[opStackDepth], 0, (v >> 16)&0xffff );
+ if ( v & 0xffff ) {
+ InstImmU( "ori", PPC_ORI, opStackIntRegisters[opStackDepth], opStackIntRegisters[opStackDepth], v & 0xffff );
+ }
+ }
+ opStackRegType[opStackDepth] = 1;
+ opStackDepth += 1;
+ if (code[pc] == OP_JUMP) {
+ jused[v] = 1;
+ }
+ break;
+ case OP_LOCAL:
+ oc1 = Constant4();
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LOCAL\t%08x\n",instruction,oc1);
+ #endif
+ if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
+ oc1 &= vm->dataMask;
+ }
+ InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], R_STACK, oc1 );
+ opStackRegType[opStackDepth] = 1;
+ opStackLoadInstructionAddr[opStackDepth] = 0;
+ opStackDepth += 1;
+ break;
+ case OP_ARG:
+ v = Constant1();
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x ARG \t%08x\n",instruction,v);
+ #endif
+ InstImm( "addi", PPC_ADDI, R_EA, R_STACK, v ); // location to put it
+ if(opStackRegType[opStackDepth-1] == 1)
+ Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1], R_EA, R_MEMBASE );
+ else
+ Inst( "stfsx", PPC_STFSX, opStackFloatRegisters[opStackDepth-1], R_EA, R_MEMBASE );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+
+ break;
+ case OP_CALL:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x CALL\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assert(opStackDepth > 0);
+ Inst( "mflr", PPC_MFSPR, R_SECOND, 8, 0 ); // move from link register
+ InstImm( "stwu", PPC_STWU, R_SECOND, R_REAL_STACK, -16 ); // save off the old return address
+
+ // Spill operand stack registers.
+ spillOpStack(opStackDepth);
+
+ // We need to leave R_OPSTACK pointing to the top entry on the stack, which is the call address.
+ // It will be consumed (and R4 decremented) by the AsmCall code.
+ InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);
+
+ Inst( "mtctr", PPC_MTSPR, R_ASMCALL, 9, 0 ); // move to count register
+ Inst( "bctrl", PPC_BCCTR | 1, 20, 0, 0 ); // jump and link to the count register
+
+ // R4 now points to the top of the operand stack, which has the return value in it. We want to
+ // back off the pointer to point to the base of our local operand stack and then reload the stack.
+
+ InstImm("addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);
+
+ // Reload operand stack.
+ loadOpStack(opStackDepth);
+
+ InstImm( "lwz", PPC_LWZ, R_SECOND, R_REAL_STACK, 0 ); // fetch the old return address
+ InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );
+ Inst( "mtlr", PPC_MTSPR, R_SECOND, 8, 0 ); // move to link register
+ break;
+ case OP_PUSH:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x PUSH\n",instruction);
+ #endif
+ opStackRegType[opStackDepth] = 1; // Garbage int value.
+ opStackDepth += 1;
+ break;
+ case OP_POP:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x POP\n",instruction);
+ #endif
+ opStackDepth -= 1;
+ opStackRegType[opStackDepth] = 0; // ??
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_LEAVE:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LEAVE\n",instruction);
+ #endif
+ assert(opStackDepth == 1);
+ assert(opStackRegType[0] != 0);
+ // Save return value onto top of op stack. We also have to increment R_OPSTACK
+ switch(opStackRegType[0])
+ {
+ case 1: // Integer register
+ InstImm( "stw", PPC_STWU, opStackIntRegisters[0], R_OPSTACK, 4);
+ break;
+ case 2: // Float register
+ InstImm( "stfs", PPC_STFSU, opStackFloatRegisters[0], R_OPSTACK, 4);
+ break;
+ }
+ InstImm( "addi", PPC_ADDI, R_STACK, R_STACK, Constant4() ); // add R_STACK, R_STACK, imm
+ if(mainFunction == 1)
+ {
+ for(i = 0; i < OP_STACK_MAX_DEPTH; i++)
+ InstImm( "lwz", PPC_LWZ, opStackIntRegisters[i], R_REAL_STACK, i*4);
+ InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, OP_STACK_MAX_DEPTH*4 );
+ }
+ opStackDepth--;
+ opStackRegType[opStackDepth] = 0;
+ opStackLoadInstructionAddr[opStackDepth] = 0;
+ Inst( "blr", PPC_BCLR, 20, 0, 0 ); // branch unconditionally to link register
+ break;
+ case OP_LOAD4:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LOAD4\n",instruction);
+ #endif
+ // We should try to figure out whether to use LWZX or LFSX based
+ // on some kind of code analysis after subsequent passes. I think what
+ // we could do is store the compiled load instruction address along with
+ // the register type. When we hit the first mismatched operator, we go back
+ // and patch the load. Since LCC's operand stack should be at 0 depth by the
+ // time we hit a branch, this should work fairly well. FIXME FIXME FIXME.
+ assertInteger(opStackDepth-1);
+ opStackLoadInstructionAddr[opStackDepth-1] = &buf[ compiledOfs ];
+ Inst( "lwzx", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
+ opStackRegType[opStackDepth-1] = 1;
+ break;
+ case OP_LOAD2:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LOAD2\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ Inst( "lhzx", PPC_LHZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
+ opStackRegType[opStackDepth-1] = 1;
+ break;
+ case OP_LOAD1:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LOAD1\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ Inst( "lbzx", PPC_LBZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
+ opStackRegType[opStackDepth-1] = 1;
+ break;
+ case OP_STORE4:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x STORE4\n",instruction);
+ #endif
+ assertInteger(opStackDepth-2);
+ if(opStackRegType[opStackDepth-1] == 1)
+ Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1],
+ opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
+ else
+ Inst( "stfsx", PPC_STFSX, opStackFloatRegisters[opStackDepth-1],
+ opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ break;
+ case OP_STORE2:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x STORE2\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "sthx", PPC_STHX, opStackIntRegisters[opStackDepth-1],
+ opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ break;
+ case OP_STORE1:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x STORE1\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "stbx", PPC_STBX, opStackIntRegisters[opStackDepth-1],
+ opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ break;
+
+ case OP_EQ:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x EQ\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 2, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (v&0x3ffffff) );
+ break;
+ case OP_NE:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x NE\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 2, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 2, v );
+
+ break;
+ case OP_LTI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LTI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
+ break;
+ case OP_LEI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LEI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
+ break;
+ case OP_GTI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GTI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
+ break;
+ case OP_GEI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GEI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
+ break;
+ case OP_LTU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LTU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
+ break;
+ case OP_LEU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LEU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
+ break;
+ case OP_GTU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GTU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
+ break;
+ case OP_GEU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GEU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
+ break;
+
+ case OP_EQF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x EQF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 2, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 2, v );
+ break;
+ case OP_NEF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x NEF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 2, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 2, v );
+ break;
+ case OP_LTF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LTF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
+ break;
+ case OP_LEF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LEF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
+ break;
+ case OP_GTF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GTF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 4, 1, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
+ break;
+ case OP_GEF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x GEF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ i = Constant4();
+ jused[i] = 1;
+ InstImm( "bc", PPC_BC, 12, 0, 8 );
+ if ( pass==1 ) {
+ v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
+ } else {
+ v = 0;
+ }
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
+ break;
+
+ case OP_NEGI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x NEGI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ InstImm( "subfic", PPC_SUBFIC, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_ADD:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x ADD\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_SUB:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x SUB\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_DIVI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x DIVI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "divw", PPC_DIVW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_DIVU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x DIVU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "divwu", PPC_DIVWU, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_MODI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x MODI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "divw", PPC_DIVW, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ Inst( "mullw", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );
+ Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_MODU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x MODU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "divwu", PPC_DIVWU, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ Inst( "mullw", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );
+ Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_MULI:
+ case OP_MULU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x MULI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "mullw", PPC_MULLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_BAND:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x BAND\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "and", PPC_AND, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_BOR:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x BOR\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "or", PPC_OR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_BXOR:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x BXOR\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "xor", PPC_XOR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_BCOM:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x BCOM\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ Inst( "nor", PPC_NOR, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1] );
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_LSH:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x LSH\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "slw", PPC_SLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_RSHI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x RSHI\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "sraw", PPC_SRAW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_RSHU:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x RSHU\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ Inst( "srw", PPC_SRW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+
+ case OP_NEGF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x NEGF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ Inst( "fneg", PPC_FNEG, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_ADDF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x ADDF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fadds", PPC_FADDS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_SUBF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x SUBF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fsubs", PPC_FSUBS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_DIVF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x DIVF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst( "fdivs", PPC_FDIVS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ case OP_MULF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x MULF\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+ makeFloat(opStackDepth-2);
+ Inst4( "fmuls", PPC_FMULS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], 0, opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+
+ case OP_CVIF:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x CVIF\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ //makeInteger(opStackDepth-1);
+ v = (int)&itofConvert;
+ InstImmU( "addis", PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );
+ InstImmU( "ori", PPC_ORI, R_EA, R_EA, v & 0xffff );
+ InstImmU( "xoris", PPC_XORIS, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0x8000 );
+ InstImm( "stw", PPC_STW, opStackIntRegisters[opStackDepth-1], R_EA, 12 );
+ InstImm( "lfd", PPC_LFD, opStackFloatRegisters[opStackDepth-1], R_EA, 0 );
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ InstImm( "lfd", PPC_LFD, 13, R_EA, 8 );
+ Inst( "fsub", PPC_FSUB, opStackFloatRegisters[opStackDepth-1], 13, opStackFloatRegisters[opStackDepth-1] );
+ opStackRegType[opStackDepth-1] = 2;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ // Inst( PPC_FRSP, R_TOP, 0, R_TOP );
+ break;
+ case OP_CVFI:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x CVFI\n",instruction);
+ #endif
+ makeFloat(opStackDepth-1);
+
+ InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);
+
+ Inst( "fctiwz", PPC_FCTIWZ, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );
+ Inst( "stfiwx", PPC_STFIWX, opStackFloatRegisters[opStackDepth-1], 0, R_OPSTACK ); // save value to opstack (dummy area now)
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ Inst( "ori", PPC_ORI, 0, 0, 0);
+ InstImm( "lwz", PPC_LWZ, opStackIntRegisters[opStackDepth-1], R_OPSTACK, 0 );
+
+ InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);
+
+ opStackRegType[opStackDepth-1] = 1;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_SEX8:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x SEX8\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ Inst( "extsb", PPC_EXTSB, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+ case OP_SEX16:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x SEX16\n",instruction);
+ #endif
+ assertInteger(opStackDepth-1);
+ Inst( "extsh", PPC_EXTSH, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ break;
+
+ case OP_BLOCK_COPY:
+ v = Constant4() >> 2;
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x BLOCK_COPY\t%08lx\n",instruction,v<<2);
+ #endif
+ assert(opStackDepth >= 2);
+ assertInteger(opStackDepth-1);
+ assertInteger(opStackDepth-2);
+ InstImmU( "addi", PPC_ADDI, R_EA, 0, v ); // count
+ // FIXME: range check
+ Inst( "mtctr", PPC_MTSPR, R_EA, 9, 0 ); // move to count register
+
+ Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );
+ InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], -4 );
+ Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], R_MEMBASE );
+ InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], -4 );
+
+ InstImm( "lwzu", PPC_LWZU, R_EA, opStackIntRegisters[opStackDepth-1], 4 ); // source
+ InstImm( "stwu", PPC_STWU, R_EA, opStackIntRegisters[opStackDepth-2], 4 ); // dest
+ Inst( "b", PPC_BC | 0xfff8 , 16, 0, 0 ); // loop
+ opStackRegType[opStackDepth-1] = 0;
+ opStackRegType[opStackDepth-2] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-2] = 0;
+ opStackDepth -= 2;
+ break;
+
+ case OP_JUMP:
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x JUMP\n",instruction);
+ #endif
+ assert(opStackDepth == 1);
+ assertInteger(opStackDepth-1);
+
+ Inst( "rlwinm", PPC_RLWINM | ( 29 << 1 ), opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 2 );
+ // FIXME: range check
+ Inst( "lwzx", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_INSTRUCTIONS );
+ Inst( "mtctr", PPC_MTSPR, opStackIntRegisters[opStackDepth-1], 9, 0 ); // move to count register
+ Inst( "bctr", PPC_BCCTR, 20, 0, 0 ); // jump to the count register
+ opStackRegType[opStackDepth-1] = 0;
+ opStackLoadInstructionAddr[opStackDepth-1] = 0;
+ opStackDepth -= 1;
+ break;
+ default:
+ Com_Error( ERR_DROP, "VM_CompilePPC: bad opcode %i at instruction %i, offset %i", op, instruction, pc );
+ }
+ pop0 = pop1;
+ pop1 = op;
+ assert(opStackDepth >= 0);
+ assert(opStackDepth < OP_STACK_MAX_DEPTH);
+
+ //printf("%4d\t%s\n",opStackDepth,opnames[op]);
+ }
+
+ Com_Printf( "VM file %s pass %d compiled to %i bytes of code\n", vm->name, (pass+1), compiledOfs*4 );
+
+ if ( pass == 0 ) {
+ // copy to an exact size buffer on the hunk
+ vm->codeLength = compiledOfs * 4;
+ vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );
+ Com_Memcpy( vm->codeBase, buf, vm->codeLength );
+
+ //printf("codeBase: %p\n",vm->codeBase);
+
+ Z_Free( buf );
+
+ // offset all the instruction pointers for the new location
+ for ( i = 0 ; i < header->instructionCount ; i++ ) {
+ vm->instructionPointers[i] += (int)vm->codeBase;
+ //printf("%08x %08lx\n",i,vm->instructionPointers[i]);
+ }
+
+ // go back over it in place now to fixup reletive jump targets
+ buf = (unsigned *)vm->codeBase;
+ } else if ( pass == 1 ) {
+ // clear the instruction cache for generated code
+ msync(vm->codeBase, vm->codeLength, MS_INVALIDATE);
+ }
+ }
+ if(0)
+ {
+ char buf[256];
+ printf("wait..\n");
+ gets(buf);
+ }
+ Z_Free( jused );
+}
+
+/*
+==============
+VM_CallCompiled
+
+This function is called directly by the generated code
+==============
+*/
+int VM_CallCompiled( vm_t *vm, int *args ) {
+ int stack[1024];
+ int programStack;
+ int stackOnEntry;
+ byte *image;
+
+ currentVM = vm;
+
+ //printf("VM_CallCompiled: %p %08lx %08lx %08lx\n",
+ // vm, args[0],args[1],args[2]);
+
+ // interpret the code
+ vm->currentlyInterpreting = qtrue;
+
+ // we might be called recursively, so this might not be the very top
+ programStack = vm->programStack;
+ stackOnEntry = programStack;
+ image = vm->dataBase;
+
+ // set up the stack frame
+ programStack -= 48;
+
+ *(int *)&image[ programStack + 44] = args[9];
+ *(int *)&image[ programStack + 40] = args[8];
+ *(int *)&image[ programStack + 36] = args[7];
+ *(int *)&image[ programStack + 32] = args[6];
+ *(int *)&image[ programStack + 28] = args[5];
+ *(int *)&image[ programStack + 24] = args[4];
+ *(int *)&image[ programStack + 20] = args[3];
+ *(int *)&image[ programStack + 16] = args[2];
+ *(int *)&image[ programStack + 12] = args[1];
+ *(int *)&image[ programStack + 8 ] = args[0];
+ *(int *)&image[ programStack + 4 ] = 0; // return stack
+ *(int *)&image[ programStack ] = -1; // will terminate the loop on return
+
+ // Cheesy... manually save registers used by VM call...
+ // off we go into generated code...
+ // the PPC calling standard says the parms will all go into R3 - R11, so
+ // no special asm code is needed here
+#ifdef __GNUC__
+ ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
+ programStack, (int)&stack,
+ (int)image, vm->dataMask, (int)&AsmCall,
+ (int)vm->instructionPointers, vm->instructionPointersLength,
+ (int)vm );
+#else
+ ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
+ programStack, (int)&stack,
+ (int)image, vm->dataMask, *(int *)&AsmCall /* skip function pointer header */,
+ (int)vm->instructionPointers, vm->instructionPointersLength,
+ (int)vm );
+#endif
+ vm->programStack = stackOnEntry;
+
+ vm->currentlyInterpreting = qfalse;
+
+ return stack[1];
+}
+
+
+/*
+==================
+AsmCall
+
+Put this at end of file because gcc messes up debug line numbers
+==================
+*/
+#ifdef __GNUC__
+
+void AsmCall( void ) {
+asm (
+ // pop off the destination instruction
+" lwz r12,0(r4) \n" // RG_TOP, 0(RG_OPSTACK)
+" addi r4,r4,-4 \n" // RG_OPSTACK, RG_OPSTACK, -4 \n"
+
+ // see if it is a system trap
+" cmpwi r12,0 \n" // RG_TOP, 0 \n"
+" bc 12,0, systemTrap \n"
+
+ // calling another VM function, so lookup in instructionPointers
+" slwi r12,r12,2 \n" // RG_TOP,RG_TOP,2
+ // FIXME: range check
+" lwzx r12, r8, r12 \n" // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
+" mtctr r12 \n" // RG_TOP
+);
+
+#if defined(MACOS_X) && defined(__OPTIMIZE__)
+ // On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.
+//#warning Mac OS X optimization on, not popping GCC AsmCall frame
+#else
+ // Mac OS X Server and unoptimized compiles include a GCC AsmCall frame
+ asm (
+" lwz r1,0(r1) \n" // pop off the GCC AsmCall frame
+" lmw r30,-8(r1) \n"
+);
+#endif
+
+asm (
+" bcctr 20,0 \n" // when it hits a leave, it will branch to the current link register
+
+ // calling a system trap
+"systemTrap: \n"
+ // convert to positive system call number
+" subfic r12,r12,-1 \n"
+
+ // save all our registers, including the current link register
+" mflr r13 \n" // RG_SECOND // copy off our link register
+" addi r1,r1,-92 \n" // required 24 byets of linkage, 32 bytes of parameter, plus our saves
+" stw r3,56(r1) \n" // RG_STACK, -36(REAL_STACK)
+" stw r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
+" stw r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
+" stw r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
+" stw r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
+" stw r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
+" stw r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
+" stw r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
+" stw r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK) // link register
+
+ // save the vm stack position to allow recursive VM entry
+" addi r13,r3,-4 \n" // RG_TOP, RG_STACK, -4
+" stw r13,0(r10) \n" //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
+
+ // save the system call number as the 0th parameter
+" add r3,r3,r5 \n" // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
+" stwu r12,4(r3) \n" // RG_TOP, 4(r3)
+
+ // make the system call with the address of all the VM parms as a parameter
+ // vm->systemCalls( &parms )
+" lwz r12,4(r10) \n" // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
+" mtctr r12 \n" // RG_TOP
+" bcctrl 20,0 \n"
+" mr r12,r3 \n" // RG_TOP, r3
+
+ // pop our saved registers
+" lwz r3,56(r1) \n" // RG_STACK, 0(RG_REAL_STACK)
+" lwz r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
+" lwz r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
+" lwz r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
+" lwz r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
+" lwz r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
+" lwz r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
+" lwz r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
+" lwz r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK)
+" addi r1,r1,92 \n" // RG_REAL_STACK, RG_REAL_STACK, 36
+
+ // restore the old link register
+" mtlr r13 \n" // RG_SECOND
+
+ // save off the return value
+" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
+
+ // GCC adds its own prolog / epliog code
+ );
+}
+#else
+
+// codewarrior version
+
+void asm AsmCall( void ) {
+
+ // pop off the destination instruction
+
+ lwz r12,0(r4) // RG_TOP, 0(RG_OPSTACK)
+
+ addi r4,r4,-4 // RG_OPSTACK, RG_OPSTACK, -4
+
+
+
+ // see if it is a system trap
+
+ cmpwi r12,0 // RG_TOP, 0
+
+ bc 12,0, systemTrap
+
+
+
+ // calling another VM function, so lookup in instructionPointers
+
+ slwi r12,r12,2 // RG_TOP,RG_TOP,2
+
+ // FIXME: range check
+
+ lwzx r12, r8, r12 // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
+
+ mtctr r12 // RG_TOP
+
+
+
+ bcctr 20,0 // when it hits a leave, it will branch to the current link register
+
+
+
+ // calling a system trap
+
+systemTrap:
+
+ // convert to positive system call number
+
+ subfic r12,r12,-1
+
+
+
+ // save all our registers, including the current link register
+
+ mflr r13 // RG_SECOND // copy off our link register
+
+ addi r1,r1,-92 // required 24 byets of linkage, 32 bytes of parameter, plus our saves
+
+ stw r3,56(r1) // RG_STACK, -36(REAL_STACK)
+
+ stw r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
+
+ stw r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
+
+ stw r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
+
+ stw r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
+
+ stw r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
+
+ stw r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
+
+ stw r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
+
+ stw r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK) // link register
+
+
+
+ // save the vm stack position to allow recursive VM entry
+
+ addi r13,r3,-4 // RG_TOP, RG_STACK, -4
+
+ stw r13,0(r10) //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
+
+
+
+ // save the system call number as the 0th parameter
+
+ add r3,r3,r5 // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
+
+ stwu r12,4(r3) // RG_TOP, 4(r3)
+
+
+
+ // make the system call with the address of all the VM parms as a parameter
+
+ // vm->systemCalls( &parms )
+
+ lwz r12,4(r10) // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
+
+
+
+ // perform macos cross fragment fixup crap
+
+ lwz r9,0(r12)
+
+ stw r2,52(r1) // save old TOC
+
+ lwz r2,4(r12)
+
+
+
+ mtctr r9 // RG_TOP
+
+ bcctrl 20,0
+
+
+
+ lwz r2,52(r1) // restore TOC
+
+
+
+ mr r12,r3 // RG_TOP, r3
+
+
+
+ // pop our saved registers
+
+ lwz r3,56(r1) // RG_STACK, 0(RG_REAL_STACK)
+
+ lwz r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
+
+ lwz r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
+
+ lwz r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
+
+ lwz r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
+
+ lwz r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
+
+ lwz r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
+
+ lwz r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
+
+ lwz r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK)
+
+ addi r1,r1,92 // RG_REAL_STACK, RG_REAL_STACK, 36
+
+
+
+ // restore the old link register
+
+ mtlr r13 // RG_SECOND
+
+
+
+ // save off the return value
+
+ stwu r12,4(r4) // RG_TOP, 0(RG_OPSTACK)
+
+
+
+ blr
+
+}
+
+
+
+
+#endif
Deleted: branches/1.34/code/qcommon/vm_ppc_new.c
===================================================================
--- branches/1.34/code/qcommon/vm_ppc_new.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm_ppc_new.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,2071 +0,0 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code 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.
-
-Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-// vm_ppc.c
-// ppc dynamic compiler
-
-#include "vm_local.h"
-
-#ifdef MACOS_X
-#include <CoreServices/CoreServices.h>
-#endif
-
-#define DEBUG_VM 0
-
-#if DEBUG_VM
-static char *opnames[256] = {
- "OP_UNDEF",
-
- "OP_IGNORE",
-
- "OP_BREAK",
-
- "OP_ENTER",
- "OP_LEAVE",
- "OP_CALL",
- "OP_PUSH",
- "OP_POP",
-
- "OP_CONST",
-
- "OP_LOCAL",
-
- "OP_JUMP",
-
- //-------------------
-
- "OP_EQ",
- "OP_NE",
-
- "OP_LTI",
- "OP_LEI",
- "OP_GTI",
- "OP_GEI",
-
- "OP_LTU",
- "OP_LEU",
- "OP_GTU",
- "OP_GEU",
-
- "OP_EQF",
- "OP_NEF",
-
- "OP_LTF",
- "OP_LEF",
- "OP_GTF",
- "OP_GEF",
-
- //-------------------
-
- "OP_LOAD1",
- "OP_LOAD2",
- "OP_LOAD4",
- "OP_STORE1",
- "OP_STORE2",
- "OP_STORE4",
- "OP_ARG",
-
- "OP_BLOCK_COPY",
-
- //-------------------
-
- "OP_SEX8",
- "OP_SEX16",
-
- "OP_NEGI",
- "OP_ADD",
- "OP_SUB",
- "OP_DIVI",
- "OP_DIVU",
- "OP_MODI",
- "OP_MODU",
- "OP_MULI",
- "OP_MULU",
-
- "OP_BAND",
- "OP_BOR",
- "OP_BXOR",
- "OP_BCOM",
-
- "OP_LSH",
- "OP_RSHI",
- "OP_RSHU",
-
- "OP_NEGF",
- "OP_ADDF",
- "OP_SUBF",
- "OP_DIVF",
- "OP_MULF",
-
- "OP_CVIF",
- "OP_CVFI"
-};
-#endif
-
-typedef enum {
- R_REAL_STACK = 1,
- // registers 3-11 are the parameter passing registers
-
- // state
- R_STACK = 3, // local
- R_OPSTACK, // global
-
- // constants
- R_MEMBASE, // global
- R_MEMMASK,
- R_ASMCALL, // global
- R_INSTRUCTIONS, // global
- R_NUM_INSTRUCTIONS, // global
- R_CVM, // currentVM
-
- // temps
- R_TOP = 11,
- R_SECOND = 12,
- R_EA = 2 // effective address calculation
-
-} regNums_t;
-
-#define RG_REAL_STACK r1
-#define RG_STACK r3
-#define RG_OPSTACK r4
-#define RG_MEMBASE r5
-#define RG_MEMMASK r6
-#define RG_ASMCALL r7
-#define RG_INSTRUCTIONS r8
-#define RG_NUM_INSTRUCTIONS r9
-#define RG_CVM r10
-#define RG_TOP r12
-#define RG_SECOND r13
-#define RG_EA r14
-
-// The deepest value I saw in the Quake3 games was 9.
-#define OP_STACK_MAX_DEPTH 16
-
-// These are all volatile and thus must be saved upon entry to the VM code.
-// NOTE: These are General Purpose Registers (GPR) numbers like the
-// R_ definitions in the regNums_t enum above (31 is the max)
-static int opStackIntRegisters[OP_STACK_MAX_DEPTH] =
-{
- 16, 17, 18, 19,
- 20, 21, 22, 23,
- 24, 25, 26, 27,
- 28, 29, 30, 31
-};
-
-static unsigned int *opStackLoadInstructionAddr[OP_STACK_MAX_DEPTH];
-
-// We use different registers for the floating point
-// operand stack (these are volatile in the PPC ABI)
-// NOTE: these are Floating Point Register (FPR) numbers, not
-// General Purpose Register (GPR) numbers
-static int opStackFloatRegisters[OP_STACK_MAX_DEPTH] =
-{
- 0, 1, 2, 3,
- 4, 5, 6, 7,
- 8, 9, 10, 11,
- 12, 13, 14, 15
-};
-
-static int opStackRegType[OP_STACK_MAX_DEPTH] =
-{
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0
-};
-
-// this doesn't have the low order bits set for instructions i'm not using...
-typedef enum {
- PPC_TDI = 0x08000000,
- PPC_TWI = 0x0c000000,
- PPC_MULLI = 0x1c000000,
- PPC_SUBFIC = 0x20000000,
- PPC_CMPI = 0x28000000,
- PPC_CMPLI = 0x2c000000,
- PPC_ADDIC = 0x30000000,
- PPC_ADDIC_ = 0x34000000,
- PPC_ADDI = 0x38000000,
- PPC_ADDIS = 0x3c000000,
- PPC_BC = 0x40000000,
- PPC_SC = 0x44000000,
- PPC_B = 0x48000000,
-
- PPC_MCRF = 0x4c000000,
- PPC_BCLR = 0x4c000020,
- PPC_RFID = 0x4c000000,
- PPC_CRNOR = 0x4c000000,
- PPC_RFI = 0x4c000000,
- PPC_CRANDC = 0x4c000000,
- PPC_ISYNC = 0x4c000000,
- PPC_CRXOR = 0x4c000000,
- PPC_CRNAND = 0x4c000000,
- PPC_CREQV = 0x4c000000,
- PPC_CRORC = 0x4c000000,
- PPC_CROR = 0x4c000000,
-//------------
- PPC_BCCTR = 0x4c000420,
- PPC_RLWIMI = 0x50000000,
- PPC_RLWINM = 0x54000000,
- PPC_RLWNM = 0x5c000000,
- PPC_ORI = 0x60000000,
- PPC_ORIS = 0x64000000,
- PPC_XORI = 0x68000000,
- PPC_XORIS = 0x6c000000,
- PPC_ANDI_ = 0x70000000,
- PPC_ANDIS_ = 0x74000000,
- PPC_RLDICL = 0x78000000,
- PPC_RLDICR = 0x78000000,
- PPC_RLDIC = 0x78000000,
- PPC_RLDIMI = 0x78000000,
- PPC_RLDCL = 0x78000000,
- PPC_RLDCR = 0x78000000,
- PPC_CMP = 0x7c000000,
- PPC_TW = 0x7c000000,
- PPC_SUBFC = 0x7c000010,
- PPC_MULHDU = 0x7c000000,
- PPC_ADDC = 0x7c000014,
- PPC_MULHWU = 0x7c000000,
- PPC_MFCR = 0x7c000000,
- PPC_LWAR = 0x7c000000,
- PPC_LDX = 0x7c000000,
- PPC_LWZX = 0x7c00002e,
- PPC_SLW = 0x7c000030,
- PPC_CNTLZW = 0x7c000000,
- PPC_SLD = 0x7c000000,
- PPC_AND = 0x7c000038,
- PPC_CMPL = 0x7c000040,
- PPC_SUBF = 0x7c000050,
- PPC_LDUX = 0x7c000000,
-//------------
- PPC_DCBST = 0x7c000000,
- PPC_LWZUX = 0x7c00006c,
- PPC_CNTLZD = 0x7c000000,
- PPC_ANDC = 0x7c000000,
- PPC_TD = 0x7c000000,
- PPC_MULHD = 0x7c000000,
- PPC_MULHW = 0x7c000000,
- PPC_MTSRD = 0x7c000000,
- PPC_MFMSR = 0x7c000000,
- PPC_LDARX = 0x7c000000,
- PPC_DCBF = 0x7c000000,
- PPC_LBZX = 0x7c0000ae,
- PPC_NEG = 0x7c000000,
- PPC_MTSRDIN = 0x7c000000,
- PPC_LBZUX = 0x7c000000,
- PPC_NOR = 0x7c0000f8,
- PPC_SUBFE = 0x7c000000,
- PPC_ADDE = 0x7c000000,
- PPC_MTCRF = 0x7c000000,
- PPC_MTMSR = 0x7c000000,
- PPC_STDX = 0x7c000000,
- PPC_STWCX_ = 0x7c000000,
- PPC_STWX = 0x7c00012e,
- PPC_MTMSRD = 0x7c000000,
- PPC_STDUX = 0x7c000000,
- PPC_STWUX = 0x7c00016e,
- PPC_SUBFZE = 0x7c000000,
- PPC_ADDZE = 0x7c000000,
- PPC_MTSR = 0x7c000000,
- PPC_STDCX_ = 0x7c000000,
- PPC_STBX = 0x7c0001ae,
- PPC_SUBFME = 0x7c000000,
- PPC_MULLD = 0x7c000000,
-//------------
- PPC_ADDME = 0x7c000000,
- PPC_MULLW = 0x7c0001d6,
- PPC_MTSRIN = 0x7c000000,
- PPC_DCBTST = 0x7c000000,
- PPC_STBUX = 0x7c000000,
- PPC_ADD = 0x7c000214,
- PPC_DCBT = 0x7c000000,
- PPC_LHZX = 0x7c00022e,
- PPC_EQV = 0x7c000000,
- PPC_TLBIE = 0x7c000000,
- PPC_ECIWX = 0x7c000000,
- PPC_LHZUX = 0x7c000000,
- PPC_XOR = 0x7c000278,
- PPC_MFSPR = 0x7c0002a6,
- PPC_LWAX = 0x7c000000,
- PPC_LHAX = 0x7c000000,
- PPC_TLBIA = 0x7c000000,
- PPC_MFTB = 0x7c000000,
- PPC_LWAUX = 0x7c000000,
- PPC_LHAUX = 0x7c000000,
- PPC_STHX = 0x7c00032e,
- PPC_ORC = 0x7c000338,
- PPC_SRADI = 0x7c000000,
- PPC_SLBIE = 0x7c000000,
- PPC_ECOWX = 0x7c000000,
- PPC_STHUX = 0x7c000000,
- PPC_OR = 0x7c000378,
- PPC_DIVDU = 0x7c000000,
- PPC_DIVWU = 0x7c000396,
- PPC_MTSPR = 0x7c0003a6,
- PPC_DCBI = 0x7c000000,
- PPC_NAND = 0x7c000000,
- PPC_DIVD = 0x7c000000,
-//------------
- PPC_DIVW = 0x7c0003d6,
- PPC_SLBIA = 0x7c000000,
- PPC_MCRXR = 0x7c000000,
- PPC_LSWX = 0x7c000000,
- PPC_LWBRX = 0x7c000000,
- PPC_LFSX = 0x7c00042e,
- PPC_SRW = 0x7c000430,
- PPC_SRD = 0x7c000000,
- PPC_TLBSYNC = 0x7c000000,
- PPC_LFSUX = 0x7c000000,
- PPC_MFSR = 0x7c000000,
- PPC_LSWI = 0x7c000000,
- PPC_SYNC = 0x7c000000,
- PPC_LFDX = 0x7c000000,
- PPC_LFDUX = 0x7c000000,
- PPC_MFSRIN = 0x7c000000,
- PPC_STSWX = 0x7c000000,
- PPC_STWBRX = 0x7c000000,
- PPC_STFSX = 0x7c00052e,
- PPC_STFSUX = 0x7c000000,
- PPC_STSWI = 0x7c000000,
- PPC_STFDX = 0x7c000000,
- PPC_DCBA = 0x7c000000,
- PPC_STFDUX = 0x7c000000,
- PPC_LHBRX = 0x7c000000,
- PPC_SRAW = 0x7c000630,
- PPC_SRAD = 0x7c000000,
- PPC_SRAWI = 0x7c000000,
- PPC_EIEIO = 0x7c000000,
- PPC_STHBRX = 0x7c000000,
- PPC_EXTSH = 0x7c000734,
- PPC_EXTSB = 0x7c000774,
- PPC_ICBI = 0x7c000000,
-//------------
- PPC_STFIWX = 0x7c0007ae,
- PPC_EXTSW = 0x7c000000,
- PPC_DCBZ = 0x7c000000,
- PPC_LWZ = 0x80000000,
- PPC_LWZU = 0x84000000,
- PPC_LBZ = 0x88000000,
- PPC_LBZU = 0x8c000000,
- PPC_STW = 0x90000000,
- PPC_STWU = 0x94000000,
- PPC_STB = 0x98000000,
- PPC_STBU = 0x9c000000,
- PPC_LHZ = 0xa0000000,
- PPC_LHZU = 0xa4000000,
- PPC_LHA = 0xa8000000,
- PPC_LHAU = 0xac000000,
- PPC_STH = 0xb0000000,
- PPC_STHU = 0xb4000000,
- PPC_LMW = 0xb8000000,
- PPC_STMW = 0xbc000000,
- PPC_LFS = 0xc0000000,
- PPC_LFSU = 0xc4000000,
- PPC_LFD = 0xc8000000,
- PPC_LFDU = 0xcc000000,
- PPC_STFS = 0xd0000000,
- PPC_STFSU = 0xd4000000,
- PPC_STFD = 0xd8000000,
- PPC_STFDU = 0xdc000000,
- PPC_LD = 0xe8000000,
- PPC_LDU = 0xe8000001,
- PPC_LWA = 0xe8000002,
- PPC_FDIVS = 0xec000024,
- PPC_FSUBS = 0xec000028,
- PPC_FADDS = 0xec00002a,
-//------------
- PPC_FSQRTS = 0xec000000,
- PPC_FRES = 0xec000000,
- PPC_FMULS = 0xec000032,
- PPC_FMSUBS = 0xec000000,
- PPC_FMADDS = 0xec000000,
- PPC_FNMSUBS = 0xec000000,
- PPC_FNMADDS = 0xec000000,
- PPC_STD = 0xf8000000,
- PPC_STDU = 0xf8000001,
- PPC_FCMPU = 0xfc000000,
- PPC_FRSP = 0xfc000018,
- PPC_FCTIW = 0xfc000000,
- PPC_FCTIWZ = 0xfc00001e,
- PPC_FDIV = 0xfc000000,
- PPC_FSUB = 0xfc000028,
- PPC_FADD = 0xfc000000,
- PPC_FSQRT = 0xfc000000,
- PPC_FSEL = 0xfc000000,
- PPC_FMUL = 0xfc000000,
- PPC_FRSQRTE = 0xfc000000,
- PPC_FMSUB = 0xfc000000,
- PPC_FMADD = 0xfc000000,
- PPC_FNMSUB = 0xfc000000,
- PPC_FNMADD = 0xfc000000,
- PPC_FCMPO = 0xfc000000,
- PPC_MTFSB1 = 0xfc000000,
- PPC_FNEG = 0xfc000050,
- PPC_MCRFS = 0xfc000000,
- PPC_MTFSB0 = 0xfc000000,
- PPC_FMR = 0xfc000000,
- PPC_MTFSFI = 0xfc000000,
- PPC_FNABS = 0xfc000000,
- PPC_FABS = 0xfc000000,
-//------------
- PPC_MFFS = 0xfc000000,
- PPC_MTFSF = 0xfc000000,
- PPC_FCTID = 0xfc000000,
- PPC_FCTIDZ = 0xfc000000,
- PPC_FCFID = 0xfc000000
-
-} ppcOpcodes_t;
-
-
-// the newly generated code
-static unsigned *buf;
-static int compiledOfs; // in dwords
-static int pass;
-
-// fromt the original bytecode
-static byte *code;
-static int pc;
-
-void AsmCall( void );
-
-double itofConvert[2];
-
-static int Constant4( void ) {
- int v;
-
- v = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);
- pc += 4;
- return v;
-}
-
-static int Constant1( void ) {
- int v;
-
- v = code[pc];
- pc += 1;
- return v;
-}
-
-static void Emit4( char *opname, int i ) {
- #if DEBUG_VM
- if(pass == 1)
- printf("\t\t\t%p %s\t%08lx\n",&buf[compiledOfs],opname,i&0x3ffffff);
- #endif
- buf[ compiledOfs ] = i;
- compiledOfs++;
-}
-
-static void Inst( char *opname, int opcode, int destReg, int aReg, int bReg ) {
- unsigned r;
-
- #if DEBUG_VM
- if(pass == 1)
- printf("\t\t\t%p %s\tr%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg);
- #endif
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void Inst4( char *opname, int opcode, int destReg, int aReg, int bReg, int cReg ) {
- unsigned r;
-
- #if DEBUG_VM
- if(pass == 1)
- printf("\t\t\t%p %s\tr%d,r%d,r%d,r%d\n",&buf[compiledOfs],opname,destReg,aReg,bReg,cReg);
- #endif
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void InstImm( char *opname, int opcode, int destReg, int aReg, int immediate ) {
- unsigned r;
-
- if ( immediate > 32767 || immediate < -32768 ) {
- Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range, opcode %x,%d,%d", immediate, opcode, destReg, aReg );
- }
- #if DEBUG_VM
- if(pass == 1)
- printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
- #endif
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static void InstImmU( char *opname, int opcode, int destReg, int aReg, int immediate ) {
- unsigned r;
-
- if ( immediate > 0xffff || immediate < 0 ) {
- Com_Error( ERR_FATAL, "VM_Compile: immediate value %i out of range", immediate );
- }
- #if DEBUG_VM
- if(pass == 1)
- printf("\t\t\t%p %s\tr%d,r%d,0x%x\n",&buf[compiledOfs],opname,destReg,aReg,immediate);
- #endif
- r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );
- buf[ compiledOfs ] = r;
- compiledOfs++;
-}
-
-static int pop0, pop1, oc0, oc1;
-static vm_t *tvm;
-static int instruction;
-static byte *jused;
-
-static void spillOpStack(int depth)
-{
- // Store out each register on the operand stack to it's correct location.
- int i;
-
- for(i = 0; i < depth; i++)
- {
- assert(opStackRegType[i]);
- assert(opStackRegType[i] == 1);
- switch(opStackRegType[i])
- {
- case 1: // Integer register
- InstImm( "stw", PPC_STW, opStackIntRegisters[i], R_OPSTACK, i*4+4);
- break;
- case 2: // Float register
- InstImm( "stfs", PPC_STFS, opStackFloatRegisters[i], R_OPSTACK, i*4+4);
- break;
- }
- opStackRegType[i] = 0;
- }
-}
-
-static void loadOpStack(int depth)
-{
- // Back off operand stack pointer and reload all operands.
-// InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -(depth)*4 );
-
- int i;
-
- for(i = 0; i < depth; i++)
- {
- assert(opStackRegType[i] == 0);
- // For now we're stuck reloading everything as an integer.
- opStackLoadInstructionAddr[i] = &buf[compiledOfs];
- InstImm( "lwz", PPC_LWZ, opStackIntRegisters[i], R_OPSTACK, i*4+4);
- opStackRegType[i] = 1;
- }
-}
-
-static void makeFloat(int depth)
-{
- //assert(opStackRegType[depth] == 1);
- if(opStackRegType[depth] == 1)
- {
- unsigned instruction;
- unsigned destReg, aReg, bReg, imm;
-
- if(opStackLoadInstructionAddr[depth])
- {
- // Repatch load instruction to use LFS instead of LWZ
- instruction = *opStackLoadInstructionAddr[depth];
- // Figure out if it's LWZ or LWZX
- if((instruction & 0xfc000000) == PPC_LWZ)
- {
- //printf("patching LWZ at %p to LFS at depth %ld\n",opStackLoadInstructionAddr[depth],depth);
- //printf("old instruction: %08lx\n",instruction);
- // Extract registers
- destReg = (instruction >> 21) & 31;
- aReg = (instruction >> 16) & 31;
- imm = instruction & 0xffff;
-
- // Calculate correct FP register to use.
- // THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!
- //printf("old dest: %ld\n",destReg);
- destReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];
- instruction = PPC_LFS | ( destReg << 21 ) | ( aReg << 16 ) | imm ;
- //printf("new dest: %ld\n",destReg);
- //printf("new instruction: %08lx\n",instruction);
- }
- else
- {
- //printf("patching LWZX at %p to LFSX at depth %ld\n",opStackLoadInstructionAddr[depth],depth);
- //printf("old instruction: %08lx\n",instruction);
- // Extract registers
- destReg = (instruction >> 21) & 31;
- aReg = (instruction >> 16) & 31;
- bReg = (instruction >> 11) & 31;
- // Calculate correct FP register to use.
- // THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!
- //printf("old dest: %ld\n",destReg);
- destReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];
- instruction = PPC_LFSX | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;
- //printf("new dest: %ld\n",destReg);
- //printf("new instruction: %08lx\n",instruction);
- }
- *opStackLoadInstructionAddr[depth] = instruction;
- opStackLoadInstructionAddr[depth] = 0;
- }
- else
- {
- //printf("doing float constant load at %p for depth %ld\n",&buf[compiledOfs],depth);
- // It was likely loaded as a constant so we have to save/load it. A more
- // interesting implementation might be to generate code to do a "PC relative"
- // load from the VM code region.
- InstImm( "stw", PPC_STW, opStackIntRegisters[depth], R_OPSTACK, depth*4+4);
- // For XXX make sure we force enough NOPs to get the load into
- // another dispatch group to avoid pipeline flush.
- Inst( "ori", PPC_ORI, 0, 0, 0 );
- Inst( "ori", PPC_ORI, 0, 0, 0 );
- Inst( "ori", PPC_ORI, 0, 0, 0 );
- Inst( "ori", PPC_ORI, 0, 0, 0 );
- InstImm( "lfs", PPC_LFS, opStackFloatRegisters[depth], R_OPSTACK, depth*4+4);
- }
- opStackRegType[depth] = 2;
- }
-}
-
-// TJW: Unused
-#if 0
-static void fltop() {
- if (rtopped == qfalse) {
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- }
-}
-#endif
-
-#if 0
-static void fltopandsecond() {
- InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 ); // get value from opstack
- InstImm( PPC_LFS, R_SECOND, R_OPSTACK, -4 ); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );
- rtopped = qfalse;
- return;
-}
-#endif
-
-#define assertInteger(depth) assert(opStackRegType[depth] == 1)
-
-/*
-=================
-VM_Compile
-=================
-*/
-void VM_Compile( vm_t *vm, vmHeader_t *header ) {
- int op;
- int maxLength;
- int v;
- int i;
- int opStackDepth;
-
- int mainFunction;
-
- // set up the into-to-float variables
- ((int *)itofConvert)[0] = 0x43300000;
- ((int *)itofConvert)[1] = 0x80000000;
- ((int *)itofConvert)[2] = 0x43300000;
-
- // allocate a very large temp buffer, we will shrink it later
- maxLength = header->codeLength * 8;
- buf = Z_Malloc( maxLength );
- jused = Z_Malloc(header->instructionCount + 2);
- Com_Memset(jused, 0, header->instructionCount+2);
-
- // compile everything twice, so the second pass will have valid instruction
- // pointers for branches
- for ( pass = -1 ; pass < 2 ; pass++ ) {
-
- // translate all instructions
- pc = 0;
- mainFunction = 0;
- opStackDepth = 0;
-
- pop0 = 343545;
- pop1 = 2443545;
- oc0 = -2343535;
- oc1 = 24353454;
- tvm = vm;
- code = (byte *)header + header->codeOffset;
- compiledOfs = 0;
-#ifndef __GNUC__
- // metrowerks seems to require this header in front of functions
- Emit4( (int)(buf+2) );
- Emit4( 0 );
-#endif
-
- for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
- if ( compiledOfs*4 > maxLength - 16 ) {
- Com_Error( ERR_DROP, "VM_Compile: maxLength exceeded" );
- }
-
- op = code[ pc ];
- if ( !pass ) {
- vm->instructionPointers[ instruction ] = compiledOfs * 4;
- }
- pc++;
- switch ( op ) {
- case 0:
- break;
- case OP_BREAK:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08lx BREAK\n",instruction);
- #endif
- InstImmU( "addi", PPC_ADDI, R_TOP, 0, 0 );
- InstImm( "lwz", PPC_LWZ, R_TOP, R_TOP, 0 ); // *(int *)0 to crash to debugger
- break;
- case OP_ENTER:
- opStackDepth = 0;
- v = Constant4();
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x ENTER\t%04x\n",instruction,v);
- #endif
- opStackRegType[opStackDepth] = 0;
- mainFunction++;
- if(mainFunction == 1)
- {
- // Main VM entry point is the first thing we compile, so save off operand stack
- // registers here. This avoids issues with trying to trick the native compiler
- // into doing it, and properly matches the PowerPC ABI
- InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, -OP_STACK_MAX_DEPTH*4 ); // sub R_STACK, R_STACK, imm
- for(i = 0; i < OP_STACK_MAX_DEPTH; i++)
- InstImm( "stw", PPC_STW, opStackIntRegisters[i], R_REAL_STACK, i*4);
- }
- InstImm( "addi", PPC_ADDI, R_STACK, R_STACK, -v ); // sub R_STACK, R_STACK, imm
- break;
- case OP_CONST:
- v = Constant4();
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x CONST\t%08x\n",instruction,v);
- #endif
- opStackLoadInstructionAddr[opStackDepth] = 0;
- if ( v < 32768 && v >= -32768 ) {
- InstImmU( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], 0, v & 0xffff );
- } else {
- InstImmU( "addis", PPC_ADDIS, opStackIntRegisters[opStackDepth], 0, (v >> 16)&0xffff );
- if ( v & 0xffff ) {
- InstImmU( "ori", PPC_ORI, opStackIntRegisters[opStackDepth], opStackIntRegisters[opStackDepth], v & 0xffff );
- }
- }
- opStackRegType[opStackDepth] = 1;
- opStackDepth += 1;
- if (code[pc] == OP_JUMP) {
- jused[v] = 1;
- }
- break;
- case OP_LOCAL:
- oc1 = Constant4();
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LOCAL\t%08x\n",instruction,oc1);
- #endif
- if (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
- oc1 &= vm->dataMask;
- }
- InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], R_STACK, oc1 );
- opStackRegType[opStackDepth] = 1;
- opStackLoadInstructionAddr[opStackDepth] = 0;
- opStackDepth += 1;
- break;
- case OP_ARG:
- v = Constant1();
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x ARG \t%08x\n",instruction,v);
- #endif
- InstImm( "addi", PPC_ADDI, R_EA, R_STACK, v ); // location to put it
- if(opStackRegType[opStackDepth-1] == 1)
- Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1], R_EA, R_MEMBASE );
- else
- Inst( "stfsx", PPC_STFSX, opStackFloatRegisters[opStackDepth-1], R_EA, R_MEMBASE );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
-
- break;
- case OP_CALL:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x CALL\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assert(opStackDepth > 0);
- Inst( "mflr", PPC_MFSPR, R_SECOND, 8, 0 ); // move from link register
- InstImm( "stwu", PPC_STWU, R_SECOND, R_REAL_STACK, -16 ); // save off the old return address
-
- // Spill operand stack registers.
- spillOpStack(opStackDepth);
-
- // We need to leave R_OPSTACK pointing to the top entry on the stack, which is the call address.
- // It will be consumed (and R4 decremented) by the AsmCall code.
- InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);
-
- Inst( "mtctr", PPC_MTSPR, R_ASMCALL, 9, 0 ); // move to count register
- Inst( "bctrl", PPC_BCCTR | 1, 20, 0, 0 ); // jump and link to the count register
-
- // R4 now points to the top of the operand stack, which has the return value in it. We want to
- // back off the pointer to point to the base of our local operand stack and then reload the stack.
-
- InstImm("addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);
-
- // Reload operand stack.
- loadOpStack(opStackDepth);
-
- InstImm( "lwz", PPC_LWZ, R_SECOND, R_REAL_STACK, 0 ); // fetch the old return address
- InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );
- Inst( "mtlr", PPC_MTSPR, R_SECOND, 8, 0 ); // move to link register
- break;
- case OP_PUSH:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x PUSH\n",instruction);
- #endif
- opStackRegType[opStackDepth] = 1; // Garbage int value.
- opStackDepth += 1;
- break;
- case OP_POP:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x POP\n",instruction);
- #endif
- opStackDepth -= 1;
- opStackRegType[opStackDepth] = 0; // ??
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_LEAVE:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LEAVE\n",instruction);
- #endif
- assert(opStackDepth == 1);
- assert(opStackRegType[0] != 0);
- // Save return value onto top of op stack. We also have to increment R_OPSTACK
- switch(opStackRegType[0])
- {
- case 1: // Integer register
- InstImm( "stw", PPC_STWU, opStackIntRegisters[0], R_OPSTACK, 4);
- break;
- case 2: // Float register
- InstImm( "stfs", PPC_STFSU, opStackFloatRegisters[0], R_OPSTACK, 4);
- break;
- }
- InstImm( "addi", PPC_ADDI, R_STACK, R_STACK, Constant4() ); // add R_STACK, R_STACK, imm
- if(mainFunction == 1)
- {
- for(i = 0; i < OP_STACK_MAX_DEPTH; i++)
- InstImm( "lwz", PPC_LWZ, opStackIntRegisters[i], R_REAL_STACK, i*4);
- InstImm( "addi", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, OP_STACK_MAX_DEPTH*4 );
- }
- opStackDepth--;
- opStackRegType[opStackDepth] = 0;
- opStackLoadInstructionAddr[opStackDepth] = 0;
- Inst( "blr", PPC_BCLR, 20, 0, 0 ); // branch unconditionally to link register
- break;
- case OP_LOAD4:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LOAD4\n",instruction);
- #endif
- // We should try to figure out whether to use LWZX or LFSX based
- // on some kind of code analysis after subsequent passes. I think what
- // we could do is store the compiled load instruction address along with
- // the register type. When we hit the first mismatched operator, we go back
- // and patch the load. Since LCC's operand stack should be at 0 depth by the
- // time we hit a branch, this should work fairly well. FIXME FIXME FIXME.
- assertInteger(opStackDepth-1);
- opStackLoadInstructionAddr[opStackDepth-1] = &buf[ compiledOfs ];
- Inst( "lwzx", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
- opStackRegType[opStackDepth-1] = 1;
- break;
- case OP_LOAD2:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LOAD2\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- Inst( "lhzx", PPC_LHZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
- opStackRegType[opStackDepth-1] = 1;
- break;
- case OP_LOAD1:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LOAD1\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- Inst( "lbzx", PPC_LBZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base
- opStackRegType[opStackDepth-1] = 1;
- break;
- case OP_STORE4:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x STORE4\n",instruction);
- #endif
- assertInteger(opStackDepth-2);
- if(opStackRegType[opStackDepth-1] == 1)
- Inst( "stwx", PPC_STWX, opStackIntRegisters[opStackDepth-1],
- opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
- else
- Inst( "stfsx", PPC_STFSX, opStackFloatRegisters[opStackDepth-1],
- opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- break;
- case OP_STORE2:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x STORE2\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "sthx", PPC_STHX, opStackIntRegisters[opStackDepth-1],
- opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- break;
- case OP_STORE1:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x STORE1\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "stbx", PPC_STBX, opStackIntRegisters[opStackDepth-1],
- opStackIntRegisters[opStackDepth-2], R_MEMBASE ); // store from memory base
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- break;
-
- case OP_EQ:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x EQ\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (v&0x3ffffff) );
- break;
- case OP_NE:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x NE\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 2, v );
-
- break;
- case OP_LTI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LTI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 0, v );
- break;
- case OP_LEI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LEI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 1, v );
- break;
- case OP_GTI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GTI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 1, v );
- break;
- case OP_GEI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GEI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmp", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 0, v );
- break;
- case OP_LTU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LTU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 0, v );
- break;
- case OP_LEU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LEU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 1, v );
- break;
- case OP_GTU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GTU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 1, v );
- break;
- case OP_GEU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GEU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "cmpl", PPC_CMPL, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 0, v );
- break;
-
- case OP_EQF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x EQF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 2, v );
- break;
- case OP_NEF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x NEF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 2, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 2, v );
- break;
- case OP_LTF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LTF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 0, v );
- break;
- case OP_LEF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LEF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 1, v );
- break;
- case OP_GTF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GTF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 4, 1, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 12, 1, v );
- break;
- case OP_GEF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x GEF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fcmpu", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- i = Constant4();
- jused[i] = 1;
- InstImm( "bc", PPC_BC, 12, 0, 8 );
- if ( pass==1 ) {
- v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];
- } else {
- v = 0;
- }
- Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
-// InstImm( "bc", PPC_BC, 4, 0, v );
- break;
-
- case OP_NEGI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x NEGI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- InstImm( "subfic", PPC_SUBFIC, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_ADD:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x ADD\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_SUB:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x SUB\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_DIVI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x DIVI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "divw", PPC_DIVW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_DIVU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x DIVU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "divwu", PPC_DIVWU, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_MODI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x MODI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "divw", PPC_DIVW, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- Inst( "mullw", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );
- Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_MODU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x MODU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "divwu", PPC_DIVWU, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- Inst( "mullw", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );
- Inst( "subf", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_MULI:
- case OP_MULU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x MULI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "mullw", PPC_MULLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_BAND:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x BAND\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "and", PPC_AND, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_BOR:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x BOR\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "or", PPC_OR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_BXOR:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x BXOR\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "xor", PPC_XOR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_BCOM:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x BCOM\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- Inst( "nor", PPC_NOR, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1] );
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_LSH:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x LSH\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "slw", PPC_SLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_RSHI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x RSHI\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "sraw", PPC_SRAW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_RSHU:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x RSHU\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- Inst( "srw", PPC_SRW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
-
- case OP_NEGF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x NEGF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- Inst( "fneg", PPC_FNEG, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_ADDF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x ADDF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fadds", PPC_FADDS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_SUBF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x SUBF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fsubs", PPC_FSUBS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_DIVF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x DIVF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst( "fdivs", PPC_FDIVS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- case OP_MULF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x MULF\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
- makeFloat(opStackDepth-2);
- Inst4( "fmuls", PPC_FMULS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], 0, opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
-
- case OP_CVIF:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x CVIF\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- //makeInteger(opStackDepth-1);
- v = (int)&itofConvert;
- InstImmU( "addis", PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );
- InstImmU( "ori", PPC_ORI, R_EA, R_EA, v & 0xffff );
- InstImmU( "xoris", PPC_XORIS, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0x8000 );
- InstImm( "stw", PPC_STW, opStackIntRegisters[opStackDepth-1], R_EA, 12 );
- InstImm( "lfd", PPC_LFD, opStackFloatRegisters[opStackDepth-1], R_EA, 0 );
- Inst( "ori", PPC_ORI, 0, 0, 0);
- Inst( "ori", PPC_ORI, 0, 0, 0);
- Inst( "ori", PPC_ORI, 0, 0, 0);
- InstImm( "lfd", PPC_LFD, 13, R_EA, 8 );
- Inst( "fsub", PPC_FSUB, opStackFloatRegisters[opStackDepth-1], 13, opStackFloatRegisters[opStackDepth-1] );
- opStackRegType[opStackDepth-1] = 2;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- // Inst( PPC_FRSP, R_TOP, 0, R_TOP );
- break;
- case OP_CVFI:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x CVFI\n",instruction);
- #endif
- makeFloat(opStackDepth-1);
-
- InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);
-
- Inst( "fctiwz", PPC_FCTIWZ, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );
- Inst( "stfiwx", PPC_STFIWX, opStackFloatRegisters[opStackDepth-1], 0, R_OPSTACK ); // save value to opstack (dummy area now)
- Inst( "ori", PPC_ORI, 0, 0, 0);
- Inst( "ori", PPC_ORI, 0, 0, 0);
- Inst( "ori", PPC_ORI, 0, 0, 0);
- Inst( "ori", PPC_ORI, 0, 0, 0);
- InstImm( "lwz", PPC_LWZ, opStackIntRegisters[opStackDepth-1], R_OPSTACK, 0 );
-
- InstImm( "addi", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);
-
- opStackRegType[opStackDepth-1] = 1;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_SEX8:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x SEX8\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- Inst( "extsb", PPC_EXTSB, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
- case OP_SEX16:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x SEX16\n",instruction);
- #endif
- assertInteger(opStackDepth-1);
- Inst( "extsh", PPC_EXTSH, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- break;
-
- case OP_BLOCK_COPY:
- v = Constant4() >> 2;
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x BLOCK_COPY\t%08lx\n",instruction,v<<2);
- #endif
- assert(opStackDepth >= 2);
- assertInteger(opStackDepth-1);
- assertInteger(opStackDepth-2);
- InstImmU( "addi", PPC_ADDI, R_EA, 0, v ); // count
- // FIXME: range check
- Inst( "mtctr", PPC_MTSPR, R_EA, 9, 0 ); // move to count register
-
- Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );
- InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], -4 );
- Inst( "add", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], R_MEMBASE );
- InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], -4 );
-
- InstImm( "lwzu", PPC_LWZU, R_EA, opStackIntRegisters[opStackDepth-1], 4 ); // source
- InstImm( "stwu", PPC_STWU, R_EA, opStackIntRegisters[opStackDepth-2], 4 ); // dest
- Inst( "b", PPC_BC | 0xfff8 , 16, 0, 0 ); // loop
- opStackRegType[opStackDepth-1] = 0;
- opStackRegType[opStackDepth-2] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-2] = 0;
- opStackDepth -= 2;
- break;
-
- case OP_JUMP:
- #if DEBUG_VM
- if(pass == 1)
- printf("%08x JUMP\n",instruction);
- #endif
- assert(opStackDepth == 1);
- assertInteger(opStackDepth-1);
-
- Inst( "rlwinm", PPC_RLWINM | ( 29 << 1 ), opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 2 );
- // FIXME: range check
- Inst( "lwzx", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_INSTRUCTIONS );
- Inst( "mtctr", PPC_MTSPR, opStackIntRegisters[opStackDepth-1], 9, 0 ); // move to count register
- Inst( "bctr", PPC_BCCTR, 20, 0, 0 ); // jump to the count register
- opStackRegType[opStackDepth-1] = 0;
- opStackLoadInstructionAddr[opStackDepth-1] = 0;
- opStackDepth -= 1;
- break;
- default:
- Com_Error( ERR_DROP, "VM_CompilePPC: bad opcode %i at instruction %i, offset %i", op, instruction, pc );
- }
- pop0 = pop1;
- pop1 = op;
- assert(opStackDepth >= 0);
- assert(opStackDepth < OP_STACK_MAX_DEPTH);
-
- //printf("%4d\t%s\n",opStackDepth,opnames[op]);
- }
-
- Com_Printf( "VM file %s pass %d compiled to %i bytes of code\n", vm->name, (pass+1), compiledOfs*4 );
-
- if ( pass == 0 ) {
- // copy to an exact size buffer on the hunk
- vm->codeLength = compiledOfs * 4;
- vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );
- Com_Memcpy( vm->codeBase, buf, vm->codeLength );
-
- //printf("codeBase: %p\n",vm->codeBase);
-
- Z_Free( buf );
-
- // offset all the instruction pointers for the new location
- for ( i = 0 ; i < header->instructionCount ; i++ ) {
- vm->instructionPointers[i] += (int)vm->codeBase;
- //printf("%08x %08lx\n",i,vm->instructionPointers[i]);
- }
-
- // go back over it in place now to fixup reletive jump targets
- buf = (unsigned *)vm->codeBase;
- } else if ( pass == 1 ) {
- #ifdef MACOS_X
- // On Mac OS X, the following library routine clears the instruction cache for generated code
- MakeDataExecutable(vm->codeBase, vm->codeLength);
- #else
- #warning Need to clear the instruction cache for generated code
- #endif
- }
- }
- if(0)
- {
- char buf[256];
- printf("wait..\n");
- gets(buf);
- }
- Z_Free( jused );
-}
-
-/*
-==============
-VM_CallCompiled
-
-This function is called directly by the generated code
-==============
-*/
-int VM_CallCompiled( vm_t *vm, int *args ) {
- int stack[1024];
- int programStack;
- int stackOnEntry;
- byte *image;
-
- currentVM = vm;
-
- //printf("VM_CallCompiled: %p %08lx %08lx %08lx\n",
- // vm, args[0],args[1],args[2]);
-
- // interpret the code
- vm->currentlyInterpreting = qtrue;
-
- // we might be called recursively, so this might not be the very top
- programStack = vm->programStack;
- stackOnEntry = programStack;
- image = vm->dataBase;
-
- // set up the stack frame
- programStack -= 48;
-
- *(int *)&image[ programStack + 44] = args[9];
- *(int *)&image[ programStack + 40] = args[8];
- *(int *)&image[ programStack + 36] = args[7];
- *(int *)&image[ programStack + 32] = args[6];
- *(int *)&image[ programStack + 28] = args[5];
- *(int *)&image[ programStack + 24] = args[4];
- *(int *)&image[ programStack + 20] = args[3];
- *(int *)&image[ programStack + 16] = args[2];
- *(int *)&image[ programStack + 12] = args[1];
- *(int *)&image[ programStack + 8 ] = args[0];
- *(int *)&image[ programStack + 4 ] = 0; // return stack
- *(int *)&image[ programStack ] = -1; // will terminate the loop on return
-
- // Cheesy... manually save registers used by VM call...
- // off we go into generated code...
- // the PPC calling standard says the parms will all go into R3 - R11, so
- // no special asm code is needed here
-#ifdef __GNUC__
- ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
- programStack, (int)&stack,
- (int)image, vm->dataMask, (int)&AsmCall,
- (int)vm->instructionPointers, vm->instructionPointersLength,
- (int)vm );
-#else
- ((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))(
- programStack, (int)&stack,
- (int)image, vm->dataMask, *(int *)&AsmCall /* skip function pointer header */,
- (int)vm->instructionPointers, vm->instructionPointersLength,
- (int)vm );
-#endif
- vm->programStack = stackOnEntry;
-
- vm->currentlyInterpreting = qfalse;
-
- return stack[1];
-}
-
-
-/*
-==================
-AsmCall
-
-Put this at end of file because gcc messes up debug line numbers
-==================
-*/
-#ifdef __GNUC__
-
-void AsmCall( void ) {
-asm (
- // pop off the destination instruction
-" lwz r12,0(r4) \n" // RG_TOP, 0(RG_OPSTACK)
-" addi r4,r4,-4 \n" // RG_OPSTACK, RG_OPSTACK, -4 \n"
-
- // see if it is a system trap
-" cmpwi r12,0 \n" // RG_TOP, 0 \n"
-" bc 12,0, systemTrap \n"
-
- // calling another VM function, so lookup in instructionPointers
-" slwi r12,r12,2 \n" // RG_TOP,RG_TOP,2
- // FIXME: range check
-" lwzx r12, r8, r12 \n" // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
-" mtctr r12 \n" // RG_TOP
-);
-
-#if defined(MACOS_X) && defined(__OPTIMIZE__)
- // On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.
-//#warning Mac OS X optimization on, not popping GCC AsmCall frame
-#else
- // Mac OS X Server and unoptimized compiles include a GCC AsmCall frame
- asm (
-" lwz r1,0(r1) \n" // pop off the GCC AsmCall frame
-" lmw r30,-8(r1) \n"
-);
-#endif
-
-asm (
-" bcctr 20,0 \n" // when it hits a leave, it will branch to the current link register
-
- // calling a system trap
-"systemTrap: \n"
- // convert to positive system call number
-" subfic r12,r12,-1 \n"
-
- // save all our registers, including the current link register
-" mflr r13 \n" // RG_SECOND // copy off our link register
-" addi r1,r1,-92 \n" // required 24 byets of linkage, 32 bytes of parameter, plus our saves
-" stw r3,56(r1) \n" // RG_STACK, -36(REAL_STACK)
-" stw r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
-" stw r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
-" stw r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
-" stw r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
-" stw r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-" stw r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-" stw r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
-" stw r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK) // link register
-
- // save the vm stack position to allow recursive VM entry
-" addi r13,r3,-4 \n" // RG_TOP, RG_STACK, -4
-" stw r13,0(r10) \n" //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
-
- // save the system call number as the 0th parameter
-" add r3,r3,r5 \n" // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
-" stwu r12,4(r3) \n" // RG_TOP, 4(r3)
-
- // make the system call with the address of all the VM parms as a parameter
- // vm->systemCalls( &parms )
-" lwz r12,4(r10) \n" // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
-" mtctr r12 \n" // RG_TOP
-" bcctrl 20,0 \n"
-" mr r12,r3 \n" // RG_TOP, r3
-
- // pop our saved registers
-" lwz r3,56(r1) \n" // RG_STACK, 0(RG_REAL_STACK)
-" lwz r4,60(r1) \n" // RG_OPSTACK, 4(RG_REAL_STACK)
-" lwz r5,64(r1) \n" // RG_MEMBASE, 8(RG_REAL_STACK)
-" lwz r6,68(r1) \n" // RG_MEMMASK, 12(RG_REAL_STACK)
-" lwz r7,72(r1) \n" // RG_ASMCALL, 16(RG_REAL_STACK)
-" lwz r8,76(r1) \n" // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-" lwz r9,80(r1) \n" // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-" lwz r10,84(r1) \n" // RG_VM, 28(RG_REAL_STACK)
-" lwz r13,88(r1) \n" // RG_SECOND, 32(RG_REAL_STACK)
-" addi r1,r1,92 \n" // RG_REAL_STACK, RG_REAL_STACK, 36
-
- // restore the old link register
-" mtlr r13 \n" // RG_SECOND
-
- // save off the return value
-" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
-
- // GCC adds its own prolog / epliog code
- );
-}
-#else
-
-// codewarrior version
-
-void asm AsmCall( void ) {
-
- // pop off the destination instruction
-
- lwz r12,0(r4) // RG_TOP, 0(RG_OPSTACK)
-
- addi r4,r4,-4 // RG_OPSTACK, RG_OPSTACK, -4
-
-
-
- // see if it is a system trap
-
- cmpwi r12,0 // RG_TOP, 0
-
- bc 12,0, systemTrap
-
-
-
- // calling another VM function, so lookup in instructionPointers
-
- slwi r12,r12,2 // RG_TOP,RG_TOP,2
-
- // FIXME: range check
-
- lwzx r12, r8, r12 // RG_TOP, RG_INSTRUCTIONS(RG_TOP)
-
- mtctr r12 // RG_TOP
-
-
-
- bcctr 20,0 // when it hits a leave, it will branch to the current link register
-
-
-
- // calling a system trap
-
-systemTrap:
-
- // convert to positive system call number
-
- subfic r12,r12,-1
-
-
-
- // save all our registers, including the current link register
-
- mflr r13 // RG_SECOND // copy off our link register
-
- addi r1,r1,-92 // required 24 byets of linkage, 32 bytes of parameter, plus our saves
-
- stw r3,56(r1) // RG_STACK, -36(REAL_STACK)
-
- stw r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
-
- stw r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
-
- stw r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
-
- stw r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
-
- stw r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-
- stw r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-
- stw r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
-
- stw r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK) // link register
-
-
-
- // save the vm stack position to allow recursive VM entry
-
- addi r13,r3,-4 // RG_TOP, RG_STACK, -4
-
- stw r13,0(r10) //RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)
-
-
-
- // save the system call number as the 0th parameter
-
- add r3,r3,r5 // r3, RG_STACK, RG_MEMBASE // r3 is the first parameter to vm->systemCalls
-
- stwu r12,4(r3) // RG_TOP, 4(r3)
-
-
-
- // make the system call with the address of all the VM parms as a parameter
-
- // vm->systemCalls( &parms )
-
- lwz r12,4(r10) // RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)
-
-
-
- // perform macos cross fragment fixup crap
-
- lwz r9,0(r12)
-
- stw r2,52(r1) // save old TOC
-
- lwz r2,4(r12)
-
-
-
- mtctr r9 // RG_TOP
-
- bcctrl 20,0
-
-
-
- lwz r2,52(r1) // restore TOC
-
-
-
- mr r12,r3 // RG_TOP, r3
-
-
-
- // pop our saved registers
-
- lwz r3,56(r1) // RG_STACK, 0(RG_REAL_STACK)
-
- lwz r4,60(r1) // RG_OPSTACK, 4(RG_REAL_STACK)
-
- lwz r5,64(r1) // RG_MEMBASE, 8(RG_REAL_STACK)
-
- lwz r6,68(r1) // RG_MEMMASK, 12(RG_REAL_STACK)
-
- lwz r7,72(r1) // RG_ASMCALL, 16(RG_REAL_STACK)
-
- lwz r8,76(r1) // RG_INSTRUCTIONS, 20(RG_REAL_STACK)
-
- lwz r9,80(r1) // RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)
-
- lwz r10,84(r1) // RG_VM, 28(RG_REAL_STACK)
-
- lwz r13,88(r1) // RG_SECOND, 32(RG_REAL_STACK)
-
- addi r1,r1,92 // RG_REAL_STACK, RG_REAL_STACK, 36
-
-
-
- // restore the old link register
-
- mtlr r13 // RG_SECOND
-
-
-
- // save off the return value
-
- stwu r12,4(r4) // RG_TOP, 0(RG_OPSTACK)
-
-
-
- blr
-
-}
-
-
-
-
-#endif
Modified: branches/1.34/code/qcommon/vm_x86.c
===================================================================
--- branches/1.34/code/qcommon/vm_x86.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm_x86.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -212,7 +212,7 @@
// arbitrarily named (though this is not true for the MSC version). When a vm
// makes a system call, control jumps straight to the doAsmCall label.
void AsmCall( void ) {
- asm( CMANG(doAsmCall) ": \n\t" \
+ __asm__( CMANG(doAsmCall) ": \n\t" \
" movl (%%edi),%%eax \n\t" \
" subl $4,%%edi \n\t" \
" orl %%eax,%%eax \n\t" \
Modified: branches/1.34/code/qcommon/vm_x86_64.c
===================================================================
--- branches/1.34/code/qcommon/vm_x86_64.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/qcommon/vm_x86_64.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -28,10 +28,16 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/time.h>
+#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
+#include <stdarg.h>
+//#define USE_GAS
+//#define DEBUG_VM
+
#ifdef DEBUG_VM
#define Dfprintf(fd, args...) fprintf(fd, ##args)
static FILE* qdasmout;
@@ -39,18 +45,35 @@
#define Dfprintf(args...)
#endif
+#define VM_X86_64_MMAP
+
+#ifndef USE_GAS
+void assembler_set_output(char* buf);
+size_t assembler_get_code_size(void);
+void assembler_init(int pass);
+void assemble_line(const char* input, size_t len);
+#ifdef Dfprintf
+#undef Dfprintf
+#define Dfprintf(args...)
+#endif
+#endif // USE_GAS
+
static void VM_Destroy_Compiled(vm_t* self);
/*
+
+ |=====================|
+ ^ dataMask ^- programStack rdi
+ |
+ +- r8
eax scratch
ebx scratch
ecx scratch (required for shifts)
edx scratch (required for divisions)
- rsi stack pointer
- rdi program frame pointer
- r8 pointer to begin of real stack memory
- r9 return address to real program
+ rsi stack pointer (opStack)
+ rdi program frame pointer (programStack)
+ r8 pointer data (vm->dataBase)
r10 start of generated code
*/
@@ -202,8 +225,29 @@
[OP_BLOCK_COPY] = 4,
};
+#ifdef USE_GAS
#define emit(x...) \
do { fprintf(fh_s, ##x); fputc('\n', fh_s); } while(0)
+#else
+void emit(const char* fmt, ...)
+{
+ va_list ap;
+ char line[4096];
+ va_start(ap, fmt);
+ vsnprintf(line, sizeof(line), fmt, ap);
+ va_end(ap);
+ assemble_line(line, strlen(line));
+}
+#endif // USE_GAS
+
+#ifdef USE_GAS
+#define JMPIARG \
+ emit("jmp i_%08x", iarg);
+#else
+#define JMPIARG \
+ emit("movq $%lu, %%rax", vm->codeBase+vm->instructionPointers[iarg]); \
+ emit("jmpq *%rax");
+#endif
// integer compare and jump
#define IJ(op) \
@@ -211,7 +255,8 @@
emit("movl 4(%%rsi), %%eax"); \
emit("cmpl 8(%%rsi), %%eax"); \
emit(op " i_%08x", instruction+1); \
- emit("jmp i_%08x", iarg);
+ JMPIARG \
+ neednilabel = 1;
#ifdef USE_X87
#define FJ(bits, op) \
@@ -221,7 +266,8 @@
emit("fnstsw %%ax");\
emit("testb $" #bits ", %%ah");\
emit(op " i_%08x", instruction+1);\
- emit("jmp i_%08x", iarg);
+ JMPIARG \
+ neednilabel = 1;
#define XJ(x)
#else
#define FJ(x, y)
@@ -231,7 +277,8 @@
emit("ucomiss 8(%%rsi), %%xmm0");\
emit("jp i_%08x", instruction+1);\
emit(op " i_%08x", instruction+1);\
- emit("jmp i_%08x", iarg);
+ JMPIARG \
+ neednilabel = 1;
#endif
#define SIMPLE(op) \
@@ -265,6 +312,15 @@
#if 1
#define RANGECHECK(reg) \
emit("andl $0x%x, %%" #reg, vm->dataMask);
+#elif 0
+#define RANGECHECK(reg) \
+ emit("pushl %%" #reg); \
+ emit("andl $0x%x, %%" #reg, ~vm->dataMask); \
+ emit("jz rangecheck_ok_i_%08x", instruction); \
+ emit("int3"); \
+ emit("rangecheck_ok_i_%08x:", instruction); \
+ emit("popl %%" #reg); \
+ emit("andl $0x%x, %%" #reg, vm->dataMask);
#else
#define RANGECHECK(reg)
#endif
@@ -279,9 +335,14 @@
static void* getentrypoint(vm_t* vm)
{
+#ifdef USE_GAS
return vm->codeBase+64; // skip ELF header
+#else
+ return vm->codeBase;
+#endif // USE_GAS
}
+#ifdef USE_GAS
char* mmapfile(const char* fn, size_t* size)
{
int fd = -1;
@@ -369,6 +430,7 @@
return size;
}
+#endif // USE_GAS
static void block_copy_vm(unsigned dest, unsigned src, unsigned count)
{
@@ -397,8 +459,13 @@
char* code;
unsigned iarg = 0;
unsigned char barg = 0;
+ int neednilabel = 0;
+ struct timeval tvstart = {0, 0};
+
+#ifdef USE_GAS
+ byte* compiledcode;
+ int compiledsize;
void* entryPoint;
-
char fn_s[2*MAX_QPATH]; // output file for assembler code
char fn_o[2*MAX_QPATH]; // file written by as
#ifdef DEBUG_VM
@@ -406,15 +473,22 @@
#endif
FILE* fh_s;
int fd_s, fd_o;
- byte* compiledcode;
- int compiledsize;
+ gettimeofday(&tvstart, NULL);
+
Com_Printf("compiling %s\n", vm->name);
+#ifdef DEBUG_VM
+ snprintf(fn_s, sizeof(fn_s), "%.63s.s", vm->name);
+ snprintf(fn_o, sizeof(fn_o), "%.63s.o", vm->name);
+ fd_s = open(fn_s, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd_o = open(fn_o, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+#else
snprintf(fn_s, sizeof(fn_s), "/tmp/%.63s.s_XXXXXX", vm->name);
snprintf(fn_o, sizeof(fn_o), "/tmp/%.63s.o_XXXXXX", vm->name);
fd_s = mkstemp(fn_s);
fd_o = mkstemp(fn_o);
+#endif
if(fd_s == -1 || fd_o == -1)
{
if(fd_s != -1) close(fd_s);
@@ -422,7 +496,7 @@
unlink(fn_s);
unlink(fn_o);
- Com_Printf(S_COLOR_RED "can't create temporary files for vm\n", fn_s);
+ Com_Printf(S_COLOR_RED "can't create temporary file %s for vm\n", fn_s);
vm->compiled = qfalse;
return;
}
@@ -442,27 +516,50 @@
return;
}
- // translate all instructions
- pc = 0;
- code = (char *)header + header->codeOffset;
-
emit("start:");
emit("or %%r8, %%r8"); // check whether to set up instruction pointers
emit("jnz main");
emit("jmp setupinstructionpointers");
- emit("exit:");
- emit("jmp *%%r9");
emit("main:");
+#else // USE_GAS
+ int pass;
+ size_t compiledOfs = 0;
+ gettimeofday(&tvstart, NULL);
+
+ for (pass = 0; pass < 2; ++pass) {
+
+ if(pass)
+ {
+ compiledOfs = assembler_get_code_size();
+ vm->codeLength = compiledOfs;
+ vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+ if(vm->codeBase == (void*)-1)
+ Com_Error(ERR_DROP, "VM_CompileX86: can't mmap memory");
+
+ assembler_set_output((char*)vm->codeBase);
+ }
+
+ assembler_init(pass);
+
+#endif // USE_GAS
+
+ // translate all instructions
+ pc = 0;
+ code = (char *)header + header->codeOffset;
+
for ( instruction = 0; instruction < header->instructionCount; ++instruction )
{
op = code[ pc ];
++pc;
- vm->instructionPointers[instruction] = pc;
+#ifndef USE_GAS
+ vm->instructionPointers[instruction] = assembler_get_code_size();
+#endif
-#if 0
+ /* store current instruction number in r15 for debugging */
+#if 1
emit("nop");
emit("movq $%d, %%r15", instruction);
emit("nop");
@@ -483,7 +580,17 @@
{
Dfprintf(qdasmout, "%s\n", opnames[op]);
}
+
+#ifdef USE_GAS
emit("i_%08x:", instruction);
+#else
+ if(neednilabel)
+ {
+ emit("i_%08x:", instruction);
+ neednilabel = 0;
+ }
+#endif
+
switch ( op )
{
case OP_UNDEF:
@@ -501,16 +608,7 @@
break;
case OP_LEAVE:
emit("addl $%d, %%edi", iarg); // get rid of stack frame
- RANGECHECK(edi);
- emit("movl 0(%%r8, %%rdi, 1), %%eax"); // get return address
- emit("movq $%lu, %%rbx", (unsigned long)vm->instructionPointers);
- emit("cmp $-1, %%eax");
- emit("je jumptoexit%d", instruction);
- emit("movl (%%rbx, %%rax, 4), %%eax"); // load new relative jump address
- emit("addq %%r10, %%rax");
- emit("jmp *%%rax");
- emit("jumptoexit%d:", instruction);
- emit("jmp exit");
+ emit("ret");
break;
case OP_CALL:
emit("movl 0(%%rsi), %%eax"); // get instr from stack
@@ -521,7 +619,8 @@
emit("movq $%lu, %%rbx", (unsigned long)vm->instructionPointers);
emit("movl (%%rbx, %%rax, 4), %%eax"); // load new relative jump address
emit("addq %%r10, %%rax");
- emit("jmp *%%rax");
+ emit("callq *%%rax");
+ emit("jmp i_%08x", instruction+1);
emit("callSyscall%d:", instruction);
// emit("fnsave 4(%%rsi)");
emit("push %%rsi");
@@ -529,22 +628,28 @@
emit("push %%r8");
emit("push %%r9");
emit("push %%r10");
- emit("push %%r10"); // align!
+ emit("movq %%rsp, %%rbx"); // we need to align the stack pointer
+ emit("subq $8, %%rbx"); // |
+ emit("andq $127, %%rbx"); // |
+ emit("subq %%rbx, %%rsp"); // <-+
+ emit("push %%rbx");
emit("negl %%eax"); // convert to actual number
emit("decl %%eax");
// first argument already in rdi
emit("movq %%rax, %%rsi"); // second argument in rsi
emit("movq $%lu, %%rax", (unsigned long)callAsmCall);
emit("callq *%%rax");
+ emit("pop %%rbx");
+ emit("addq %%rbx, %%rsp");
emit("pop %%r10");
- emit("pop %%r10");
emit("pop %%r9");
emit("pop %%r8");
emit("pop %%rdi");
emit("pop %%rsi");
// emit("frstor 4(%%rsi)");
emit("addq $4, %%rsi");
- emit("movl %%eax, (%%rsi)");
+ emit("movl %%eax, (%%rsi)"); // store return value
+ neednilabel = 1;
break;
case OP_PUSH:
emit("addq $4, %%rsi");
@@ -613,7 +718,8 @@
emit("jp dojump_i_%08x", instruction);
emit("jz i_%08x", instruction+1);
emit("dojump_i_%08x:", instruction);
- emit("jmp i_%08x", iarg);
+ JMPIARG
+ neednilabel = 1;
#endif
break;
case OP_LTF:
@@ -633,21 +739,21 @@
XJ("jb");
break;
case OP_LOAD1:
- emit("movl 0(%%rsi), %%eax"); // get pointer from stack
+ emit("movl 0(%%rsi), %%eax"); // get value from stack
RANGECHECK(eax);
emit("movb 0(%%r8, %%rax, 1), %%al"); // deref into eax
emit("andq $255, %%rax");
emit("movl %%eax, 0(%%rsi)"); // store on stack
break;
case OP_LOAD2:
- emit("movl 0(%%rsi), %%eax"); // get pointer from stack
+ emit("movl 0(%%rsi), %%eax"); // get value from stack
RANGECHECK(eax);
- emit("movw 0(%%r8, %%rax, 1), %%rax"); // deref into eax
+ emit("movw 0(%%r8, %%rax, 1), %%ax"); // deref into eax
emit("movl %%eax, 0(%%rsi)"); // store on stack
break;
case OP_LOAD4:
- emit("movl 0(%%rsi), %%eax"); // get pointer from stack
- RANGECHECK(eax);
+ emit("movl 0(%%rsi), %%eax"); // get value from stack
+ RANGECHECK(eax); // not a pointer!?
emit("movl 0(%%r8, %%rax, 1), %%eax"); // deref into eax
emit("movl %%eax, 0(%%rsi)"); // store on stack
break;
@@ -663,7 +769,7 @@
emit("movl 0(%%rsi), %%eax"); // get value from stack
emit("movl -4(%%rsi), %%ebx"); // get pointer from stack
RANGECHECK(ebx);
- emit("movw %%rax, 0(%%r8, %%rbx, 1)"); // store in memory
+ emit("movw %%ax, 0(%%r8, %%rbx, 1)"); // store in memory
emit("subq $8, %%rsi");
break;
case OP_STORE4:
@@ -702,14 +808,14 @@
break;
case OP_SEX8:
- emit("movw 0(%%rsi), %%rax");
+ emit("movw 0(%%rsi), %%ax");
emit("andq $255, %%rax");
emit("cbw");
emit("cwde");
emit("movl %%eax, 0(%%rsi)");
break;
case OP_SEX16:
- emit("movw 0(%%rsi), %%rax");
+ emit("movw 0(%%rsi), %%ax");
emit("cwde");
emit("movl %%eax, 0(%%rsi)");
break;
@@ -740,14 +846,15 @@
emit("subq $4, %%rsi");
emit("movl 0(%%rsi), %%eax");
emit("xorl %%edx, %%edx");
- emit("divl 4(%%rsi)");
+ emit("cdq");
+ emit("idivl 4(%%rsi)");
emit("movl %%edx, 0(%%rsi)");
break;
case OP_MODU:
emit("subq $4, %%rsi");
emit("movl 0(%%rsi), %%eax");
emit("xorl %%edx, %%edx");
- emit("idivl 4(%%rsi)");
+ emit("divl 4(%%rsi)");
emit("movl %%edx, 0(%%rsi)");
break;
case OP_MULI:
@@ -839,14 +946,14 @@
}
}
-
+#ifdef USE_GAS
emit("setupinstructionpointers:");
emit("movq $%lu, %%rax", (unsigned long)vm->instructionPointers);
for ( instruction = 0; instruction < header->instructionCount; ++instruction )
{
emit("movl $i_%08x-start, %d(%%rax)", instruction, instruction*4);
}
- emit("jmp exit");
+ emit("ret");
emit("debugger:");
if(1);
@@ -872,8 +979,17 @@
vm->codeBase = compiledcode; // remember to skip ELF header!
vm->codeLength = compiledsize;
+#else // USE_GAS
+ }
+ assembler_init(0);
+
+ if(mprotect(vm->codeBase, compiledOfs, PROT_READ|PROT_EXEC))
+ Com_Error(ERR_DROP, "VM_CompileX86: mprotect failed");
+#endif // USE_GAS
+
vm->destroy = VM_Destroy_Compiled;
+#ifdef USE_GAS
entryPoint = getentrypoint(vm);
// __asm__ __volatile__ ("int3");
@@ -882,34 +998,52 @@
// call code with r8 set to zero to set up instruction pointers
__asm__ __volatile__ (
" xorq %%r8,%%r8 \r\n" \
- " movq $doneinit,%%r9 \r\n" \
" movq %0,%%r10 \r\n" \
- " jmp *%%r10 \r\n" \
- "doneinit: \r\n" \
+ " callq *%%r10 \r\n" \
:
: "m" (entryPoint)
- : "%r8", "%r9", "%r10", "%rax"
+ : "%r8", "%r10", "%rax"
);
#ifdef DEBUG_VM
fflush(qdasmout);
+ fclose(qdasmout);
#endif
- Com_Printf( "VM file %s compiled to %i bytes of code (0x%lx - 0x%lx)\n", vm->name, vm->codeLength, vm->codeBase, vm->codeBase+vm->codeLength );
-
out:
close(fd_o);
+
+#ifndef DEBUG_VM
if(!com_developer->integer)
{
unlink(fn_o);
unlink(fn_s);
}
+#endif
+#endif // USE_GAS
+
+ if(vm->compiled)
+ {
+ struct timeval tvdone = {0, 0};
+ struct timeval dur = {0, 0};
+ Com_Printf( "VM file %s compiled to %i bytes of code (%p - %p)\n", vm->name, vm->codeLength, vm->codeBase, vm->codeBase+vm->codeLength );
+
+ gettimeofday(&tvdone, NULL);
+ timersub(&tvdone, &tvstart, &dur);
+ Com_Printf( "compilation took %lu.%06lu seconds\n", dur.tv_sec, dur.tv_usec );
+ }
}
void VM_Destroy_Compiled(vm_t* self)
{
+#ifdef USE_GAS
munmap(self->codeBase, self->codeLength);
+#elif _WIN32
+ VirtualFree(self->codeBase, self->codeLength, MEM_RELEASE);
+#else
+ munmap(self->codeBase, self->codeLength);
+#endif
}
/*
@@ -977,20 +1111,20 @@
__asm__ __volatile__ (
" movq %5,%%rsi \r\n" \
" movl %4,%%edi \r\n" \
- " movq $done,%%r9 \r\n" \
" movq %2,%%r10 \r\n" \
" movq %3,%%r8 \r\n" \
- " jmp *%%r10 \r\n" \
- "done: \r\n" \
+ " subq $24, %%rsp # fix alignment as call pushes one value \r\n" \
+ " callq *%%r10 \r\n" \
+ " addq $24, %%rsp \r\n" \
" movl %%edi, %0 \r\n" \
" movq %%rsi, %1 \r\n" \
: "=m" (programStack), "=m" (opStack)
: "m" (entryPoint), "m" (vm->dataBase), "m" (programStack), "m" (opStack)
- : "%rsi", "%rdi", "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r15", "%xmm0"
+ : "%rsi", "%rdi", "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r10", "%r15", "%xmm0"
);
if ( opStack != &stack[1] ) {
- Com_Error( ERR_DROP, "opStack corrupted in compiled code (offset %d)\n", (void*)&stack[1] - opStack);
+ Com_Error( ERR_DROP, "opStack corrupted in compiled code (offset %ld)\n", (long int) ((void *) &stack[1] - opStack));
}
if ( programStack != stackOnEntry - 48 ) {
Com_Error( ERR_DROP, "programStack corrupted in compiled code\n" );
Copied: branches/1.34/code/qcommon/vm_x86_64_assembler.c (from rev 1126, trunk/code/qcommon/vm_x86_64_assembler.c)
===================================================================
--- branches/1.34/code/qcommon/vm_x86_64_assembler.c (rev 0)
+++ branches/1.34/code/qcommon/vm_x86_64_assembler.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,1419 @@
+/*
+===========================================================================
+vm_x86_64_assembler.c -- assembler for x86-64
+
+Copyright (C) 2007 Ludwig Nussel <ludwig.nussel at suse.de>, Novell inc.
+
+Quake III Arena source code 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.
+
+Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef unsigned long u64;
+
+static char* out;
+static unsigned compiledOfs;
+static unsigned assembler_pass;
+
+static const char* cur_line;
+
+static FILE* fout;
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#define crap(fmt, args...) do { \
+ _crap(__FUNCTION__, fmt, ##args); \
+} while(0)
+
+#define CRAP_INVALID_ARGS crap("invalid arguments %s, %s", argtype2str(arg1.type),argtype2str(arg2.type));
+
+#ifdef DEBUG
+#define debug(fmt, args...) printf(fmt, ##args)
+#else
+#define debug(fmt, args...)
+#endif
+
+static void _crap(const char* func, const char* fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "%s() - ", func);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ if(cur_line && cur_line[0])
+ fprintf(stderr, "-> %s\n", cur_line);
+ exit(1);
+}
+
+static void emit1(unsigned char v)
+{
+ if(assembler_pass)
+ {
+ out[compiledOfs++] = v;
+ if(fout) fwrite(&v, 1, 1, fout);
+ debug("%02hhx ", v);
+ }
+ else
+ {
+ ++compiledOfs;
+ }
+}
+
+static inline void emit2(u16 v)
+{
+ emit1(v&0xFF);
+ emit1((v>>8)&0xFF);
+}
+
+static inline void emit4(u32 v)
+{
+ emit1(v&0xFF);
+ emit1((v>>8)&0xFF);
+ emit1((v>>16)&0xFF);
+ emit1((v>>24)&0xFF);
+}
+
+static inline void emit8(u64 v)
+{
+ emit4(v&0xFFFFFFFF);
+ emit4((v>>32)&0xFFFFFFFF);
+}
+
+enum {
+ REX_W = 0x08,
+ REX_R = 0x04,
+ REX_X = 0x02,
+ REX_B = 0x01,
+};
+
+enum {
+ MODRM_MOD_00 = 0x00,
+ MODRM_MOD_01 = 0x01 << 6,
+ MODRM_MOD_10 = 0x02 << 6,
+ MODRM_MOD_11 = 0x03 << 6,
+ MODRM_RM_SIB = 0x04,
+};
+
+typedef enum
+{
+ T_NONE = 0x00,
+ T_REGISTER = 0x01,
+ T_IMMEDIATE = 0x02,
+ T_MEMORY = 0x04,
+ T_LABEL = 0x08,
+ T_ABSOLUTE = 0x80
+} argtype_t;
+
+typedef enum {
+ R_8 = 0x100,
+ R_16 = 0x200,
+ R_64 = 0x800,
+ R_MSZ = 0xF00, // size mask
+ R_XMM = 0x2000, // xmm register. year, sucks
+ R_EAX = 0x00,
+ R_EBX = 0x03,
+ R_ECX = 0x01,
+ R_EDX = 0x02,
+ R_ESI = 0x06,
+ R_EDI = 0x07,
+ R_ESP = 0x04,
+ R_RAX = R_EAX | R_64,
+ R_RBX = R_EBX | R_64,
+ R_RCX = R_ECX | R_64,
+ R_RDX = R_EDX | R_64,
+ R_RSI = R_ESI | R_64,
+ R_RDI = R_EDI | R_64,
+ R_RSP = R_ESP | R_64,
+ R_R8 = 0x08 | R_64,
+ R_R9 = 0x09 | R_64,
+ R_R10 = 0x0A | R_64,
+ R_R15 = 0x0F | R_64,
+ R_AL = R_EAX | R_8,
+ R_AX = R_EAX | R_16,
+ R_CL = R_ECX | R_8,
+ R_XMM0 = 0x00 | R_XMM,
+ R_MGP = 0x0F, // mask for general purpose registers
+} reg_t;
+
+typedef enum {
+ MODRM_SIB = 0,
+ MODRM_NOSIB = 0x3,
+} modrm_sib_t;
+
+typedef struct {
+ unsigned disp;
+ argtype_t basetype;
+ union {
+ u64 imm;
+ reg_t reg;
+ } base;
+ argtype_t indextype;
+ union {
+ u64 imm;
+ reg_t reg;
+ } index;
+ unsigned scale;
+} memref_t;
+
+#define LABELLEN 32
+
+typedef struct {
+ argtype_t type;
+ union {
+ u64 imm;
+ reg_t reg;
+ memref_t mem;
+ char label[LABELLEN];
+ } v;
+ int absolute:1;
+} arg_t;
+
+typedef void (*emitfunc)(const char* op, arg_t arg1, arg_t arg2, void* data);
+
+typedef struct {
+ char* mnemonic;
+ emitfunc func;
+ void* data;
+} op_t;
+
+typedef struct {
+ u8 xmmprefix;
+ u8 subcode; // in modrm
+ u8 rmcode; // opcode for reg/mem, reg
+ u8 mrcode; // opcode for reg, reg/mem
+ u8 rcode8; // opcode for reg8/mem8
+ u8 rcode; // opcode for reg/mem
+} opparam_t;
+
+/* ************************* */
+
+static unsigned hashkey(const char *string, unsigned len) {
+ unsigned register hash, i;
+
+ hash = 0;
+ for (i = 0; i < len && string[i] != '\0'; ++i) {
+ hash += string[i] * (119 + i);
+ }
+ hash = (hash ^ (hash >> 10) ^ (hash >> 20));
+ return hash;
+}
+
+struct hashentry {
+ char* label;
+ unsigned address;
+ struct hashentry* next;
+};
+static struct hashentry* labelhash[1021];
+
+// no dup check!
+static void hash_add_label(const char* label, unsigned address)
+{
+ struct hashentry* h;
+ unsigned i = hashkey(label, -1U);
+ i %= sizeof(labelhash)/sizeof(labelhash[0]);
+ h = malloc(sizeof(struct hashentry));
+ h->label = strdup(label);
+ h->address = address;
+ h->next = labelhash[i];
+ labelhash[i] = h;
+}
+
+static unsigned lookup_label(const char* label)
+{
+ struct hashentry* h;
+ unsigned i = hashkey(label, -1U);
+ i %= sizeof(labelhash)/sizeof(labelhash[0]);
+ for(h = labelhash[i]; h; h = h->next )
+ {
+ if(!strcmp(h->label, label))
+ return h->address;
+ }
+ if(assembler_pass)
+ crap("label %s undefined", label);
+ return 0;
+}
+
+static void labelhash_free(void)
+{
+ struct hashentry* h;
+ unsigned i;
+ unsigned z = 0, min = -1U, max = 0, t = 0;
+ for ( i = 0; i < sizeof(labelhash)/sizeof(labelhash[0]); ++i)
+ {
+ unsigned n = 0;
+ h = labelhash[i];
+ while(h)
+ {
+ struct hashentry* next = h->next;
+ free(h->label);
+ free(h);
+ h = next;
+ ++n;
+ }
+ t+=n;
+ if(!n) ++z;
+ //else printf("%u\n", n);
+ min = MIN(min, n);
+ max = MAX(max, n);
+ }
+ printf("total %u, hsize %lu, zero %u, min %u, max %u\n", t, sizeof(labelhash)/sizeof(labelhash[0]), z, min, max);
+ memset(labelhash, 0, sizeof(labelhash));
+}
+
+/* ************************* */
+
+
+static const char* argtype2str(argtype_t t)
+{
+ switch(t)
+ {
+ case T_NONE: return "none";
+ case T_REGISTER: return "register";
+ case T_IMMEDIATE: return "immediate";
+ case T_MEMORY: return "memory";
+ case T_LABEL: return "label";
+ default: crap("invalid type");
+ }
+ /* not reached */
+ return T_NONE;
+}
+
+/* ************************* */
+
+static inline int iss8(u64 v)
+{
+ return (labs(v) <= 0x80);
+}
+
+static inline int isu8(u64 v)
+{
+ return (v <= 0xff);
+}
+
+static inline int iss16(u64 v)
+{
+ return (labs(v) <= 0x8000);
+}
+
+static inline int isu16(u64 v)
+{
+ return (v <= 0xffff);
+}
+
+static inline int iss32(u64 v)
+{
+ return (labs(v) <= 0x80000000);
+}
+
+static inline int isu32(u64 v)
+{
+ return (v <= 0xffffffff);
+}
+
+static void emit_opsingle(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 op = (u8)((unsigned long) data);
+
+ if(arg1.type != T_NONE || arg2.type != T_NONE)
+ CRAP_INVALID_ARGS;
+
+ emit1(op);
+}
+
+static void emit_opsingle16(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ emit1(0x66);
+ emit_opsingle(mnemonic, arg1, arg2, data);
+}
+
+static void compute_rexmodrmsib(u8* rex_r, u8* modrm_r, u8* sib_r, arg_t* arg1, arg_t* arg2)
+{
+ u8 rex = 0;
+ u8 modrm = 0;
+ u8 sib = 0;
+
+ if((arg1->type == T_REGISTER && arg2->type == T_REGISTER)
+ && ((arg1->v.reg & R_MSZ) != (arg2->v.reg & R_MSZ))
+ && !((arg1->v.reg & R_XMM) || (arg2->v.reg & R_XMM)))
+ crap("both registers must be of same width");
+
+ if((arg1->type == T_REGISTER && arg1->v.reg & R_64)
+ || (arg2->type == T_REGISTER && arg2->v.reg & R_64))
+ {
+ rex |= REX_W;
+ }
+
+ if(arg1->type == T_REGISTER)
+ {
+ if((arg1->v.reg & R_MGP) > 0x07)
+ rex |= REX_R;
+
+ modrm |= (arg1->v.reg & 0x07) << 3;
+ }
+
+ if(arg2->type == T_REGISTER)
+ {
+ if((arg2->v.reg & R_MGP) > 0x07)
+ rex |= REX_B;
+
+ modrm |= (arg2->v.reg & 0x07);
+ }
+
+ if(arg2->type == T_MEMORY)
+ {
+ if((arg2->v.mem.basetype == T_REGISTER && !(arg2->v.mem.base.reg & R_64))
+ || (arg2->v.mem.indextype == T_REGISTER && !(arg2->v.mem.index.reg & R_64)))
+ {
+ crap("only 64bit base/index registers are %x %x", arg2->v.mem.base.reg, arg2->v.mem.index.reg);
+ }
+
+ if(arg2->v.mem.indextype == T_REGISTER)
+ {
+ modrm |= MODRM_RM_SIB;
+ if(!arg2->v.mem.disp)
+ {
+ modrm |= MODRM_MOD_00;
+ }
+ else if(iss8(arg2->v.mem.disp))
+ {
+ modrm |= MODRM_MOD_01;
+ }
+ else if(isu32(arg2->v.mem.disp))
+ {
+ modrm |= MODRM_MOD_10;
+ }
+ else
+ {
+ crap("invalid displacement");
+ }
+
+ if((arg2->v.mem.index.reg & R_MGP) > 0x07)
+ rex |= REX_X;
+
+ if((arg2->v.mem.base.reg & R_MGP) > 0x07)
+ rex |= REX_B;
+
+ if(arg2->v.mem.basetype != T_REGISTER)
+ crap("base must be register");
+ switch(arg2->v.mem.scale)
+ {
+ case 1: break;
+ case 2: sib |= 1 << 6; break;
+ case 4: sib |= 2 << 6; break;
+ case 8: sib |= 3 << 6; break;
+ }
+ sib |= (arg2->v.mem.index.reg & 0x07) << 3;
+ sib |= (arg2->v.mem.base.reg & 0x07);
+ }
+ else if(arg2->v.mem.indextype == T_NONE)
+ {
+ if(!arg2->v.mem.disp)
+ {
+ modrm |= MODRM_MOD_00;
+ }
+ else if(iss8(arg2->v.mem.disp))
+ {
+ modrm |= MODRM_MOD_01;
+ }
+ else if(isu32(arg2->v.mem.disp))
+ {
+ modrm |= MODRM_MOD_10;
+ }
+ else
+ {
+ crap("invalid displacement");
+ }
+
+ if(arg2->v.mem.basetype != T_REGISTER)
+ crap("todo: base != register");
+
+ if((arg2->v.mem.base.reg & R_MGP) > 0x07)
+ rex |= REX_B;
+
+ modrm |= arg2->v.mem.base.reg & 0x07;
+ }
+ else
+ {
+ crap("invalid indextype");
+ }
+ }
+ else
+ {
+ modrm |= MODRM_MOD_11;
+ }
+
+ if(rex)
+ rex |= 0x40; // XXX
+
+ *rex_r = rex;
+ *modrm_r = modrm;
+ *sib_r = sib;
+}
+
+static void maybe_emit_displacement(arg_t* arg)
+{
+ if(arg->type != T_MEMORY)
+ return;
+
+ if(arg->v.mem.disp)
+ {
+ if(iss8(arg->v.mem.disp))
+ {
+ emit1((u8)arg->v.mem.disp);
+ }
+ else if(isu32(arg->v.mem.disp))
+ {
+ emit4(arg->v.mem.disp);
+ }
+ else
+ {
+ crap("invalid displacement");
+ }
+ }
+}
+
+/* one byte operator with register added to operator */
+static void emit_opreg(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 op = (u8)((unsigned long) data);
+
+ if(arg1.type != T_REGISTER || arg2.type != T_NONE)
+ CRAP_INVALID_ARGS;
+
+ if((arg1.v.reg & R_MGP) > 0x07)
+ emit1(0x40 | REX_B);
+
+ op |= (arg1.v.reg & 0x07);
+
+ emit1(op);
+}
+
+/* operator which operates on reg/mem */
+static void emit_op_rm(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex, modrm, sib;
+ opparam_t* params = data;
+
+ if((arg1.type != T_REGISTER && arg1.type != T_MEMORY) || arg2.type != T_NONE)
+ CRAP_INVALID_ARGS;
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ modrm |= params->subcode << 3;
+
+ if(arg1.v.reg & R_16)
+ emit1(0x66);
+
+ if(rex) emit1(rex);
+ if(arg1.v.reg & R_8)
+ emit1(params->rcode8); // op reg8/mem8,
+ else
+ emit1(params->rcode); // op reg/mem,
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg1);
+}
+
+/* operator which operates on reg/mem with cl */
+static void emit_op_rm_cl(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex, modrm, sib;
+ opparam_t* params = data;
+
+ if(arg2.type != T_REGISTER || arg1.type != T_REGISTER)
+ CRAP_INVALID_ARGS;
+
+ if((arg1.v.reg & R_MGP) != R_ECX && !(arg1.v.reg & R_8))
+ crap("only cl register is valid");
+
+ arg1.type = T_NONE; // don't complain, we know it's cl anyways
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ modrm |= params->subcode << 3;
+
+ if(arg2.v.reg & R_16)
+ emit1(0x66);
+
+ if(rex) emit1(rex);
+ if(arg2.v.reg & R_8)
+ emit1(params->rcode8); // op reg8/mem8,
+ else
+ emit1(params->rcode); // op reg/mem,
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg2);
+}
+
+static void emit_mov(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex = 0;
+ u8 modrm = 0;
+ u8 sib = 0;
+
+ if(arg1.type == T_IMMEDIATE && arg2.type == T_REGISTER)
+ {
+ u8 op = 0xb8;
+
+ if(arg2.v.reg & R_8)
+ {
+ if(!isu8(arg1.v.imm))
+ crap("value too large for 8bit register");
+
+ op = 0xb0;
+ }
+ else if(arg2.v.reg & R_16)
+ {
+ if(!isu16(arg1.v.imm))
+ crap("value too large for 16bit register");
+ emit1(0x66);
+ }
+ else if(!arg2.v.reg & R_64)
+ {
+ if(!isu32(arg1.v.imm))
+ crap("value too large for 32bit register");
+ }
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ if(rex) emit1(rex);
+
+ op |= (arg2.v.reg & 0x07);
+
+ emit1(op);
+
+ if(arg2.v.reg & R_8) emit1(arg1.v.imm);
+ else if(arg2.v.reg & R_16) emit2(arg1.v.imm);
+ else if(arg2.v.reg & R_64) emit8(arg1.v.imm);
+ else emit4(arg1.v.imm);
+ }
+ else if(arg1.type == T_IMMEDIATE && arg2.type == T_MEMORY)
+ {
+ if(!iss32(arg1.v.imm))
+ {
+ crap("only 32bit immediates supported");
+ }
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+ if(rex) emit1(rex);
+ emit1(0xc7); // mov reg/mem, imm
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ emit4(arg1.v.imm);
+ }
+ else if(arg1.type == T_REGISTER && arg2.type == T_REGISTER) // XXX: same as next
+ {
+ if(arg1.type != T_REGISTER || arg2.type != T_REGISTER)
+ crap("both args must be registers");
+
+ if((arg1.v.reg & R_MSZ) != (arg2.v.reg & R_MSZ))
+ crap("both registers must be same width");
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ if(rex) emit1(rex);
+ emit1(0x89); // mov reg reg/mem,
+ emit1(modrm);
+ }
+ else if(arg1.type == T_REGISTER && arg2.type == T_MEMORY)
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ if(arg1.v.reg & R_16)
+ emit1(0x66);
+
+ if(rex) emit1(rex);
+ if(arg1.v.reg & R_8)
+ emit1(0x88); // mov reg reg/mem,
+ else
+ emit1(0x89); // mov reg reg/mem,
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg2);
+ }
+ else if(arg1.type == T_MEMORY && arg2.type == T_REGISTER)
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ if(arg2.v.reg & R_16)
+ emit1(0x66);
+
+ if(rex) emit1(rex);
+ if(arg2.v.reg & R_8)
+ emit1(0x8a); // mov reg/mem, reg
+ else
+ emit1(0x8b); // mov reg/mem, reg
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg1);
+ }
+ else
+ CRAP_INVALID_ARGS;
+}
+
+static void emit_subaddand(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex = 0;
+ u8 modrm = 0;
+ u8 sib = 0;
+
+ opparam_t* params = data;
+
+ if(arg1.type == T_IMMEDIATE && arg2.type == T_REGISTER)
+ {
+ if(!iss32(arg1.v.imm))
+ {
+ crap("only 8 and 32 bit immediates supported");
+ }
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ modrm |= params->subcode << 3;
+
+ if(rex) emit1(rex);
+#if 0
+ if(isu8(arg1.v.imm))
+ {
+ emit1(0x83); // sub reg/mem, imm8
+ emit1(modrm);
+ emit1(arg1.v.imm&0xFF);
+ }
+ else
+#endif
+ {
+ emit1(0x81); // sub reg/mem, imm32
+ emit1(modrm);
+ emit4(arg1.v.imm);
+ }
+ }
+ else if(arg1.type == T_REGISTER && (arg2.type == T_MEMORY || arg2.type == T_REGISTER))
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ if(rex) emit1(rex);
+ emit1(params->rmcode); // sub reg/mem, reg
+ emit1(modrm);
+ if(arg2.type == T_MEMORY && (modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg2);
+ }
+ else if(arg1.type == T_MEMORY && arg2.type == T_REGISTER && params->mrcode)
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ if(rex) emit1(rex);
+ emit1(params->mrcode); // sub reg, reg/mem
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg1);
+ }
+ else
+ CRAP_INVALID_ARGS;
+}
+
+static void emit_condjump(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ unsigned off;
+ int disp;
+ unsigned char opcode = (unsigned char)(((unsigned long)data)&0xFF);
+
+ if(arg1.type != T_LABEL || arg2.type != T_NONE)
+ crap("%s: argument must be label", mnemonic);
+
+ emit1(opcode);
+
+ off = lookup_label(arg1.v.label);
+ disp = off-(compiledOfs+1);
+ if(assembler_pass && abs(disp) > 127)
+ crap("cannot jump that far (%x -> %x = %x)", compiledOfs, off, disp);
+
+ emit1(disp);
+}
+
+static void emit_jmp(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ if((arg1.type != T_LABEL && arg1.type != T_REGISTER && arg1.type != T_MEMORY) || arg2.type != T_NONE)
+ CRAP_INVALID_ARGS;
+
+ if(arg1.type == T_LABEL)
+ {
+ unsigned off;
+ int disp;
+
+ off = lookup_label(arg1.v.label);
+ disp = off-(compiledOfs+5);
+ emit1(0xe9);
+ emit4(disp);
+ }
+ else
+ {
+ u8 rex, modrm, sib;
+
+ if(arg1.type == T_REGISTER)
+ {
+ if(!arg1.absolute)
+ crap("jmp must be absolute");
+
+ if((arg1.v.reg & R_64) != R_64)
+ crap("register must be 64bit");
+
+ arg1.v.reg ^= R_64; // no rex required for call
+ }
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ modrm |= 0x4 << 3;
+
+ if(rex) emit1(rex);
+ emit1(0xff);
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+ maybe_emit_displacement(&arg1);
+ }
+}
+
+static void emit_call(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex, modrm, sib;
+
+ if(arg1.type != T_REGISTER || arg2.type != T_NONE)
+ CRAP_INVALID_ARGS;
+
+ if(!arg1.absolute)
+ crap("call must be absolute");
+
+ if((arg1.v.reg & R_64) != R_64)
+ crap("register must be 64bit");
+
+ arg1.v.reg ^= R_64; // no rex required for call
+
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ modrm |= 0x2 << 3;
+
+ if(rex) emit1(rex);
+ emit1(0xff);
+ emit1(modrm);
+}
+
+
+static void emit_twobyte(const char* mnemonic, arg_t arg1, arg_t arg2, void* data)
+{
+ u8 rex, modrm, sib;
+
+ opparam_t* params = data;
+
+ if(arg1.type == T_REGISTER && (arg2.type == T_MEMORY || arg2.type == T_REGISTER))
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg1, &arg2);
+
+ if(params->xmmprefix) emit1(params->xmmprefix);
+ if(rex) emit1(rex);
+ emit1(0x0f);
+ emit1(params->rmcode); // sub reg/mem, reg
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg2);
+ }
+ else if(arg1.type == T_MEMORY && arg2.type == T_REGISTER && params->mrcode)
+ {
+ compute_rexmodrmsib(&rex, &modrm, &sib, &arg2, &arg1);
+
+ if(params->xmmprefix) emit1(params->xmmprefix);
+ if(rex) emit1(rex);
+ emit1(0x0f);
+ emit1(params->mrcode); // sub reg, reg/mem
+ emit1(modrm);
+ if((modrm & 0x07) == MODRM_RM_SIB)
+ emit1(sib);
+
+ maybe_emit_displacement(&arg1);
+ }
+ else
+ CRAP_INVALID_ARGS;
+}
+
+static opparam_t params_add = { subcode: 0, rmcode: 0x01, };
+static opparam_t params_or = { subcode: 1, rmcode: 0x09, };
+static opparam_t params_and = { subcode: 4, rmcode: 0x21, };
+static opparam_t params_sub = { subcode: 5, rmcode: 0x29, };
+static opparam_t params_xor = { subcode: 6, rmcode: 0x31, };
+static opparam_t params_cmp = { subcode: 6, rmcode: 0x39, mrcode: 0x3b, };
+static opparam_t params_dec = { subcode: 1, rcode: 0xff, rcode8: 0xfe, };
+static opparam_t params_sar = { subcode: 7, rcode: 0xd3, rcode8: 0xd2, };
+static opparam_t params_shl = { subcode: 4, rcode: 0xd3, rcode8: 0xd2, };
+static opparam_t params_shr = { subcode: 5, rcode: 0xd3, rcode8: 0xd2, };
+static opparam_t params_idiv = { subcode: 7, rcode: 0xf7, rcode8: 0xf6, };
+static opparam_t params_div = { subcode: 6, rcode: 0xf7, rcode8: 0xf6, };
+static opparam_t params_imul = { subcode: 5, rcode: 0xf7, rcode8: 0xf6, };
+static opparam_t params_mul = { subcode: 4, rcode: 0xf7, rcode8: 0xf6, };
+static opparam_t params_neg = { subcode: 3, rcode: 0xf7, rcode8: 0xf6, };
+static opparam_t params_not = { subcode: 2, rcode: 0xf7, rcode8: 0xf6, };
+
+static opparam_t params_cvtsi2ss = { xmmprefix: 0xf3, rmcode: 0x2a };
+static opparam_t params_cvttss2si = { xmmprefix: 0xf3, rmcode: 0x2c };
+static opparam_t params_addss = { xmmprefix: 0xf3, mrcode: 0x58 };
+static opparam_t params_divss = { xmmprefix: 0xf3, mrcode: 0x5e };
+static opparam_t params_movss = { xmmprefix: 0xf3, mrcode: 0x10, rmcode: 0x11 };
+static opparam_t params_mulss = { xmmprefix: 0xf3, mrcode: 0x59 };
+static opparam_t params_subss = { xmmprefix: 0xf3, mrcode: 0x5c };
+static opparam_t params_ucomiss = { mrcode: 0x2e };
+
+static int ops_sorted = 0;
+static op_t ops[] = {
+ { "addl", emit_subaddand, ¶ms_add },
+ { "addq", emit_subaddand, ¶ms_add },
+ { "addss", emit_twobyte, ¶ms_addss },
+ { "andl", emit_subaddand, ¶ms_and },
+ { "andq", emit_subaddand, ¶ms_and },
+ { "callq", emit_call, NULL },
+ { "cbw", emit_opsingle16, (void*)0x98 },
+ { "cdq", emit_opsingle, (void*)0x99 },
+ { "cmpl", emit_subaddand, ¶ms_cmp },
+ { "cmpq", emit_subaddand, ¶ms_cmp },
+ { "cvtsi2ss", emit_twobyte, ¶ms_cvtsi2ss },
+ { "cvttss2si", emit_twobyte, ¶ms_cvttss2si },
+ { "cwde", emit_opsingle, (void*)0x98 },
+ { "decl", emit_op_rm, ¶ms_dec },
+ { "decq", emit_op_rm, ¶ms_dec },
+ { "divl", emit_op_rm, ¶ms_div },
+ { "divq", emit_op_rm, ¶ms_div },
+ { "divss", emit_twobyte, ¶ms_divss },
+ { "idivl", emit_op_rm, ¶ms_idiv },
+ { "imull", emit_op_rm, ¶ms_imul },
+ { "int3", emit_opsingle, (void*)0xcc },
+ { "ja", emit_condjump, (void*)0x77 },
+ { "jbe", emit_condjump, (void*)0x76 },
+ { "jb", emit_condjump, (void*)0x72 },
+ { "je", emit_condjump, (void*)0x74 },
+ { "jl", emit_condjump, (void*)0x7c },
+ { "jmp", emit_jmp, NULL },
+ { "jmpq", emit_jmp, NULL },
+ { "jnae", emit_condjump, (void*)0x72 },
+ { "jna", emit_condjump, (void*)0x76 },
+ { "jnbe", emit_condjump, (void*)0x77 },
+ { "jnb", emit_condjump, (void*)0x73 },
+ { "jnc", emit_condjump, (void*)0x73 },
+ { "jne", emit_condjump, (void*)0x75 },
+ { "jnge", emit_condjump, (void*)0x7c },
+ { "jng", emit_condjump, (void*)0x7e },
+ { "jnle", emit_condjump, (void*)0x7f },
+ { "jnl", emit_condjump, (void*)0x7d },
+ { "jnz", emit_condjump, (void*)0x75 },
+ { "jp", emit_condjump, (void*)0x7a },
+ { "jz", emit_condjump, (void*)0x74 },
+ { "movb", emit_mov, NULL },
+ { "movl", emit_mov, NULL },
+ { "movq", emit_mov, NULL },
+ { "movss", emit_twobyte, ¶ms_movss },
+ { "movw", emit_mov, NULL },
+ { "mull", emit_op_rm, ¶ms_mul },
+ { "mulss", emit_twobyte, ¶ms_mulss },
+ { "negl", emit_op_rm, ¶ms_neg },
+ { "negq", emit_op_rm, ¶ms_neg },
+ { "nop", emit_opsingle, (void*)0x90 },
+ { "notl", emit_op_rm, ¶ms_not },
+ { "notq", emit_op_rm, ¶ms_not },
+ { "or", emit_subaddand, ¶ms_or },
+ { "orl", emit_subaddand, ¶ms_or },
+ { "pop", emit_opreg, (void*)0x58 },
+ { "push", emit_opreg, (void*)0x50 },
+ { "ret", emit_opsingle, (void*)0xc3 },
+ { "sarl", emit_op_rm_cl, ¶ms_sar },
+ { "shl", emit_op_rm_cl, ¶ms_shl },
+ { "shrl", emit_op_rm_cl, ¶ms_shr },
+ { "subl", emit_subaddand, ¶ms_sub },
+ { "subq", emit_subaddand, ¶ms_sub },
+ { "subss", emit_twobyte, ¶ms_subss },
+ { "ucomiss", emit_twobyte, ¶ms_ucomiss },
+ { "xorl", emit_subaddand, ¶ms_xor },
+ { "xorq", emit_subaddand, ¶ms_xor },
+ { NULL, NULL, NULL }
+};
+
+static int opsort(const void* A, const void* B)
+{
+ const op_t* a = A;
+ const op_t* b = B;
+ return strcmp(a->mnemonic, b->mnemonic);
+}
+
+static op_t* getop(const char* n)
+{
+#if 0
+ op_t* o = ops;
+ while(o->mnemonic)
+ {
+ if(!strcmp(o->mnemonic, n))
+ return o;
+ ++o;
+ }
+
+#else
+ unsigned m, t, b;
+ int r;
+ t = sizeof(ops)/sizeof(ops[0])-1;
+ b = 0;
+
+ while(b <= t)
+ {
+ m = ((t-b)>>1) + b;
+ if((r = strcmp(ops[m].mnemonic, n)) == 0)
+ {
+ return &ops[m];
+ }
+ else if(r < 0)
+ {
+ b = m + 1;
+ }
+ else
+ {
+ t = m - 1;
+ }
+ }
+#endif
+
+ return NULL;
+}
+
+static reg_t parsereg(const char* str)
+{
+ const char* s = str;
+ if(*s == 'a' && s[1] == 'l' && !s[2])
+ {
+ return R_AL;
+ }
+ else if(*s == 'a' && s[1] == 'x' && !s[2])
+ {
+ return R_AX;
+ }
+ if(*s == 'c' && s[1] == 'l' && !s[2])
+ {
+ return R_CL;
+ }
+ if(*s == 'x')
+ {
+ if(!strcmp(s, "xmm0"))
+ return R_XMM0;
+ }
+ else if(*s == 'r' && s[1])
+ {
+ ++s;
+ if(s[1] == 'x')
+ {
+ switch(*s++)
+ {
+ case 'a': return R_RAX;
+ case 'b': return R_RBX;
+ case 'c': return R_RCX;
+ case 'd': return R_RDX;
+ }
+ }
+ else if(s[1] == 'i')
+ {
+ switch(*s++)
+ {
+ case 's': return R_RSI;
+ case 'd': return R_RDI;
+ }
+ }
+ else if(s[0] == 's' && s[1] == 'p' && !s[2])
+ {
+ return R_RSP;
+ }
+ else if(*s == '8' && !s[1])
+ return R_R8;
+ else if(*s == '9' && !s[1])
+ return R_R9;
+ else if(*s == '1' && s[1] == '0')
+ return R_R10;
+ else if(*s == '1' && s[1] == '5')
+ return R_R15;
+ }
+ else if(*s == 'e' && s[1])
+ {
+ ++s;
+ if(s[1] == 'x')
+ {
+ switch(*s++)
+ {
+ case 'a': return R_EAX;
+ case 'b': return R_EBX;
+ case 'c': return R_ECX;
+ case 'd': return R_EDX;
+ }
+ }
+ else if(s[1] == 'i')
+ {
+ switch(*s++)
+ {
+ case 's': return R_ESI;
+ case 'd': return R_EDI;
+ }
+ }
+ }
+
+ crap("invalid register %s", str);
+
+ return 0;
+}
+
+typedef enum {
+ TOK_LABEL = 0x80,
+ TOK_INT = 0x81,
+ TOK_END = 0x82,
+ TOK_INVALID = 0x83,
+} token_t;
+
+static unsigned char nexttok(const char** str, char* label, u64* val)
+{
+ const char* s = *str;
+
+ if(label) *label = 0;
+ if(val) *val = 0;
+
+ while(*s && *s == ' ') ++s;
+
+ if(!*s)
+ {
+ return TOK_END;
+ }
+ else if(*s == '$' || *s == '*' || *s == '%' || *s == '-' || *s == ')' || *s == '(' || *s == ',')
+ {
+ *str = s+1;
+ return *s;
+ }
+ else if(*s >= 'a' && *s <= 'z')
+ {
+ size_t a = strspn(s+1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
+ if(a+1 >= LABELLEN)
+ crap("label %s too long", s);
+ if(label)
+ {
+ strncpy(label, s, a+1);
+ label[a+1] = 0;
+ }
+ *str = s+a+1;
+ return TOK_LABEL;
+ }
+ else if(*s >= '0' && *s <= '9')
+ {
+ char* endptr = NULL;
+ u64 v = strtol(s, &endptr, 0);
+ if(endptr && (endptr-s == 0))
+ crap("invalid integer %s", s);
+ if(val) *val = v;
+ *str = endptr;
+ return TOK_INT;
+ }
+ crap("can't parse '%s'", *str);
+ return TOK_INVALID;
+}
+
+static arg_t parsearg(const char** str)
+{
+ arg_t arg;
+ const char* s = *str;
+ char label[20];
+ u64 val;
+ int negative = 1;
+ unsigned ttype;
+
+ arg.type = T_NONE;
+ arg.absolute = 0;
+
+ while(*s && *s == ' ') ++s;
+
+ switch(nexttok(&s, label, &val))
+ {
+ case '$' :
+ ttype = nexttok(&s, NULL, &val);
+ if(ttype == '-')
+ {
+ negative = -1;
+ ttype = nexttok(&s, NULL, &val);
+ }
+ if(ttype != TOK_INT)
+ crap("expected integer");
+ arg.type = T_IMMEDIATE;
+ arg.v.imm = negative * val;
+ break;
+ case '*' :
+ if((ttype = nexttok(&s, NULL, NULL)) != '%')
+ {
+ if(ttype == '(')
+ goto tok_memory;
+ crap("expected '%%'");
+ }
+ arg.absolute = 1;
+ /* fall through */
+ case '%' :
+ if(nexttok(&s, label, &val) != TOK_LABEL)
+ crap("expected label");
+ arg.type = T_REGISTER;
+ arg.v.reg = parsereg(label);
+ break;
+ case TOK_LABEL:
+ arg.type = T_LABEL;
+ strncpy(arg.v.label, label, LABELLEN);
+ break;
+ case '-':
+ negative = -1;
+ if(nexttok(&s, NULL, &val) != TOK_INT)
+ crap("expected integer");
+ /* fall through */
+ case TOK_INT:
+ if(nexttok(&s, label, NULL) != '(')
+ crap("expected '('"); // mov to/from fixed address not supported
+ /* fall through */
+ case '(':
+tok_memory:
+ arg.type = T_MEMORY;
+ arg.v.mem.indextype = T_NONE;
+ arg.v.mem.disp = negative * val;
+ ttype = nexttok(&s, label, &val);
+ if(ttype == '%' && nexttok(&s, label, &val) != TOK_LABEL)
+ {
+ crap("expected register");
+ }
+ if (ttype == '%')
+ {
+ arg.v.mem.basetype = T_REGISTER;
+ arg.v.mem.base.reg = parsereg(label);
+ }
+ else if (ttype == TOK_INT)
+ {
+ arg.v.mem.basetype = T_IMMEDIATE;
+ arg.v.mem.base.imm = val;
+ }
+ if((ttype = nexttok(&s, NULL, NULL)) == ',')
+ {
+ ttype = nexttok(&s, label, &val);
+ if(ttype == '%' && nexttok(&s, label, &val) != TOK_LABEL)
+ {
+ crap("expected register");
+ }
+ if (ttype == '%')
+ {
+ arg.v.mem.indextype = T_REGISTER;
+ arg.v.mem.index.reg = parsereg(label);
+ }
+ else if (ttype == TOK_INT)
+ {
+ crap("index must be register");
+ arg.v.mem.indextype = T_IMMEDIATE;
+ arg.v.mem.index.imm = val;
+ }
+ if(nexttok(&s, NULL, NULL) != ',')
+ crap("expected ','");
+ if(nexttok(&s, NULL, &val) != TOK_INT)
+ crap("expected integer");
+ if(val != 1 && val != 2 && val != 4 && val != 8)
+ crap("scale must 1, 2, 4 or 8");
+ arg.v.mem.scale = val;
+
+ ttype = nexttok(&s, NULL, NULL);
+ }
+ if(ttype != ')')
+ {
+ crap("expected ')' or ','");
+ }
+ break;
+ default:
+ crap("invalid token %hhu in %s", *(unsigned char*)s, *str);
+ break;
+ }
+
+ *str = s;
+
+ return arg;
+}
+
+/* ************************* */
+
+void assembler_init(int pass)
+{
+ compiledOfs = 0;
+ assembler_pass = pass;
+ if(!pass)
+ {
+ labelhash_free();
+ cur_line = NULL;
+ }
+ if(!ops_sorted)
+ {
+ ops_sorted = 1;
+ qsort(ops, sizeof(ops)/sizeof(ops[0])-1, sizeof(ops[0]), opsort);
+ }
+}
+
+size_t assembler_get_code_size(void)
+{
+ return compiledOfs;
+}
+
+void assembler_set_output(char* buf)
+{
+ out = buf;
+}
+
+void assemble_line(const char* input, size_t len)
+{
+ char line[4096];
+ char* s;
+ op_t* o;
+ char* opn;
+ arg_t arg1, arg2;
+
+ arg1.type = T_NONE;
+ arg2.type = T_NONE;
+ opn = NULL;
+ o = NULL;
+
+ if(len < 1)
+ return;
+
+ if(len >= sizeof(line))
+ crap("line too long");
+
+ memcpy(line, input, sizeof(line));
+ cur_line = input;
+
+ if(line[len-1] == '\n') line[--len] = 0;
+ if(line[len-1] == ':')
+ {
+ line[--len] = 0;
+ if(assembler_pass)
+ debug("%s: 0x%x\n", line, compiledOfs);
+ else
+ hash_add_label(line, compiledOfs);
+ }
+ else
+ {
+ opn = line;
+ s = strchr(line, ' ');
+ if(s)
+ {
+ *s++ = 0;
+ arg1 = parsearg((const char**)&s);
+ if(*s)
+ {
+ if(*s != ',')
+ crap("expected ',', got '%c'", *s);
+ ++s;
+ arg2 = parsearg((const char**)&s);
+ }
+ }
+
+ if(!opn)
+ {
+ crap("no operator in %s", line);
+ }
+
+ o = getop(opn);
+ if(!o)
+ {
+ crap("cannot handle op %s", opn);
+ }
+ o->func(opn, arg1, arg2, o->data);
+ if(assembler_pass)
+ debug(" - %s%s", cur_line, cur_line[strlen(cur_line)-1]=='\n'?"":"\n");
+ }
+}
+
+#ifdef SA_STANDALONE
+int main(int argc, char* argv[])
+{
+ char line[4096];
+ size_t len;
+ int pass;
+ FILE* file = NULL;
+
+ if(argc < 2)
+ {
+ crap("specify file");
+ }
+
+ file = fopen(argv[1], "r");
+ if(!file)
+ {
+ crap("can't open file");
+ }
+
+ if(argc > 2)
+ {
+ fout = fopen(argv[2], "w");
+ if(!fout)
+ {
+ crap("can't open %s for writing", argv[2]);
+ }
+ }
+
+ for(pass = 0; pass < 2; ++pass)
+ {
+ if(fseek(file, 0, SEEK_SET))
+ crap("can't rewind file");
+
+ if(pass)
+ {
+ char* b = malloc(assembler_get_code_size());
+ if(!b)
+ crap("cannot allocate memory");
+ assembler_set_output(b);
+ }
+
+ assembler_init(pass);
+
+ while(fgets(line, sizeof(line), file))
+ {
+ len = strlen(line);
+ if(!len) continue;
+
+ assemble_line(line, len);
+ }
+ }
+
+ assembler_init(0);
+
+ fclose(file);
+
+ return 0;
+}
+#endif
Modified: branches/1.34/code/renderer/tr_init.c
===================================================================
--- branches/1.34/code/renderer/tr_init.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/renderer/tr_init.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -132,7 +132,7 @@
cvar_t *r_customwidth;
cvar_t *r_customheight;
-cvar_t *r_customaspect;
+cvar_t *r_customPixelAspect;
cvar_t *r_overBrightBits;
cvar_t *r_mapOverBrightBits;
@@ -307,6 +307,7 @@
qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) {
vidmode_t *vm;
+ float pixelAspect;
if ( mode < -1 ) {
return qfalse;
@@ -318,17 +319,18 @@
if ( mode == -1 ) {
*width = r_customwidth->integer;
*height = r_customheight->integer;
- *windowAspect = r_customaspect->value;
- return qtrue;
+ pixelAspect = r_customPixelAspect->value;
+ } else {
+ vm = &r_vidModes[mode];
+
+ *width = vm->width;
+ *height = vm->height;
+ pixelAspect = vm->pixelAspect;
}
- vm = &r_vidModes[mode];
+ *windowAspect = (float)*width / ( *height * pixelAspect );
- *width = vm->width;
- *height = vm->height;
- *windowAspect = (float)vm->width / ( vm->height * vm->pixelAspect );
-
- return qtrue;
+ return qtrue;
}
/*
@@ -943,7 +945,7 @@
#endif
r_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH );
r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH );
- r_customaspect = ri.Cvar_Get( "r_customaspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
+ r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0);
@@ -977,7 +979,12 @@
r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE );
r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE);
r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE );
+#if USE_SDL_VIDEO
+ r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0",
+ CVAR_ARCHIVE | CVAR_LATCH );
+#else
r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0", CVAR_ARCHIVE );
+#endif
r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE );
r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE );
@@ -1077,7 +1084,7 @@
// Swap_Init();
- if ( (int)tess.xyz & 15 ) {
+ if ( (intptr_t)tess.xyz & 15 ) {
Com_Printf( "WARNING: tess.xyz not 16 byte aligned\n" );
}
Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );
Modified: branches/1.34/code/renderer/tr_shader.c
===================================================================
--- branches/1.34/code/renderer/tr_shader.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/renderer/tr_shader.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -2282,9 +2282,8 @@
shader.numUnfoggedPasses = stage;
// fogonly shaders don't have any normal passes
- if ( stage == 0 ) {
+ if (stage == 0 && !shader.isSky)
shader.sort = SS_FOG;
- }
// determine which stage iterator function is appropriate
ComputeStageIteratorFunc();
@@ -2892,7 +2891,7 @@
char filename[MAX_QPATH];
Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] );
- ri.Printf( PRINT_ALL, "...loading '%s'\n", filename );
+ ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename );
sum += ri.FS_ReadFile( filename, (void **)&buffers[i] );
if ( !buffers[i] ) {
ri.Error( ERR_DROP, "Couldn't load %s", filename );
Modified: branches/1.34/code/server/sv_client.c
===================================================================
--- branches/1.34/code/server/sv_client.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/server/sv_client.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -149,7 +149,6 @@
int i;
char *s;
char *r;
- char ret[1024];
if ( !NET_CompareBaseAdr( from, svs.authorizeAddress ) ) {
Com_Printf( "SV_AuthorizeIpPacket: not from authorize server\n" );
@@ -195,8 +194,7 @@
if (!r) {
NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, "print\nAwaiting CD key authorization\n" );
} else {
- sprintf(ret, "print\n%s\n", r);
- NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, ret );
+ NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, "print\n%s\n", r);
}
// clear the challenge record so it won't timeout and let them through
Com_Memset( &svs.challenges[i], 0, sizeof( svs.challenges[i] ) );
@@ -207,8 +205,7 @@
if (!r) {
NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, "print\nSomeone is using this CD Key\n" );
} else {
- sprintf(ret, "print\n%s\n", r);
- NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, ret );
+ NET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, "print\n%s\n", r );
}
// clear the challenge record so it won't timeout and let them through
@@ -241,6 +238,7 @@
int startIndex;
intptr_t denied;
int count;
+ char *ip;
Com_DPrintf ("SVC_DirectConnect ()\n");
@@ -272,6 +270,19 @@
break;
}
}
+
+ // don't let "ip" overflow userinfo string
+ if ( NET_IsLocalAddress (from) )
+ ip = "localhost";
+ else
+ ip = (char *)NET_AdrToString( from );
+ if( ( strlen( ip ) + strlen( userinfo ) + 4 ) >= MAX_INFO_STRING ) {
+ NET_OutOfBandPrint( NS_SERVER, from,
+ "print\nUserinfo string length exceeded. "
+ "Try removing setu cvars from your config.\n" );
+ return;
+ }
+ Info_SetValueForKey( userinfo, "ip", ip );
// see if the challenge is valid (LAN clients don't need to challenge)
if ( !NET_IsLocalAddress (from) ) {
@@ -288,8 +299,6 @@
NET_OutOfBandPrint( NS_SERVER, from, "print\nNo or bad challenge for address.\n" );
return;
}
- // force the IP key/value pair so the game can filter based on ip
- Info_SetValueForKey( userinfo, "ip", NET_AdrToString( from ) );
ping = svs.time - svs.challenges[i].pingTime;
Com_Printf( "Client %i connecting with %i challenge ping\n", i, ping );
@@ -312,9 +321,6 @@
return;
}
}
- } else {
- // force the "ip" info key to "localhost"
- Info_SetValueForKey( userinfo, "ip", "localhost" );
}
newcl = &temp;
@@ -496,8 +502,6 @@
// tell everyone why they got dropped
SV_SendServerCommand( NULL, "print \"%s" S_COLOR_WHITE " %s\n\"", drop->name, reason );
- Com_DPrintf( "Going to CS_ZOMBIE for %s\n", drop->name );
- drop->state = CS_ZOMBIE; // become free in a few seconds
if (drop->download) {
FS_FCloseFile( drop->download );
@@ -517,6 +521,9 @@
// nuke user info
SV_SetUserinfo( drop - svs.clients, "" );
+
+ Com_DPrintf( "Going to CS_ZOMBIE for %s\n", drop->name );
+ drop->state = CS_ZOMBIE; // become free in a few seconds
// if this was the last client on the server, send a heartbeat
// to the master so it is known the server is empty
@@ -682,7 +689,7 @@
*/
void SV_StopDownload_f( client_t *cl ) {
if (*cl->downloadName)
- Com_DPrintf( "clientDownload: %d : file \"%s\" aborted\n", cl - svs.clients, cl->downloadName );
+ Com_DPrintf( "clientDownload: %d : file \"%s\" aborted\n", (int) (cl - svs.clients), cl->downloadName );
SV_CloseDownload( cl );
}
@@ -713,11 +720,11 @@
int block = atoi( Cmd_Argv(1) );
if (block == cl->downloadClientBlock) {
- Com_DPrintf( "clientDownload: %d : client acknowledge of block %d\n", cl - svs.clients, block );
+ Com_DPrintf( "clientDownload: %d : client acknowledge of block %d\n", (int) (cl - svs.clients), block );
// Find out if we are done. A zero-length block indicates EOF
if (cl->downloadBlockSize[cl->downloadClientBlock % MAX_DOWNLOAD_WINDOW] == 0) {
- Com_Printf( "clientDownload: %d : file \"%s\" completed\n", cl - svs.clients, cl->downloadName );
+ Com_Printf( "clientDownload: %d : file \"%s\" completed\n", (int) (cl - svs.clients), cl->downloadName );
SV_CloseDownload( cl );
return;
}
@@ -805,16 +812,18 @@
}
// We open the file here
- if ( !sv_allowDownload->integer || idPack || unreferenced ||
+ if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
+ (sv_allowDownload->integer & DLF_NO_UDP) ||
+ idPack || unreferenced ||
( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) <= 0 ) {
// cannot auto-download file
if(unreferenced)
{
- Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", cl - svs.clients, cl->downloadName);
+ Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", (int) (cl - svs.clients), cl->downloadName);
Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" is not referenced and cannot be downloaded.", cl->downloadName);
}
else if (idPack) {
- Com_Printf("clientDownload: %d : \"%s\" cannot download id pk3 files\n", cl - svs.clients, cl->downloadName);
+ Com_Printf("clientDownload: %d : \"%s\" cannot download id pk3 files\n", (int) (cl - svs.clients), cl->downloadName);
if (missionPack) {
Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload Team Arena file \"%s\"\n"
"The Team Arena mission pack can be found in your local game store.", cl->downloadName);
@@ -822,8 +831,11 @@
else {
Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload id pk3 file \"%s\"", cl->downloadName);
}
- } else if ( !sv_allowDownload->integer ) {
- Com_Printf("clientDownload: %d : \"%s\" download disabled", cl - svs.clients, cl->downloadName);
+ }
+ else if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
+ (sv_allowDownload->integer & DLF_NO_UDP) ) {
+
+ Com_Printf("clientDownload: %d : \"%s\" download disabled", (int) (cl - svs.clients), cl->downloadName);
if (sv_pure->integer) {
Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n"
"You will need to get this file elsewhere before you "
@@ -837,7 +849,7 @@
} else {
// NOTE TTimo this is NOT supposed to happen unless bug in our filesystem scheme?
// if the pk3 is referenced, it must have been found somewhere in the filesystem
- Com_Printf("clientDownload: %d : \"%s\" file not found on server\n", cl - svs.clients, cl->downloadName);
+ Com_Printf("clientDownload: %d : \"%s\" file not found on server\n", (int) (cl - svs.clients), cl->downloadName);
Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" not found on server for autodownloading.\n", cl->downloadName);
}
MSG_WriteByte( msg, svc_download );
@@ -849,7 +861,7 @@
return;
}
- Com_Printf( "clientDownload: %d : beginning \"%s\"\n", cl - svs.clients, cl->downloadName );
+ Com_Printf( "clientDownload: %d : beginning \"%s\"\n", (int) (cl - svs.clients), cl->downloadName );
// Init
cl->downloadCurrentBlock = cl->downloadClientBlock = cl->downloadXmitBlock = 0;
@@ -958,7 +970,7 @@
MSG_WriteData( msg, cl->downloadBlocks[curindex], cl->downloadBlockSize[curindex] );
}
- Com_DPrintf( "clientDownload: %d : writing block %d\n", cl - svs.clients, cl->downloadXmitBlock );
+ Com_DPrintf( "clientDownload: %d : writing block %d\n", (int) (cl - svs.clients), cl->downloadXmitBlock );
// Move on to the next block
// It will get sent with next snap shot. The rate will keep us in line.
@@ -1162,7 +1174,9 @@
*/
void SV_UserinfoChanged( client_t *cl ) {
char *val;
+ char *ip;
int i;
+ int len;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name) );
@@ -1211,18 +1225,23 @@
// TTimo
// maintain the IP information
- // this is set in SV_DirectConnect (directly on the server, not transmitted), may be lost when client updates it's userinfo
// the banning code relies on this being consistently present
- val = Info_ValueForKey (cl->userinfo, "ip");
- if (!val[0])
- {
- //Com_DPrintf("Maintain IP in userinfo for '%s'\n", cl->name);
- if ( !NET_IsLocalAddress(cl->netchan.remoteAddress) )
- Info_SetValueForKey( cl->userinfo, "ip", NET_AdrToString( cl->netchan.remoteAddress ) );
- else
- // force the "ip" info key to "localhost" for local clients
- Info_SetValueForKey( cl->userinfo, "ip", "localhost" );
- }
+ if( NET_IsLocalAddress(cl->netchan.remoteAddress) )
+ ip = "localhost";
+ else
+ ip = (char*)NET_AdrToString( cl->netchan.remoteAddress );
+
+ val = Info_ValueForKey( cl->userinfo, "ip" );
+ if( val[0] )
+ len = strlen( ip ) - strlen( val ) + strlen( cl->userinfo );
+ else
+ len = strlen( ip ) + 4 + strlen( cl->userinfo );
+
+ if( len >= MAX_INFO_STRING )
+ SV_DropClient( cl, "userinfo string length exceeded" );
+ else
+ Info_SetValueForKey( cl->userinfo, "ip", ip );
+
}
@@ -1428,7 +1447,7 @@
if (cl->state == CS_ACTIVE)
{
// we didn't get a cp yet, don't assume anything and just send the gamestate all over again
- Com_DPrintf( "%s: didn't get cp command, resending gamestate\n", cl->name, cl->state );
+ Com_DPrintf( "%s: didn't get cp command, resending gamestate\n", cl->name);
SV_SendClientGameState( cl );
}
return;
@@ -1578,7 +1597,7 @@
} else if ( c == clc_moveNoDelta ) {
SV_UserMove( cl, msg, qfalse );
} else if ( c != clc_EOF ) {
- Com_Printf( "WARNING: bad command byte for client %i\n", cl - svs.clients );
+ Com_Printf( "WARNING: bad command byte for client %i\n", (int) (cl - svs.clients) );
}
// if ( msg->readcount != msg->cursize ) {
// Com_Printf( "WARNING: Junk at end of packet for client %i\n", cl - svs.clients );
Modified: branches/1.34/code/server/sv_game.c
===================================================================
--- branches/1.34/code/server/sv_game.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/server/sv_game.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -308,10 +308,10 @@
intptr_t SV_GameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case G_PRINT:
- Com_Printf( "%s", VMA(1) );
+ Com_Printf( "%s", (const char*)VMA(1) );
return 0;
case G_ERROR:
- Com_Error( ERR_DROP, "%s", VMA(1) );
+ Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
return 0;
case G_MILLISECONDS:
return Sys_Milliseconds();
@@ -854,7 +854,7 @@
default:
- Com_Error( ERR_DROP, "Bad game system trap: %i", args[0] );
+ Com_Error( ERR_DROP, "Bad game system trap: %ld", (long int) args[0] );
}
return -1;
}
Modified: branches/1.34/code/server/sv_init.c
===================================================================
--- branches/1.34/code/server/sv_init.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/server/sv_init.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -655,6 +655,7 @@
Cvar_Get ("nextmap", "", CVAR_TEMP );
sv_allowDownload = Cvar_Get ("sv_allowDownload", "0", CVAR_SERVERINFO);
+ Cvar_Get ("sv_dlURL", "", CVAR_SERVERINFO | CVAR_ARCHIVE);
sv_master[0] = Cvar_Get ("sv_master1", MASTER_SERVER_NAME, 0 );
sv_master[1] = Cvar_Get ("sv_master2", "", CVAR_ARCHIVE );
sv_master[2] = Cvar_Get ("sv_master3", "", CVAR_ARCHIVE );
@@ -746,6 +747,7 @@
Com_Printf( "---------------------------\n" );
// disconnect any local clients
- CL_Disconnect( qfalse );
+ if( sv_killserver->integer != 2 )
+ CL_Disconnect( qfalse );
}
Modified: branches/1.34/code/server/sv_main.c
===================================================================
--- branches/1.34/code/server/sv_main.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/server/sv_main.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -461,7 +461,7 @@
// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=534
time = Com_Milliseconds();
- if (time<(lasttime+500)) {
+ if ( (unsigned)( time - lasttime ) < 500u ) {
return;
}
lasttime = time;
Modified: branches/1.34/code/tools/asm/Makefile
===================================================================
--- branches/1.34/code/tools/asm/Makefile 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/tools/asm/Makefile 2007-08-22 21:25:32 UTC (rev 1127)
@@ -28,9 +28,9 @@
CXX := ccache $(CXX)
endif
-default: q3asm
+default: q3asm
-q3asm: q3asm.c cmdlib.c
+q3asm: q3asm.c cmdlib.c
$(CC) $(Q3ASM_CFLAGS) -o $@ $^
clean:
Modified: branches/1.34/code/tools/asm/cmdlib.c
===================================================================
--- branches/1.34/code/tools/asm/cmdlib.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/tools/asm/cmdlib.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -312,7 +312,7 @@
char *ExpandPath (const char *path)
{
static char full[1024];
- if (!qdir)
+ if (!qdir[0])
Error ("ExpandPath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path );
@@ -325,7 +325,7 @@
char *ExpandGamePath (const char *path)
{
static char full[1024];
- if (!qdir)
+ if (!qdir[0])
Error ("ExpandGamePath called without qdir set");
if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
strcpy( full, path );
Modified: branches/1.34/code/ui/ui_main.c
===================================================================
--- branches/1.34/code/ui/ui_main.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/ui/ui_main.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -946,7 +946,7 @@
trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
handle = trap_PC_LoadSource( "ui/menus.txt" );
if (!handle) {
- trap_Error( va( S_COLOR_RED "default menu file not found: ui/menus.txt, unable to continue!\n", menuFile ) );
+ trap_Error( va( S_COLOR_RED "default menu file not found: ui/menus.txt, unable to continue!\n") );
}
}
Modified: branches/1.34/code/ui/ui_players.c
===================================================================
--- branches/1.34/code/ui/ui_players.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/ui/ui_players.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1204,7 +1204,7 @@
}
}
- if (headModelName && headModelName[0] == '*' ) {
+ if (headModelName[0] == '*' ) {
Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headModelName[1], &headModelName[1] );
}
else {
Modified: branches/1.34/code/unix/linux_glimp.c
===================================================================
--- branches/1.34/code/unix/linux_glimp.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/linux_glimp.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -199,8 +199,8 @@
static char *XLateKey(XKeyEvent *ev, int *key)
{
- static char buf[64];
- static char bufnomod[2];
+ static unsigned char buf[64];
+ static unsigned char bufnomod[2];
KeySym keysym;
int XLookupRet;
Modified: branches/1.34/code/unix/linux_signals.c
===================================================================
--- branches/1.34/code/unix/linux_signals.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/linux_signals.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -27,7 +27,7 @@
#include "../renderer/tr_local.h"
#endif
-static qboolean signalcaught = qfalse;;
+static qboolean signalcaught = qfalse;
void Sys_Exit(int); // bk010104 - abstraction
Modified: branches/1.34/code/unix/sdl_glimp.c
===================================================================
--- branches/1.34/code/unix/sdl_glimp.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/sdl_glimp.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -10,7 +10,7 @@
* GPL release of Quake 3.
*
* Written by Ryan C. Gordon (icculus at icculus.org). Please refer to
- * http://icculus.org/quake3/ for the latest version of this code.
+ * http://ioquake3.org/ for the latest version of this code.
*
* Patches and comments are welcome at the above address.
*
@@ -83,6 +83,9 @@
/* Just hack it for now. */
#ifdef MACOS_X
+#include <IOKit/hidsystem/IOHIDLib.h>
+#include <IOKit/hidsystem/IOHIDParameter.h>
+#include <drivers/event_status_driver.h>
typedef CGLContextObj QGLContext;
#define GLimp_GetCurrentContext() CGLGetCurrentContext()
#define GLimp_SetCurrentContext(ctx) CGLSetCurrentContext(ctx)
@@ -116,6 +119,10 @@
static qboolean sdlrepeatenabled = qfalse;
static cvar_t *in_mouse;
+static cvar_t *in_disablemacosxmouseaccel;
+#ifdef MACOS_X
+static double originalMouseSpeed = -1.0;
+#endif
cvar_t *in_subframe;
cvar_t *in_nograb; // this is strictly for developers
@@ -225,6 +232,9 @@
case SDLK_F10: *key = K_F10; break;
case SDLK_F11: *key = K_F11; break;
case SDLK_F12: *key = K_F12; break;
+ case SDLK_F13: *key = K_F13; break;
+ case SDLK_F14: *key = K_F14; break;
+ case SDLK_F15: *key = K_F15; break;
// bk001206 - from Ryan's Fakk2
case SDLK_BACKSPACE: *key = K_BACKSPACE; break; // ctrl-h
@@ -243,15 +253,35 @@
case SDLK_RALT:
case SDLK_LALT: *key = K_ALT; break;
+ case SDLK_LSUPER:
+ case SDLK_RSUPER: *key = K_SUPER; break;
+
case SDLK_KP5: *key = K_KP_5; break;
case SDLK_INSERT: *key = K_INS; break;
case SDLK_KP0: *key = K_KP_INS; break;
- case SDLK_KP_MULTIPLY: *key = '*'; break;
+ case SDLK_KP_MULTIPLY: *key = K_KP_STAR; break;
case SDLK_KP_PLUS: *key = K_KP_PLUS; break;
case SDLK_KP_MINUS: *key = K_KP_MINUS; break;
case SDLK_KP_DIVIDE: *key = K_KP_SLASH; break;
- default: break;
+ case SDLK_MODE: *key = K_MODE; break;
+ case SDLK_COMPOSE: *key = K_COMPOSE; break;
+ case SDLK_HELP: *key = K_HELP; break;
+ case SDLK_PRINT: *key = K_PRINT; break;
+ case SDLK_SYSREQ: *key = K_SYSREQ; break;
+ case SDLK_BREAK: *key = K_BREAK; break;
+ case SDLK_MENU: *key = K_MENU; break;
+ case SDLK_POWER: *key = K_POWER; break;
+ case SDLK_EURO: *key = K_EURO; break;
+ case SDLK_UNDO: * key = K_UNDO; break;
+ case SDLK_SCROLLOCK: *key = K_SCROLLOCK; break;
+ case SDLK_NUMLOCK: *key = K_KP_NUMLOCK; break;
+ case SDLK_CAPSLOCK: *key = K_CAPSLOCK; break;
+
+ default:
+ if (keysym->sym >= SDLK_WORLD_0 && keysym->sym <= SDLK_WORLD_95)
+ *key = (keysym->sym - SDLK_WORLD_0) + K_WORLD_0;
+ break;
}
if( keysym->unicode <= 127 ) // maps to ASCII?
@@ -267,8 +297,8 @@
//else if (ch >= 'A' && ch <= 'Z')
// ch = ch - 'A' + 'a';
- // tjw: translate K_BACKSPACE to ctrl-h for MACOS_X (others?)
- if (ch == K_BACKSPACE)
+ // translate K_BACKSPACE to ctrl-h for MACOS_X (others?)
+ if (ch == K_BACKSPACE && keysym->sym != SDLK_DELETE)
{
*key = 'h' - 'a' + 1;
buf[0] = *key;
@@ -409,11 +439,69 @@
{
}
+#ifdef MACOS_X
+io_connect_t IN_GetIOHandle() // mac os x mouse accel hack
+ {
+ io_connect_t iohandle = MACH_PORT_NULL;
+ kern_return_t status;
+ io_service_t iohidsystem = MACH_PORT_NULL;
+ mach_port_t masterport;
+
+ status = IOMasterPort(MACH_PORT_NULL, &masterport);
+ if(status != KERN_SUCCESS)
+ return 0;
+
+ iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem");
+ if(!iohidsystem)
+ return 0;
+
+ status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle);
+ IOObjectRelease(iohidsystem);
+
+ return iohandle;
+ }
+#endif
+
void IN_ActivateMouse( void )
{
if (!mouse_avail || !screen)
return;
+ #ifdef MACOS_X
+ if (!mouse_active && mouse_avail) // mac os x mouse accel hack
+ {
+ // Save the status of mouse acceleration
+ originalMouseSpeed = -1.0; // in case of error
+ if(in_disablemacosxmouseaccel->integer)
+ {
+ io_connect_t mouseDev = IN_GetIOHandle();
+ if(mouseDev != 0)
+ {
+ if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
+ {
+ Com_Printf("previous mouse acceleration: %f\n", originalMouseSpeed);
+ if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
+ {
+ Com_Printf("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
+ Cvar_Set ("in_disablemacosxmouseaccel", 0);
+ }
+ }
+ else
+ {
+ Com_Printf("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
+ Cvar_Set ("in_disablemacosxmouseaccel", 0);
+ }
+ IOServiceClose(mouseDev);
+ }
+ else
+ {
+ Com_Printf("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
+ Cvar_Set ("in_disablemacosxmouseaccel", 0);
+ }
+ }
+ }
+ #endif
+
if (!mouse_active)
{
if (!in_nograb->value)
@@ -426,6 +514,25 @@
{
if (!mouse_avail || !screen)
return;
+
+ #ifdef MACOS_X
+ if (mouse_active) // mac os x mouse accel hack
+ {
+ if(originalMouseSpeed != -1.0)
+ {
+ io_connect_t mouseDev = IN_GetIOHandle();
+ if(mouseDev != 0)
+ {
+ Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
+ if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
+ Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
+ IOServiceClose(mouseDev);
+ }
+ else
+ Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
+ }
+ }
+ #endif
if (mouse_active)
{
@@ -666,6 +773,13 @@
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, tstencilbits );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+#if SDL_VERSION_ATLEAST( 1, 2, 10 )
+ if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval->integer ) )
+ ri.Printf( PRINT_ALL, "r_swapInterval requires libSDL >= 1.2.10\n" );
+#else
+ #warning libSDL >= 1.2.10 required for r_swapInterval support
+#endif // SDL_GL_SWAP_CONTROL
+
SDL_WM_SetCaption(CLIENT_WINDOW_TITLE, CLIENT_WINDOW_ICON);
SDL_ShowCursor(0);
SDL_EnableUNICODE(1);
@@ -1327,6 +1441,7 @@
Com_Printf ("\n------- Input Initialization -------\n");
// mouse variables
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
+ in_disablemacosxmouseaccel = Cvar_Get ("in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE);
// turn on-off sub-frame timing of X events
in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE);
Modified: branches/1.34/code/unix/sdl_snd.c
===================================================================
--- branches/1.34/code/unix/sdl_snd.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/sdl_snd.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -14,7 +14,7 @@
* positional audio, compliments of OpenAL...
*
* Written by Ryan C. Gordon (icculus at icculus.org). Please refer to
- * http://icculus.org/quake3/ for the latest version of this code.
+ * http://ioquake3.org/ for the latest version of this code.
*
* Patches and comments are welcome at the above address.
*
@@ -186,7 +186,7 @@
if( fmt ) {
Com_Printf( " Format: %s\n", fmt );
} else {
- Com_Printf( " Format: " S_COLOR_RED "UNKNOWN\n", fmt );
+ Com_Printf( " Format: " S_COLOR_RED "UNKNOWN\n");
}
Com_Printf( " Freq: %d\n", (int) spec->freq );
Modified: branches/1.34/code/unix/setup/Makefile
===================================================================
--- branches/1.34/code/unix/setup/Makefile 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/setup/Makefile 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,5 +1,5 @@
VERSION=1.34
-RELEASE=rc3
+RELEASE=rc4
all:
VERSION=$(VERSION) RELEASE=$(RELEASE) ./doit
Modified: branches/1.34/code/unix/setup/Solaris_pkg.sh
===================================================================
--- branches/1.34/code/unix/setup/Solaris_pkg.sh 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/setup/Solaris_pkg.sh 2007-08-22 21:25:32 UTC (rev 1127)
@@ -5,7 +5,7 @@
# Solaris stuff
PLATFORM=`uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'`
-if [ "X`uname -m`" = "Xi386" ]; then
+if [ "X`uname -m`" = "Xi86pc" ]; then
ARCH=i386
else
ARCH=sparc
@@ -18,7 +18,7 @@
SVNVERSION=/usr/local/bin/svnversion
if [ -x /usr/local/bin/svnversion ]; then
SVN_BANNER=`/usr/local/bin/svnversion ${MOUNT_DIR}|sed -e 's/S$//' -e 's/M$//' `
- BUILD_VERSION="1.34-rc3"
+ BUILD_VERSION="1.34-rc4"
else
BUILD_VERSION="1.34-rc3"
fi
Modified: branches/1.34/code/unix/setup/pkg/ioquake3/pkginfo.template
===================================================================
--- branches/1.34/code/unix/setup/pkg/ioquake3/pkginfo.template 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/setup/pkg/ioquake3/pkginfo.template 2007-08-22 21:25:32 UTC (rev 1127)
@@ -3,10 +3,10 @@
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=ioquake3
-NAME=Icculus.Org Quake3 1.34 for Solaris 10 (X11,GLX,SDL)
+NAME=ioquake3 1.34 for Solaris 10 (X11,GLX,SDL)
VERSION=
CATEGORY=application,graphics,opengl
-DESC=Icculus.Org Quake3 1.34 for Solaris 10 (http://www.icculus.org/quake3)
-VENDOR=http://www.icculus.org/quake3
+DESC=Icculus.Org Quake3 1.34 for Solaris 10 (http://www.ioquake3.org/)
+VENDOR=http://www.ioquake3.org/
EMAIL=quake at cojot.name
PKGSAV=/var/sadm/pkg/ioquake3/save
Modified: branches/1.34/code/unix/setup/pkg/ioquake3d/pkginfo.template
===================================================================
--- branches/1.34/code/unix/setup/pkg/ioquake3d/pkginfo.template 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/setup/pkg/ioquake3d/pkginfo.template 2007-08-22 21:25:32 UTC (rev 1127)
@@ -3,10 +3,10 @@
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=ioquake3d
-NAME=Icculus.Org Quake3 game data files for Solaris 10 (X11,GLX,SDL)
+NAME=ioquake3 game data files for Solaris 10 (X11,GLX,SDL)
VERSION=
CATEGORY=application,graphics,opengl
-DESC=Icculus.Org Quake3 game data files for Solaris 10 (http://www.icculus.org/quake3)
-VENDOR=http://www.icculus.org/quake3
+DESC=ioquake3 game data files for Solaris 10 (http://www.ioquake3.org/)
+VENDOR=http://www.ioquake3.org/
EMAIL=quake at cojot.name
PKGSAV=/var/sadm/pkg/ioquake3d/save
Modified: branches/1.34/code/unix/setup/setup.xml
===================================================================
--- branches/1.34/code/unix/setup/setup.xml 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/setup/setup.xml 2007-08-22 21:25:32 UTC (rev 1127)
@@ -2,7 +2,7 @@
<install product="ioquake3"
desc="ioquake3"
version="@VERSION@"
- update_url="http://www.icculus.org/quake3/updates.txt"
+ update_url="http://www.ioquake3.org/updates.txt"
promptbinaries="yes"
reinstall="yes"
nopromptoverwrite="yes"
@@ -25,6 +25,7 @@
</files>
</option>
<option required="true" install="true" show="false">
+ This needs to be fixed properly.
<files path="baseq3">
idpatchpk3s.tar
</files>
Modified: branches/1.34/code/unix/unix_main.c
===================================================================
--- branches/1.34/code/unix/unix_main.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/unix_main.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -72,7 +72,7 @@
#if idppc_altivec
#ifdef MACOS_X
- #include <Carbon/Carbon.h>
+ #include <sys/sysctl.h>
#endif
#endif
@@ -383,11 +383,13 @@
#if idppc_altivec
#ifdef MACOS_X
- long feat = 0;
- OSErr err = Gestalt(gestaltPowerPCProcessorFeatures, &feat);
- if ((err==noErr) && ((1 << gestaltPowerPCHasVectorInstructions) & feat)) {
- altivec = qtrue;
- }
+ int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+ int hasVectorUnit = 0;
+ size_t length = sizeof(hasVectorUnit);
+ int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
+
+ if( 0 == error )
+ altivec = (hasVectorUnit != 0);
#else
void (*handler)(int sig);
handler = signal(SIGILL, illegal_instruction);
Modified: branches/1.34/code/unix/unix_net.c
===================================================================
--- branches/1.34/code/unix/unix_net.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/unix_net.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -382,8 +382,6 @@
int interfaceSocket;
int family;
- Com_Printf("NET_GetLocalAddress: Querying for network interfaces\n");
-
// Set this early so we can just return if there is an error
numIP = 0;
@@ -405,7 +403,6 @@
return;
}
-
linkInterface = (struct ifreq *) ifc.ifc_buf;
while ((char *) linkInterface < &ifc.ifc_buf[ifc.ifc_len]) {
unsigned int nameLength;
@@ -469,7 +466,6 @@
}
linkInterface = IFR_NEXT(linkInterface);
}
- Com_Printf("NET_GetLocalAddress: DONE querying for network interfaces\n");
close(interfaceSocket);
}
Modified: branches/1.34/code/unix/unix_shared.c
===================================================================
--- branches/1.34/code/unix/unix_shared.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/unix/unix_shared.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -174,6 +174,22 @@
return s; // bk001204 - duh
}
+qboolean Sys_RandomBytes( byte *string, int len )
+{
+ FILE *fp;
+
+ fp = fopen( "/dev/urandom", "r" );
+ if( !fp )
+ return qfalse;
+
+ if( !fread( string, sizeof( byte ), len, fp ) ) {
+ fclose( fp );
+ return qfalse;
+ }
+ fclose( fp );
+ return qtrue;
+}
+
//============================================
#define MAX_FOUND_FILES 0x1000
Modified: branches/1.34/code/win32/win_gamma.c
===================================================================
--- branches/1.34/code/win32/win_gamma.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/win32/win_gamma.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -148,11 +148,11 @@
table[2][i] = ( ( ( unsigned short ) blue[i] ) << 8 ) | blue[i];
}
- // Win2K puts this odd restriction on gamma ramps...
+ // Win2K and newer put this odd restriction on gamma ramps...
vinfo.dwOSVersionInfoSize = sizeof(vinfo);
GetVersionEx( &vinfo );
- if ( vinfo.dwMajorVersion == 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
- Com_DPrintf( "performing W2K gamma clamp.\n" );
+ if ( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
+ Com_DPrintf( "performing gamma clamp.\n" );
for ( j = 0 ; j < 3 ; j++ ) {
for ( i = 0 ; i < 128 ; i++ ) {
if ( table[j][i] > ( (128+i) << 8 ) ) {
@@ -164,7 +164,7 @@
}
}
} else {
- Com_DPrintf( "skipping W2K gamma clamp.\n" );
+ Com_DPrintf( "skipping gamma clamp.\n" );
}
// enforce constantly increasing
Modified: branches/1.34/code/win32/win_input.c
===================================================================
--- branches/1.34/code/win32/win_input.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/win32/win_input.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -937,8 +937,8 @@
if ( in_debugJoystick->integer ) {
Com_Printf( "%8x %5i %5.2f %5.2f %5.2f %5.2f %6i %6i\n",
- joy.ji.dwButtons,
- joy.ji.dwPOV,
+ JoyToI( joy.ji.dwButtons ),
+ JoyToI( joy.ji.dwPOV ),
JoyToF( joy.ji.dwXpos ), JoyToF( joy.ji.dwYpos ),
JoyToF( joy.ji.dwZpos ), JoyToF( joy.ji.dwRpos ),
JoyToI( joy.ji.dwUpos ), JoyToI( joy.ji.dwVpos ) );
@@ -1130,7 +1130,8 @@
( unsigned long ) NULL,
CALLBACK_FUNCTION ) != MMSYSERR_NOERROR )
{
- Com_Printf( "WARNING: could not open MIDI device %d: '%s'\n", in_mididevice->integer , s_midiInfo.caps[( int ) in_mididevice->value] );
+ Com_Printf( "WARNING: could not open MIDI device %d: '%s'\n",
+ in_mididevice->integer , s_midiInfo.caps[( int ) in_mididevice->value].szPname );
return;
}
Copied: branches/1.34/code/win32/win_resource.rc (from rev 1126, trunk/code/win32/win_resource.rc)
===================================================================
--- branches/1.34/code/win32/win_resource.rc (rev 0)
+++ branches/1.34/code/win32/win_resource.rc 2007-08-22 21:25:32 UTC (rev 1127)
@@ -0,0 +1,79 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#ifndef __MINGW32__
+#include "winres.h"
+#else
+#include <winresrc.h>
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+#ifndef __MINGW32__
+IDI_ICON1 ICON DISCARDABLE "qe3.ico"
+#else
+IDI_ICON1 ICON DISCARDABLE "code/win32/qe3.ico"
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_STRING1 "Quake3"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
Modified: branches/1.34/code/win32/win_shared.c
===================================================================
--- branches/1.34/code/win32/win_shared.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/win32/win_shared.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -32,6 +32,7 @@
#include <direct.h>
#include <io.h>
#include <conio.h>
+#include <wincrypt.h>
/*
================
@@ -81,7 +82,25 @@
}
#endif
+qboolean Sys_RandomBytes( byte *string, int len )
+{
+ HCRYPTPROV prov;
+ if( !CryptAcquireContext( &prov, NULL, NULL,
+ PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) ) {
+
+ return qfalse;
+ }
+
+ if( !CryptGenRandom( prov, len, (BYTE *)string ) ) {
+ CryptReleaseContext( prov, 0 );
+ return qfalse;
+ }
+ CryptReleaseContext( prov, 0 );
+ return qtrue;
+}
+
+
/*
**
** Disable all optimizations temporarily so this code works correctly!
Modified: branches/1.34/code/win32/win_wndproc.c
===================================================================
--- branches/1.34/code/win32/win_wndproc.c 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/win32/win_wndproc.c 2007-08-22 21:25:32 UTC (rev 1127)
@@ -55,7 +55,7 @@
{
BOOL old;
- SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, &old, 0 );
+ SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, 1, &old, 0 );
}
s_alttab_disabled = qtrue;
}
@@ -72,7 +72,7 @@
{
BOOL old;
- SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, &old, 0 );
+ SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, 0, &old, 0 );
}
s_alttab_disabled = qfalse;
Deleted: branches/1.34/code/win32/winquake.rc
===================================================================
--- branches/1.34/code/win32/winquake.rc 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/code/win32/winquake.rc 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,79 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#ifndef __MINGW32__
-#include "winres.h"
-#else
-#include <winresrc.h>
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#include ""winres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-#ifndef __MINGW32__
-IDI_ICON1 ICON DISCARDABLE "qe3.ico"
-#else
-IDI_ICON1 ICON DISCARDABLE "code/win32/qe3.ico"
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE DISCARDABLE
-BEGIN
- IDS_STRING1 "Quake3"
-END
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
Modified: branches/1.34/cross-make-mingw.sh
===================================================================
--- branches/1.34/cross-make-mingw.sh 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/cross-make-mingw.sh 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,8 +1,6 @@
#!/bin/sh
-PREFIX=/usr/local/cross-tools
-TARGET=i386-mingw32msvc
-PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PATH"
-export PATH
+export CC=i586-mingw32msvc-gcc
+export WINDRES=i586-mingw32msvc-windres
export PLATFORM=mingw32
exec make $*
Modified: branches/1.34/make-macosx-ub.sh
===================================================================
--- branches/1.34/make-macosx-ub.sh 2007-08-19 12:11:39 UTC (rev 1126)
+++ branches/1.34/make-macosx-ub.sh 2007-08-22 21:25:32 UTC (rev 1127)
@@ -1,7 +1,7 @@
#!/bin/sh
APPBUNDLE=ioquake3.app
BINARY=ioquake3.ub
-PKGINFO=APPIOQ3
+PKGINFO=APPLIOQ3
ICNS=code/unix/MacSupport/ioquake3.icns
DESTDIR=build/release-darwin-ub
BASEDIR=baseq3
More information about the quake3-commits
mailing list