Prev: 7A6A Up: Map Next: 7AB5
7A82: Make a gangster chase and pick up Sam
Used by the routine at 6329. Makes a gangster start or continue chasing Sam if appropriate. Whether the gangster continues to chase Sam depends on Sam's and the gangster's locations relative to the two regions defined in the gangster's region definition table. If Sam has left the first region, the gangster gives up the chase and restarts his command list; if the gangster has already chased Sam to the boundary of the second region, he will stand on guard there; and if the gangster is close enough to Sam to pick him up, he will do so and move to the next command in the command list.
Input
H Gangster's character number (0xD7-0xE0)
7A82 CALL $61F2 Is the gangster close enough to Sam to pick him up?
7A85 JP C,$71DD Jump if so
7A88 CALL $F698 Exit now if the gangster is midstride
7A8B LD L,$17 Point HL at byte 0x17 of the gangster's buffer
7A8D LD E,(HL) Collect the command list start address in DE
7A8E INC L
7A8F LD D,(HL)
7A90 LD B,H B=gangster's character number
7A91 LD HL,$FFF6 Point HL at the relevant table of region definitions (FD0C, FD26, FD44, FD64 or FD7C)
7A94 ADD HL,DE
7A95 LD D,$E6 0xE6=Sam
7A97 CALL $738A Check whether Sam is inside the first region
7A9A LD D,B D=gangster's character number
7A9B EX DE,HL H=gangster's character number
7A9C JP C,$F6DE Restart the command list if Sam is outside the first region
7A9F EX DE,HL D=gangster's character number
7AA0 CALL $738A Check whether the gangster is inside the second region
7AA3 RET C Return if he's outside the second region
Sam is inside the first region, and the gangster hasn't reached the boundary of the second region, so the chase is still on.
7AA4 LD H,B H=gangster's character number
7AA5 CALL $7190 Set the gangster's destination to Sam's current location
7AA8 CALL $ED8C Determine the next move the gangster should make to reach Sam
7AAB CP $05 Is the gangster standing next to a closed door?
7AAD JP NC,$F67C Jump if so
7AB0 AND A Has the gangster reached his destination?
7AB1 RET Z Return if so
7AB2 JP $F63C Move the gangster one step closer to Sam
Prev: 7A6A Up: Map Next: 7AB5