Routines |
Prev: 38434 | Up: Map | Next: 38724 |
38585 | LD A,(23451) | Load B with Magic Knight's temporary store movement flags... | ||
38588 | LD B,A | ... | ||
38589 | LD A,(24840) | Load Magic Knight's x-coordinate into A | ||
38592 | CP 5 | If x-coordinate is less than 5... | ||
38594 | JP C,38604 | ...then jump ahead to 38604 | ||
38597 | CP 230 | If x-coordinate is 230 or greater... | ||
38599 | JP NC,38604 | ...then jump ahead to 38604 | ||
Magic Knight is not at the outer edges of his current room, so can move both left and right
|
||||
38602 | LD B,0 | Set B (Magic Knight's temporary store movement flags) to zero | ||
38604 | LD A,B | Load Magic Knight's temporary store movement flags into A | ||
38605 | LD (23474),A | Set Magic Knight's movement flags | ||
38608 | LD A,(24841) | Load Magic Knight's y-coordinate into B | ||
38611 | LD B,A | ... | ||
38612 | LD A,(24845) | Add Magic Knight's y-velocity to y-coordinate in A... | ||
38615 | ADD A,B | ... | ||
38616 | LD (23483),A | Store this new (predicted) y-coordinate at 23483 | ||
38619 | LD C,4 | Set C to 4 (as Magic Knight is normally four characters tall) | ||
38621 | AND 7 | If predicted y-coordinate is divisible by eight... | ||
38623 | JR Z,38626 | ...then skip ahead to 38626... | ||
38625 | INC C | ...else Magic Knight must be airborne and at non-integer y-coordinate, and so spans five character blocks rather than four | ||
38626 | LD A,C | Load A with number of vertical characters spanned by Magic Knight... | ||
38627 | LD (38659),A | ...and update instructions at 38658... | ||
38630 | LD (38698),A | ...and 38697 with this value | ||
38633 | LD A,(24840) | Load Magic Knight's current x-coordinate into C... | ||
38636 | LD C,A | ... | ||
38637 | LD A,(24844) | Add Magic Knight's x-velocity to x-coordinate in A... | ||
38640 | ADD A,C | ... | ||
38641 | LD (23482),A | Store this new (predicted) x-coordinate at 23482 | ||
38644 | CALL 40658 | Divide predicted x-coordinate by eight, rounding down to nearest integer... | ||
38647 | LD C,A | ...and load into C | ||
38648 | LD A,(23483) | Load predicted y-coordinate into A... | ||
38651 | CALL 40658 | ...divide it by eight, rounding down to nearest integer... | ||
38654 | LD (23483),A | ...store back at 23483... | ||
38657 | LD B,A | ...and load into B | ||
38658 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
38660 | PUSH AF | Store remaining number of character blocks spanned by Magic Knight vertically to check | ||
38661 | CALL 63233 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
38664 | BIT 6,(HL) | If bit 6 of terrain data is set (i.e. Magic Knight cannot pass block horizontally)... | ||
38666 | JR NZ,38675 | ...then jump ahead to 38675 | ||
38668 | INC B | Advance check to next character down | ||
38669 | POP AF | Restore remaining number of character blocks spanned by Magic Knight vertically to check | ||
38670 | DEC A | Decrease count of remaining character blocks by one | ||
38671 | JR NZ,38660 | Loop back to 38660 to check next block down | ||
38673 | JR 38684 | Skip over setting Magic Knight's can't-move-left flag as there are no obstructions to the left | ||
38675 | POP AF | Restore AF | ||
38676 | LD A,(23474) | Set Magic-Knight-can't-move-left flag... | ||
38679 | OR 1 | ... | ||
38681 | LD (23474),A | ... | ||
38684 | LD A,(23482) | Load Magic Knight's predicted x-coordinate (pixels) into A... | ||
38687 | ADD A,15 | ...and add 15... | ||
38689 | CALL 40658 | ...divide by eight, rounding down to nearest integer... | ||
38692 | LD C,A | ...and load into C | ||
38693 | LD A,(23483) | Load Magic Knight's predicted y-coordinate (chars) into B... | ||
38696 | LD B,A | ... | ||
38697 | LD A,0 | Load number of characters (vertically) to check for impassibility | ||
38699 | PUSH AF | Store AF (remaining number of vertical characters to check for impassibility) | ||
38700 | CALL 63233 | Point HL at terrain interaction data for character coordinates x=C, y=B | ||
38703 | BIT 6,(HL) | If bit 6 is set (i.e. Magic Knight cannot pass block horizontally)... | ||
38705 | JR NZ,38714 | ...jump ahead to 38714 | ||
38707 | INC B | Increase y-coordinate by one character | ||
38708 | POP AF | Restore AF | ||
38709 | DEC A | Decrease number of remaining blocks to check | ||
38710 | JR NZ,38699 | If number of remaining blocks to check is not zero then loop back to 38699 | ||
38712 | JR 38723 | Exit routine | ||
38714 | POP AF | Restore AF | ||
38715 | LD A,(23474) | Set Magic-Knight-can't-move-right flag... | ||
38718 | OR 2 | ... | ||
38720 | LD (23474),A | ... | ||
38723 | RET | Return |
Prev: 38434 | Up: Map | Next: 38724 |