| 704 | |
| 705 | bool 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 | } |