[mupen64plus-core] 272/310: Allow multiple preconditions per cheat

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 05:58:16 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-core.

commit 66663d0d5909e023620a3163334cb9a53fd261b4
Author: Sven Eckelmann <sven at narfation.org>
Date:   Wed Jan 29 21:37:51 2014 +0100

    Allow multiple preconditions per cheat
    
    Each cheat code can have multiple preconditions which all have to be fulfilled
    before it can be executed. The default implementation in mupen64plus could not
    handle these extra test codes because a failed test only caused a jump over
    the next cheatcode (ignoring whether is also a test or a non-test cheatcode).
    
    Therefore, all (negative) results before a non-test cheat code have to be
    aggregated. The first non-test cheatcode evaluates the result of the
    preconditions and only executes the non-test cheatcode when no precondition
    test failed. The earlier results are always dropped after a non-test cheatcode
    to allow a fresh start.
---
 debian/changelog                           |   1 +
 debian/patches/cheat_multiconditions.patch | 129 +++++++++++++++++++++++++++++
 debian/patches/series                      |   1 +
 3 files changed, 131 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c48bc28..219a676 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ mupen64plus-core (2.0-5) UNRELEASED; urgency=medium
       subsystem
     - Add interpreter_cmd_link_unconditionally.patch, Save link information
       in *AL(L) instructions unconditionally
+    - Add cheat_multiconditions.patch, Allow multiple preconditions per cheat
   * debian/watch:
     - Change upstream check from bitbucket to github
   * debian/copyright:
diff --git a/debian/patches/cheat_multiconditions.patch b/debian/patches/cheat_multiconditions.patch
new file mode 100644
index 0000000..1b18434
--- /dev/null
+++ b/debian/patches/cheat_multiconditions.patch
@@ -0,0 +1,129 @@
+Description: Allow multiple preconditions per cheat
+ Each cheat code can have multiple preconditions which all have to be fulfilled
+ before it can be executed. The default implementation in mupen64plus could not
+ handle these extra test codes because a failed test only caused a jump over
+ the next cheatcode (ignoring whether is also a test or a non-test cheatcode).
+ .
+ Therefore, all (negative) results before a non-test cheat code have to be
+ aggregated. The first non-test cheatcode evaluates the result of the
+ preconditions and only executes the non-test cheatcode when no precondition
+ test failed. The earlier results are always dropped after a non-test cheatcode
+ to allow a fresh start.
+Author: Sven Eckelmann <sven at narfation.org>
+
+---
+diff --git a/src/main/cheat.c b/src/main/cheat.c
+index 7266762fda1d063c89f6b671ddcfeef9039c37e1..2455efa07b939316af84d544c6efefd4d0f6d50b 100644
+--- a/src/main/cheat.c
++++ b/src/main/cheat.c
+@@ -201,8 +201,7 @@ void cheat_apply_cheats(int entry)
+ {
+     cheat_t *cheat;
+     cheat_code_t *code;
+-    int skip;
+-    int execute_next;
++    int cond_failed;
+ 
+     // If game is Zelda OOT, apply subscreen delay fix
+     if (entry == ENTRY_VI && strncmp((char *)ROM_HEADER.Name, "THE LEGEND OF ZELDA", 19) == 0) {
+@@ -312,67 +311,52 @@ void cheat_apply_cheats(int entry)
+                     }
+                     break;
+                 case ENTRY_VI:
+-                    skip = 0;
+-                    execute_next = 0;
++                    /* a cheat starts without failed preconditions */
++                    cond_failed = 0;
++
+                     list_for_each_entry(code, &cheat->cheat_codes, cheat_code_t, list) {
+-                        if (skip) {
+-                            skip = 0;
+-                            continue;
+-                        }
+-                        if (execute_next) {
+-                            execute_next = 0;
+-
+-                            // if code needs GS button pressed, don't save old value
+-                            if(((code->address & 0xFF000000) == 0xD8000000 ||
+-                                (code->address & 0xFF000000) == 0xD9000000 ||
+-                                (code->address & 0xFF000000) == 0xDA000000 ||
+-                                (code->address & 0xFF000000) == 0xDB000000))
+-                               execute_cheat(code->address, code->value, NULL);
+-                            else
+-                               execute_cheat(code->address, code->value, &code->old_value);
+-
+-                            continue;
+-                        }
+-                        // conditional cheat codes
++                        /* conditional cheat codes */
+                         if((code->address & 0xF0000000) == 0xD0000000)
+                         {
+-                            // if code needs GS button pressed and it's not, skip it
++                            /* if code needs GS button pressed and it's not, skip it */
+                             if(((code->address & 0xFF000000) == 0xD8000000 ||
+                                 (code->address & 0xFF000000) == 0xD9000000 ||
+                                 (code->address & 0xFF000000) == 0xDA000000 ||
+                                 (code->address & 0xFF000000) == 0xDB000000) &&
+                                !event_gameshark_active())
+-                            {
+-                                // skip next code
+-                                skip = 1;
++                                /* if condition false, skip next code non-test code */
++                                cond_failed = 1;
++
++                            /* if condition false, skip next code non-test code */
++                            if (!execute_cheat(code->address, code->value, NULL))
++                                cond_failed = 1;
++                        }
++                        else {
++                            /* preconditions were false for this non-test code
++                             * reset the condition state and skip the cheat
++                             */
++                            if (cond_failed) {
++                                cond_failed = 0;
+                                 continue;
+                             }
+ 
+-                            if (execute_cheat(code->address, code->value, NULL)) {
+-                                // if condition true, execute next cheat code
+-                                execute_next = 1;
+-                            } else {
+-                                // if condition false, skip next code
+-                                skip = 1;
+-                                continue;
++                            switch (code->address & 0xFF000000) {
++                            /* GS button triggers cheat code */
++                            case 0x88000000:
++                            case 0x89000000:
++                            case 0xA8000000:
++                            case 0xA9000000:
++                                if(event_gameshark_active())
++                                    execute_cheat(code->address, code->value, NULL);
++                                break;
++                            /* normal cheat code */
++                            default:
++                                /* exclude boot-time cheat codes */
++                                if((code->address & 0xF0000000) != 0xF0000000)
++                                    execute_cheat(code->address, code->value, &code->old_value);
++                                break;
+                             }
+                         }
+-                        // GS button triggers cheat code
+-                        else if((code->address & 0xFF000000) == 0x88000000 ||
+-                                (code->address & 0xFF000000) == 0x89000000 ||
+-                                (code->address & 0xFF000000) == 0xA8000000 ||
+-                                (code->address & 0xFF000000) == 0xA9000000)
+-                        {
+-                            if(event_gameshark_active())
+-                                execute_cheat(code->address, code->value, NULL);
+-                        }
+-                        // normal cheat code
+-                        else
+-                        {
+-                            // exclude boot-time cheat codes
+-                            if((code->address & 0xF0000000) != 0xF0000000)
+-                                execute_cheat(code->address, code->value, &code->old_value);
+-                        }
+                     }
+                     break;
+                 default:
diff --git a/debian/patches/series b/debian/patches/series
index dea89d4..498c189 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -19,3 +19,4 @@ countperop_romdb.patch
 sdl2_no_surface.patch
 sdl2_destroywindow.patch
 interpreter_cmd_link_unconditionally.patch
+cheat_multiconditions.patch

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



More information about the Pkg-games-commits mailing list