| Routines

25534: Make a character go to a location

Used by command lists 128, 130, 132, 134, 136, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 184, 186, 188, 190, 192, 198, 200, 202, 208, 212, 214, 216, 218 and 222 to make a character go to a specified place.
Input
H | Character number (152-169)
L | 122
25534 | LD A,(HL) | Reset bits 5 and 6 of byte 122 of the character's buffer, indicating that he should no longer walk fast or slow continuously (if he was doing so)
25535 | AND 159
25537 | LD (HL),A
25538 | LD L,101 | Get the destination y-coordinate from the command list and place it in byte 101 of the character's buffer
25540 | CALL 24972
25543 | LD (HL),A
25544 | INC L | Get the destination x-coordinate from the command list and place it in byte 102 of the character's buffer
25545 | CALL 24972
25548 | LD (HL),A
This entry point is used by the routines at 27111 and 27266.
25549 | NOP |
25550 | CALL 27888 | Make the character stand up if he's not already
The address of this entry point is placed into bytes 99 and 100 of the character's buffer (by the routine at 27888, called above, and by the routine at 27111) so that we return here after the character has stood up.
25553 | LD L,97 | Collect the character's x- and y-coordinates in E and D
25555 | LD D,(HL)
25556 | INC L
25557 | LD E,(HL)
25558 | LD L,101 | Bytes 101 and 102 of the character's buffer contain the destination coordinates
25560 | LD BC,25404 | Point BC at 25404 (guide character to intermediate destination)
25563 | LD A,D | A=character's y-coordinate
25564 | CP (HL) | Is the character on the same floor as his destination?
25565 | JP Z,25750 | Jump if so
25568 | CP 155 | Is the character on the top floor?
25570 | JP Z,25695 | Jump if so
25573 | CP 169 | Is the character on the bottom floor?
25575 | JP Z,25700 | Jump if so
The character is on the middle floor and is destined for another floor.
25578 | LD A,(HL) | A=y-coordinate of destination
25579 | CP 169 | Set the zero flag if the character is going to the bottom floor
25581 | LD A,38 | This is the x-coordinate of the wall between the White and Exam Rooms
25583 | JR NZ,25639 | Jump if the character is going to the top floor
This entry point is used by the routine at 25695 with A=57 (the x-coordinate of the wall between the Map and Reading Rooms).
25585 | CP E | E holds the character's x-coordinate
25586 | LD A,12 | This is the x-coordinate of the tops of the staircases at the left of the skool
25588 | JR NC,25592 | Jump if the character is to the left of the wall whose x-coordinate (38 or 57) was in A
This entry point is used by the routine at 25750 when the character is on the right-middle or right-top floor and needs to go down the stairs to get to his destination.
25590 | LD A,77 | This is the x-coordinate of the tops of the staircases at the right of the skool
This entry point is used by the routine at 25750 with A=12 (the x-coordinate of the tops of the staircases at the left of the skool) when the character is on the left-middle or left-top floors and needs to go down the stairs to get to his destination.
25592 | CP E | Is the character at the top of the stairs he needs to descend?
25593 | JR NZ,25627 | Jump if not
25595 | LD L,96 | Byte 96 of the character's buffer holds his animatory state
25597 | BIT 0,(HL) | Is the character midstride (about to descend)?
25599 | JR NZ,25627 | Jump if so
25601 | CP 48 | Is the target staircase on the right of the skool?
25603 | JR NC,25611 | Jump if so
25605 | BIT 7,(HL) | Is the character facing left?
25607 | JR Z,25615 | Jump if so
25609 | JR 25623 |
The character must go to the top of a staircase at the right of the skool.
25611 | BIT 7,(HL) | Is the character facing left?
25613 | JR Z,25623 | Jump if so
This entry point is used by the routine at 25700.
25615 | CALL 25108 | Update the SRB for the character's current location
25618 | XOR 128 | Turn the character round
25620 | JP 25008 | Update the character's animatory state and location and update the SRB
25623 | LD C,144 | BC=25488 (guide character down stairs)
This entry point is used by the routine at 25700.
25625 | LD A,15 | Going up or down a staircase entails 15 movements
This entry point is used by the routines at 25700 and 25750.
25627 | LD L,105 | Place the interruptible subcommand routine address in BC (25404, 25484 or 25488) into bytes 105 and 106 of the character's buffer
25629 | LD (HL),C
25630 | INC L
25631 | LD (HL),B
25632 | INC L | Byte 107 will contain either (a) the x-coordinate of the next intermediate destination (i.e. the final destination itself, or the top or bottom of the next staircase the character must negotiate first) (BC=25404), or (b) 15, that being the number of movements required to ascend or descend a staircase (BC=25484 or 25488)
25633 | LD (HL),A
25634 | INC L | Initialise byte 108 to 9; this ensures that the routine at 25404 will move the character at most 9 paces towards the destination before relinquishing control (and thus giving the routine at 25126 a chance to check whether the command list should be restarted, e.g. for a new lesson)
25635 | LD (HL),9
25637 | PUSH BC | Make an indirect jump to 25404, 25484 or 25488
25638 | RET
The character is on the middle floor but is destined for the top floor. At this point A=38 (the x-coordinate of the wall between the White and Exam Rooms).
25639 | INC L | Point HL at the destination x-coordinate
25640 | CP E |
25641 | LD A,57 | This is the x-coordinate of the wall between the Map and Reading Rooms
25643 | JR NC,25667 | Jump if the character is to the left of the White Room wall
25645 | CP (HL) | (HL) holds the destination x-coordinate
25646 | LD A,70 | This is the x-coordinate of the bottoms of the staircases at the right of the skool
25648 | JR NC,25590 | Jump if the destination is to the left of the Map Room wall
25650 | CP E | Is the character at the bottom of the staircase just outside the Exam Room?
25651 | JR NZ,25627 | Jump if not (to send the character there)
25653 | LD L,96 | Byte 96 of the character's buffer holds his animatory state
25655 | BIT 0,(HL) | Is the character midstride?
25657 | JR NZ,25627 | Jump if so (to finish the stride)
25659 | BIT 7,(HL) | Is the character facing left?
25661 | JR Z,25615 | Jump if so (to turn the character round)
25663 | LD C,140 | BC=25484 (guide character up stairs)
25665 | JR 25625 |
The character is on the middle floor to the left of the White Room wall, and is destined for the top floor. At this point A=57 (the x-coordinate of the wall between the Map and Reading Rooms).
25667 | CP (HL) | (HL) holds the destination x-coordinate
25668 | LD A,12 | This is the x-coordinate of the tops of the staircases at the left of the skool
25670 | JR C,25592 | Jump if the destination is to the right of the Map Room wall
25672 | LD A,19 | This is the x-coordinate of the bottoms of the staircases at the left of the skool
25674 | CP E | Is the character at the bottom of the staircase just outside the White Room?
25675 | JR NZ,25627 | Jump if not (to send the character there)
25677 | LD L,96 | Byte 96 of the character's buffer holds his animatory state
25679 | BIT 0,(HL) | Is the character midstride?
25681 | JR NZ,25627 | Jump if so (to finish the stride)
25683 | BIT 7,(HL) | Is the character facing right?
25685 | JR NZ,25615 | Jump if so (to turn the character round)
25687 | LD C,140 | BC=25484 (guide character up stairs)
25689 | JR 25625 |