[mupen64plus-ui-console] 36/172: Imported Upstream version 1.99.4

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


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

ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-ui-console.

commit a986cde87dcbff19c882ca833cc5c8eaf5019cd4
Author: Sven Eckelmann <sven.eckelmann at gmx.de>
Date:   Wed Nov 24 20:41:55 2010 +0100

    Imported Upstream version 1.99.4
---
 README                 |   5 +-
 RELEASE                |   6 +
 projects/unix/Makefile |  13 +-
 src/cheat.c            | 354 +++++++++++++++++++++++++++++++------------------
 src/cheat.h            |   2 +-
 src/main.c             |  26 ++--
 src/osal_preproc.h     |   5 +
 src/version.h          |   2 +-
 8 files changed, 269 insertions(+), 144 deletions(-)

diff --git a/README b/README
index 84a7043..0895ef5 100644
--- a/README
+++ b/README
@@ -41,9 +41,12 @@ Parameters:
         (pluginname)          : filename (without path) of plugin to find in plugin directory
         (pluginpath)          : full path and filename of plugin
         'dummy'               : use dummy plugin
+
     (cheat-spec):
         'list'                : show all of the available cheat codes
         'all'                 : enable all of the available cheat codes
-        (codelist)            : a comma-separated list of cheat code numbers to enable
+        (codelist)            : a comma-separated list of cheat code numbers to enable,
+                                with dashes to use code variables (ex 1-2 to use cheat 1 option 2)
+
 
 
diff --git a/RELEASE b/RELEASE
index eee6eb9..a0f856d 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,6 +1,12 @@
 Mupen64Plus-UI-Console RELEASE
 ------------------------------
 
+Mupen64Plus-UI-Console Front-End v1.99.4 - November 22, 2010
+------------------------------------------------------------
+ - add some parameter checking for --emumode option
+ - new cheat file format from spinout182
+ - makefile fixes and improvements
+
 Mupen64Plus-UI-Console Front-End v1.99.3 - February 13, 2010
 ------------------------------------------------------------
  - New feature: command-line option --set for setting arbitrary configuration variables
diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index d7ca29c..0d4e5f6 100644
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -29,6 +29,9 @@ endif
 ifeq ("$(UNAME)","linux")
   OS = LINUX
 endif
+ifneq ("$(filter GNU hurd,$(UNAME))","")
+  OS = LINUX
+endif
 ifeq ("$(UNAME)","Darwin")
   OS = OSX
 endif
@@ -73,28 +76,30 @@ endif
 
 # base CFLAGS, LIBS, and LDFLAGS
 CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -I../../src
-LDFLAGS += -ldl -lpthread
+LDFLAGS += -lpthread
 
 # set special flags per-system
 ifeq ($(OS), LINUX)
   ifeq ($(CPU), X86)
     ifeq ($(ARCH_DETECTED), 64BITS)
       CFLAGS += -pipe -O3 -march=athlon64
+      LDFLAGS += -ldl
     else
       CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
+      LDFLAGS += -ldl
     endif
   endif
 endif
 ifeq ($(OS), OSX)
   # The mac version of SDL requires inclusion of SDL_main in the executable
-  LDFLAGS += $(shell sdl-config --libs)
+  LDFLAGS += -ldl $(shell sdl-config --libs)
   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 += `sdl-config --libs` -arch x86_64
+      LDFLAGS += -arch x86_64
     else
       CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
-      LDFLAGS += `sdl-config --libs` -arch i686
+      LDFLAGS += -arch i686
     endif
   endif
 endif
diff --git a/src/cheat.c b/src/cheat.c
index 43ec454..afc971c 100644
--- a/src/cheat.c
+++ b/src/cheat.c
@@ -1,7 +1,8 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *   Mupen64plus - cheat.c                                                 *
  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
- *   Copyright (C) 2009 Richard Goedeken                                   *
+ *   Copyright (C) 2009-2010 Richard Goedeken                              *
+ *   Copyright (C) 2010 Rhett Osborne (spinout)                            *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -28,24 +29,33 @@
 #include "core_interface.h"
 
 /* local definitions */
