|  | Routines | 
| Prev: 27168 | Up: Map | Next: 27490 | 
|  | ||||
| 27176 | CALL 34821 | Update Magic Knight's current frame based on x-coordinate | ||
| 27179 | LD (65528),A | Store frame number at 65528... | ||
| 27182 | LD (25390),A | ...and in Magic Knight's current data | ||
| 27185 | XOR A | Set A to zero (Magic Knight) and... | ||
| 27186 | CALL 39224 | ...draw Magic Knight (erase old frame and draw new frame) | ||
| 
This entry point is used by the routines at 26906, 27168, 31636, 32035, 32194, 32258, 32390, 32655, 33312, 33593 and 33663.
 | ||||
| 27189 | CALL 29763 | Run checks and updates (Magic Knight's current room and room-specific routines) | ||
| 27192 | CALL 27495 | Handle Magic Knight's fall | ||
| 27195 | LD A,127 | Reset bit 7 in A to select the keyboard half-row SPACE - B | ||
| 27197 | IN A,(254) | Read the keyboard | ||
| 27199 | RRA | Reset carry flag if SPACE pressed, else set it | ||
| 27200 | JR C,27213 | SPACE was not pressed, so skip ahead to 27213 | ||
| 27202 | LD A,254 | Reset bit 0 in A to select the keyboard half-row SHIFT - V | ||
| 27204 | IN A,(254) | Read the keyboard | ||
| 27206 | RRA | Reset carry flag if SHIFT pressed, else set it | ||
| 27207 | LD HL,43450 | Point HL at "BREAK KEY PRESSED" text | ||
| 27210 | JP NC,35101 | If SHIFT was pressed (i.e. SHIFT-SPACE, or BREAK) jump to "game over" window routine and exit | ||
| 27213 | CALL 27666 | Kill Magic Knight's x-velocity if he cannot horizontally pass through a block beside him | ||
| 27216 | CALL 37876 | Capture keyboard/joystick input into A | ||
| 27219 | BIT 0,A | If "left" pressed then... | ||
| 27221 | JP NZ,27307 | Skip ahead to move left subroutine | ||
| 27224 | BIT 1,A | If "right" pressed then... | ||
| 27226 | JP NZ,27358 | Skip ahead to move right subroutine | ||
| 27229 | BIT 2,A | If "up" pressed then... | ||
| 27231 | JP NZ,27374 | Skip ahead to jump subroutine | ||
| 27234 | BIT 3,A | Check for "down" pressed | ||
| 
The following three bytes are set to zero (NOP) by the instructions between 26633 and 26640. This disables the conditional jump to the cheat / debug routine at 35420 (see trivia).
 | ||||
| 27236 | NOP | |||
| 27237 | NOP | |||
| 27238 | NOP | |||
| 27239 | BIT 4,A | If "fire" pressed then... | ||
| 27241 | JP NZ,27301 | Skip ahead to 27301 | ||
| 27244 | LD A,(65528) | Set Magic Knight's current frame to stored value... | ||
| 27247 | LD (25390),A | ... | ||
| 27250 | XOR A | Set A to zero (Magic Knight) and... | ||
| 27251 | CALL 39224 | ...draw Magic Knight (erase old frame and draw new frame) | ||
| 27254 | LD A,(23560) | Load A with last pressed key (LAST K system variable) | ||
| 27257 | OR A | If last key pressed is null (i.e. key NOT pressed)... | ||
| 27258 | JP Z,27189 | ...then jump into main game loop (process keyboard input and move Magic Knight, enter menus or execute other command) | ||
| 27261 | LD HL,41811 | Point HL at string of keyboard shortcuts for commands | ||
| 27264 | LD B,A | Load index of key pressed into B | ||
| 27265 | LD C,0 | Set C (index of command shortcut) to zero initially | ||
| 27267 | LD A,(HL) | Load command shortcut from table at 41811 into A | ||
| 27268 | OR A | If A is zero (i.e. we have reached the last command shortcut in the table)... | ||
| 27269 | JP Z,27189 | ...then jump into main game loop (process keyboard input and move Magic Knight, enter menus or execute other command) | ||
| 27272 | CP B | If key pressed matches current command shortcut... | ||
| 27273 | JP Z,27280 | ...then skip ahead to 27280 | ||
| 27276 | INC C | Increase C to advance to next command shortcut to test | ||
| 27277 | INC HL | Advance pointer to next shortcut | ||
| 27278 | JR 27267 | Loop back to 27267 for next shortcut | ||
| 27280 | CALL 37472 | Wait for keyboard to be released | ||
| 27283 | LD A,C | Load double the index of command shortcut chosen into BC... | ||
| 27284 | ADD A,A | ... | ||
| 27285 | LD B,0 | ... | ||
| 27287 | LD C,A | ... | ||
| 27288 | LD HL,41827 | Point HL at table of routine start addresses for Magic Knight's main menu commands | ||
| 27291 | ADD HL,BC | Add double index of this command's entry as offset, so HL now points at address in table of chosen command | ||
| 27292 | LD A,(HL) | Load address into HL... | ||
| 27293 | INC HL | ... | ||
| 27294 | LD H,(HL) | ... | ||
| 27295 | LD L,A | ... | ||
| 27296 | XOR A | Clear last pressed key (LAST K system variable)... | ||
| 27297 | LD (23560),A | ... | ||
| 27300 | JP (HL) | Execute the command, then return to game | ||
| 
Fire pressed
 | ||||
| 27301 | CALL 37486 | Wait for fire button / key to be released | ||
| 27304 | JP 31153 | Display and handle main in-game menu, execute selected command and return to game | ||
| 
Left pressed
 | ||||
| 27307 | LD HL,23470 | If Magic-Knight-can't-move-left flag is set... | ||
| 27310 | BIT 0,(HL) | ... | ||
| 27312 | JP NZ,27254 | ...then loop back to start of keyboard check routine | ||
| 27315 | LD HL,34824 | Load HL with 34824 (left-facing version of update Magic Knight's current frame routine) | ||
| 27318 | EX AF,AF' | Switch AF and AF' | ||
| 27319 | LD A,254 | Set Magic Knight's x-velocity to minus 2... | ||
| 27321 | LD (25391),A | ... | ||
| 27324 | LD (27405),A | Prepare to set Magic Knight's x-velocity to minus 2 | ||
| 27327 | LD (34822),HL | Set instruction at 34821 to jump to 34824 (left-facing version of update Magic Knight's current frame routine) | ||
| 27330 | EX AF,AF' | Switch AF and AF' (A now holds pressed controls bitmap) | ||
| 27331 | BIT 2,A | If "up" was also pressed... | ||
| 27333 | JR NZ,27378 | ...then skip ahead to 27378 (jumping subroutine) | ||
| 27335 | XOR A | Set Magic Knight's current y-velocity to zero... | ||
| 27336 | LD (25392),A | ... | ||
| 27339 | CALL 34821 | Update Magic Knight's current frame based on x-coordinate... | ||
| 27342 | LD (25390),A | ... | ||
| 27345 | LD (65528),A | Store frame number at 65528 | ||
| 27348 | XOR A | Set A to zero (Magic Knight) and... | ||
| 27349 | CALL 39224 | ...draw Magic Knight (erase old frame and draw new frame) | ||
| 27352 | CALL 27495 | Handle Magic Knight's fall | ||
| 27355 | JP 27254 | Loop back for next key / control press | ||
| 
Right pressed
 | ||||
| 27358 | LD HL,23470 | If Magic-Knight-can't-move-right flag is set... | ||
| 27361 | BIT 1,(HL) | ... | ||
| 27363 | JP NZ,27254 | ...then loop back to start of keyboard check routine | ||
| 27366 | LD HL,34838 | Load HL with 34838 (right-facing version of update Magic Knight's current frame routine) | ||
| 27369 | EX AF,AF' | Switch AF and AF' | ||
| 27370 | LD A,2 | Jump to 27321, setting Magic Knight's x-velocity to 2... | ||
| 27372 | JR 27321 | ... | ||
| 
Up pressed
 | ||||
| 27374 | XOR A | Prepare to set Magic Knight's x-velocity to zero... | ||
| 27375 | LD (27405),A | ... | ||
| 27378 | LD HL,41859 | Point HL at start of Magic Knight's y-velocities sequence table | ||
| 27381 | LD (41857),HL | Store current position in Magic Knight's y-velocities sequence table at 41857 | ||
| 27384 | LD A,(25388) | Load Magic Knight's current y-coordinate into A | ||
| 27387 | CP 8 | If y-coordinate is less than 8... | ||
| 27389 | JP C,27468 | ...then jump to 27468 (exit loop as Magic Knight can't get any higher!) | ||
| 27392 | LD HL,(41857) | Load HL with current position in Magic Knight's y-velocities sequence table | ||
| 27395 | LD A,(HL) | Load the current y-velocity in the sequence into A | ||
| 27396 | NEG | Negate (as Magic Knight is jumping upwards) | ||
| 27398 | OR A | If A is zero... | ||
| 27399 | JR Z,27468 | ...jump to 27468 (exit loop as we have reached the end of the sequence) | ||
| 27401 | LD (25392),A | Load A into Magic Knight's y-velocity | ||
| 27404 | LD A,0 | Set Magic Knight's x-velocity... | ||
| 27406 | LD (25391),A | ... | ||
| 27409 | CALL 27666 | Kill Magic Knight's x-velocity if he cannot horizontally pass through a block beside him | ||
| 27412 | LD A,(25391) | Load Magic Knight's x-velocity into B... | ||
| 27415 | LD B,A | ... | ||
| 27416 | LD A,(23470) | Load Magic Knight movement flags into A | ||
| 27419 | XOR B | Check: | ||
| 27420 | CP 255 | If x-velocity is -2 (left), and Magic Knight can't move left... | ||
| 27422 | JP Z,27480 | ...then jump ahead to 27480 | ||
| 27425 | CP 253 | If x-velocity is -2 (left), and Magic Knight can't move left or right... | ||
| 27427 | JP Z,27480 | ...then jump ahead to 27480 | ||
| 27430 | CP 1 | If x-velocity is +2 (right), and Magic Knight can't move left or right... | ||
| 27432 | JP Z,27480 | ...then jump ahead to 27480 | ||
| 27435 | OR A | If x-velocity is +2 (right), and Magic Knight can't move right... | ||
| 27436 | JP Z,27480 | ...then jump ahead to 27480 | ||
| 27439 | CALL 34821 | Update Magic Knight's current frame based on x-coordinate... | ||
| 27442 | LD (25390),A | ... | ||
| 27445 | LD (65528),A | Store frame number at 65528 | ||
| 27448 | CALL 27809 | Kill Magic Knight's jump if he cannot vertically pass through a block above him | ||
| 27451 | PUSH AF | Store AF | ||
| 27452 | XOR A | Set A to zero (Magic Knight) and... | ||
| 27453 | CALL 39224 | ...draw Magic Knight (erase old frame and draw new frame) | ||
| 27456 | POP AF | Restore AF | ||
| 27457 | JR NZ,27468 | If Magic Knight's jump was impeded by a block above him then jump to 27468 | ||
| 27459 | CALL 29763 | Run checks and updates (Magic Knight's current room and room-specific routines) | ||
| 27462 | LD HL,(41857) | Load HL with current position in Magic Knight's y-velocities sequence table at 41857 | ||
| 27465 | INC HL | Advance to next y-velocity in the sequence | ||
| 27466 | JR 27381 | Loop back to 27381 | ||
| 27468 | CALL 34821 | Update Magic Knight's current frame based on x-coordinate | ||
| 27471 | LD (65528),A | Store frame number at 65528 | ||
| 27474 | CALL 27490 | Handle Magic Knight's fall, preserving x-velocity | ||
| 27477 | JP 27254 | Loop back to start of keyboard check routine | ||
| 27480 | XOR A | Set Magic Knight's x-velocity to zero... | ||
| 27481 | LD (25391),A | ... | ||
| 27484 | LD (27405),A | Prepare to set Magic Knight's x-velocity to zero | ||
| 27487 | JP 27439 | Jump back to 27439 | ||
| Prev: 27168 | Up: Map | Next: 27490 |