|  | Routines | 
| Prev: 27357 | Up: Map | Next: 27647 | 
| 27508 | LD A,(23463) | Load B with Magic Knight's temporary store movement flags... | ||
| 27511 | LD B,A | ... | ||
| 27512 | LD A,(25156) | Load Magic Knight's x-coordinate into A | ||
| 27515 | CP 5 | If x-coordinate is less than 5... | ||
| 27517 | JP C,27527 | ...then jump ahead to 27527 | ||
| 27520 | CP 230 | If x-coordinate is greater than 230... | ||
| 27522 | JP NC,27527 | ...then jump ahead to 27527 | ||
| 
Magic Knight is not at the outer edges of his current room, so can move both left and right
 | ||||
| 27525 | LD B,0 | Set B (Magic Knight's temporary store movement flags) to zero | ||
| 27527 | LD A,B | Load Magic Knight's temporary store movement flags into A | ||
| 27528 | LD (23474),A | Set Magic Knight's movement flags | ||
| 27531 | LD A,(25157) | Load Magic Knight's y-coordinate into B | ||
| 27534 | LD B,A | ... | ||
| 27535 | LD A,(25161) | Add Magic Knight's y-velocity to y-coordinate in A... | ||
| 27538 | ADD A,B | ... | ||
| 27539 | LD (23483),A | Store this new (predicted) y-coordinate at 23483 | ||
| 27542 | LD C,4 | Set C to 4 (as Magic Knight is normally four characters tall) | ||
| 27544 | AND 7 | If predicted y-coordinate is divisible by eight... | ||
| 27546 | JR Z,27549 | ...then skip ahead to 27549... | ||
| 27548 | INC C | ...else Magic Knight must be airborne and at non-integer y-coordinate, and so spans five character blocks rather than four | ||
| 27549 | LD A,C | Load A with number of vertical characters spanned by Magic Knight... | ||
| 27550 | LD (27582),A | ...and update instructions at 27581... | ||
| 27553 | LD (27621),A | ...and 27620 with this value | ||
| 27556 | LD A,(25156) | Load Magic Knight's current x-coordinate into C... | ||
| 27559 | LD C,A | ... | ||
| 27560 | LD A,(25160) | Add Magic Knight's x-velocity to x-coordinate in A... | ||
| 27563 | ADD A,C | ... | ||
| 27564 | LD (23482),A | Store this new (predicted) x-coordinate at 23482 | ||
| 27567 | CALL 28625 | Divide predicted x-coordinate by eight, rounding down to nearest integer... | ||
| 27570 | LD C,A | ...and load into C | ||
| 27571 | LD A,(23483) | Load predicted y-coordinate into A... | ||
| 27574 | CALL 28625 | ...divide it by eight, rounding down to nearest integer... | ||
| 27577 | LD (23483),A | ...store back at 23483... | ||
| 27580 | LD B,A | ...and load into B | ||
| 27581 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
| 27583 | PUSH AF | Store remaining number of character blocks spanned by Magic Knight vertically to check | ||
| 27584 | CALL 54162 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
| 27587 | BIT 6,(HL) | If bit 6 of terrain data is set (i.e. Magic Knight cannot pass block horizontally)... | ||
| 27589 | JR NZ,27598 | ...then jump ahead to 27598 | ||
| 27591 | INC B | Advance check to next character down | ||
| 27592 | POP AF | Restore remaining number of character blocks spanned by Magic Knight vertically to check | ||
| 27593 | DEC A | Decrease count of remaining character blocks by one | ||
| 27594 | JR NZ,27583 | Loop back to 27583 to check next block down | ||
| 27596 | JR 27607 | Skip over setting Magic Knight's can't-move-left flag as there are no obstructions to the left | ||
| 27598 | POP AF | Restore AF | ||
| 27599 | LD A,(23474) | Set Magic-Knight-can't-move-left flag... | ||
| 27602 | OR 1 | ... | ||
| 27604 | LD (23474),A | ... | ||
| 27607 | LD A,(23482) | Load Magic Knight's predicted x-coordinate (pixels) into A... | ||
| 27610 | ADD A,15 | ...and add 15... | ||
| 27612 | CALL 28625 | ...divide by eight, rounding down to nearest integer... | ||
| 27615 | LD C,A | ...and load into C | ||
| 27616 | LD A,(23483) | Load Magic Knight's predicted y-coordinate (chars) into B... | ||
| 27619 | LD B,A | ... | ||
| 27620 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
| 27622 | PUSH AF | Store AF (remaining number of vertical characters to check for impassibility) | ||
| 27623 | CALL 54162 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
| 27626 | BIT 6,(HL) | If bit 6 is set (i.e. Magic Knight cannot pass block horizontally)... | ||
| 27628 | JR NZ,27637 | ...jump ahead to 27637 | ||
| 27630 | INC B | Increase y-coordinate by one character | ||
| 27631 | POP AF | Restore AF | ||
| 27632 | DEC A | Decrease number of remaining blocks to check | ||
| 27633 | JR NZ,27622 | If number of remaining blocks to check is not zero then loop back to 27622 | ||
| 27635 | JR 27646 | Exit routine | ||
| 27637 | POP AF | Restore AF | ||
| 27638 | LD A,(23474) | Set Magic-Knight-can't-move-right flag... | ||
| 27641 | OR 2 | ... | ||
| 27643 | LD (23474),A | ... | ||
| 27646 | RET | Return | ||
| Prev: 27357 | Up: Map | Next: 27647 |