Routines |
Prev: 60334 | Up: Map | Next: 60504 |
|
||||||||||||||||||
60347 | CALL 60293 | Make the character stand up if he's lying down | ||||||||||||||||
60350 | RET C | Return if the character was lying down | ||||||||||||||||
60351 | BIT 7,(HL) | Set the zero flag if the character is facing left | ||||||||||||||||
60353 | LD DE,40985 | Point DE at the direction indicator table at 40985 | ||||||||||||||||
60356 | JR Z,60368 | Jump if the character is facing left | ||||||||||||||||
The character is facing right, so we make him turn round first. This entry point is also used by the routine at 60334 to make a character who is facing left turn round.
|
||||||||||||||||||
60358 | CALL 59848 | Update the SRB for the character's current animatory state and location | ||||||||||||||||
60361 | XOR 128 | Flip bit 7 of the character's animatory state, thus turning him round | ||||||||||||||||
This entry point is used by the routine at 60293.
|
||||||||||||||||||
60363 | CALL 59861 | Update the character's animatory state and location and update the SRB | ||||||||||||||||
60366 | SCF | Set the carry flag to indicate that the character was moved | ||||||||||||||||
60367 | RET | |||||||||||||||||
60368 | PUSH HL | Save the character buffer pointer briefly | ||||||||||||||||
60369 | PUSH DE | Save the pointer to the direction indicator table | ||||||||||||||||
60370 | CALL 60179 | Obtain descriptors for the character's current location | ||||||||||||||||
60373 | POP HL | Point HL at the direction indicator table (40985, 41241, 41496, 41752, 42008 or 42264) | ||||||||||||||||
60374 | LD E,A | E=location type indicator (1-5; see 60179) | ||||||||||||||||
60375 | LD A,C | A=direction descriptor (see 60179) | ||||||||||||||||
60376 | AND (HL) | Does this direction indicator correspond to a direction that is available at the character's current location? | ||||||||||||||||
60377 | JR NZ,60386 | Jump if so | ||||||||||||||||
60379 | INC L | Point HL at the next byte in the direction indicator table | ||||||||||||||||
60380 | BIT 2,L | Have we reached the end of the direction indicator table? | ||||||||||||||||
60382 | JR Z,60375 | Jump back if not | ||||||||||||||||
60384 | POP HL | Restore the character buffer pointer to HL | ||||||||||||||||
60385 | RET | Return with the carry flag reset (the character did not move) | ||||||||||||||||
Now A=128, 64, 32, 16, 8 or 4; the bit set in A indicates the direction in which the character has chosen to move next:
|
||||||||||||||||||
60386 | LD D,A | D=direction indicator (128, 64, 32, 16, 8 or 4) | ||||||||||||||||
60387 | POP HL | Restore the character buffer pointer to HL | ||||||||||||||||
60388 | BIT 7,(HL) | Set the zero flag if the character is facing left | ||||||||||||||||
60390 | LD A,84 | A=84: bits 6 (right), 4 (up/right) and 2 (down/right) set | ||||||||||||||||
60392 | JR NZ,60395 | Jump if the character is facing right | ||||||||||||||||
60394 | ADD A,A | A=168: bits 7 (left), 5 (up/left) and 3 (down/left) set | ||||||||||||||||
60395 | AND D | Is the character facing the direction in which he wants to move? | ||||||||||||||||
60396 | JR Z,60358 | Make him turn round if not | ||||||||||||||||
The character is facing the direction in which he wants to move. Now we examine the character's current location to determine whether the desired move requires any special handling.
|
||||||||||||||||||
60398 | LD L,4 | Point HL at byte 4 of the character's buffer | ||||||||||||||||
60400 | LD A,E | A=location type indicator for the character's current location (1-5; see 60179) | ||||||||||||||||
60401 | DEC A | Is the character on the sidewalk or the road? | ||||||||||||||||
60402 | JR NZ,60420 | Jump if not | ||||||||||||||||
The character is on the sidewalk or the road. In this case we need to check whether the character is going up a step, and change his z-coordinate accordingly.
|
||||||||||||||||||
60404 | LD A,D | A=direction indicator (128, 64, 32, 16, 8 or 4) | ||||||||||||||||
60405 | AND 48 | Check bits 4 and 5: is the character going to move up a step? | ||||||||||||||||
60407 | JR Z,60423 | Jump if not | ||||||||||||||||
60409 | RRCA | Slide bits 5 and 4 of A into bits 1 and 0 | ||||||||||||||||
60410 | RRCA | |||||||||||||||||
60411 | RRCA | |||||||||||||||||
60412 | RRCA | |||||||||||||||||
60413 | AND C | Will going up the step change the character's z-coordinate to 2? | ||||||||||||||||
60414 | JR Z,60423 | Jump if not | ||||||||||||||||
60416 | LD (HL),2 | Set the character's z-coordinate to 2 | ||||||||||||||||
60418 | JR 60423 | |||||||||||||||||
The character is not on the sidewalk or the road.
|
||||||||||||||||||
60420 | RRCA | Is the location type indicator 3 (at the open entrance to a building) or 5 (a location that requires special handling)? | ||||||||||||||||
60421 | JR NC,60473 | Jump if so | ||||||||||||||||
Finally we can move the character midstride in the desired direction and update the SRB accordingly. This entry point is used by the routines at 31580 and 64512. The address of this entry point is also found at 40982; it is used to handle a character who is moving from one of a set of certain special locations, but it does not actually do anything special.
|
||||||||||||||||||
60423 | LD L,0 | Point HL at byte 0 of the character's buffer | ||||||||||||||||
60425 | LD C,5 | Point BC at byte 5 of the character's buffer | ||||||||||||||||
60427 | LD B,H | |||||||||||||||||
60428 | LD A,(HL) | A=character's animatory state | ||||||||||||||||
60429 | XOR 2 | A=character's post-midstride animatory state | ||||||||||||||||
60431 | LD (BC),A | Save this in byte 5 of the character's buffer | ||||||||||||||||
60432 | INC L | Point HL at byte 1 of the character's buffer | ||||||||||||||||
60433 | INC C | Point BC at byte 6 of the character's buffer | ||||||||||||||||
60434 | RLCA | A=-1 if the character is facing left, 1 if he's facing right | ||||||||||||||||
60435 | SBC A,A | |||||||||||||||||
60436 | ADD A,A | |||||||||||||||||
60437 | CPL | |||||||||||||||||
60438 | ADD A,(HL) | Add the character's current x-coordinate to obtain his post-midstride x-coordinate | ||||||||||||||||
60439 | LD (BC),A | Save this in byte 6 of the character's buffer | ||||||||||||||||
60440 | INC L | Point HL at byte 2 of the character's buffer | ||||||||||||||||
60441 | INC C | Point BC at byte 7 of the character's buffer | ||||||||||||||||
60442 | LD A,D | A=direction indicator (128, 64, 32, 16, 8 or 4) | ||||||||||||||||
60443 | AND 60 | Is the character going up or down a step? | ||||||||||||||||
60445 | JR Z,60454 | Jump if not | ||||||||||||||||
60447 | AND 48 | Is the character going up a step? | ||||||||||||||||
60449 | JR Z,60453 | Jump if not | ||||||||||||||||
60451 | LD A,254 | A=-2 | ||||||||||||||||
60453 | INC A | A=-1 if the character is going up a step, or 1 if he's going down a step | ||||||||||||||||
60454 | ADD A,(HL) | Add the character's y-coordinate; now the carry flag is set if the character will be going up a step | ||||||||||||||||
60455 | LD L,0 | Point HL at byte 0 of the character's buffer | ||||||||||||||||
60457 | LD (BC),A | Save the character's post-midstride y-coordinate in byte 7 of his buffer | ||||||||||||||||
60458 | LD A,(HL) | A=character's animatory state | ||||||||||||||||
60459 | PUSH AF | Save the carry flag briefly | ||||||||||||||||
60460 | CALL 59848 | Update the SRB for the character's current animatory state and location | ||||||||||||||||
60463 | POP AF | Restore the carry flag | ||||||||||||||||
60464 | JR NC,60467 | Jump unless the character is going up a step | ||||||||||||||||
60466 | DEC D | D=character's new y-coordinate | ||||||||||||||||
60467 | INC A | A=character's new animatory state | ||||||||||||||||
60468 | CALL 59861 | Update the character's animatory state and location and update the SRB | ||||||||||||||||
60471 | SCF | Set the carry flag to indicate that the character was moved | ||||||||||||||||
60472 | RET | |||||||||||||||||
The location type indicator is 3 (at the open entrance to a building) or 5 (a location that requires special handling).
|
||||||||||||||||||
60473 | RRCA | Is the location type indicator 5 (a location that requires special handling)? | ||||||||||||||||
60474 | JR NC,60485 | Jump if so | ||||||||||||||||
The character is standing at the open entrance to a building.
|
||||||||||||||||||
60476 | DEC (HL) | Set the zero flag if the character is indoors | ||||||||||||||||
60477 | LD (HL),1 | Set the character's z-coordinate to 1 (indoors) | ||||||||||||||||
60479 | LD A,D | A=direction indicator (128, 64, 32, 16, 8 or 4) | ||||||||||||||||
60480 | CALL 30396 | Adjust the character's z-coordinate according to whether he is going to enter or exit the building, and, if dealing with Sam, check whether he is entering a house without a key | ||||||||||||||||
60483 | JR 60423 | Move the character midstride | ||||||||||||||||
The character is at a location that may require special handling depending on the direction in which he is going.
|
||||||||||||||||||
60485 | LD A,D | A=direction indicator (128, 64, 32, 16, 8 or 4) | ||||||||||||||||
60486 | RLCA | Move bits 7 (left) and 6 (right) into bits 1 and 0 for comparison with bits 1 and 0 of the direction descriptor in C | ||||||||||||||||
60487 | RLCA | |||||||||||||||||
60488 | AND C | Is the character moving in a direction that requires special handling (e.g. off the edge of a roof)? | ||||||||||||||||
60489 | JR Z,60423 | Jump if not to move the character midstride | ||||||||||||||||
The character's next move requires special handling.
|
||||||||||||||||||
60491 | LD A,B | A=Q'', the third byte of the location descriptor (1-7; see 60179) | ||||||||||||||||
60492 | ADD A,159 | A=160-166 | ||||||||||||||||
60494 | PUSH HL | Save the character number briefly | ||||||||||||||||
60495 | LD H,A | Collect in HL the special location handler routine address (31580, 60423 or 64338) from 40982, 41238, 41494, 41750, 42006, 42262 or 42518 | ||||||||||||||||
60496 | LD L,22 | |||||||||||||||||
60498 | LD A,(HL) | |||||||||||||||||
60499 | INC L | |||||||||||||||||
60500 | LD H,(HL) | |||||||||||||||||
60501 | LD L,A | |||||||||||||||||
60502 | EX (SP),HL | Restore the character number to H, and copy the special location handler routine address onto the stack | ||||||||||||||||
60503 | RET | To 31580 (if Q''=7), 60423 (Q''=1) or 64338 (Q''=2, 3, 4, 5 or 6) |
Prev: 60334 | Up: Map | Next: 60504 |