-#define DATABASE_FILENAME "mupen64plus.cht"
+#define CHEAT_FILE	"mupencheat.txt"
+
+typedef struct {
+   int    address;
+   int   *variables;
+   char **variable_names;
+   int    var_to_use;
+   int    var_count;
+} cheat_code;
 
 typedef struct _sCheatInfo {
   int                 Number;
+  int                 Count;
+  int                 VariableLine;
   const char         *Name;
   const char         *Description;
-  const char         *Codes;
+  cheat_code         *Codes;
   struct _sCheatInfo *Next;
   } sCheatInfo;
 
 /* local variables */
-static m64p_rom_header  l_RomHeader;
-
-static char            *l_IniText = NULL;
-static const char      *l_CheatGameName = NULL;
-static sCheatInfo      *l_CheatList = NULL;
-static int              l_CheatCodesFound = 0;
-static int              l_RomFound = 0;
+static m64p_rom_header    l_RomHeader;
+static char              *l_IniText = NULL;
+static char              *l_CheatGameName = NULL;
+static sCheatInfo        *l_CheatList = NULL;
+static int                l_CheatCodesFound = 0;
+static int                l_RomFound = 0;
 
 /*********************************************************************************************************
  *  Static (Local) functions
@@ -56,17 +66,92 @@ static int isSpace(char ch)
     return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n');
 }
 
-static void CheatNewCode(char *CheatName, int CheatNum, char *CheatCodes)
+/* Find cheat code */
+static sCheatInfo *CheatFindCode(int Number)
+{
+    sCheatInfo *pCur = l_CheatList;
+    while (pCur != NULL)
+    {
+        if (pCur->Number == Number) break;
+        pCur = pCur->Next;
+    }
+    return pCur;
+}
+
+
+/* Activate a code */
+static void CheatActivate(sCheatInfo *pCheat)
+{
+    int i;
+
+    /* Get a m64p_cheat_code object */
+    m64p_cheat_code * code = (m64p_cheat_code*) calloc(pCheat->Count, sizeof(m64p_cheat_code));
+    if (code == NULL)
+    {
+        printf("UI-Console Warning: could not allocate memory for code '%s'\n", pCheat->Name);
+        return;
+    }
+    /* Fill in members */
+    for (i = 0; i < pCheat->Count; i++)
+    {
+        code[i].address = pCheat->Codes[i].address;
+        code[i].value = pCheat->Codes[i].variables[pCheat->Codes[i].var_to_use];
+    }
+    /* Enable cheat */
+    if (CoreAddCheat(pCheat->Name, code, pCheat->Count) != M64ERR_SUCCESS)
+    {
+        printf("UI-Console Warning: CoreAddCheat() failed for cheat code %i (%s)\n", pCheat->Number, pCheat->Name);
+        free(code);
+        return;
+    }
+
+    free(code);
+    printf("UI-Console: activated cheat code %i: %s\n", pCheat->Number, pCheat->Name);
+}
+
+static void CheatFreeAll(void)
+{
+    if (l_IniText != NULL)
+        free(l_IniText);
+    l_IniText = NULL;
+
+    sCheatInfo *pCur = l_CheatList;
+    while (pCur != NULL)
+    {
+        sCheatInfo *pNext = pCur->Next;
+        if (pCur->Codes != NULL)
+        {
+            int i;
+            for (i=0; i < pCur->Count; i++)
+            {
+                if (pCur->Codes[i].variables != NULL)
+                    free(pCur->Codes[i].variables);
+                if (pCur->Codes[i].variable_names != NULL)
+                    free(pCur->Codes[i].variable_names);
+            }
+            free(pCur->Codes);
+        }
+        free(pCur);
+        pCur = pNext;
+    }
+
+    l_CheatList = NULL;
+}
+
+/* Append new code */
+static sCheatInfo * NewCode(char *CheatName, int CheatNum)
 {
     /* allocate memory for a new sCheatInfo struct */
     sCheatInfo *pNew = (sCheatInfo *) malloc(sizeof(sCheatInfo));
-    if (pNew == NULL) return;
+    if (pNew == NULL) return NULL;
 
     /* fill in the data members */
     pNew->Number = CheatNum;
+    pNew->Count = 0;
+    pNew->VariableLine = -1;
     pNew->Name = CheatName;
     pNew->Description = NULL;
-    pNew->Codes = CheatCodes;
+    pNew->Codes = NULL;
     pNew->Next = NULL;
 
     l_CheatCodesFound++;
@@ -75,33 +160,51 @@ static void CheatNewCode(char *CheatName, int CheatNum, char *CheatCodes)
     if (l_CheatList == NULL)
     {
         l_CheatList = pNew;
-        return;
+        return pNew;
     }
     sCheatInfo *pLast = l_CheatList;
     while (pLast->Next != NULL) pLast = pLast->Next;
     pLast->Next = pNew;
+    return pNew;
 }
 
