Routines |
Prev: 38429 | Up: Map | Next: 38585 |
Used by the routine at 38205.
|
||||
38434 | XOR A | Set A to zero | ||
This entry point is used by the routine at 38429.
|
||||
38435 | LD (38470),A | Prepare to set Magic Knight's x-velocity to A | ||
38438 | LD HL,49032 | Point HL at end of table of y-velocities sequence for jumping and falling | ||
38441 | LD (23442),HL | Store current position at 23442 | ||
38444 | LD A,(23474) | If Magic Knight's movement flags are reset... | ||
38447 | OR A | ... | ||
38448 | JR Z,38454 | ...then skip ahead to 38454 | ||
38450 | XOR A | Prepare to set Magic Knight's x-velocity to zero... | ||
38451 | LD (38470),A | ... | ||
38454 | LD HL,(23442) | Load current position in y-velocities table into HL | ||
38457 | LD A,(HL) | Load current y-velocity from table into A | ||
38458 | CP 7 | If velocity is 7... | ||
38460 | JR Z,38466 | ...then skip ahead to 38466 | ||
38462 | DEC HL | Step pointer back one byte in y-velocities table | ||
38463 | LD (23442),HL | Store pointer | ||
38466 | LD (24845),A | Load last y-velocity read from table into Magic Knight's y-velocity | ||
38469 | LD A,0 | Set Magic Knight's x-velocity... | ||
38471 | LD (24844),A | ... | ||
38474 | LD A,(24840) | Load A with Magic Knight's current x-coordinate (pixels) | ||
38477 | ADD A,4 | Add 4 to x-coordinate | ||
38479 | CALL 40658 | Divide x-coordinate by eight, rounding down to nearest integer | ||
38482 | LD C,A | Load result (Magic Knight's x-coordinate in characters) into C, setting B to zero... | ||
38483 | LD B,0 | ... | ||
38485 | LD A,(24841) | Load A with Magic Knight's current y-coordinate (pixels) | ||
38488 | AND 7 | If y-coordinate is a multiple of eight... | ||
38490 | JR Z,38494 | ...then skip ahead to 38494 | ||
y-coordinate is not a multiple of eight
|
||||
38492 | LD B,8 | Set B to 8, as we need to look one character block lower due to Magic Knight spanning five, rather than four, characters | ||
38494 | LD A,(24841) | Load A with Magic Knight's current y-coordinate (pixels) | ||
38497 | ADD A,B | Add B to current y-coordinate (i.e. y-coordinate of highest full character block spanned by Magic Knight) | ||
38498 | ADD A,32 | Add 32 (as Magic Knight is 32 pixels high, so now y-coordinate of highest full character block not occupied by Magic Knight) | ||
38500 | CALL 40658 | Divide A by eight, rounding down to nearest integer | ||
38503 | LD B,A | Load result (y-coordinate in characters) into B | ||
38504 | CALL 63233 | Point HL at terrain interaction data for character coordinates x=C, y=B (block that Magic Knight is "falling through") | ||
38507 | LD A,(HL) | If this block, or the one to the right of it cannot be passed vertically (downwards)... | ||
38508 | INC HL | ...(i.e. Magic Knight has landed)... | ||
38509 | OR (HL) | ... | ||
38510 | BIT 7,A | ... | ||
38512 | JR NZ,38553 | ...then skip ahead to 38553 | ||
38514 | CALL 38585 | Kill Magic Knight's x-velocity if he cannot horizontally pass through a block beside him | ||
38517 | LD A,(24844) | Load Magic Knight's x-velocity into B... | ||
38520 | LD B,A | ... | ||
38521 | LD A,(23474) | Load Magic Knight's movement flags into A | ||
38524 | XOR B | Check: | ||
38525 | CP 255 | If x-velocity is -2 (left), and Magic Knight can't move left... | ||
38527 | JP Z,38575 | ...then jump ahead to 38575 | ||
38530 | CP 253 | If x-velocity is -2 (left), and Magic Knight can't move left or right... | ||
38532 | JP Z,38575 | ...then jump ahead to 38575 | ||
38535 | CP 1 | If x-velocity is +2 (right), and Magic Knight can't move left or right... | ||
38537 | JP Z,38575 | ...then jump ahead to 38575 | ||
38540 | OR A | If x-velocity is +2 (right), and Magic Knight can't move right... | ||
38541 | JP Z,38575 | ...then jump ahead to 38575 | ||
38544 | CALL 61816 | Wait for interrupt then erase Magic Knight from display, advance his current position then redraw | ||
38547 | CALL 40008 | Set Magic Knight's velocity to zero, if appropriate move to new room, update state of Storm Cloud and execute room-specific routine | ||
38550 | JP 38444 | Loop back to 38444 | ||
38553 | LD A,(24841) | Load A with Magic Knight's current y-coordinate (pixels) | ||
38556 | AND 7 | Retain only pixel-within-character component (e.g. 5 pixels down the pair of character blocks) | ||
38558 | NEG | Negate (i.e. -5 pixels) | ||
38560 | AND 7 | Retain only pixel-within-character component (e.g. 3 pixels up the pair of character blocks, or 3 pixels down to the ground) | ||
38562 | LD (24845),A | Set Magic Knight's y-velocity so that it will take his feet to the ground | ||
38565 | CALL 61816 | Wait for interrupt then erase Magic Knight from display, advance his current position then redraw | ||
38568 | LD HL,0 | Set Magic Knight's x- and y-velocities to zero... | ||
38571 | LD (24844),HL | ... | ||
38574 | RET | Return (Magic Knight has landed) | ||
38575 | XOR A | Set Magic Knight's x-velocity to zero... | ||
38576 | LD (24844),A | ... | ||
38579 | LD (38470),A | Prepare to set Magic Knight's x-velocity to zero | ||
38582 | JP 38544 | Loop back to 38544 |
Prev: 38429 | Up: Map | Next: 38585 |