| Routines

31462: Release some mice (if possible)

The address of this routine is placed into 32727 by the routine at 57893. It releases up to five mice, depending on (a) how many ERIC has caught, and (b) the availability of character buffers 198 and 199 (little boys 9 and 10) and 206-208 (BOY WANDER, ANGELFACE and EINSTEIN).
Input
H | 210 (ERIC)
31462 | LD A,(32767) | A=leftmost column of the play area on screen
31465 | CP 144 | Is at least half of the girls' skool on-screen?
31467 | RET C | Return if not
31468 | LD A,(32737) | 32737 holds the number of mice ERIC has caught
31471 | AND A | Has ERIC caught any mice?
31472 | RET Z | Return if not
31473 | PUSH HL |
31474 | PUSH AF | Save the number of captive mice
31475 | LD L,2 | Collect ERIC's coordinates in DE
31477 | LD D,(HL)
31478 | DEC L
31479 | LD E,(HL)
31480 | INC E | E=x-coordinate of the spot in front of ERIC (if he's facing right)
31481 | DEC L | L=0
31482 | BIT 7,(HL) | Is ERIC facing right?
31484 | JR NZ,31488 | Jump if so
31486 | DEC E | E=x-coordinate of the spot in front of ERIC (if he's facing left)
31487 | DEC E
31488 | CALL 31502 | Release up to five mice at the spot in front of ERIC
31491 | POP AF | A=number of mice ERIC had before trying to release some
31492 | LD HL,32737 | 32737 holds the number of mice ERIC has left
31495 | CP (HL) | Set the zero flag if ERIC couldn't release any mice
31496 | LD A,(HL) | A=number of mice left in ERIC's pocket
31497 | CALL NZ,31682 | Print these in the inventory
31500 | POP HL |
31501 | RET |