-static sCheatInfo *CheatFindCode(int Number)
+static void CheatAddVariables(cheat_code * Code, char *varlist)
 {
-    sCheatInfo *pCur = l_CheatList;
-    while (pCur != NULL)
+    /* needs to be more verbose? */
+    Code->variables = NULL;
+    Code->variable_names = NULL;
+    Code->var_count = 0;
+    while (*varlist != 0)
     {
-        if (pCur->Number == Number) break;
-        pCur = pCur->Next;
+        if ((Code->variables = (int*) realloc(Code->variables, sizeof(int) * (Code->var_count + 1))) == NULL)
+            return;
+        if ((Code->variable_names = (char**) realloc(Code->variable_names, sizeof(char*) * (Code->var_count + 1))) == NULL)
+            return;
+        if (sscanf(varlist, "%04X", &Code->variables[Code->var_count]) != 1)
+            Code->variables[Code->var_count] = 0;
+        if (strchr(varlist, '"') == NULL)
+            return;
+        Code->variable_names[Code->var_count] = strchr(varlist, '"') + 1;
+        if ((varlist = strchr(Code->variable_names[Code->var_count], '"')) == NULL)
+            return;
+        *varlist++ = 0;
+        if (*varlist == ',')
+            varlist++;
+        Code->var_count++;
     }
-    return pCur;
 }
 
