Ticket #8209: loom-drafts.diff

File loom-drafts.diff, 3.8 KB (added by eriktorbjorn, 21 years ago)

Patch against an April 30 CVS snapshot

  • scummvm/scumm/debugger.cpp

    diff -ur ScummVM-cvs20030430/scummvm/scumm/debugger.cpp ScummVM-cvs20030430+hack/scummvm/scumm/debugger.cpp
    old new  
    9191                DCmd_Register("scripts", &ScummDebugger::Cmd_PrintScript);
    9292                DCmd_Register("importres", &ScummDebugger::Cmd_ImportRes);
    9393
     94                DCmd_Register("drafts", &ScummDebugger::Cmd_PrintDraft);
     95
    9496                DCmd_Register("loadgame", &ScummDebugger::Cmd_LoadGame);
    9597                DCmd_Register("savegame", &ScummDebugger::Cmd_SaveGame);
    9698
     
    699701                                                                coords.ur.x, coords.ur.y, coords.lr.x, coords.lr.y,
    700702                                                                flags, mask, scale);
    701703}
     704
     705bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) {
     706        char *names[] = {
     707                "Opening",      "Straw to Gold", "Dyeing",
     708                "Night Vision", "Twisting",      "Sleep",
     709                "Emptying",     "Invisibility",  "Terror",
     710                "Sharpening",   "Reflection",    "Healing",
     711                "Silence",      "Shaping",       "Unmaking",
     712                "Transcendence"
     713        };
     714        int odds[] = {
     715                15162, 15676, 16190,    64, 16961, 17475, 17989, 18503,
     716                   73, 19274,    76,    77, 20302, 20816, 21330,    84
     717        };
     718               
     719        char *notes = "cdefgabC";
     720        int i, base, draft;
     721
     722        if (_s->_gameId != GID_LOOM && _s->_gameId != GID_LOOM256) {
     723                Debug_Printf("Command only works with Loom/LoomCD\n");
     724                return true;
     725        }
     726
     727        // There are 16 drafts, stored from variable 50 or 100 and upwards.
     728        // Each draft occupies two variables. Even-numbered variables contain
     729        // the notes for each draft, and a number of flags:
     730        //
     731        // +---+---+---+---+-----+-----+-----+-----+
     732        // | A | B | C | D | 444 | 333 | 222 | 111 |
     733        // +---+---+---+---+-----+-----+-----+-----+
     734        //
     735        // A   Unknown
     736        // B   The player has used the draft successfully at least once
     737        // C   The player has knowledge of the draft
     738        // D   Unknown
     739        // 444 The fourth note
     740        // 333 The third note
     741        // 222 The second note
     742        // 111 The first note
     743        //
     744        // I don't yet know what the odd-numbered variables are used for.
     745        // Possibly they store information on where and/or how the draft can
     746        // be used. They appear to remain constant throughout the game.
     747
     748        base = (_s->_gameId == GID_LOOM) ? 50 : 100;
     749
     750        // During the testing of EGA Loom we had some trouble with the drafts
     751        // data structure being overwritten. I don't expect this command is
     752        // particularly useful any more, but it will attempt to repair the
     753        // (probably) static part of it.
     754
     755        if (argc == 2 && strcmp(argv[1], "fix") == 0) {
     756                for (i = 0; i < 16; i++) {
     757                        _s->_vars[base + 2 * i + 1] = odds[i];
     758                }
     759                Debug_Printf(
     760                        "An attempt has been made to repair\n"
     761                        "the internal drafts data structure.\n"
     762                        "Continue on your own risk.\n");
     763                return true;
     764        }
     765
     766        // More useful, list the drafts.
     767
     768        for (i = 0; i < 16; i++) {
     769                draft = _s->_vars[base + i * 2];
     770                Debug_Printf("%d %-13s %c%c%c%c %c%c %5d %c\n",
     771                        base + 2 * i,
     772                        names[i],
     773                        notes[draft & 0x0007],
     774                        notes[(draft & 0x0038) >> 3],
     775                        notes[(draft & 0x01c0) >> 6],
     776                        notes[(draft & 0x0e00) >> 9],
     777                        (draft & 0x2000) ? 'K' : ' ',
     778                        (draft & 0x4000) ? 'U' : ' ',
     779                        _s->_vars[base + 2 * i + 1],
     780                        (_s->_vars[base + 2 * i + 1] != odds[i]) ? '!' : ' ');
     781        }
     782
     783        return true;
     784}
  • scummvm/scumm/debugger.h

    diff -ur ScummVM-cvs20030430/scummvm/scumm/debugger.h ScummVM-cvs20030430+hack/scummvm/scumm/debugger.h
    old new  
    8383        bool Cmd_Script(int argc, const char **argv);
    8484        bool Cmd_PrintScript(int argc, const char **argv);
    8585        bool Cmd_ImportRes(int argc, const char **argv);
    86        
     86
     87        bool Cmd_PrintDraft(int argc, const char **argv);
     88
    8789        bool Cmd_DebugLevel(int argc, const char **argv);
    8890        bool Cmd_Help(int argc, const char **argv);
    8991