Routines |
Prev: 27495 | Up: Map | Next: 27809 |
27666 | LD A,(23410) | Load B with Magic Knight's "temporary store" movement flags... | ||
27669 | LD B,A | ... | ||
27670 | LD A,(25387) | Load Magic Knight's x-coordinate into A | ||
27673 | CP 5 | If x-coordinate is less than 5... | ||
27675 | JP C,27685 | ...then jump ahead to 27685 | ||
27678 | CP 229 | If x-coordinate is greater than 229... | ||
27680 | JP NC,27685 | ...then jump ahead to 27685 | ||
Magic Knight is not at the outer edges of his current room, so can move both left and right
|
||||
27683 | LD B,0 | Set B (Magic Knight's temporary store movement flags) to zero | ||
27685 | LD A,B | Load Magic Knight's temporary store movement flags into A | ||
27686 | LD (23470),A | Set Magic Knight's movement flags | ||
27689 | LD A,(25388) | Load Magic Knight's y-coordinate into B | ||
27692 | LD B,A | ... | ||
27693 | LD A,(25392) | Add Magic Knight's y-velocity to y-coordinate in A... | ||
27696 | ADD A,B | ... | ||
27697 | LD (23479),A | Store this new (predicted) y-coordinate at 23479 | ||
27700 | LD C,4 | Set C to 4 (as Magic Knight is normally four characters tall) | ||
27702 | AND 7 | If predicted y-coordinate is divisible by eight... | ||
27704 | JR Z,27707 | ...then skip ahead to 27707... | ||
27706 | INC C | ...else Magic Knight must be airborne and at non-integer y-coordinate, and so spans five character blocks rather than four | ||
27707 | LD A,C | Load A with number of vertical characters spanned by Magic Knight... | ||
27708 | LD (27740),A | ...and update instructions at 27739... | ||
27711 | LD (27781),A | ...and 27780 with this value | ||
27714 | LD A,(25387) | Load Magic Knight's current x-coordinate into C... | ||
27717 | LD C,A | ... | ||
27718 | LD A,(25391) | Add Magic Knight's x-velocity to x-coordinate in A... | ||
27721 | ADD A,C | ... | ||
27722 | LD (23478),A | Store this new (predicted) x-coordinate at 23478 | ||
27725 | CALL 30123 | Divide predicted x-coordinate by eight, rounding down to nearest integer... | ||
27728 | LD C,A | ...and load into C | ||
27729 | LD A,(23479) | Load predicted y-coordinate into A... | ||
27732 | CALL 30123 | ...divide it by eight, rounding down to nearest integer... | ||
27735 | LD (23479),A | ...store back at 23479... | ||
27738 | LD B,A | ...and load into B | ||
27739 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
27741 | PUSH AF | Store remaining number of character blocks spanned by Magic Knight vertically to check | ||
27742 | PUSH BC | Store predicted x- and y-coordinates (characters) | ||
27743 | CALL 36586 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
27746 | POP BC | Restore predicted x- and y-coordinates (characters) | ||
27747 | BIT 5,(HL) | If bit 5 of terrain data is set (i.e. Magic Knight cannot pass block horizontally)... | ||
27749 | JR NZ,27758 | ...then jump ahead to 27758 | ||
27751 | INC B | Advance check to next character down | ||
27752 | POP AF | Restore remaining number of character blocks spanned by Magic Knight vertically to check | ||
27753 | DEC A | Decrease count of remaining character blocks by one | ||
27754 | JR NZ,27741 | Loop back to 27741 to check next block down | ||
27756 | JR 27767 | Skip over setting Magic Knight's can't-move-left flag as there are no obstructions to the left | ||
27758 | POP AF | Restore AF | ||
27759 | LD A,(23470) | Set Magic-Knight-can't-move-left flag... | ||
27762 | OR 1 | ... | ||
27764 | LD (23470),A | ... | ||
27767 | LD A,(23478) | Load Magic Knight's predicted x-coordinate (pixels) into A... | ||
27770 | ADD A,15 | ...and add 15 | ||
27772 | CALL 30123 | Divide A by eight, rounding down to nearest integer... | ||
27775 | LD C,A | ...and load into C | ||
27776 | LD A,(23479) | Load Magic Knight's predicted y-coordinate (characters) into B... | ||
27779 | LD B,A | ... | ||
27780 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
27782 | PUSH AF | Store AF (remaining number of vertical characters to check for impassibility) | ||
27783 | PUSH BC | Store BC (predicted y- and x-coordinates in characters) | ||
27784 | CALL 36586 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
27787 | POP BC | Restore predicted coordinates | ||
27788 | BIT 5,(HL) | If bit 5 is set (i.e. Magic Knight cannot pass block horizontally)... | ||
27790 | JR NZ,27799 | ...jump ahead to 27799 | ||
27792 | INC B | Increase y-coordinate by one character | ||
27793 | POP AF | Restore AF | ||
27794 | DEC A | Decrease number of remaining blocks to check | ||
27795 | JR NZ,27782 | If number of remaining blocks to check is not zero then loop back to 27782 | ||
27797 | JR 27808 | Exit routine | ||
27799 | POP AF | Restore AF | ||
27800 | LD A,(23470) | Set Magic-Knight-can't-move-right flag... | ||
27803 | OR 2 | ... | ||
27805 | LD (23470),A | ... | ||
27808 | RET | Return |
Prev: 27495 | Up: Map | Next: 27809 |