Routines

25503: Redirect control of character to another routine temporarily


Used by several routines to redirect control of a game character from one routine to another temporarily

BC Address of routine to hand over temporary control to
H Character number (183-214)

25503 2E09 LD L,9 Place the address of the temporary control routine into bytes 9 and 10 of the character's buffer
25505 71 LD (HL),C
25506 2C INC L
25507 70 LD (HL),B
25508 7C LD A,H A=character number
25509 E1 POP HL Collect address of instruction after CALL 25503 into HL
25510 C5 PUSH BC Push address of temporary control routine onto the stack
25511 4D LD C,L
25512 2E03 LD L,3

This entry point is used by the routine at 25525 with L=9:
25514 44 LD B,H Now BC=address of instruction after CALL 25503/25525
25515 67 LD H,A H=character reference number

This entry point is used by the routine at 25520 with L=9:
25516 71 LD (HL),C Place the address in BC into bytes 3 and 4 (9 and 10) of the character's buffer (so control can be returned to it later)
25517 2C INC L
25518 70 LD (HL),B
25519 C9 RET Make an indirect jump to the temporary control routine