Prev: 27508 Up: Map Next: 27703
27647: Kill Magic Knight's jump if he cannot vertically pass through a block above him
Used by the routine at 27136.
Output
A Zero (if Magic Knight's jump was not impeded) or 1 (if the jump was impeded)
27647 LD A,(25157) Load Magic Knight's current y-coordinate into B...
27650 LD B,A ...
27651 LD A,(25161) Load A with Magic Knight's y-velocity
27654 ADD A,B Add y-velocity to y-coordinate in A
27655 CALL 28625 Divide A by eight, rounding down to nearest integer
27658 LD B,A Load Magic Knight's y-coordinate (characters) into B
27659 LD A,(25156) Load Magic Knight's current x-coordinate into A
27662 ADD A,4 Add 4 to x-coordinate (to get point roughly quarter of the way through Magic Knight's total width)
27664 CALL 28625 Divide A by eight, rounding down to nearest integer
27667 LD C,A Load Magic Knight's current x-coordinate (characters) into C
27668 CALL 54162 Point HL at terrain interaction data for character coordinates x=C, y=B
27671 BIT 4,(HL) If bit 4 of Magic Knight's current position's terrain data (block is impassable vertically, upwards) is set then...
27673 JR NZ,27695 ...kill Magic Knight's y-velocity and exit routine
27675 INC HL Advance to next character block along in "terrain interaction data"
27676 BIT 4,(HL) If bit 4 of this position's terrain data (block is impassable vertically, upwards) is set then...
27678 JR NZ,27695 ...kill Magic Knight's y-velocity and exit routine
27680 DEC B Advance y-coordinate by one character (to get point roughly three quarters of the way through Magic Knight's total width)
27681 CALL 54162 Point HL at terrain interaction data for character coordinates x=C, y=B
27684 BIT 4,(HL) If bit 4 of this position's terrain data (block is impassable vertically, upwards) is set then...
27686 JR NZ,27695 ...kill Magic Knight's y-velocity and exit routine
27688 INC HL Advance to next character block along in "terrain interaction data"
27689 BIT 4,(HL) If bit 4 of this position's terrain data (block is impassable vertically, upwards) is set then...
27691 JR NZ,27695 ...kill Magic Knight's y-velocity and exit routine
27693 XOR A Set A to zero, as jump was not impeded
27694 RET Return
27695 XOR A Set Magic Knight's y-velocity to zero...
27696 LD (25161),A ...
27699 LD A,1 Set A to one
27701 OR A Reset zero flag
27702 RET Return
Prev: 27508 Up: Map Next: 27703