Routines |
Prev: 42491 | Up: Map | Next: 42616 |
Used by the routine at 38205.
|
||||
42494 | CALL 47930 | Play downward scale sound | ||
42497 | CALL 46183 | Set Magic Knight's available action flags | ||
42500 | LD BC,2048 | Set B = 8 (eight action flags) and C = 0 (count of set flags) | ||
42503 | LD A,(23698) | Load A with available in-game menu command flags, part 1 | ||
42506 | RLCA | Pop a bit into carry flag | ||
42507 | JR NC,42510 | If Magic Knight action flag is not set then skip ahead to 42510 to repeat loop for next flag... | ||
42509 | INC C | ...else increase count of set flags | ||
42510 | DJNZ 42506 | Loop back for next bit until all eight are done | ||
42512 | LD B,8 | Set B = 8 (another eight action flags) | ||
42514 | LD A,(23699) | Load A with available in-game menu command flags, part 2 | ||
42517 | RLCA | Pop a bit into carry flag | ||
42518 | JR NC,42521 | If Magic Knight action flag is not set then skip ahead to 42521 to repeat loop for next flag... | ||
42520 | INC C | ...else increase count of set flags | ||
42521 | DJNZ 42517 | Loop back for next bit until all eight are done | ||
42523 | LD A,8 | Load A with 8 (as minimal command window has bottom y-coordinate of 8) | ||
42525 | ADD A,C | Increase A by number of extra commands available | ||
42526 | LD C,A | Load value back into C | ||
42527 | LD A,(49036) | Load A with y-coordinate (characters) of top of menu window | ||
42530 | ADD A,C | Update y-coordinate of bottom of window according to number of extra commands... | ||
42531 | LD (49037),A | ... | ||
42534 | LD A,0 | Display main in-game menu window (window number zero)... | ||
42536 | CALL 47185 | ... | ||
42539 | LD HL,51434 | Print "COMMANDS AVAILABLE:-" followed by first five commands (pick up, drop, etc.) that are always available... | ||
42542 | CALL 46902 | ... | ||
42545 | LD HL,51486 | Point HL at zero immediately preceding list of conditional entry (main in-game menu) texts | ||
42548 | LD A,(23698) | Load A with available in-game menu command flags, part 1 | ||
42551 | CALL 42616 | Print currently available additional in-game menu command options, part 1 | ||
42554 | LD A,(23699) | Load A with available in-game menu command flags, part 2 | ||
42557 | CALL 42616 | Print currently available additional in-game menu command options, part 2 | ||
42560 | CALL 47502 | Process keyboard / joystick input on a menu and load A with selected item index | ||
42563 | CP 5 | If index of selected item is less than 5 (i.e. is a permanent, yellow entry)... | ||
42565 | JR C,42587 | ...then skip ahead to 42587 | ||
42567 | SUB 4 | Subtract 4 from index to get index within currently available conditional entries... | ||
42569 | LD B,A | ...and load this value into B | ||
42570 | LD C,0 | Load C with zero | ||
42572 | LD HL,(23698) | Load HL with available in-game menu command flags | ||
At this point, B is initialised to the index of the selected menu option among the currently available conditional entries. The following loop loads C with the index of the selected action's action flag (bit) in the WORD value at 23698.
|
||||
42575 | RR H | Perform 16-bit rotation (right) through HL and into carry flag... | ||
42577 | RR L | ...so that carry flag contains "current" action flag | ||
42579 | INC C | Increase C (index of current action flag) | ||
42580 | JR NC,42575 | If current action flag is not set then loop back to 42575... | ||
42582 | DJNZ 42575 | ...otherwise decrease B then loop back to 42575 | ||
42584 | LD A,C | Load index of appropriate action flag into A | ||
42585 | ADD A,4 | Add 4, to restore original index value (i.e. reverse of instruction at 42567) | ||
At this point, A holds either the index of the appropriate action flag plus four, or the index of the originally selected menu item if less than 5. In either case, A contains the index of the command to initiate.
|
||||
42587 | LD HL,48535 | Point HL at list of command indices | ||
42590 | LD B,A | Load index of selected command into B, setting C to zero... | ||
42591 | LD C,0 | ... | ||
42593 | LD A,(HL) | If current entry in list of command indices is the same as the index of the selected command... | ||
42594 | CP B | ... | ||
42595 | JR Z,42601 | ...then skip ahead to 42601 | ||
42597 | INC C | Increase C (index of command index) | ||
42598 | INC HL | Advance HL to next command index in list | ||
42599 | JR 42593 | Loop back to 42593 | ||
42601 | PUSH BC | Store BC (B = selected command index, C = index of selected command index) | ||
42602 | CALL 47897 | Play upward scale sound | ||
42605 | POP BC | Restore BC (B = selected command index, C = index of selected command index) | ||
42606 | LD A,C | Load index (of selected command index) into A... | ||
42607 | LD (23716),A | ...and set as Current Command | ||
42610 | LD HL,48553 | Point HL at start of table of command routine addresses | ||
42613 | JP 64623 | Advance HL by A words, load HL with word at location HL as address and jump to it |
Prev: 42491 | Up: Map | Next: 42616 |