![]() |
Routines |
Prev: 60152 | Up: Map | Next: 60291 |
Used by the routines at 28942, 60347, 60812, 62216 and 64005. Returns with A holding a value indicating the nature of the character's current location:
In addition, C returns holding a value indicating which directions are available, and (when A=1 or 5) which directions require special handling:
|
||||||||||||||||||||||||||||||||||||||||||||||||
60179 | CALL 60152 | Is the character on the sidewalk or the road? | ||||||||||||||||||||||||||||||||||||||||||||||
60182 | JR C,60192 | Jump if not | ||||||||||||||||||||||||||||||||||||||||||||||
60184 | LD (HL),L | Set the character's z-coordinate to 4 (on the sidewalk or road) | ||||||||||||||||||||||||||||||||||||||||||||||
60185 | LD D,196 | Collect a location descriptor from the table at 50176 | ||||||||||||||||||||||||||||||||||||||||||||||
60187 | LD A,(DE) | |||||||||||||||||||||||||||||||||||||||||||||||
60188 | LD C,A | Copy the location descriptor to C | ||||||||||||||||||||||||||||||||||||||||||||||
60189 | LD A,1 | A=1 (character is on the sidewalk or the road) | ||||||||||||||||||||||||||||||||||||||||||||||
60191 | RET | |||||||||||||||||||||||||||||||||||||||||||||||
The character is not on the sidewalk or the road.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60192 | LD A,(HL) | A=character's z-coordinate | ||||||||||||||||||||||||||||||||||||||||||||||
60193 | CP 4 | Is the character outside? | ||||||||||||||||||||||||||||||||||||||||||||||
60195 | JR NZ,60199 | Jump if not | ||||||||||||||||||||||||||||||||||||||||||||||
60197 | LD (HL),2 | Set the character's z-coordinate to 2 | ||||||||||||||||||||||||||||||||||||||||||||||
60199 | LD A,D | A=y, the character's y-coordinate (6-35) | ||||||||||||||||||||||||||||||||||||||||||||||
60200 | SUB 4 | B=4*(y-4) | ||||||||||||||||||||||||||||||||||||||||||||||
60202 | ADD A,A | |||||||||||||||||||||||||||||||||||||||||||||||
60203 | ADD A,A | |||||||||||||||||||||||||||||||||||||||||||||||
60204 | LD B,A | |||||||||||||||||||||||||||||||||||||||||||||||
60205 | BIT 0,(HL) | Is the character indoors? | ||||||||||||||||||||||||||||||||||||||||||||||
60207 | JR NZ,60211 | Jump if so | ||||||||||||||||||||||||||||||||||||||||||||||
60209 | SET 7,B | B=128+4*(y-4) if the character's z-coordinate is 2 | ||||||||||||||||||||||||||||||||||||||||||||||
Now B holds a value indicating the character's y-coordinate (bits 2-6: y-4) and z-coordinate (bit 7: z-1).
|
||||||||||||||||||||||||||||||||||||||||||||||||
60211 | EX DE,HL | L=character's x-coordinate | ||||||||||||||||||||||||||||||||||||||||||||||
60212 | LD H,197 | Collect an LSB from the table at 50432 | ||||||||||||||||||||||||||||||||||||||||||||||
60214 | LD A,(HL) | |||||||||||||||||||||||||||||||||||||||||||||||
60215 | SUB 2 | Subtract 2 from this LSB | ||||||||||||||||||||||||||||||||||||||||||||||
60217 | INC H | Point HL at an MSB in the table at 50688 | ||||||||||||||||||||||||||||||||||||||||||||||
60218 | LD H,(HL) | Pick up the MSB in H | ||||||||||||||||||||||||||||||||||||||||||||||
60219 | LD E,L | E=character's x-coordinate | ||||||||||||||||||||||||||||||||||||||||||||||
60220 | LD L,A | Now HL holds 2 less than the address formed by the LSB and MSB just collected from the tables at 50432 and 50688 | ||||||||||||||||||||||||||||||||||||||||||||||
The loop that iterates over the location descriptors for the character's x-coordinate begins here.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60221 | INC L | Move HL along the location descriptor table | ||||||||||||||||||||||||||||||||||||||||||||||
This entry point is used by the routine at 60720.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60222 | INC L | Point HL at the first byte of a location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60223 | JR Z,60229 | Jump if we reached a page boundary | ||||||||||||||||||||||||||||||||||||||||||||||
60225 | LD A,(HL) | Pick up the first byte (Q) of the location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60226 | INC A | Have we reached the end of the location descriptors for the character's x-coordinate? | ||||||||||||||||||||||||||||||||||||||||||||||
60227 | JR NZ,60234 | Jump if not | ||||||||||||||||||||||||||||||||||||||||||||||
The character is not at any of the locations to which the location descriptors for his x-coordinate correspond.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60229 | LD C,192 | Bits 7 and 6 set: the character can move left or right only | ||||||||||||||||||||||||||||||||||||||||||||||
60231 | LD A,2 | A=2: regular location | ||||||||||||||||||||||||||||||||||||||||||||||
60233 | RET | |||||||||||||||||||||||||||||||||||||||||||||||
Here we examine a location descriptor and check whether the character is at the location to which it corresponds.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60234 | DEC A | A=Q (the first byte of the location descriptor) | ||||||||||||||||||||||||||||||||||||||||||||||
60235 | INC L | Point HL at the second byte of the location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60236 | ADD A,A | Is bit 7 of Q set (meaning this location is next to the entrance to a building or requires special handling)? | ||||||||||||||||||||||||||||||||||||||||||||||
60237 | JR C,60246 | Jump if so | ||||||||||||||||||||||||||||||||||||||||||||||
60239 | CP B | Is the character at the location to which the location descriptor corresponds? | ||||||||||||||||||||||||||||||||||||||||||||||
60240 | JR NZ,60222 | Move along to the next location descriptor if not | ||||||||||||||||||||||||||||||||||||||||||||||
60242 | LD C,(HL) | C=second byte of the location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60243 | LD A,2 | A=2: regular location | ||||||||||||||||||||||||||||||||||||||||||||||
60245 | RET | |||||||||||||||||||||||||||||||||||||||||||||||
The location descriptor being examined has bit 7 of its first byte set, which means that it corresponds to a location that is next to the entrance to a building, or a location that requires special handling.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60246 | ADD A,A | Is bit 6 of Q set (meaning this location is next to the entrance to a building)? | ||||||||||||||||||||||||||||||||||||||||||||||
60247 | JR C,60258 | Jump if so | ||||||||||||||||||||||||||||||||||||||||||||||
60249 | CP B | Is the character at the location to which the location descriptor corresponds? | ||||||||||||||||||||||||||||||||||||||||||||||
60250 | JR NZ,60221 | Move along to the next location descriptor if not | ||||||||||||||||||||||||||||||||||||||||||||||
60252 | LD A,5 | A=5: this location requires special handling | ||||||||||||||||||||||||||||||||||||||||||||||
60254 | LD C,(HL) | Collect the second byte of the location descriptor in C | ||||||||||||||||||||||||||||||||||||||||||||||
60255 | INC L | Collect the third byte of the location descriptor in B | ||||||||||||||||||||||||||||||||||||||||||||||
60256 | LD B,(HL) | |||||||||||||||||||||||||||||||||||||||||||||||
60257 | RET | |||||||||||||||||||||||||||||||||||||||||||||||
The location descriptor being examined has bits 7 and 6 of its first byte set, which means that it corresponds to a location that is next to the entrance to a building.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60258 | LD C,B | C=4*(y-4) (where y is the character's y-coordinate) | ||||||||||||||||||||||||||||||||||||||||||||||
60259 | RES 7,C | |||||||||||||||||||||||||||||||||||||||||||||||
60261 | CP C | Is the character at the location to which the location descriptor corresponds? | ||||||||||||||||||||||||||||||||||||||||||||||
60262 | JR NZ,60221 | Move along to the next location descriptor if not | ||||||||||||||||||||||||||||||||||||||||||||||
The character is standing next to the entrance to a building. Check whether a closed door is in his way.
|
||||||||||||||||||||||||||||||||||||||||||||||||
60264 | INC L | Point HL at the third byte of the location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60265 | BIT 0,(HL) | Is there a door at this location? | ||||||||||||||||||||||||||||||||||||||||||||||
60267 | JR Z,60286 | Jump if not | ||||||||||||||||||||||||||||||||||||||||||||||
60269 | LD A,E | A=x, the character's x-coordinate | ||||||||||||||||||||||||||||||||||||||||||||||
60270 | INC A | A=INT((x+1)/8) | ||||||||||||||||||||||||||||||||||||||||||||||
60271 | RRCA | |||||||||||||||||||||||||||||||||||||||||||||||
60272 | RRCA | |||||||||||||||||||||||||||||||||||||||||||||||
60273 | RRCA | |||||||||||||||||||||||||||||||||||||||||||||||
60274 | AND 31 | |||||||||||||||||||||||||||||||||||||||||||||||
60276 | PUSH HL | Save the location descriptor pointer briefly | ||||||||||||||||||||||||||||||||||||||||||||||
60277 | LD L,A | Point HL at the entry in the table of Z values at 48384 that corresponds to the door | ||||||||||||||||||||||||||||||||||||||||||||||
60278 | LD H,189 | |||||||||||||||||||||||||||||||||||||||||||||||
60280 | BIT 2,(HL) | Set the zero flag if the door is open | ||||||||||||||||||||||||||||||||||||||||||||||
60282 | POP HL | Restore the location descriptor pointer to HL | ||||||||||||||||||||||||||||||||||||||||||||||
60283 | JP NZ,60720 | Jump if the door is closed to find the location descriptor that corresponds to the character's z-coordinate (1=behind the door, 2=in front of it) | ||||||||||||||||||||||||||||||||||||||||||||||
60286 | LD A,3 | A=3: the character is standing next to the open entrance to a building | ||||||||||||||||||||||||||||||||||||||||||||||
60288 | DEC L | Point HL at the second byte of the location descriptor | ||||||||||||||||||||||||||||||||||||||||||||||
60289 | JR 60254 | Jump back to collect the second and third bytes in C and B |
Prev: 60152 | Up: Map | Next: 60291 |