Prev: 35101 Up: Map Next: 35293
35141: Display and process input for character selection menu (current room's characters only)
Used by the routines at 30602, 30880, 31370, 31636 and 32390.
Input
HL Pointer to primary text
DE Pointer to secondary text
35141 PUSH HL Store HL
35142 PUSH BC Store BC
35143 PUSH IX Store IX
35145 PUSH DE Store DE
35146 CALL 38116 Play short downward scale sound
35149 POP DE Restore DE
35150 LD A,D If DE is zero...
35151 OR E ...
35152 JR Z,35162 ...then skip ahead to 35162
35154 PUSH DE Store DE
35155 CALL 37654 Display / update command summary window at bottom of screen
35158 POP DE Restore DE
35159 CALL 38693 ...and print in command summary window at bottom of screen
35162 LD A,(65529) Load A with Magic Knight's current room
35165 CALL 35931 Load number of characters in this room into C and load their indices into table at 23464
35168 JR NZ,35199 If there are characters present then jump to 35199
35170 LD HL,44035 Point HL at "THERE IS NOBODY IN THIS ROOM" text
35173 LD A,(HL) Load text height (rows) into A...
35174 LD (41981),A ...and then into stored bottom y-coordinate of window #13
35177 INC HL Advance HL to next byte (start of actual text)
35178 PUSH HL Store HL
35179 LD A,13 Draw window 13...
35181 CALL 36987 ...
35184 POP HL Restore HL
35185 CALL 36725 Print "THERE IS NOBODY IN THIS ROOM" text to screen
35188 CALL 38749 Display "PRESS SPACE OR FIRE TO CONTINUE" window and wait for space / fire
35191 POP IX Restore IX
35193 POP BC Restore BC
35194 POP HL Restore HL
35195 POP HL Restore HL again (as this routine was called, but we are not returning from it, so need to keep stack tidy!)
35196 JP 30428 Reset Gimbal-white-out-safe flag, redraw current room and return to main game loop
35199 ADD A,4 Add four to number of characters in current room (for menu size padding) and load value into "bottom position (characters)" field of fourth window in windows data table at 41874 (i.e. adjust window's height to accommodate all the characters present)
35201 LD (41901),A
35204 POP IX Restore IX
35206 POP BC Restore BC
35207 LD A,3 Draw "WHO DO YOU WANT TO COMMAND?" menu window...
35209 CALL 36979 ...
35212 LD HL,44017 Point HL at "WHO DO YOU WANT TO COMMAND?" text
35215 CALL 36725 Print text in window
35218 POP HL Restore HL (primary text, as at beginning of this routine)
35219 CALL 36725 Print text in window
35222 LD HL,43221 Point HL at "0]" text (i.e. letters corresponding to menu items)
35225 LD A,64 Set this character to ASCII code 64 (character immediately before "A")...
35227 LD (HL),A ...
35228 LD IX,23464 Point IX at list of indices of characters in current room
35232 LD B,3 Load 3 into B (as we can have up to three characters in this room)
35234 PUSH BC Store BC
35235 LD A,(IX+0) Load index of next character in room...
35238 CP 255 ...compare with 255 (i.e. empty slot)...
35240 JP Z,35282 ...and if this is an empty slot (i.e. no more characters) then jump to 35282
35243 LD HL,43221 Point HL at "0]" text (i.e. letters corresponding to menu items)
35246 LD A,(HL) Load the first text character into A...
35247 INC A ...increment...
35248 LD (HL),A ...and write back to location HL (i.e. advance to next letter, as menu choices are labelled "A", "B", "C", etc.)
35249 LD HL,43220 Point to beginning of this modified string...
35252 CALL 36725 ...and print it to screen
35255 LD A,(IX+0) Load index of character into A again...
35258 LD (30615),A ...and set this as the Current Character
35261 LD HL,34905 Point HL to code to print full name of Current Character...
35264 CALL 36725 ...and print it to screen
35267 INC IX Advance IX to next character
35269 POP BC Restore BC
35270 DJNZ 35234 Repeat loop if we have not yet reached the third character
35272 CALL 37333 Process input for menu, and load ASCII code of shortcut for selected (i.e. SPACE or fire pressed) item into A
35275 CALL 34883 Update Current Character based upon selection made in menu
35278 CALL 35393 Display warning and abort if command is not safe while Gimbal whited-out
35281 RET Return
35282 POP BC Restore BC
35283 CALL 37333 Process input for menu, and load ASCII code of shortcut for selected (i.e. SPACE or fire pressed) item into A
35286 CALL 34883 Update Current Character based upon selection made in menu
35289 CALL 35393 Display warning and abort if command is not safe while Gimbal whited-out
35292 RET Return
Prev: 35101 Up: Map Next: 35293