| Routines

7B0E: Prepare character buffers for released mice

Used by the routine at 7AE6. Releases up to five mice from ERIC's pocket. Each mouse will use a character buffer at page 0xC6, 0xC7 or 0xCE-0xD0, provided that the character who usually occupies it is off-screen.
Input
DE | Coordinates at which to release the mice
7B0E | LD H,$C6 | Use buffers 0xC6 and 0xC7 (little boys nos. 9 and 10) for released mice if possible
7B10 | LD B,$02
7B12 | CALL $7B1A | Prepare these buffers
7B15 | RET Z | Return if ERIC has no mice left
7B16 | LD H,$CE | Also use buffers 0xCE-0xD0 (BOY WANDER, ANGELFACE and EINSTEIN) for released mice if possible
7B18 | LD B,$03
7B1A | LD L,$12 | Pick up the MSB of the uninterruptible subcommand routine address in bytes 0x11 and 0x12 of the character's buffer
7B1C | LD A,(HL)
7B1D | CP $7A | Does the MSB match that of 7A16?
7B1F | JR Z,$7B50 | Jump if so
7B21 | LD L,$01 | A=x-coordinate of the character using this buffer
7B23 | LD A,(HL)
7B24 | CP $8E | Is this character inside or close to the girls' skool?
7B26 | JR NC,$7B50 | Jump if so (we can't use his buffer)
7B28 | DEC L | L=0x00
7B29 | LD A,(HL) | A=character's animatory state
7B2A | LD L,$0F | Store this in byte 0x0F of the buffer for retrieval when the mouse dies
7B2C | LD (HL),A
7B2D | CALL $6291 | A=random number between 0x0A and 0x29; this determines the lifespan of the mouse
7B30 | AND $1F
7B32 | ADD A,$0A
7B34 | INC L | Store this lifespan parameter in byte 0x10 of the buffer
7B35 | LD (HL),A
7B36 | INC L | Place the address of the uninterruptible subcommand routine at 7A16 into bytes 0x11 and 0x12 of the character's buffer
7B37 | LD (HL),$16
7B39 | INC L
7B3A | LD (HL),$7A
7B3C | XOR A | Set bytes 0x13 and 0x14 to 0 so that the mouse is initially hidden (see 7A16 for details on how these bytes are used)
7B3D | INC L
7B3E | LD (HL),A
7B3F | INC L
7B40 | LD (HL),A
7B41 | INC L | Set byte 0x15 (time remaining before coming out of hiding) to 3, 2 or 1
7B42 | LD (HL),B
7B43 | INC L | Store the x-coordinate of the mouse in byte 0x16, so it appears there when it comes out of hiding
7B44 | LD (HL),E
7B45 | LD L,$02 | Store the y-coordinate in byte 0x02
7B47 | LD (HL),D
7B48 | LD A,($7FE1) | 7FE1 holds the number of mice ERIC has caught
7B4B | DEC A | One fewer now
7B4C | LD ($7FE1),A
7B4F | RET Z | Return if ERIC has no mice left
7B50 | INC H | Point to the next potential buffer for a released mouse
7B51 | DJNZ $7B1A | Jump back until all have been considered
7B53 | RET |