Prev: 30880 Up: Map Next: 31370
31153: Display and handle main in-game menu (when fire is pressed)
Used by the routine at 27176.
31153 CALL 38108 Set parameters for and play downward scale sound
31156 LD BC,2048 Set B = 8 (eight action flags) and C = 0 (count of set flags)
31159 LD A,(65532) Load Magic Knight's action flags, part 1 into A
31162 RLCA Pop a flag into carry flag
31163 JR NC,31166 If Magic Knight action flag is not set then skip ahead to 31166 to repeat loop for next flag...
31165 INC C ...else increase count of set flags
31166 DJNZ 31162 Loop back for next flag until all eight are done
31168 LD B,8 Set B = 8 (another eight action flags)
31170 LD A,(65533) Load Magic Knight's action flags, part 2 into A
31173 RLCA Pop a flag into carry flag
31174 JR NC,31177 If Magic Knight action flag is not set then skip ahead to 31177 to repeat loop for next flag...
31176 INC C ...else increase count of set flags
31177 DJNZ 31173 Loop back for next flag until all eight are done
31179 LD A,9 Load A with 9 (as minimal command window has bottom y-coordinate of 9)
31181 ADD A,C Increase A by number of extra commands available
31182 LD C,A Load value back into C
31183 LD A,(41876) Load A with y-coordinate (characters) of top of menu window
31186 ADD A,C Update y-coordinate of bottom of window according to number of extra commands...
31187 LD (41877),A ...
31190 XOR A Display main in-game menu window (window number zero)...
31191 CALL 36979 ...
31194 LD HL,44103 Print "COMMANDS AVAILABLE:-" followed by first five commands (pick up, drop, etc.) that are always available...
31197 CALL 36725 ...
31200 LD HL,16608 Set memory location to start printing character to start of last character row of permanent (yellow) menu options...
31203 LD (36488),HL ...(i.e. "E EXAMINE") in preparation for printing conditional (white) ones, which are [CR]-prefixed so will print to next line down
31206 LD A,(65532) Load A with Magic Knight's action flags, part 1
31209 BIT 0,A If command-a-character-enabled flag is not set then...
31211 JR Z,31219 ...skip ahead to next flag's check
31213 LD HL,44173 Else print "C COMMAND A CHARACTER" text...
31216 CALL 36725 ...
31219 LD A,(65532) Load A with Magic Knight's action flags, part 1
31222 BIT 1,A If locate-a-character-enabled flag is not set then...
31224 JR Z,31232 ...skip ahead to next flag's check
31226 LD HL,44181 Print "L LOCATE A CHARACTER" text...
31229 CALL 36725 ...
31232 LD A,(65532) Load A with Magic Knight's action flags, part 1
31235 BIT 2,A If teleport-enabled flag is not set then...
31237 JR Z,31245 ...skip ahead to next flag's check
31239 LD HL,44189 Print "X TELEPORT" text...
31242 CALL 36725 ...
31245 LD A,(65532) Load A with Magic Knight's action flags, part 1
31248 BIT 3,A If read-enabled flag is not set then...
31250 JR Z,31258 ...skip ahead to next flag's check
31252 LD HL,44194 Print "R READ SOMETHING" text...
31255 CALL 36725 ...
31258 LD A,(65532) Load A with Magic Knight's action flags, part 1
31261 BIT 4,A If throw-enabled flag is not set then...
31263 JR Z,31271 ...skip ahead to next flag's check
31265 LD HL,44200 Print "Y THROW SOMETHING" text...
31268 CALL 36725 ...
31271 LD A,(65532) Load A with Magic Knight's action flags, part 1
31274 BIT 5,A If cast-a-spell-enabled flag is not set then...
31276 JR Z,31284 ...skip ahead to next flag's check
31278 LD HL,44206 Print "S CAST A SPELL" text...
31281 CALL 36725 ...
31284 LD A,(65532) Load A with Magic Knight's action flags, part 1
31287 BIT 6,A If blow-enabled flag is not set then...
31289 JR Z,31297 ...skip ahead to next flag's check
31291 LD HL,44214 Print "B BLOW SOMETHING" text...
31294 CALL 36725 ...
31297 LD A,(65532) Load A with Magic Knight's action flags, part 1
31300 BIT 7,A If call-lift-enabled flag is not set then...
31302 JR Z,31310 ...skip ahead to next flag's check
31304 LD HL,44224 Print "W CALL LIFT" text...
31307 CALL 36725 ...
31310 LD A,(65533) Load A with Magic Knight's action flags, part 2
31313 BIT 0,A If move-lift-enabled flag is not set then...
31315 JR Z,31323 ...skip ahead to next menu object
31317 LD HL,44234 Print "V MOVE LIFT" text...
31320 CALL 36725 ...
31323 LD HL,44159 Print "Z EXIT MENU" text...
31326 CALL 36725 ...
31329 CALL 37333 Process input for menu, and load ASCII code of shortcut for selected (i.e. SPACE or fire pressed) item into A
31332 CP 90 If "Z" was pressed...
31334 JP Z,30428 ...reset Gimbal-white-out-safe flag, redraw current room and return to main game loop
31337 LD HL,41811 Point HL at start of string of keyboard shortcuts for commands
31340 LD B,A Load ASCII code of key pressed into B
31341 LD C,0 Set C (selected command number) to zero
31343 LD A,(HL) Load keyboard shortcut pointed to by HL into A
31344 CP B If key pressed matches currently-pointed-at shortcut...
31345 JP Z,31352 ...then jump ahead to 31352
31348 INC C Increase C (advance to next command to check if that was selected instead)
31349 INC HL Advance to next entry in list of command shortcuts
31350 JR 31343 Loop back to 31343 to test next command
31352 LD A,C Load double index of selected command into BC...
31353 ADD A,A ...
31354 LD B,0 ...
31356 LD C,A ...
31357 LD HL,41827 Point HL at table of routine start addresses for Magic Knight's main menu commands
31360 ADD HL,BC Add double index of selected command as offset
31361 LD A,(HL) Load address of appropriate command processing routine into HL...
31362 INC HL ...
31363 LD H,(HL) ...
31364 LD L,A ...
31365 XOR A Clear last pressed key (LAST K system variable)...
31366 LD (23560),A ...
31369 JP (HL) Jump to routine to process selected command
Prev: 30880 Up: Map Next: 31370