Routines |
Prev: 31807 | Up: Map | Next: 31943 |
Used by the routine at 60812. Checks whether a character will soon be entering or leaving the hotel, and if so, determines where he should start climbing the front steps (depending on his current location), or through which door he should leave (left or right, depending on his destination).
|
||||||||
31808 | CALL 60726 | Obtain an identifier for the character's current location | ||||||
31811 | PUSH AF | Save the identifier | ||||||
31812 | AND A | Is the character on the sidewalk or the road? | ||||||
31813 | JR NZ,31856 | Jump if not | ||||||
The character is on the sidewalk or the road.
|
||||||||
31815 | LD L,12 | Collect the character's destination location identifier from byte 12 of his buffer | ||||||
31817 | LD A,(HL) | |||||||
31818 | AND 240 | Keep only the region identifier bits (bits 4-7) | ||||||
31820 | CP 144 | Is the character going to the hotel? | ||||||
31822 | JR NZ,31854 | Jump if not | ||||||
The character is on the sidewalk or road, and destined for somewhere inside or outside the hotel. Figure out which entrance (left or right) the character should use, based on his current location and his destination.
|
||||||||
31824 | LD A,(HL) | A=destination location identifier | ||||||
31825 | CP 149 | Set the carry flag if the destination is on the first floor or the front steps of the hotel | ||||||
31827 | LD L,10 | Point HL at byte 10 of the character's buffer | ||||||
31829 | LD A,(HL) | A=x' (the character's destination x-coordinate) | ||||||
31830 | JR C,31834 | Jump if the destination is on the first floor or the front steps of the hotel (in which case 75<=x'<=82) | ||||||
31832 | LD A,79 | Assume x'=79 (the x-coordinate of the middle of the doorsteps of the hotel) | ||||||
31834 | LD L,1 | Add x (the character's current x-coordinate) | ||||||
31836 | ADD A,(HL) | |||||||
31837 | SUB 158 | Reset the carry flag if 158-x'<=x<=285-x' | ||||||
31839 | RLCA | |||||||
31840 | LD A,88 | This is the x-coordinate of the rightmost front doorstep of the hotel | ||||||
31842 | JR NC,31846 | Jump if x>=158-x' (the character will enter the hotel from the right) | ||||||
31844 | LD A,67 | This is the x-coordinate of the leftmost front doorstep of the hotel | ||||||
31846 | LD BC,65448 | Point BC at the first byte of the entry that corresponds to the hotel in the data table of building entrance x-coordinates at 65432 | ||||||
31849 | LD (BC),A | Set the first byte to 67 or 88 | ||||||
31850 | ADD A,2 | Set the second byte of the entry to 69 or 90 | ||||||
31852 | INC C | |||||||
31853 | LD (BC),A | |||||||
31854 | POP AF | Restore the identifier for the character's current location to A | ||||||
31855 | RET | |||||||
The character is not on the sidewalk or the road.
|
||||||||
31856 | CP 149 | If the character's location identifier is at least 149, then he's not on the first floor or the front steps of the hotel | ||||||
31858 | JR NC,31854 | Jump if this is the case | ||||||
31860 | CP 145 | Is the character on the front steps of the hotel (below the level of the first floor)? | ||||||
31862 | JR Z,31887 | Jump if so | ||||||
31864 | AND 240 | Keep only the region identifier bits (bits 4-7) | ||||||
31866 | CP 144 | Is the character on the first floor of the hotel? | ||||||
31868 | JR NZ,31854 | Jump if not | ||||||
The character is on the first floor of the hotel.
|
||||||||
31870 | LD L,10 | Point HL at byte 10 of the character's buffer | ||||||
31872 | LD A,(HL) | A=x' (character's destination x-coordinate) | ||||||
31873 | LD L,1 | Add x (the character's current x-coordinate; 75<=x<=82) | ||||||
31875 | ADD A,(HL) | |||||||
31876 | SUB 158 | Reset the carry flag if 158-x<=x'<=285-x | ||||||
31878 | RLCA | |||||||
31879 | LD D,76 | Set D (which holds the x-coordinate of the top of the steps going down to the sidewalk below) to 76 (x-coordinate of the left-hand entrance of the hotel) | ||||||
31881 | JR C,31854 | Jump if x'<158-x (the character will exit the hotel on the left) | ||||||
31883 | LD D,81 | This is the x-coordinate of the right-hand entrance of the hotel | ||||||
31885 | JR 31854 | Return to the caller with D adjusted depending on the character's destination x-coordinate | ||||||
The character is on the front steps of the hotel (below the level of the first floor).
|
||||||||
31887 | LD L,13 | Set the location/destination indicator in byte 13 of the character's buffer to 0 (the front steps of the hotel count as part of the sidewalk if the character is going somewhere other than the hotel) | ||||||
31889 | LD (HL),0 | |||||||
31891 | DEC L | L=12 | ||||||
31892 | LD A,(HL) | A=destination location identifier | ||||||
31893 | AND 240 | Keep only the region identifier bits (bits 4-7) | ||||||
31895 | CP 144 | Is the character going to the hotel? | ||||||
31897 | JR NZ,31854 | Jump if not | ||||||
The character is on the front steps of the hotel (below the level of the first floor), and his destination is somewhere inside or outside the hotel.
|
||||||||
31899 | INC L | Set byte 13 of the character's buffer to 1 (indicating that the character is not on the sidewalk or the road, and is in the same region as his destination) | ||||||
31900 | INC (HL) | |||||||
31901 | DEC L | L=12 | ||||||
31902 | LD A,(HL) | A=destination location identifier | ||||||
31903 | CP 149 | Is the destination on or below the first floor of the hotel? | ||||||
31905 | JR C,31938 | Jump if so | ||||||
The character is on the front steps of the hotel (below the level of the first floor), and his destination is somewhere inside the hotel, above the first floor.
|
||||||||
31907 | LD L,1 | Point HL at byte 1 of the character's buffer | ||||||
31909 | LD B,L | B=1 (go right) | ||||||
31910 | LD A,(HL) | A=x (the character's x-coordinate) | ||||||
31911 | CP 79 | Set the carry flag if x<79 | ||||||
31913 | LD A,76 | This is the x-coordinate of the left edge of the front door of the hotel | ||||||
31915 | JR C,31919 | Jump if x<79 | ||||||
31917 | LD A,82 | This is the x-coordinate of the right edge of the front door of the hotel | ||||||
31919 | CP (HL) | Compare A (76 or 82) with x (the character's x-coordinate) | ||||||
31920 | DEC HL | Point HL at byte 0 of the character's buffer | ||||||
31921 | JR C,31931 | Jump if x is 77 or 78, or greater than 82 (meaning the character should go left to reach the hotel entrance) | ||||||
31923 | BIT 7,(HL) | Is the character facing right? | ||||||
31925 | JR NZ,31854 | Jump if so | ||||||
31927 | POP AF | Restore the identifier for the character's current location to A (though it is ignored) | ||||||
31928 | LD A,B | A=1 (go right) or 2 (go left) | ||||||
31929 | POP BC | Drop the return address from the stack | ||||||
31930 | RET | Return to the caller of 60812 | ||||||
31931 | BIT 7,(HL) | Is the character facing left? | ||||||
31933 | JR Z,31854 | Jump if so | ||||||
31935 | INC B | B=2 (go left) | ||||||
31936 | JR 31928 | |||||||
The character is on the front steps of the hotel (below the level of the first floor), and his destination is on or below the first floor of the hotel.
|
||||||||
31938 | POP AF | Restore the identifier for the character's current location to A (though it is ignored) | ||||||
31939 | POP BC | Drop the return address from the stack | ||||||
31940 | JP 60827 | Re-enter the calling routine at 60827 |
Prev: 31807 | Up: Map | Next: 31943 |