-/*
- * Read and parse the Cheat DATABASE (PJ64), and load up any cheat codes found for the specified ROM section
- */
-void CheatParseIni(const char *RomSection)
+/*********************************************************************************************************
+* global functions
+*/
+
+void ReadCheats(char *RomSection)
 {
-    const char *romdbpath = ConfigGetSharedDataFilepath(DATABASE_FILENAME);
+    sCheatInfo *curr_code;
+    const char *romdbpath = ConfigGetSharedDataFilepath(CHEAT_FILE);
     if (romdbpath == NULL)
     {
-        printf("UI-Console: Cheat code database file '%s' not found.\n", DATABASE_FILENAME);
+        printf("UI-Console: cheat code database file '%s' not found.\n", CHEAT_FILE);
         return;
     }
 
@@ -119,13 +222,13 @@ void CheatParseIni(const char *RomSection)
     l_IniText = (char *) malloc(IniLength + 1);
     if (l_IniText == NULL)
     {
-        printf("UI-Console: Couldn't allocate %li bytes of memory to read cheat ini file.\n", IniLength);
+        printf("UI-Console: Couldn't allocate %li bytes of memory to read cheat file.\n", IniLength);
         fclose(fPtr);
         return;
     }
     if (fread(l_IniText, 1, IniLength, fPtr) != IniLength)
     {
-        printf("UI-Console: Couldn't read %li bytes from cheat ini file.\n", IniLength);
+        printf("UI-Console: Couldn't read %li bytes from cheat file.\n", IniLength);
         free(l_IniText);
         l_IniText = NULL;
         fclose(fPtr);
@@ -137,6 +240,8 @@ void CheatParseIni(const char *RomSection)
     /* parse lines from cheat database */
     char *curline = NULL;
     char *nextline = l_IniText;
+    int NumCheats = 0;
+
     while(nextline != NULL && *nextline != 0)
     {
         curline = nextline;
@@ -153,16 +258,18 @@ void CheatParseIni(const char *RomSection)
         char *endptr = curline + strlen(curline) - 1;
         while(isSpace(*endptr)) *endptr-- = 0;
 
+        /* ignore line if comment or empty */
+        if (*curline == '#' || strncmp(curline, "//", 2) == 0 || *curline == 0)
+            continue;
+
         /* handle beginning of new rom section */
-        if (*curline == '[' && *endptr == ']')
+        if (strncmp(curline, "crc ", 4) == 0)
         {
             /* if we have already found cheats for the given ROM file, then exit upon encountering a new ROM section */
-            if (l_RomFound)
+            if (l_RomFound && (l_CheatGameName != NULL || l_CheatList != NULL))
                 return;
             /* else see if this Rom Section matches */
-            curline++;
-            *endptr-- = 0;
-            if (strcmp(curline, RomSection) == 0)
+            if (strcmp(curline+4, RomSection) == 0)
                 l_RomFound = 1;
             continue;
         }
@@ -171,115 +278,75 @@ void CheatParseIni(const char *RomSection)
         if (!l_RomFound)
             continue;
 
-        /* skip over any comments or blank lines */
-        if (curline[0] == '/' && curline[1] == '/')
-            continue;
-        if (strlen(curline) == 0)
-            continue;
-
-        /* Handle the game's name in the cheat file */
-        if (strncmp(curline, "Name=", 5) == 0)
+        /* Game name */
+        if (strncmp(curline, "gn ", 3) == 0)
         {
-            l_CheatGameName = curline + 5;
+            l_CheatGameName = curline+3;
             continue;
         }
-        /* Handle new cheat codes */
-        char lineextra[64]; /* this isn't used but is needed because sscanf sucks */
-        int CheatNum;
-        if (sscanf(curline, "Cheat%i = \"%32s", &CheatNum, lineextra) == 2)
+
+        /* code name */
+        if (strncmp(curline, "cn ", 3) == 0)
         {
-            char *CheatName = strchr(curline, '"') + 1;
-            /* NULL-terminate the cheat code's name and get a pointer to the start of the codes */
-            char *CheatCodes = strchr(CheatName, '"');
-            if (CheatCodes == NULL) continue;
-            *CheatCodes++ = 0;
-            CheatCodes = strchr(CheatCodes, ',');
-            if (CheatCodes == NULL) continue;
-            CheatCodes++;
-            /* If this is a cheat code with options, just skip it; too complicated for command-line UI */
-            if (strchr(CheatCodes, '?') != NULL)
-                continue;
-            /* create a new cheat code in our list */
-            CheatNewCode(CheatName, CheatNum, CheatCodes);
+            curr_code = NewCode(curline + 3, l_CheatCodesFound);
+            if (curr_code == NULL)
+                printf("UI-Console error: error getting new code (%s)\n", curline+3);
             continue;
         }
-        /* Handle descriptions for cheat codes */
-        if (sscanf(curline, "Cheat%i_N =%32s", &CheatNum, lineextra) == 2)
-        {
-            char *CheatDesc = strchr(curline, '=') + 1;
-            sCheatInfo *pCheat = CheatFindCode(CheatNum);
-            if (pCheat != NULL)
-                pCheat->Description = CheatDesc;
+        
+        /* if curr_code is NULL, don't do these checks */
+        if (curr_code == NULL)
             continue;
-        }
-        /* Handle options for cheat codes */
-        if (sscanf(curline, "Cheat%i_O =%32s", &CheatNum, lineextra) == 2)
+
+        /* code description */
+        if (strncmp(curline, "cd ", 3) == 0)
         {
-            /* just skip it, options are too complicated for command-line UI */
+            curr_code->Description = curline+3;
             continue;
         }
-        /* otherwise we don't know what this line is */
-        printf("UI-Console Warning: unrecognized line in cheat ini file: '%s'\n", curline);
-    }
-
-}
-
-static void CheatActivate(sCheatInfo *pCheat)
-{
-    m64p_cheat_code CodeArray[32];
-    const char *pCodes = pCheat->Codes;
-    int NumCodes = 0;
 
-    while (pCodes != NULL && *pCodes != 0 && NumCodes < 32) /* I'm pretty sure none of the cheats contain 30 codes or more */
-    {
-        unsigned int address;
-        int value;
-        if (sscanf(pCodes, "%x %x", &address, &value) != 2)
+        /* code line */
+        int address;
+        if (sscanf(curline, "%8X %*s", &address) == 1)
         {
-            printf("UI-Console Error: reading hex values in cheat code %i (%s)\n", pCheat->Number, pCodes);
-            return;
+            curr_code->Codes = (cheat_code*) realloc(curr_code->Codes, sizeof(cheat_code) * (curr_code->Count + 1));
+            if (strncmp(curline+9, "????", 4) == 0)
+            {
+                curr_code->Codes[curr_code->Count].var_count = 0;
+                CheatAddVariables(&curr_code->Codes[curr_code->Count], curline+14);
+                curr_code->VariableLine = curr_code->Count;
+            }
+            else
+            {
+                int var;
+                curr_code->Codes[curr_code->Count].var_count = 1;
+                curr_code->Codes[curr_code->Count].variables = (int*) malloc(sizeof(int));
+                if(curr_code->Codes[curr_code->Count].variables == NULL)
+                {
+                    printf("UI-Console Error: error allocating memory; ignoring line: '%s'\n", curline);
+                    continue;
+                }
+                if (sscanf(curline+9, "%04X", &var) != 1)
+                    var = 0;
+                curr_code->Codes[curr_code->Count].variables[0] = var;
+                curr_code->Codes[curr_code->Count].variable_names = NULL;
+            }
+            curr_code->Codes[curr_code->Count].var_to_use = 0;
+            curr_code->Codes[curr_code->Count].address = address;
+            curr_code->Count++;
+            continue;
         }
-        CodeArray[NumCodes].address = address;
-        CodeArray[NumCodes].value = value;
-        NumCodes++;
-        pCodes = strchr(pCodes, ',');
-        if (pCodes != NULL) pCodes++;
-    }
-
-    if (CoreAddCheat(pCheat->Name, CodeArray, NumCodes) != M64ERR_SUCCESS)
-    {
-        printf("UI-Console Warning: CoreAddCheat() failed for cheat code %i (%s)\n", pCheat->Number, pCheat->Name);
-        return;
-    }
 
-    printf("UI-Console: activated cheat code %i: %s\n", pCheat->Number, pCheat->Name);
-}
-
-static void CheatFreeAll(void)
-{
-    if (l_IniText != NULL)
-        free(l_IniText);
-    l_IniText = NULL;
-
-    sCheatInfo *pCur = l_CheatList;
-    while (pCur != NULL)
-    {
-        sCheatInfo *pNext = pCur->Next;
-        free(pCur);
-        pCur = pNext;
+        /* otherwise we don't know what this line is */
+        printf("UI-Console Warning: unrecognized line in cheat file: '%s'\n", curline);
     }
 
-    l_CheatList = NULL;
 }
 
-/*********************************************************************************************************
-* global functions
-*/
-
-void CheatStart(eCheatMode CheatMode, int *CheatNumList, int CheatListLength)
+void CheatStart(eCheatMode CheatMode, char *CheatNumList)
 {
     /* if cheat codes are disabled, then we don't have to do anything */
-    if (CheatMode == CHEAT_DISABLE || (CheatMode == CHEAT_LIST && CheatListLength < 1))
+    if (CheatMode == CHEAT_DISABLE || (CheatMode == CHEAT_LIST && strlen(CheatNumList) == 0))
     {
         printf("UI-Console: Cheat codes disabled.\n");
         return;
@@ -297,7 +364,7 @@ void CheatStart(eCheatMode CheatMode, int *CheatNumList, int CheatListLength)
     sprintf(RomSection, "%X-%X-C:%X", sl(l_RomHeader.CRC1), sl(l_RomHeader.CRC2), l_RomHeader.Country_code & 0xff);
 
     /* parse through the cheat INI file and load up any cheat codes found for this ROM */
-    CheatParseIni(RomSection);
+    ReadCheats(RomSection);
     if (!l_RomFound || l_CheatCodesFound == 0)
     {
         printf("UI-Console: no cheat codes found for ROM image '%.20s'\n", l_RomHeader.Name);
@@ -316,6 +383,12 @@ void CheatStart(eCheatMode CheatMode, int *CheatNumList, int CheatListLength)
                 printf("   %i: %s\n", pCur->Number, pCur->Name);
             else
                 printf("   %i: %s (%s)\n", pCur->Number, pCur->Name, pCur->Description);
+            if(pCur->VariableLine != -1)
+            {
+                int i;
+                for (i = 0; i < pCur->Codes[pCur->VariableLine].var_count; i++)
+                    printf("      %i: %s\n", i, pCur->Codes[pCur->VariableLine].variable_names[i]);
+            }
             pCur = pCur->Next;
         }
         CheatFreeAll();
@@ -338,22 +411,47 @@ void CheatStart(eCheatMode CheatMode, int *CheatNumList, int CheatListLength)
     /* handle list of cheats enabled mode */
     if (CheatMode == CHEAT_LIST)
     {
-        int i;
-        for (i = 0; i < CheatListLength; i++)
+        int option, number;
+        char *cheat_next;
+        sCheatInfo *pCheat;
+        while(CheatNumList != NULL && *CheatNumList)
         {
-            sCheatInfo *pCheat = CheatFindCode(CheatNumList[i]);
+            if ((cheat_next = strchr(CheatNumList, ',')) != NULL)
+            {
+                *cheat_next = 0;
+                cheat_next ++;
+            }
+
+            if (strchr(CheatNumList, '-') != NULL)
+            {
+                sscanf(CheatNumList, "%i-%i", &number, &option); /* option */
+            }
+            else
+            {
+                option=0;
+                sscanf(CheatNumList, "%i", &number);
+            }
+
+            pCheat = CheatFindCode(number);
             if (pCheat == NULL)
-                printf("UI-Console Warning: invalid cheat code number %i\n", CheatNumList[i]);
+                printf("UI-Console Warning: invalid cheat code number %i\n", number);
             else
+            {
+                if (pCheat->VariableLine != -1 && pCheat->Count > pCheat->VariableLine && option < pCheat->Codes[pCheat->VariableLine].var_count)
+                    pCheat->Codes[pCheat->VariableLine].var_to_use = option;
                 CheatActivate(pCheat);
+            }
+
+            CheatNumList = cheat_next;
         }
         CheatFreeAll();
+        
         return;
     }
 
     /* otherwise the mode is invalid */
     printf("UI-Console: internal error; invalid CheatMode in CheatStart()\n");
+    
     return;
 }
 
-
diff --git a/src/cheat.h b/src/cheat.h
index 8a10a55..611121a 100644
--- a/src/cheat.h
+++ b/src/cheat.h
@@ -35,7 +35,7 @@ typedef enum {
   CHEAT_SHOW_LIST
   } eCheatMode;
 
-void CheatStart(eCheatMode CheatMode, int *CheatNumList, int CheatListLength);
+void CheatStart(eCheatMode CheatMode, char *CheatNumList);
 
 #endif // #define CHEAT_H
 
diff --git a/src/main.c b/src/main.c
index e61b35a..e87276f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *   Mupen64plus-ui-console - main.c                                       *
  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
- *   Copyright (C) 2007-2009 Richard42                                     *
+ *   Copyright (C) 2007-2010 Richard42                                     *
  *   Copyright (C) 2008 Ebenblues Nmn Okaygo Tillin9                       *
  *   Copyright (C) 2002 Hacktarux                                          *
  *                                                                         *
@@ -66,8 +66,7 @@ static int   l_SaveOptions = 0;          // save command-line options in configu
 static int   l_CoreCompareMode = 0;      // 0 = disable, 1 = send, 2 = receive
 
 static eCheatMode l_CheatMode = CHEAT_DISABLE;
-static int       *l_CheatNumList = NULL;
-static int        l_CheatListLength = 0;
+static char      *l_CheatNumList = NULL;
 
 /*********************************************************************************************************
  *  Callback functions from the core
@@ -206,7 +205,8 @@ static void printUsage(const char *progname)
            "(cheat-spec):\n"
            "    'list'                : show all of the available cheat codes\n"
            "    'all'                 : enable all of the available cheat codes\n"
-           "    (codelist)            : a comma-separated list of cheat code numbers to enable\n"
+           "    (codelist)            : a comma-separated list of cheat code numbers to enable,\n"
+           "                            with dashes to use code variables (ex 1-2 to use cheat 1 option 2)\n"
            "\n", progname);
 
     return;
@@ -418,7 +418,7 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
             else
             {
                 l_CheatMode = CHEAT_LIST;
-                l_CheatNumList = ParseNumberList(argv[i+1], &l_CheatListLength);
+                l_CheatNumList = (char*) argv[i+1];
             }
             i++;
         }
@@ -455,8 +455,18 @@ static m64p_error ParseCommandLineFinal(int argc, const char **argv)
         else if (strcmp(argv[i], "--emumode") == 0 && ArgsLeft >= 1)
         {
             int emumode = atoi(argv[i+1]);
-            (*ConfigSetParameter)(l_ConfigCore, "R4300Emulator", M64TYPE_INT, &emumode);
             i++;
+            if (emumode < 0 || emumode > 2)
+            {
+                fprintf(stderr, "Warning: invalid --emumode value '%i'\n", emumode);
+                continue;
+            }
+            if (emumode == 2 && !(g_CoreCapabilities & M64CAPS_DYNAREC))
+            {
+                fprintf(stderr, "Warning: Emulator core doesn't support Dynamic Recompiler.\n");
+                emumode = 1;
+            }
+            (*ConfigSetParameter)(l_ConfigCore, "R4300Emulator", M64TYPE_INT, &emumode);
         }
         else if (strcmp(argv[i], "--testshots") == 0 && ArgsLeft >= 1)
         {
@@ -613,7 +623,7 @@ int main(int argc, char *argv[])
     free(ROM_buffer); /* the core copies the ROM image, so we can release this buffer immediately */
 
     /* handle the cheat codes */
-    CheatStart(l_CheatMode, l_CheatNumList, l_CheatListLength);
+    CheatStart(l_CheatMode, l_CheatNumList);
     if (l_CheatMode == CHEAT_SHOW_LIST)
     {
         (*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
@@ -676,8 +686,6 @@ int main(int argc, char *argv[])
     /* free allocated memory */
     if (l_TestShotList != NULL)
         free(l_TestShotList);
-    if (l_CheatNumList != NULL)
-        free(l_CheatNumList);
 
     return 0;
 }
diff --git a/src/osal_preproc.h b/src/osal_preproc.h
index 2b69de0..8503ff6 100644
--- a/src/osal_preproc.h
+++ b/src/osal_preproc.h
@@ -54,6 +54,11 @@
   #define OSAL_DLL_EXTENSION           ".so"
   #define osal_insensitive_strcmp(x, y) strcasecmp(x, y)
 
+  /* PATH_MAX only may be defined by limits.h */
+  #ifndef PATH_MAX
+    #define PATH_MAX 4096
+  #endif
+
 #endif
 
 #endif /* #define OSAL_PREPROC_H */
diff --git a/src/version.h b/src/version.h
index 39a4575..d3391e3 100644
--- a/src/version.h
+++ b/src/version.h
@@ -26,7 +26,7 @@
 #if !defined(VERSION_H)
 #define VERSION_H
 
-#define CONSOLE_UI_VERSION 0x016303
+#define CONSOLE_UI_VERSION 0x016304
 #define CONSOLE_API_VERSION 0x10000
 #define CONSOLE_UI_NAME    "Mupen64Plus Console User-Interface"
 

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



More information about the Pkg-games-commits mailing list