| Routines

7AE6: Release some mice (if possible)

The address of this routine is placed into 7FD7 by the routine at E225. It releases up to five mice, depending on (a) how many ERIC has caught, and (b) the availability of character buffers 0xC6 and 0xC7 (little boys 9 and 10) and 0xCE-0xD0 (BOY WANDER, ANGELFACE and EINSTEIN).
Input
H | 0xD2 (ERIC)
7AE6 | LD A,($7FFF) | A=leftmost column of the play area on screen
7AE9 | CP $90 | Is at least half of the girls' skool on-screen?
7AEB | RET C | Return if not
7AEC | LD A,($7FE1) | 7FE1 holds the number of mice ERIC has caught
7AEF | AND A | Has ERIC caught any mice?
7AF0 | RET Z | Return if not
7AF1 | PUSH HL |
7AF2 | PUSH AF | Save the number of captive mice
7AF3 | LD L,$02 | Collect ERIC's coordinates in DE
7AF5 | LD D,(HL)
7AF6 | DEC L
7AF7 | LD E,(HL)
7AF8 | INC E | E=x-coordinate of the spot in front of ERIC (if he's facing right)
7AF9 | DEC L | L=0x00
7AFA | BIT 7,(HL) | Is ERIC facing right?
7AFC | JR NZ,$7B00 | Jump if so
7AFE | DEC E | E=x-coordinate of the spot in front of ERIC (if he's facing left)
7AFF | DEC E
7B00 | CALL $7B0E | Release up to five mice at the spot in front of ERIC
7B03 | POP AF | A=number of mice ERIC had before trying to release some
7B04 | LD HL,$7FE1 | 7FE1 holds the number of mice ERIC has left
7B07 | CP (HL) | Set the zero flag if ERIC couldn't release any mice
7B08 | LD A,(HL) | A=number of mice left in ERIC's pocket
7B09 | CALL NZ,$7BC2 | Print these in the inventory
7B0C | POP HL |
7B0D | RET |