Prev: 30968 Up: Map Next: 31112
31041: Process command to cast a spell
Used by the routine at 55726.
31041 CALL 54333 Print or update command summary window at top of screen
31044 LD DE,41705 Point DE at "CAST A SPELL"...
31047 CALL 54283 ...and print in command summary window at top of screen
31050 LD HL,41711 Point HL at byte before "WHICH SPELL DO YOU WANT TO CAST?" full menu text
31053 LD DE,37307 Adjust height of window 27 to accommodate text...
31056 CALL 33774 ...
31059 PUSH HL Store HL (pointer to menu text to print)
31060 LD A,27 Draw menu window 27...
31062 CALL 34982 ...
31065 POP HL Restore HL (pointer to menu text to print)
31066 CALL 34762 Print text to screen
31069 CALL 35296 Process keyboard / joystick input on a menu and load A with selected item index
31072 LD (31105),A Store index of spell selected in this routine at 31105
31075 CALL 54333 Print or update command summary window at top of screen
31078 LD HL,41794 Point HL at "CAST REMOVE BARRIERS" text (i.e. first in list of "CAST [SPELL]" strings)
31081 LD A,(31105) Load index of spell selected into B...
31084 LD B,A ...
31085 CALL 54269 ...and advance HL to relevant "CAST [SPELL]" string
31088 EX DE,HL Swap DE (now points to "CAST [SPELL]" text) and HL...
31089 CALL 54283 ...and print in command summary window at top of screen
31092 LD A,(31105) Load index of spell selected into A
31095 CP 2 If selected spell is 2 (FORTIFY CHARACTER)...
31097 JR Z,31104 ...then skip ahead to 31104
31099 CP 5 If selected spell is not 5 (or 2, i.e. any spell except FORTIFY CHARACTER)...
31101 CALL NZ,55115 ...then display execute / reject command window and return here if execute chosen, else exit to main game loop
The operand of the instruction at 31104 represents the index of the selected spell. This is modified by the instruction at 31072.
31104 LD A,0 Load A with index of selected spell
31106 LD HL,31112 Point HL at table of cast a spell routine addresses
31109 JP 55726 Load HL with address of appropriate cast a spell routine and jump to it
Prev: 30968 Up: Map Next: 31112