Prev: 31370 Up: Map Next: 31710
31636: Process and execute command to command a character
Used by the routines at 27176 and 31153.
31636 LD A,(65532) Check Magic Knight's action flags...
31639 BIT 0,A ...and if he can't command...
31641 JP Z,27189 ...then jump into main game loop (process keyboard input and move Magic Knight, enter menus or execute other command)
31644 CALL 38075 Play upward scale sound
31647 LD HL,44073 Point HL at "COMMAND ?" text
31650 LD DE,46402 Point DE at "COMMAND" text
31653 CALL 35141 Display and process input for character selection menu (current room's characters only), setting Current Character
31656 LD DE,45820 Point DE at "TO" text...
31659 CALL 38693 ...and print in command summary window at bottom of screen
31662 LD A,23 Display "WHICH COMMAND DO YOU WANT TO USE" (Command [CHARACTER] to...) menu window...
31664 CALL 36979 ...
31667 LD HL,46405 Print "WHICH COMMAND DO YOU WANT TO USE" + "A GO TO SLEEP ... B WAKE UP ..." etc. text...
31670 CALL 36725 ...
31673 CALL 37333 Process input for menu, and load ASCII code of shortcut for selected (i.e. SPACE or fire pressed) item into A
31676 SUB 65 Subtract 65 (ASCII code for "A") to leave index of selected command
31678 LD (31696),A Set index of "command a character" routine to jump to later
31681 LD B,A Copy into B
31682 CALL 34859 Advance HL to the B-th entry in list of option texts from "command a character" menu
31685 EX DE,HL Swap DE (now points to selected command's "command a character" menu text) and HL (now undefined)
31686 CALL 38693 ...and print in command summary window at bottom of screen
31689 LD A,(30615) Load A with index of Current Character (see trivia)
31692 CALL 38725 Display execute / reject command window and return if execute chosen, else exit
The operand of the instruction at 31695 represents the index of the "command a character" routine to jump to as stored previously. This is modified by the instruction at 31678.
31695 LD A,0 Load A with index of "command a character" routine to jump to...
31697 ADD A,A ...double it (as entries are two bytes wide)...
31698 LD E,A ...and load it into DE...
31699 LD D,0 ...
31701 LD HL,31710 Point HL to start of "Magic Knight command a character to..." routines table
31704 ADD HL,DE Add offset to obtain entry of interest
31705 LD A,(HL) Load address at this location into HL...
31706 INC HL ...
31707 LD H,(HL) ...
31708 LD L,A ...
31709 JP (HL) ...and jump to it
Prev: 31370 Up: Map Next: 31710