| Routines

639F: Call an interruptible subcommand

Used by the routines at 6D00, 7CD0, 7CE1, 7EF1, F000, F05D, F073, F0BF, F100, F250 and F55F. Drops the return address from the stack and copies it into bytes 0x03 and 0x04 of the character's buffer (where the address of the primary command routine is held), copies the address of the interruptible subcommand routine from BC into bytes 0x09 and 0x0A of the character's buffer, and then jumps to that routine.
Input
BC | Interruptible subcommand routine address
H | Character number (0xB7-0xD6)
639F | LD L,$09 | Copy the routine address from BC into bytes 0x09 and 0x0A of the character's buffer
63A1 | LD (HL),C
63A2 | INC L
63A3 | LD (HL),B
63A4 | LD A,H | A=character number
63A5 | POP HL | Drop the return address from the stack into HL
63A6 | PUSH BC | Push the routine address in BC onto the stack
63A7 | LD C,L |
63A8 | LD L,$03 |
This entry point is used by the (unused) routine at 63B5 with L=0x09.
63AA | LD B,H | Now BC=address of the instruction after the CALL that got us here
63AB | LD H,A | H=character number
This entry point is used by the routine at 63B0 with L=0x09 and BC=63ED, 6438, 644D or F54A.
63AC | LD (HL),C | Copy the routine address in BC into bytes 0x03 and 0x04 (or 0x09 and 0x0A) of the character's buffer
63AD | INC L
63AE | LD (HL),B
63AF | RET | Make an indirect jump to the interruptible subcommand routine