summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2007-07-15 14:15:41 +0000
committerTim Angus <tim@ngus.net>2007-07-15 14:15:41 +0000
commitffbf946dd63dccf0d6b6553c8bc1c9da4d3c89b3 (patch)
tree62b48381afabceca4c2aad7c39e0eeb51e328126
parent655d4c12eea45edf2041300eccace352a503b690 (diff)
* Merge of ioq3-r1112
-rw-r--r--Makefile440
-rwxr-xr-xcross-make-mingw.sh6
-rwxr-xr-xmake-macosx-ub.sh2
-rw-r--r--src/SDL12/include/SDL.h35
-rw-r--r--src/SDL12/include/SDL_active.h22
-rw-r--r--src/SDL12/include/SDL_audio.h28
-rw-r--r--src/SDL12/include/SDL_byteorder.h62
-rw-r--r--src/SDL12/include/SDL_cdrom.h22
-rw-r--r--src/SDL12/include/SDL_config.h45
-rw-r--r--src/SDL12/include/SDL_config_amiga.h80
-rw-r--r--src/SDL12/include/SDL_config_dreamcast.h106
-rw-r--r--src/SDL12/include/SDL_config_macos.h112
-rw-r--r--src/SDL12/include/SDL_config_macosx.h132
-rw-r--r--src/SDL12/include/SDL_config_minimal.h62
-rw-r--r--src/SDL12/include/SDL_config_os2.h141
-rw-r--r--src/SDL12/include/SDL_config_win32.h173
-rw-r--r--src/SDL12/include/SDL_copying.h19
-rw-r--r--src/SDL12/include/SDL_cpuinfo.h37
-rw-r--r--src/SDL12/include/SDL_endian.h68
-rw-r--r--src/SDL12/include/SDL_error.h23
-rw-r--r--src/SDL12/include/SDL_events.h39
-rw-r--r--src/SDL12/include/SDL_getenv.h54
-rw-r--r--src/SDL12/include/SDL_joystick.h22
-rw-r--r--src/SDL12/include/SDL_keyboard.h23
-rw-r--r--src/SDL12/include/SDL_keysym.h19
-rw-r--r--src/SDL12/include/SDL_loadso.h22
-rw-r--r--src/SDL12/include/SDL_main.h36
-rw-r--r--src/SDL12/include/SDL_mouse.h24
-rw-r--r--src/SDL12/include/SDL_mutex.h24
-rw-r--r--src/SDL12/include/SDL_opengl.h629
-rw-r--r--src/SDL12/include/SDL_platform.h104
-rw-r--r--src/SDL12/include/SDL_quit.h22
-rw-r--r--src/SDL12/include/SDL_rwops.h63
-rw-r--r--src/SDL12/include/SDL_stdinc.h586
-rw-r--r--src/SDL12/include/SDL_syswm.h44
-rw-r--r--src/SDL12/include/SDL_thread.h68
-rw-r--r--src/SDL12/include/SDL_timer.h23
-rw-r--r--src/SDL12/include/SDL_types.h114
-rw-r--r--src/SDL12/include/SDL_version.h23
-rw-r--r--src/SDL12/include/SDL_video.h41
-rw-r--r--src/SDL12/include/begin_code.h41
-rw-r--r--src/SDL12/include/close_code.h2
-rw-r--r--src/client/cl_cgame.c2
-rw-r--r--src/client/cl_curl.c2
-rw-r--r--src/client/cl_keys.c107
-rw-r--r--src/client/cl_main.c3
-rw-r--r--src/client/cl_ui.c2
-rw-r--r--src/jpeg-6/jerror.c4
-rw-r--r--src/jpeg-6/jmemnobs.c4
-rw-r--r--src/jpeg-6/jmorecfg.h11
-rwxr-xr-xsrc/libs/macosx/libSDL-1.2.0.dylibbin4469500 -> 4474044 bytes
-rw-r--r--src/qcommon/vm_interpreted.c8
-rw-r--r--src/qcommon/vm_ppc.c1448
-rw-r--r--src/qcommon/vm_ppc_new.c2072
-rw-r--r--src/qcommon/vm_x86_64.c96
-rw-r--r--src/renderer/tr_init.c5
-rw-r--r--src/server/sv_init.c3
-rw-r--r--src/server/sv_main.c2
-rw-r--r--src/tools/asm/Makefile4
-rw-r--r--src/tools/asm/cmdlib.c4
-rw-r--r--src/unix/sdl_glimp.c92
-rw-r--r--src/win32/win_input.c7
62 files changed, 3994 insertions, 3520 deletions
diff --git a/Makefile b/Makefile
index 1ef730c9..5e12bf23 100644
--- a/Makefile
+++ b/Makefile
@@ -162,8 +162,6 @@ endif
#############################################################################
## Defaults
-VM_PPC=
-
LIB=lib
INSTALL=install
@@ -171,8 +169,6 @@ MKDIR=mkdir
ifeq ($(PLATFORM),linux)
- CC=gcc
-
ifeq ($(ARCH),alpha)
ARCH=axp
else
@@ -197,7 +193,7 @@ ifeq ($(PLATFORM),linux)
BASE_CFLAGS += -DUSE_OPENAL_DLOPEN=1
endif
endif
-
+
ifeq ($(USE_CURL),1)
BASE_CFLAGS += -DUSE_CURL=1
ifeq ($(USE_CURL_DLOPEN),1)
@@ -211,9 +207,8 @@ ifeq ($(PLATFORM),linux)
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
@@ -233,9 +228,7 @@ ifeq ($(PLATFORM),linux)
else
ifeq ($(ARCH),ppc)
BASE_CFLAGS += -maltivec
- ifneq ($(VM_PPC),)
- HAVE_VM_COMPILED=true
- endif
+ HAVE_VM_COMPILED=false
endif
endif
endif
@@ -266,7 +259,7 @@ ifeq ($(PLATFORM),linux)
CLIENT_LDFLAGS += -lopenal
endif
endif
-
+
ifeq ($(USE_CURL),1)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LDFLAGS += -lcurl
@@ -290,8 +283,6 @@ else # ifeq Linux
#############################################################################
ifeq ($(PLATFORM),darwin)
- CC=gcc
- VM_PPC=vm_ppc_new
HAVE_VM_COMPILED=true
BASE_CFLAGS=
CLIENT_LDFLAGS=
@@ -371,7 +362,7 @@ ifeq ($(PLATFORM),darwin)
BASE_CFLAGS += -DUSE_OPENAL_DLOPEN=1
endif
endif
-
+
ifeq ($(USE_CURL),1)
BASE_CFLAGS += -DUSE_CURL=1
ifneq ($(USE_CURL_DLOPEN),1)
@@ -389,12 +380,11 @@ ifeq ($(PLATFORM),darwin)
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...
@@ -426,8 +416,9 @@ else # ifeq darwin
ifeq ($(PLATFORM),mingw32)
- CC=gcc
- WINDRES=windres
+ifndef WINDRES
+WINDRES=windres
+endif
ARCH=x86
@@ -436,7 +427,7 @@ ifeq ($(PLATFORM),mingw32)
ifeq ($(USE_OPENAL),1)
BASE_CFLAGS += -DUSE_OPENAL=1 -DUSE_OPENAL_DLOPEN=1
endif
-
+
ifeq ($(USE_CURL),1)
BASE_CFLAGS += -DUSE_CURL=1
ifneq ($(USE_CURL_DLOPEN),1)
@@ -448,9 +439,6 @@ ifeq ($(PLATFORM),mingw32)
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
@@ -503,9 +491,8 @@ ifeq ($(PLATFORM),freebsd)
endif #alpha test
- BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
-
- GL_CFLAGS = -I/usr/X11R6/include
+ BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+ -I/usr/X11R6/include
DEBUG_CFLAGS=$(BASE_CFLAGS) -g
@@ -525,13 +512,11 @@ ifeq ($(PLATFORM),freebsd)
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),x86)
- 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 \
@@ -581,7 +566,6 @@ ifeq ($(PLATFORM),netbsd)
ARCH=x86
endif
- CC=gcc
LDFLAGS=-lm
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
@@ -608,7 +592,6 @@ ifeq ($(PLATFORM),irix)
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
@@ -629,7 +612,6 @@ else # ifeq IRIX
ifeq ($(PLATFORM),sunos)
- CC=gcc
INSTALL=ginstall
MKDIR=gmkdir
COPYDIR="/usr/local/share/games/tremulous"
@@ -651,9 +633,8 @@ ifeq ($(PLATFORM),sunos)
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
@@ -670,8 +651,8 @@ ifeq ($(PLATFORM),sunos)
-falign-functions=2 -fstrength-reduce
HAVE_VM_COMPILED=true
BASE_CFLAGS += -m32
- LDFLAGS+=-m32
- GL_CFLAGS+= -I/usr/X11/include/NVIDIA
+ LDFLAGS += -m32
+ BASE_CFLAGS += -I/usr/X11/include/NVIDIA
endif
endif
@@ -703,7 +684,6 @@ 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
@@ -763,50 +743,53 @@ ifeq ($(USE_LOCAL_HEADERS),1)
endif
ifeq ($(GENERATE_DEPENDENCIES),1)
- ifeq ($(CC),gcc)
- DEPEND_CFLAGS=-MMD
- endif
+ DEPEND_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 $@
+DO_CC = @echo "CC $<"; \
+ $(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $<
+DO_SMP_CC = @echo "SMP_CC $<"; \
+ $(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $<
+DO_BOT_CC = @echo "BOT_CC $<"; \
+ $(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $<
+DO_SHLIB_CC = @echo "SHLIB_CC $<"; \
+ $(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
+DO_AS = @echo "AS $<"; \
+ $(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
+DO_DED_CC = @echo "DED_CC $<"; \
+ $(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $<
+DO_WINDRES = @echo "WINDRES $<"; \
+ $(WINDRES) -i $< -o $@
#############################################################################
# MAIN TARGETS
#############################################################################
-default:build_release
+default: build_release
debug: build_debug
release: build_release
-build_debug: B=$(BD)
-build_debug: makedirs tools
- $(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS) $(DEPEND_CFLAGS)"
+build_debug: tools
+ $(MAKE) makedirs targets B=$(BD) \
+ CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS) $(DEPEND_CFLAGS)"
ifeq ($(BUILD_MASTER_SERVER),1)
$(MAKE) -C $(MASTERDIR) debug
endif
-build_release: B=$(BR)
-build_release: makedirs tools
- $(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS) $(DEPEND_CFLAGS)"
+build_release: tools
+ $(MAKE) makedirs targets B=$(BR) \
+ CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS) $(DEPEND_CFLAGS)"
ifeq ($(BUILD_MASTER_SERVER),1)
$(MAKE) -C $(MASTERDIR) release
endif
-#Build both debug and release builds
-all:build_debug build_release
+# Build both debug and release builds
+all: build_debug build_release
targets: $(TARGETS)
@@ -814,6 +797,7 @@ 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)/base ];then $(MKDIR) $(B)/base;fi
@if [ ! -d $(B)/base/cgame ];then $(MKDIR) $(B)/base/cgame;fi
@@ -831,14 +815,15 @@ Q3ASM=$(TOOLSDIR)/q3asm$(BINEXT)
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 $@ $<
+DO_Q3LCC = @echo "Q3LCC $<"; \
+ $(Q3LCC) -o $@ $<
#############################################################################
# CLIENT/SERVER
@@ -981,7 +966,7 @@ ifeq ($(HAVE_VM_COMPILED),true)
Q3OBJ += $(B)/client/vm_x86_64.o
endif
ifeq ($(ARCH),ppc)
- Q3OBJ += $(B)/client/$(VM_PPC).o
+ Q3OBJ += $(B)/client/vm_ppc.o
endif
endif
@@ -1023,15 +1008,18 @@ else
$(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)/tremulous.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
- $(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
+ @echo "LD $@"
+ @$(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) \
+ $(LDFLAGS) $(LIBSDLMAIN)
$(B)/tremulous-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)),)
@@ -1042,172 +1030,7 @@ $(LIBSDLMAIN) : $(LIBSDLMAINSRC)
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/cl_curl.o : $(CDIR)/cl_curl.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/parse.o : $(CMDIR)/parse.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/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)/win_resource.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
@@ -1269,62 +1092,13 @@ ifeq ($(HAVE_VM_COMPILED),true)
Q3DOBJ += $(B)/ded/vm_x86_64.o
endif
ifeq ($(ARCH),ppc)
- Q3DOBJ += $(B)/ded/$(VM_PPC).o
+ Q3DOBJ += $(B)/ded/vm_ppc.o
endif
endif
$(B)/tremded.$(ARCH)$(BINEXT): $(Q3DOBJ)
- $(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
-
-$(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/parse.o : $(CMDIR)/parse.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/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
+ @echo "LD $@"
+ @$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
@@ -1369,10 +1143,12 @@ CGOBJ = $(CGOBJ_) $(B)/base/cgame/cg_syscalls.o
CGVMOBJ = $(CGOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm
$(B)/base/cgame$(ARCH).$(SHLIBEXT) : $(CGOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(CGOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(CGOBJ)
$(B)/base/vm/cgame.qvm: $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm
- $(Q3ASM) -o $@ $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(CGVMOBJ) $(CGDIR)/cg_syscalls.asm
@@ -1414,10 +1190,12 @@ GOBJ = $(GOBJ_) $(B)/base/game/g_syscalls.o
GVMOBJ = $(GOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm
$(B)/base/game$(ARCH).$(SHLIBEXT) : $(GOBJ)
- $(CC) $(SHLIBLDFLAGS) -o $@ $(GOBJ)
+ @echo "LD $@"
+ @$(CC) $(SHLIBLDFLAGS) -o $@ $(GOBJ)
$(B)/base/vm/game.qvm: $(GVMOBJ) $(GDIR)/g_syscalls.asm
- $(Q3ASM) -o $@ $(GVMOBJ) $(GDIR)/g_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(GVMOBJ) $(GDIR)/g_syscalls.asm
@@ -1440,10 +1218,77 @@ UIOBJ = $(UIOBJ_) $(B)/base/ui/ui_syscalls.o
UIVMOBJ = $(UIOBJ_:%.o=%.asm) $(B)/base/game/bg_lib.asm
$(B)/base/ui$(ARCH).$(SHLIBEXT) : $(UIOBJ)
- $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(UIOBJ)
+ @echo "LD $@"
+ @$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(UIOBJ)
$(B)/base/vm/ui.qvm: $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm
- $(Q3ASM) -o $@ $(UIVMOBJ) $(UIDIR)/ui_syscalls.asm
+ @echo "Q3ASM $@"
+ @$(Q3ASM) -o $@ $(UIVMOBJ) $(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
#############################################################################
@@ -1483,30 +1328,31 @@ $(B)/base/qcommon/%.asm: $(CMDIR)/%.c
#############################################################################
clean: clean-debug clean-release
- $(MAKE) -C $(MASTERDIR) clean
+ @$(MAKE) -C $(MASTERDIR) 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) \
$(GOBJ) $(CGOBJ) $(UIOBJ) \
$(GVMOBJ) $(CGVMOBJ) $(UIVMOBJ)
- rm -f $(TARGETS)
+ @rm -f $(TARGETS)
clean-debug:
- $(MAKE) clean2 B=$(BD) CFLAGS="$(DEBUG_CFLAGS)"
+ @$(MAKE) clean2 B=$(BD) CFLAGS="$(DEBUG_CFLAGS)"
clean-release:
- $(MAKE) clean2 B=$(BR) CFLAGS="$(RELEASE_CFLAGS)"
+ @$(MAKE) clean2 B=$(BR) CFLAGS="$(RELEASE_CFLAGS)"
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)
+ @$(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR)
dist:
rm -rf tremulous-$(SVN_VERSION)
@@ -1521,7 +1367,7 @@ dist:
D_FILES=$(shell find . -name '*.d')
$(B)/base/vm/vm.d: $(GOBJ) $(CGOBJ) $(UIOBJ)
- cat $(^:%.o=%.d) | sed -e 's/\.o/\.asm/g' > $@
+ @cat $(^:%.o=%.d) | sed -e 's/\.o/\.asm/g' > $@
qvmdeps: $(B)/base/vm/vm.d
diff --git a/cross-make-mingw.sh b/cross-make-mingw.sh
index bb9c23e9..c6dbe377 100755
--- a/cross-make-mingw.sh
+++ b/cross-make-mingw.sh
@@ -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 $*
diff --git a/make-macosx-ub.sh b/make-macosx-ub.sh
index c781427f..77673739 100755
--- a/make-macosx-ub.sh
+++ b/make-macosx-ub.sh
@@ -1,7 +1,7 @@
#!/bin/sh
APPBUNDLE=Tremulous.app
BINARY=Tremulous.ub
-PKGINFO=APPTREM
+PKGINFO=APPLTREM
ICNS=src/unix/MacSupport/Tremulous.icns
DESTDIR=build/release-darwin-ub
BASEDIR=base
diff --git a/src/SDL12/include/SDL.h b/src/SDL12/include/SDL.h
index 76425889..60ac26ce 100644
--- a/src/SDL12/include/SDL.h
+++ b/src/SDL12/include/SDL.h
@@ -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@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"
diff --git a/src/SDL12/include/SDL_active.h b/src/SDL12/include/SDL_active.h
index bbb306ba..2cf474c5 100644
--- a/src/SDL12/include/SDL_active.h
+++ b/src/SDL12/include/SDL_active.h
@@ -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@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
diff --git a/src/SDL12/include/SDL_audio.h b/src/SDL12/include/SDL_audio.h
index f03d59e8..68ec4759 100644
--- a/src/SDL12/include/SDL_audio.h
+++ b/src/SDL12/include/SDL_audio.h
@@ -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@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++ */
diff --git a/src/SDL12/include/SDL_byteorder.h b/src/SDL12/include/SDL_byteorder.h
index 85b40b59..3871cfed 100644
--- a/src/SDL12/include/SDL_byteorder.h
+++ b/src/SDL12/include/SDL_byteorder.h
@@ -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@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"
diff --git a/src/SDL12/include/SDL_cdrom.h b/src/SDL12/include/SDL_cdrom.h
index b8d3783b..5f8f0c62 100644
--- a/src/SDL12/include/SDL_cdrom.h
+++ b/src/SDL12/include/SDL_cdrom.h
@@ -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@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++ */
diff --git a/src/SDL12/include/SDL_config.h b/src/SDL12/include/SDL_config.h
new file mode 100644
index 00000000..8970ec3d
--- /dev/null
+++ b/src/SDL12/include/SDL_config.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_amiga.h b/src/SDL12/include/SDL_config_amiga.h
new file mode 100644
index 00000000..23e08619
--- /dev/null
+++ b/src/SDL12/include/SDL_config_amiga.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_dreamcast.h b/src/SDL12/include/SDL_config_dreamcast.h
new file mode 100644
index 00000000..9cbeea31
--- /dev/null
+++ b/src/SDL12/include/SDL_config_dreamcast.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_macos.h b/src/SDL12/include/SDL_config_macos.h
new file mode 100644
index 00000000..c4a1c598
--- /dev/null
+++ b/src/SDL12/include/SDL_config_macos.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_macosx.h b/src/SDL12/include/SDL_config_macosx.h
new file mode 100644
index 00000000..8f04930d
--- /dev/null
+++ b/src/SDL12/include/SDL_config_macosx.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_minimal.h b/src/SDL12/include/SDL_config_minimal.h
new file mode 100644
index 00000000..78b6148c
--- /dev/null
+++ b/src/SDL12/include/SDL_config_minimal.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_os2.h b/src/SDL12/include/SDL_config_os2.h
new file mode 100644
index 00000000..8cdea9ff
--- /dev/null
+++ b/src/SDL12/include/SDL_config_os2.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_config_win32.h b/src/SDL12/include/SDL_config_win32.h
new file mode 100644
index 00000000..23e4868c
--- /dev/null
+++ b/src/SDL12/include/SDL_config_win32.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_copying.h b/src/SDL12/include/SDL_copying.h
index 14bb1016..39e122db 100644
--- a/src/SDL12/include/SDL_copying.h
+++ b/src/SDL12/include/SDL_copying.h
@@ -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@libsdl.org
*/
-#ifdef SAVE_RCSID
-static char rcsid =
- "@(#) $Id: SDL_copying.h,v 1.5 2004/01/04 16:49:07 slouken Exp $";
-#endif
-
diff --git a/src/SDL12/include/SDL_cpuinfo.h b/src/SDL12/include/SDL_cpuinfo.h
index f9332b4a..72acbdd8 100644
--- a/src/SDL12/include/SDL_cpuinfo.h
+++ b/src/SDL12/include/SDL_cpuinfo.h
@@ -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@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 @@ extern "C" {
/* 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
diff --git a/src/SDL12/include/SDL_endian.h b/src/SDL12/include/SDL_endian.h
index 4fc2cf12..6257a649 100644
--- a/src/SDL12/include/SDL_endian.h
+++ b/src/SDL12/include/SDL_endian.h
@@ -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@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 @@ extern "C" {
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 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
#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
}
diff --git a/src/SDL12/include/SDL_error.h b/src/SDL12/include/SDL_error.h
index 74e2174e..26d6bfae 100644
--- a/src/SDL12/include/SDL_error.h
+++ b/src/SDL12/include/SDL_error.h
@@ -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@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 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void);
/* 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);
diff --git a/src/SDL12/include/SDL_events.h b/src/SDL12/include/SDL_events.h
index bdcf9a81..9fe918c7 100644
--- a/src/SDL12/include/SDL_events.h
+++ b/src/SDL12/include/SDL_events.h
@@ -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@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 @@ static char rcsid =
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 @@ enum { SDL_NOEVENT = 0, /* Unused (do not remove) */
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 @@ enum {
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 @@ typedef struct SDL_SysWMEvent {
} SDL_SysWMEvent;
/* General event structure */
-typedef union {
+typedef union SDL_Event {
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
diff --git a/src/SDL12/include/SDL_getenv.h b/src/SDL12/include/SDL_getenv.h
index 42037dd4..853b9ce4 100644
--- a/src/SDL12/include/SDL_getenv.h
+++ b/src/SDL12/include/SDL_getenv.h
@@ -1,30 +1,24 @@
-
-/* Not all environments have a working getenv()/putenv() */
-
-#if defined(macintosh) || defined(_WIN32_WCE)
-#define NEED_SDL_GETENV
-#endif
-
-#ifdef NEED_SDL_GETENV
-
-#include "begin_code.h"
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* 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 */
+/*
+ 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@libsdl.org
+*/
+
+/* DEPRECATED */
+#include "SDL_stdinc.h"
diff --git a/src/SDL12/include/SDL_joystick.h b/src/SDL12/include/SDL_joystick.h
index 1fa2d074..e4f72f1a 100644
--- a/src/SDL12/include/SDL_joystick.h
+++ b/src/SDL12/include/SDL_joystick.h
@@ -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@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++ */
diff --git a/src/SDL12/include/SDL_keyboard.h b/src/SDL12/include/SDL_keyboard.h
index 99e2a127..1ad7dcaa 100644
--- a/src/SDL12/include/SDL_keyboard.h
+++ b/src/SDL12/include/SDL_keyboard.h
@@ -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@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 @@ extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
* 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.
diff --git a/src/SDL12/include/SDL_keysym.h b/src/SDL12/include/SDL_keysym.h
index 0e46ab9d..ff44a035 100644
--- a/src/SDL12/include/SDL_keysym.h
+++ b/src/SDL12/include/SDL_keysym.h
@@ -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@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
diff --git a/src/SDL12/include/SDL_loadso.h b/src/SDL12/include/SDL_loadso.h
index 6045a99c..ce964494 100644
--- a/src/SDL12/include/SDL_loadso.h
+++ b/src/SDL12/include/SDL_loadso.h
@@ -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@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 @@ static char rcsid =
#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
diff --git a/src/SDL12/include/SDL_main.h b/src/SDL12/include/SDL_main.h
index eacaca03..cf8b728d 100644
--- a/src/SDL12/include/SDL_main.h
+++ b/src/SDL12/include/SDL_main.h
@@ -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@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 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]);
/* 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 @@ extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
/* 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 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp();
#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
diff --git a/src/SDL12/include/SDL_mouse.h b/src/SDL12/include/SDL_mouse.h
index e250293a..c2364d85 100644
--- a/src/SDL12/include/SDL_mouse.h
+++ b/src/SDL12/include/SDL_mouse.h
@@ -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@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 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
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
diff --git a/src/SDL12/include/SDL_mutex.h b/src/SDL12/include/SDL_mutex.h
index 37e5c9c3..00165281 100644
--- a/src/SDL12/include/SDL_mutex.h
+++ b/src/SDL12/include/SDL_mutex.h
@@ -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@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 @@ static char rcsid =
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 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
/* 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);
diff --git a/src/SDL12/include/SDL_opengl.h b/src/SDL12/include/SDL_opengl.h
index a7e66254..36c0a309 100644
--- a/src/SDL12/include/SDL_opengl.h
+++ b/src/SDL12/include/SDL_opengl.h
@@ -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@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 @@ static char rcsid =
#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 @@ extern "C" {
**
** 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 @@ extern "C" {
/*************************************************************/
/* 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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ extern "C" {
#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 @@ typedef ptrdiff_t GLsizeiptrARB;
#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 PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pn
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 @@ typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type
#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 @@ typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj,
#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 @@ GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *);
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 PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index,
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,6 +6474,74 @@ typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLen
#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
}
diff --git a/src/SDL12/include/SDL_platform.h b/src/SDL12/include/SDL_platform.h
new file mode 100644
index 00000000..80274bc4
--- /dev/null
+++ b/src/SDL12/include/SDL_platform.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_quit.h b/src/SDL12/include/SDL_quit.h
index a4e2d089..fcf40fbd 100644
--- a/src/SDL12/include/SDL_quit.h
+++ b/src/SDL12/include/SDL_quit.h
@@ -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@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.
diff --git a/src/SDL12/include/SDL_rwops.h b/src/SDL12/include/SDL_rwops.h
index 43aa6784..d7e01d8f 100644
--- a/src/SDL12/include/SDL_rwops.h
+++ b/src/SDL12/include/SDL_rwops.h
@@ -1,40 +1,34 @@
/*
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@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
-
-#include <stdio.h>
+#ifndef _SDL_rwops_h
+#define _SDL_rwops_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++ */
@@ -68,10 +62,18 @@ typedef struct SDL_RWops {
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 @@ typedef struct SDL_RWops {
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_RWFromConstMem(const void *mem, int size
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 */
diff --git a/src/SDL12/include/SDL_stdinc.h b/src/SDL12/include/SDL_stdinc.h
new file mode 100644
index 00000000..62535629
--- /dev/null
+++ b/src/SDL12/include/SDL_stdinc.h
@@ -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@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 */
diff --git a/src/SDL12/include/SDL_syswm.h b/src/SDL12/include/SDL_syswm.h
index 03229769..e7f35139 100644
--- a/src/SDL12/include/SDL_syswm.h
+++ b/src/SDL12/include/SDL_syswm.h
@@ -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@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 @@ struct SDL_SysWMinfo;
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 @@ typedef struct SDL_SysWMinfo {
} 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 @@ typedef struct SDL_SysWMinfo {
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 @@ typedef struct SDL_SysWMinfo {
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 @@ typedef struct SDL_SysWMinfo {
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 @@ typedef struct SDL_SysWMinfo {
int data;
} SDL_SysWMinfo;
-#endif /* OS type */
+#endif /* video driver type */
#endif /* SDL_PROTOTYPES_ONLY */
diff --git a/src/SDL12/include/SDL_thread.h b/src/SDL12/include/SDL_thread.h
index d826f974..e0a35b1a 100644
--- a/src/SDL12/include/SDL_thread.h
+++ b/src/SDL12/include/SDL_thread.h
@@ -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@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 @@ static char rcsid =
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 @@ struct SDL_Thread;
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);
diff --git a/src/SDL12/include/SDL_timer.h b/src/SDL12/include/SDL_timer.h
index d28c1701..d21159fe 100644
--- a/src/SDL12/include/SDL_timer.h
+++ b/src/SDL12/include/SDL_timer.h
@@ -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@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++ */
diff --git a/src/SDL12/include/SDL_types.h b/src/SDL12/include/SDL_types.h
index 8f65b424..853b9ce4 100644
--- a/src/SDL12/include/SDL_types.h
+++ b/src/SDL12/include/SDL_types.h
@@ -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@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"
diff --git a/src/SDL12/include/SDL_version.h b/src/SDL12/include/SDL_version.h
index 8483d491..262aa7b5 100644
--- a/src/SDL12/include/SDL_version.h
+++ b/src/SDL12/include/SDL_version.h
@@ -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@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 @@ extern "C" {
*/
#define SDL_MAJOR_VERSION 1
#define SDL_MINOR_VERSION 2
-#define SDL_PATCHLEVEL 9
+#define SDL_PATCHLEVEL 11
typedef struct SDL_version {
Uint8 major;
diff --git a/src/SDL12/include/SDL_video.h b/src/SDL12/include/SDL_video.h
index d79701a9..720022e3 100644
--- a/src/SDL12/include/SDL_video.h
+++ b/src/SDL12/include/SDL_video.h
@@ -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@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 @@ typedef struct SDL_VideoInfo {
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 @@ typedef enum {
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 @@ extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * 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 @@ extern DECLSPEC void SDLCALL SDL_GL_Unlock(void);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * 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);
diff --git a/src/SDL12/include/begin_code.h b/src/SDL12/include/begin_code.h
index 925d3790..40279337 100644
--- a/src/SDL12/include/begin_code.h
+++ b/src/SDL12/include/begin_code.h
@@ -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
-# endif
+# if defined(__GNUC__) && __GNUC__ >= 4
+# define DECLSPEC __attribute__ ((visibility("default")))
+# else
+# define DECLSPEC
+# 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 */
diff --git a/src/SDL12/include/close_code.h b/src/SDL12/include/close_code.h
index ca6da95d..afbb6504 100644
--- a/src/SDL12/include/close_code.h
+++ b/src/SDL12/include/close_code.h
@@ -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
diff --git a/src/client/cl_cgame.c b/src/client/cl_cgame.c
index b2fafe08..68b34c6b 100644
--- a/src/client/cl_cgame.c
+++ b/src/client/cl_cgame.c
@@ -775,7 +775,7 @@ void CL_InitCGame( void ) {
VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum );
// reset any CVAR_CHEAT cvars registered by cgame
- if ( !cl_connectedToCheatServer )
+ if ( !clc.demoplaying && !cl_connectedToCheatServer )
Cvar_SetCheatState();
// we will send a usercmd this frame, which
diff --git a/src/client/cl_curl.c b/src/client/cl_curl.c
index 734cc306..9c5e3cc4 100644
--- a/src/client/cl_curl.c
+++ b/src/client/cl_curl.c
@@ -298,6 +298,8 @@ void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
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);
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c
index fe88526a..b283ffbc 100644
--- a/src/client/cl_keys.c
+++ b/src/client/cl_keys.c
@@ -1417,8 +1417,10 @@ void Key_SetCatcher( int catcher ) {
}
// 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;
/*
================
@@ -1429,51 +1431,63 @@ Load the console history from cl_consoleHistory
*/
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 );
-
- text_p = consoleSaveBuffer;
+ consoleSaveBufferSize = FS_FOpenFileRead( CONSOLE_HISTORY_FILE, &f, qfalse );
+ if( !f )
+ {
+ Com_Printf( "Couldn't read %s.\n", CONSOLE_HISTORY_FILE );
+ return;
+ }
- 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;
+
+ for( i = COMMAND_HISTORY - 1; i >= 0; i-- )
+ {
+ if( !*( token = COM_Parse( &text_p ) ) )
+ break;
- historyEditLines[ i ].cursor = atoi( token );
+ historyEditLines[ i ].cursor = atoi( token );
- if( !*( token = COM_Parse( &text_p ) ) )
- break;
+ if( !*( token = COM_Parse( &text_p ) ) )
+ break;
- historyEditLines[ i ].scroll = atoi( token );
+ historyEditLines[ i ].scroll = atoi( token );
- if( !*( token = COM_Parse( &text_p ) ) )
- 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;
+ 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 ] );
- 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 );
- historyLine = nextHistoryLine = numLines;
+ FS_FCloseFile( f );
}
/*
@@ -1486,8 +1500,9 @@ so that it persists across invocations of q3
*/
void CL_SaveConsoleHistory( void )
{
- int i;
- int lineLength, saveBufferLength, additionalLength;
+ int i;
+ int lineLength, saveBufferLength, additionalLength;
+ fileHandle_t f;
consoleSaveBuffer[ 0 ] = '\0';
@@ -1499,8 +1514,8 @@ void CL_SaveConsoleHistory( void )
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 )
{
@@ -1518,5 +1533,17 @@ void CL_SaveConsoleHistory( void )
}
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 );
}
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index 2fe3151d..28d95739 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -509,7 +509,8 @@ void CL_PlayDemo_f( void ) {
}
// 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 );
diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c
index 2ba7736a..6a4bb16f 100644
--- a/src/client/cl_ui.c
+++ b/src/client/cl_ui.c
@@ -1082,7 +1082,7 @@ void CL_InitUI( void ) {
}
// reset any CVAR_CHEAT cvars registered by ui
- if ( !cl_connectedToCheatServer )
+ if ( !clc.demoplaying && !cl_connectedToCheatServer )
Cvar_SetCheatState();
}
diff --git a/src/jpeg-6/jerror.c b/src/jpeg-6/jerror.c
index 255c0921..026e2d11 100644
--- a/src/jpeg-6/jerror.c
+++ b/src/jpeg-6/jerror.c
@@ -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
diff --git a/src/jpeg-6/jmemnobs.c b/src/jpeg-6/jmemnobs.c
index ea7ead71..87533a19 100644
--- a/src/jpeg-6/jmemnobs.c
+++ b/src/jpeg-6/jmemnobs.c
@@ -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().
diff --git a/src/jpeg-6/jmorecfg.h b/src/jpeg-6/jmorecfg.h
index a2fea833..4cae5a4f 100644
--- a/src/jpeg-6/jmorecfg.h
+++ b/src/jpeg-6/jmorecfg.h
@@ -149,7 +149,10 @@ typedef unsigned short UINT16;
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 long INT32;
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
diff --git a/src/libs/macosx/libSDL-1.2.0.dylib b/src/libs/macosx/libSDL-1.2.0.dylib
index 3c510544..2ea0f454 100755
--- a/src/libs/macosx/libSDL-1.2.0.dylib
+++ b/src/libs/macosx/libSDL-1.2.0.dylib
Binary files differ
diff --git a/src/qcommon/vm_interpreted.c b/src/qcommon/vm_interpreted.c
index 00aa4710..35096e5b 100644
--- a/src/qcommon/vm_interpreted.c
+++ b/src/qcommon/vm_interpreted.c
@@ -395,9 +395,8 @@ nextInstruction:
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" );
}
@@ -421,6 +420,7 @@ nextInstruction2:
}
profileSymbol->profileCount++;
#endif
+ opcode = codeImage[ programCounter++ ];
switch ( opcode ) {
#ifdef DEBUG_VM
@@ -565,6 +565,8 @@ nextInstruction2:
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 ];
}
@@ -620,6 +622,8 @@ nextInstruction2:
// 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;
diff --git a/src/qcommon/vm_ppc.c b/src/qcommon/vm_ppc.c
index 9475a833..79fc506f 100644
--- a/src/qcommon/vm_ppc.c
+++ b/src/qcommon/vm_ppc.c
@@ -25,8 +25,101 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "vm_local.h"
-#pragma opt_pointer_analysis off
+#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,
@@ -64,6 +157,42 @@ typedef enum {
#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,
@@ -200,7 +329,7 @@ typedef enum {
PPC_MCRXR = 0x7c000000,
PPC_LSWX = 0x7c000000,
PPC_LWBRX = 0x7c000000,
- PPC_LFSX = 0x7c000000,
+ PPC_LFSX = 0x7c00042e,
PPC_SRW = 0x7c000430,
PPC_SRD = 0x7c000000,
PPC_TLBSYNC = 0x7c000000,
@@ -213,7 +342,7 @@ typedef enum {
PPC_MFSRIN = 0x7c000000,
PPC_STSWX = 0x7c000000,
PPC_STWBRX = 0x7c000000,
- PPC_STFSX = 0x7c000000,
+ PPC_STFSX = 0x7c00052e,
PPC_STFSUX = 0x7c000000,
PPC_STSWI = 0x7c000000,
PPC_STFDX = 0x7c000000,
@@ -309,6 +438,7 @@ typedef enum {
// the newly generated code
static unsigned *buf;
static int compiledOfs; // in dwords
+static int pass;
// fromt the original bytecode
static byte *code;
@@ -334,83 +464,179 @@ static int Constant1( void ) {
return v;
}
-static void Emit4( int i ) {
+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( int opcode, int destReg, int aReg, int bReg ) {
+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( int opcode, int destReg, int aReg, int bReg, int cReg ) {
+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( int opcode, int destReg, int aReg, int immediate ) {
+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( int opcode, int destReg, int aReg, int immediate ) {
+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 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 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 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;
+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;
}
- 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
@@ -422,6 +648,7 @@ static void fltop() {
}
#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
@@ -429,6 +656,9 @@ static void fltopandsecond() {
rtopped = qfalse;
return;
}
+#endif
+
+#define assertInteger(depth) assert(opStackRegType[depth] == 1)
/*
=================
@@ -440,7 +670,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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;
@@ -456,9 +689,10 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
// pointers for branches
for ( pass = -1 ; pass < 2 ; pass++ ) {
- rtopped = qfalse;
// translate all instructions
pc = 0;
+ mainFunction = 0;
+ opStackDepth = 0;
pop0 = 343545;
pop1 = 2443545;
@@ -473,7 +707,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
Emit4( 0 );
#endif
- for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
+ for ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {
if ( compiledOfs*4 > maxLength - 16 ) {
Com_Error( ERR_DROP, "VM_Compile: maxLength exceeded" );
}
@@ -487,651 +721,988 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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;
+ #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:
- InstImm( PPC_ADDI, R_STACK, R_STACK, -Constant4() ); // sub R_STACK, R_STACK, imm
- rtopped = qfalse;
+ 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 (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {
- v &= vm->dataMask;
- }
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x CONST\t%08x\n",instruction,v);
+ #endif
+ opStackLoadInstructionAddr[opStackDepth] = 0;
if ( v < 32768 && v >= -32768 ) {
- InstImmU( PPC_ADDI, R_TOP, 0, v & 0xffff );
+ InstImmU( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], 0, v & 0xffff );
} else {
- InstImmU( PPC_ADDIS, R_TOP, 0, (v >> 16)&0xffff );
+ InstImmU( "addis", PPC_ADDIS, opStackIntRegisters[opStackDepth], 0, (v >> 16)&0xffff );
if ( v & 0xffff ) {
- InstImmU( PPC_ORI, R_TOP, R_TOP, v & 0xffff );
+ InstImmU( "ori", PPC_ORI, opStackIntRegisters[opStackDepth], opStackIntRegisters[opStackDepth], 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;
- }
+ opStackRegType[opStackDepth] = 1;
+ opStackDepth += 1;
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 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( 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;
+ InstImm( "addi", PPC_ADDI, opStackIntRegisters[opStackDepth], R_STACK, oc1 );
+ opStackRegType[opStackDepth] = 1;
+ opStackLoadInstructionAddr[opStackDepth] = 0;
+ opStackDepth += 1;
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;
+ 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:
- 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;
+ #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:
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, 4 );
- rtopped = qfalse;
+ #if DEBUG_VM
+ if(pass == 1)
+ printf("%08x PUSH\n",instruction);
+ #endif
+ opStackRegType[opStackDepth] = 1; // Garbage int value.
+ opStackDepth += 1;
break;
case OP_POP:
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- rtopped = qfalse;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 2, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (v&0x3ffffff) );
break;
case OP_NE:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 2, 8 );
+ InstImm( "bc", 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 );
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 2, v );
- rtopped = qfalse;
break;
case OP_LTI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
break;
case OP_LEI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
break;
case OP_GTI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
break;
case OP_GEI:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMP, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
break;
case OP_LTU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
break;
case OP_LEU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
break;
case OP_GTU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
break;
case OP_GEU:
- ltopandsecond(); // get value from opstack
- Inst( PPC_CMPL, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
break;
case OP_EQF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
+ #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( PPC_BC, 4, 2, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 2, v );
break;
case OP_NEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );
+ #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( PPC_BC, 12, 2, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 2, v );
break;
case OP_LTF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 0, v );
break;
case OP_LEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 1, v );
break;
case OP_GTF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 4, 1, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 12, 1, v );
break;
case OP_GEF:
- fltopandsecond(); // get value from opstack
- Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );
+ #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( PPC_BC, 12, 0, 8 );
+ InstImm( "bc", 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;
+ Emit4("b", PPC_B | (unsigned int)(v&0x3ffffff) );
+// InstImm( "bc", PPC_BC, 4, 0, v );
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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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:
- 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;
+ #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( 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 );
+ 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 );
- 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;
+ #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:
- ltop(); // get value from opstack
- Inst( PPC_EXTSB, R_TOP, R_TOP, 0 );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
+ #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:
- ltop(); // get value from opstack
- Inst( PPC_EXTSH, R_TOP, R_TOP, 0 );
- InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );
- rtopped = qtrue;
+ #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;
- 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
+ #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( 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;
+ 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:
- ltop(); // get value from opstack
- InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );
- Inst( PPC_RLWINM | ( 29 << 1 ), R_TOP, R_TOP, 2 );
+ #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( 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;
+ 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 );
@@ -1141,16 +1712,33 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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 );
}
@@ -1170,6 +1758,9 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
currentVM = vm;
+ //printf("VM_CallCompiled: %p %08lx %08lx %08lx\n",
+ // vm, args[0],args[1],args[2]);
+
// interpret the code
vm->currentlyInterpreting = qtrue;
@@ -1194,6 +1785,7 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
*(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
@@ -1246,7 +1838,7 @@ asm (
#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
+//#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 (
@@ -1309,7 +1901,7 @@ asm (
// save off the return value
" stwu r12,4(r4) \n" // RG_TOP, 0(RG_OPSTACK)
- // GCC adds its own prolog / epilog code
+ // GCC adds its own prolog / epliog code
);
}
#else
diff --git a/src/qcommon/vm_ppc_new.c b/src/qcommon/vm_ppc_new.c
deleted file mode 100644
index 79fc506f..00000000
--- a/src/qcommon/vm_ppc_new.c
+++ /dev/null
@@ -1,2072 +0,0 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-Copyright (C) 2000-2006 Tim Angus
-
-This file is part of Tremulous.
-
-Tremulous 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.
-
-Tremulous 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 Tremulous; 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
diff --git a/src/qcommon/vm_x86_64.c b/src/qcommon/vm_x86_64.c
index 9fde6e75..e8e827e5 100644
--- a/src/qcommon/vm_x86_64.c
+++ b/src/qcommon/vm_x86_64.c
@@ -43,15 +43,19 @@ static FILE* qdasmout;
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
*/
@@ -266,6 +270,15 @@ static unsigned char op_argsize[256] =
#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
@@ -412,10 +425,17 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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, 0644);
+ fd_o = open(fn_o, O_CREAT|O_WRONLY, 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);
@@ -451,8 +471,6 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
emit("or %%r8, %%r8"); // check whether to set up instruction pointers
emit("jnz main");
emit("jmp setupinstructionpointers");
- emit("exit:");
- emit("jmp *%%r9");
emit("main:");
@@ -502,16 +520,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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
@@ -522,7 +531,8 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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");
@@ -530,14 +540,19 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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 %%r10");
+ emit("pop %%rbx");
+ emit("addq %%rbx, %%rsp");
emit("pop %%r10");
emit("pop %%r9");
emit("pop %%r8");
@@ -545,7 +560,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
emit("pop %%rsi");
// emit("frstor 4(%%rsi)");
emit("addq $4, %%rsi");
- emit("movl %%eax, (%%rsi)");
+ emit("movl %%eax, (%%rsi)"); // store return value
break;
case OP_PUSH:
emit("addq $4, %%rsi");
@@ -634,21 +649,21 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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;
@@ -664,7 +679,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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:
@@ -703,14 +718,14 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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;
@@ -741,14 +756,15 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
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:
@@ -847,7 +863,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
{
emit("movl $i_%08x-start, %d(%%rax)", instruction, instruction*4);
}
- emit("jmp exit");
+ emit("ret");
emit("debugger:");
if(1);
@@ -883,28 +899,30 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
// 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 (%p - %p)\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
}
@@ -978,16 +996,16 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
__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] ) {
diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c
index ce966699..b9b676a9 100644
--- a/src/renderer/tr_init.c
+++ b/src/renderer/tr_init.c
@@ -1061,7 +1061,12 @@ void R_Register( void )
r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE);
r_textureMode = ri.Cvar_Get( "r_textureMode",
GENERIC_HW_R_TEXTUREMODE_DEFAULT, 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 );
diff --git a/src/server/sv_init.c b/src/server/sv_init.c
index 293b31c9..2106816c 100644
--- a/src/server/sv_init.c
+++ b/src/server/sv_init.c
@@ -696,6 +696,7 @@ void SV_Shutdown( char *finalmsg ) {
Com_Printf( "---------------------------\n" );
// disconnect any local clients
- CL_Disconnect( qfalse );
+ if( sv_killserver->integer != 2 )
+ CL_Disconnect( qfalse );
}
diff --git a/src/server/sv_main.c b/src/server/sv_main.c
index 2dc5a778..ad9669b4 100644
--- a/src/server/sv_main.c
+++ b/src/server/sv_main.c
@@ -474,7 +474,7 @@ void SVC_RemoteCommand( netadr_t from, msg_t *msg ) {
// 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;
diff --git a/src/tools/asm/Makefile b/src/tools/asm/Makefile
index df355719..52f1060d 100644
--- a/src/tools/asm/Makefile
+++ b/src/tools/asm/Makefile
@@ -28,9 +28,9 @@ ifeq ($(USE_CCACHE),1)
CXX := ccache $(CXX)
endif
-default: q3asm
+default: q3asm
-q3asm: q3asm.c cmdlib.c
+q3asm: q3asm.c cmdlib.c
$(CC) $(Q3ASM_CFLAGS) -o $@ $^
clean:
diff --git a/src/tools/asm/cmdlib.c b/src/tools/asm/cmdlib.c
index 4eece87f..69ce3ffd 100644
--- a/src/tools/asm/cmdlib.c
+++ b/src/tools/asm/cmdlib.c
@@ -313,7 +313,7 @@ char *ExpandArg (const char *path)
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 );
@@ -326,7 +326,7 @@ char *ExpandPath (const char *path)
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 );
diff --git a/src/unix/sdl_glimp.c b/src/unix/sdl_glimp.c
index 6fa5943b..dcfa0a89 100644
--- a/src/unix/sdl_glimp.c
+++ b/src/unix/sdl_glimp.c
@@ -84,6 +84,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/* 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)
@@ -117,6 +120,10 @@ static qboolean mouse_active = qfalse;
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
@@ -433,11 +440,69 @@ void KBD_Close(void)
{
}
+#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)
@@ -450,6 +515,25 @@ void IN_DeactivateMouse( void )
{
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)
{
@@ -690,6 +774,13 @@ static int GLW_SetMode( const char *drivername, int mode, qboolean fullscreen )
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);
@@ -1291,6 +1382,7 @@ void IN_Init(void) {
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);
diff --git a/src/win32/win_input.c b/src/win32/win_input.c
index ccf1e2e0..e7253860 100644
--- a/src/win32/win_input.c
+++ b/src/win32/win_input.c
@@ -938,8 +938,8 @@ void IN_JoyMove( void ) {
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 ) );
@@ -1131,7 +1131,8 @@ static void IN_StartupMIDI( void )
( 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;
}