[mupen64plus-rsp-z64] 54/140: Imported Upstream version 1.99.5~hg20110828

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:05:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch master
in repository mupen64plus-rsp-z64.

commit 4d912695bb7f4c3555bd1884808d1ed6ad34ea5a
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Aug 28 18:47:36 2011 +0200

    Imported Upstream version 1.99.5~hg20110828
---
 projects/unix/Makefile | 144 ++++++++++++++++++++++++++++---------------------
 src/main_rsp.cpp       |   7 ++-
 src/rsp.cpp            |  75 +++-----------------------
 src/rsp.h              |   3 +-
 src/rsp_opinfo.cpp     |   3 +-
 src/rsp_recomp.cpp     |  20 +++----
 6 files changed, 109 insertions(+), 143 deletions(-)

diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index d890f32..76f1c1c 100755
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -50,6 +50,12 @@ ifeq ("$(UNAME)","FreeBSD")
   SO_EXTENSION = so
   SHARED = -shared
 endif
+ifeq ("$(UNAME)","OpenBSD")
+  OS = FREEBSD
+  SO_EXTENSION = so
+  SHARED = -shared
+  $(warning OS type "$(UNAME)" not officially supported.')
+endif
 ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
   OS = LINUX
   SO_EXTENSION = so
@@ -67,72 +73,83 @@ ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
   CPU := X86
   ifeq ("$(BITS)", "32")
     ARCH_DETECTED := 64BITS_32
+    PIC ?= 0
   else
     ARCH_DETECTED := 64BITS
+    PIC ?= 1
   endif
 endif
 ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
   CPU := X86
   ARCH_DETECTED := 32BITS
+  PIC ?= 0
+endif
+ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
+  CPU := PPC
+  ARCH_DETECTED := 32BITS
+  BIG_ENDIAN := 1
+  PIC ?= 1
+  $(warning Architecture "$(HOST_CPU)" not officially supported.')
+endif
+ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
+  CPU := PPC
+  ARCH_DETECTED := 64BITS
+  BIG_ENDIAN := 1
+  PIC ?= 1
+  $(warning Architecture "$(HOST_CPU)" not officially supported.')
 endif
-# PPC doesn't work yet
-#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
-#  CPU := PPC
-#  ARCH_DETECTED := 32BITS
-#endif
-#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
-#  CPU := PPC
-#  ARCH_DETECTED := 64BITS
-#endif
 ifeq ("$(CPU)","NONE")
   $(error CPU type "$(HOST_CPU)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
 endif
 
-# base CFLAGS, LIBS, and LDFLAGS
-CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src
+# base CFLAGS, LDLIBS, and LDFLAGS
+OPTFLAGS ?= -O3
+CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
 CXXFLAGS += -fvisibility-inlines-hidden
-LDFLAGS += -ldl
+LDFLAGS += $(SHARED)
+
+# Since we are building a shared library, we must compile with -fPIC on some architectures
+# On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
+ifeq ($(PIC), 1)
+  CFLAGS += -fPIC
+  LDFLAGS += -fPIC
+endif
 
-# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
-# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
-ifeq ($(ARCH_DETECTED), 64BITS)
-  CFLAGS += -fPIC -DPIC
+ifeq ($(BIG_ENDIAN), 1)
+  CFLAGS += -DM64P_BIG_ENDIAN
 endif
+
 # tweak flags for 32-bit build on 64-bit system
 ifeq ($(ARCH_DETECTED), 64BITS_32)
   ifeq ($(OS), FREEBSD)
     $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
   endif
   CFLAGS += -m32
-  LDFLAGS += -m32 -m elf_i386
+  LDFLAGS += -m32 -Wl,-m,elf_i386
 endif
 
 # set special flags per-system
 ifeq ($(OS), LINUX)
   # only export api symbols
   LDFLAGS += -Wl,-version-script,$(SRCDIR)/rsp_api_export.ver
-  ifeq ($(CPU), X86)
-    ifeq ($(ARCH_DETECTED), 64BITS)
-      CFLAGS += -pipe -O3 -march=athlon64
-    else
-      CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
-    endif
-  endif
+  LDLIBS += -ldl
+endif
+ifeq ($(OS), FREEBSD)
+  LDLIBS += -lc
 endif
 ifeq ($(OS), OSX)
   ifeq ($(CPU), X86)
     ifeq ($(ARCH_DETECTED), 64BITS)
       CFLAGS += -pipe -O3 -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
       LDFLAGS += -arch x86_64
+      LDLIBS += -ldl
     else
       CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
       LDFLAGS += -arch i686
+      LDLIBS += -ldl
     endif
   endif
 endif
-ifeq ($(CPU), PPC)
-  CFLAGS += -mcpu=powerpc
-endif
 
 # set mupen64plus core API header path
 ifneq ("$(APIDIR)","")
@@ -156,20 +173,31 @@ else
   endif
 endif
 
-# set shell function names
-CC      ?= gcc
-CXX     ?= g++
-INSTALL ?= install
-ifeq ($(OS),OSX)
-  STRIP	?= strip -x 
-else
-  STRIP	?= strip -s
+# reduced compile output when running make without V=1
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+	Q_CC  = @echo '    CC  '$@;
+	Q_CXX = @echo '    CXX '$@;
+	Q_LD  = @echo '    LD  '$@;
 endif
+endif
+
+# set base program pointers and flags
+CC       ?= gcc
+CXX      ?= g++
+RM       ?= rm -f
+INSTALL  ?= install
+MKDIR ?= mkdir -p
+COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
+COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
+LINK.o = $(Q_LD)$(CXX) $(LDFLAGS) $(TARGET_ARCH)
 
 # set special flags for given Makefile parameters
 ifeq ($(DEBUG),1)
   CFLAGS += -g
-  STRIP = true # disable binary strip
+  INSTALL_STRIP_FLAG ?= 
+else
+  INSTALL_STRIP_FLAG ?= -s
 endif
 
 # set installation options
@@ -177,7 +205,10 @@ ifeq ($(PREFIX),)
   PREFIX := /usr/local
 endif
 ifeq ($(LIBDIR),)
-  LIBDIR := $(PREFIX)/lib/mupen64plus
+  LIBDIR := $(PREFIX)/lib
+endif
+ifeq ($(PLUGINDIR),)
+  PLUGINDIR := $(LIBDIR)/mupen64plus
 endif
 
 SRCDIR = ../../src
@@ -195,7 +226,7 @@ SOURCE = \
 OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
 OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
 OBJDIRS = $(dir $(OBJECTS))
-$(shell mkdir -p $(OBJDIRS))
+$(shell $(MKDIR) $(OBJDIRS))
 
 # build targets
 TARGET = mupen64plus-rsp-z64.$(SO_EXTENSION)
@@ -211,9 +242,12 @@ targets:
 	@echo "  Options:"
 	@echo "    BITS=32       == build 32-bit binaries on 64-bit machine"
 	@echo "    APIDIR=path   == path to find Mupen64Plus Core headers"
+	@echo "    OPTFLAGS=flag == compiler optimization (default: -O3)"
+	@echo "    PIC=(1|0)     == Force enable/disable of position independent code"
 	@echo "  Install Options:"
 	@echo "    PREFIX=path   == install/uninstall prefix (default: /usr/local)"
-	@echo "    LIBDIR=path   == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
+	@echo "    LIBDIR=path   == library prefix (default: PREFIX/lib)"
+	@echo "    PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
 	@echo "    DESTDIR=path  == path to prepend to all installation paths (only for packagers)"
 	@echo "  Debugging Options:"
 	@echo "    DEBUG=1       == add debugging symbols"
@@ -222,15 +256,14 @@ targets:
 all: $(TARGET)
 
 install: $(TARGET)
-	$(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
-	$(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
+	$(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
+	$(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
 
 uninstall:
-	rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
+	$(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
 
 clean:
-	rm -rf ./_obj/* $(TARGET)
-	rmdir ./_obj
+	$(RM) -r ./_obj $(TARGET)
 
 rebuild: clean all
 
@@ -240,23 +273,14 @@ CFLAGS += -MD
 
 CXXFLAGS += $(CFLAGS)
 
-# reduced compile output when running make without V=1
-ifneq ($(findstring $(MAKEFLAGS),s),s)
-ifndef V
-	Q_CC  = @echo '    CC  '$@;
-	Q_CXX = @echo '    CXX '$@;
-	Q_LD  = @echo '    LD  '$@;
-endif
-endif
+# standard build rules
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+	$(COMPILE.c) -o $@ $<
 
-# build rules
+$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
+	$(COMPILE.cc) -o $@ $<
 
 $(TARGET): $(OBJECTS)
-	$(Q_LD)$(CXX) $(SHARED) $^ $(LDFLAGS) -o $@
-	$(STRIP) $@
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
 
-$(OBJDIR)/%.o: $(SRCDIR)/%.c
-	$(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
-
-$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
-	$(Q_CXX)$(CXX) -o $@ $(CXXFLAGS) -c $<
+.PHONY: all clean install uninstall targets
diff --git a/src/main_rsp.cpp b/src/main_rsp.cpp
index 4c5b8ad..8f47939 100644
--- a/src/main_rsp.cpp
+++ b/src/main_rsp.cpp
@@ -23,6 +23,9 @@
 #include <assert.h>
 #include <stdarg.h>
 
+#define RSP_Z64_VERSION        0x016304
+#define RSP_PLUGIN_API_VERSION 0x020000
+
 static void (*l_DebugCallback)(void *, int, const char *) = NULL;
 static void *l_DebugCallContext = NULL;
 static bool l_PluginInit = false;
@@ -114,10 +117,10 @@ extern "C" {
             *PluginType = M64PLUGIN_RSP;
 
         if (PluginVersion != NULL)
-            *PluginVersion = 0x016304;
+            *PluginVersion = RSP_Z64_VERSION;
 
         if (APIVersion != NULL)
-            *APIVersion = PLUGIN_API_VERSION;
+            *APIVersion = RSP_PLUGIN_API_VERSION;
 
         if (PluginNamePtr != NULL)
             *PluginNamePtr = "Z64 RSP Plugin";
diff --git a/src/rsp.cpp b/src/rsp.cpp
index 669f63b..2822d12 100644
--- a/src/rsp.cpp
+++ b/src/rsp.cpp
@@ -201,6 +201,7 @@ UINT32 get_cop0_reg(int reg)
     else
     {
         log(M64MSG_ERROR, "RSP: get_cop0_reg: %d", reg);
+	return ~0;
     }
 }
 
@@ -315,61 +316,14 @@ void rsp_init(RSP_INFO info)
     rsp.ext = info;
 
     sp_pc = 0; //0x4001000;
-    rsp.nextpc = ~0;
+    rsp.nextpc = ~0U;
     //rsp_invalidate(0, 0x1000);
     rsp.step_count=0;
 }
 
-static void rsp_exit(void)
-{
-#if SAVE_DISASM
-    {
-        char string[200];
-        int i;
-        FILE *dasm;
-        dasm = fopen("rsp_disasm.txt", "wt");
-
-        for (i=0; i < 0x1000; i+=4)
-        {
-            UINT32 opcode = ROPCODE(0x04001000 + i);
-            rsp_dasm_one(string, 0x04001000 + i, opcode);
-            fprintf(dasm, "%08X: %08X   %s\n", 0x04001000 + i, opcode, string);
-        }
-        fclose(dasm);
-    }
-#endif
-#if SAVE_DMEM
-    {
-        /*int i;
-        FILE *dmem;
-        dmem = fopen("rsp_dmem.txt", "wt");
-
-        for (i=0; i < 0x1000; i+=4)
-        {
-        fprintf(dmem, "%08X: %08X\n", 0x04000000 + i, READ32(0x04000000 + i));
-        }
-        fclose(dmem);*/
-
-        int i;
-        FILE *dmem;
-        dmem = fopen("rsp_dmem.bin", "wb");
-
-        for (i=0; i < 0x1000; i++)
-        {
-            fputc(READ8(0x04000000 + i), dmem);
-        }
-        fclose(dmem);
-    }
-#endif
-
-#if LOG_INSTRUCTION_EXECUTION
-    fclose(exec_output);
-#endif
-}
-
 void rsp_reset(void)
 {
-    rsp.nextpc = ~0;
+    rsp.nextpc = ~0U;
 }
 
 void handle_lwc2(UINT32 op)
@@ -2452,7 +2406,7 @@ void handle_vector_ops(UINT32 op)
 
             int del = (VS1REG & 7);
             int sel = VEC_EL_2(EL, del);
-            INT32 sqr;
+            UINT32 sqr;
 
             sqr = (UINT16)(VREG_S(VS2REG, sel)) | ((UINT32)(rsp.square_root_high) << 16);
 
@@ -2469,7 +2423,7 @@ void handle_vector_ops(UINT32 op)
             else
             {
                 int negative = 0;
-                if (sqr < 0)
+                if (sqr > 0x7fffffff)
                 {
                     if (((UINT32)(sqr & 0xffff0000) == 0xffff0000) && ((INT16)(sqr & 0xffff) < 0))
                     {
@@ -2579,10 +2533,10 @@ int rsp_execute(int cycles)
         GENTRACE("%2x %3x\t%s\n", ((UINT8*)rsp_dmem)[0x1934], sp_pc, s);
 #endif
 
-        if (rsp.nextpc != ~0)///DELAY SLOT USAGE
+        if (rsp.nextpc != ~0U)///DELAY SLOT USAGE
         {
             sp_pc = /*0x4001000 | */(rsp.nextpc & 0xfff); //rsp.nextpc;
-            rsp.nextpc = ~0;
+            rsp.nextpc = ~0U;
         }
         else
         {
@@ -2881,21 +2835,6 @@ int rsp_execute(int cycles)
 
 /*****************************************************************************/
 
-static void rsp_get_context(void *dst)
-{
-    /* copy the context */
-    if (dst)
-        *(RSP_REGS *)dst = rsp;
-}
-
-
-static void rsp_set_context(void *src)
-{
-    /* copy the context */
-    if (src)
-        rsp = *(RSP_REGS *)src;
-}
-
 
 
 
diff --git a/src/rsp.h b/src/rsp.h
index bea1611..6c1cf73 100644
--- a/src/rsp.h
+++ b/src/rsp.h
@@ -22,6 +22,7 @@
 #ifndef _RSP_H_
 #define _RSP_H_
 
+#define M64P_PLUGIN_PROTOTYPES 1
 #include "m64p_types.h"
 #include "m64p_plugin.h"
 #include "z64.h"
@@ -387,7 +388,7 @@ static __inline__ unsigned long long RDTSC(void)
 // }
 // #define RDTSC1(n) __asm__ __volatile__("rdtsc" : "=a" (n): )
 // #define RDTSC2(n) __asm__ __volatile__ ("rdtsc\nmov %%edx,%%eax" : "=a" (n): )
-// inline void RDTSC(uint64_t& a) { uint32_t b, c; RDTSC1(b); RDTSC2(c); \
+// inline void RDTSC(uint64_t& a) { uint32_t b, c; RDTSC1(b); RDTSC2(c);
 //  a = (((uint64_t)c)<<32) | b; }
 #elif defined(INTEL86) && defined WIN32
 #define rdtsc __asm __emit 0fh __asm __emit 031h
diff --git a/src/rsp_opinfo.cpp b/src/rsp_opinfo.cpp
index 163b490..d02b561 100644
--- a/src/rsp_opinfo.cpp
+++ b/src/rsp_opinfo.cpp
@@ -88,7 +88,6 @@ void rsp_get_opinfo(UINT32 op, rsp_opinfo_t * info)
     info->flags = 0;
 
     int dest = (op >> 16) & 0x1f;
-    int base = (op >> 21) & 0x1f;
     int index = (op >> 7) & 0xf;
     int offset = (op & 0x7f);
     if (offset & 0x40)
@@ -296,7 +295,7 @@ void rsp_get_opinfo(UINT32 op, rsp_opinfo_t * info)
             //
             // Stores one element from maximum of 8 vectors, while incrementing element index
 
-            int element, eaoffset;
+            int element;
             int vs = dest;
             int ve = dest + 8;
             if (ve > 32)
diff --git a/src/rsp_recomp.cpp b/src/rsp_recomp.cpp
index 951be4a..f771955 100644
--- a/src/rsp_recomp.cpp
+++ b/src/rsp_recomp.cpp
@@ -37,8 +37,8 @@ struct opinfo_t {
     int visit, labeled;
     int label;
 
-    int nbgen;
-    int szgen;
+    unsigned int nbgen;
+    unsigned int szgen;
     gen_t * gentable;
     gen_t * curgen;
 };
@@ -50,9 +50,9 @@ struct branch_t {
 static int curvisit;
 static opinfo_t opinfo[0x1000/4];
 static int jumps[0x1000];
-static int nb_branches;
+static unsigned int nb_branches;
 static branch_t branches[256];
-static int nb_labels;
+static unsigned int nb_labels;
 static int labels[256];
 
 #define OPI(pc) opinfo[(pc)>>2]
@@ -153,7 +153,7 @@ static UINT32 prep_gen(int pc, UINT32 crc, int & len)
 
 static void rsp_gen(int pc)
 {
-    int i;
+    unsigned int i;
 
     curvisit++;
     if (!curvisit) {
@@ -197,7 +197,7 @@ static void rsp_gen(int pc)
     opi->curgen = gen;
 
     // convert to bytecode
-    int lbc = 0;
+    unsigned int lbc = 0;
     static rsp_bc_t bc[0x1000*2+10];
     for (i=0; i<nb_branches; i++) {
         int pc;
@@ -232,13 +232,13 @@ static void rsp_gen(int pc)
                 if (!nop) {
                     bc[lbc].op = op;
                     bc[lbc].op2 = info.op2;
-                    bc[lbc].flags = info.flags | ((pc&0xffc)<<5-2) | (!cont? (1<<15):0);
+                    bc[lbc].flags = info.flags | (((pc&0xffc)<<5)-2) | (!cont? (1<<15):0);
                     lbc++;
                 }
                 loopc = (pc+4)&0xfff;
             }
             if (delayed.op) {
-                int addop;
+                int addop = 0;
                 const UINT32 op = delayed.op;
                 switch (delayed.op2) {
                 case RSP_BLTZ:
@@ -561,10 +561,10 @@ int rsp_jump(int pc)
     int res = run(rsp, gen);
 
     //fprintf(stderr, "r31 %x from %x nextpc %x pc %x res %d (%s)\n", rsp.r[31], pc, rsp.nextpc, sp_pc, res, gen->name);
-    if (rsp.nextpc != ~0)
+    if (rsp.nextpc != ~0U)
     {
         sp_pc = (rsp.nextpc & 0xfff);
-        rsp.nextpc = ~0;
+        rsp.nextpc = ~0U;
     }
     else
     {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-rsp-z64.git



More information about the Pkg-games-commits mailing list