Routines

31573: Make ERIC catch a mouse or frog (if present)


The address of this routine is placed in 32727 by the routine at 57637 after 'C' has been pressed

H 210 (ERIC)

31573 2E00 LD L,0
31575 7E LD A,(HL) A=ERIC's animatory state
31576 07 RLCA
31577 9F SBC A,A
31578 87 ADD A,A
31579 2F CPL
31580 2C INC L
31581 86 ADD A,(HL) Now A=x-coordinate of spot in front of ERIC
31582 2C INC L
31583 ED5B01D4 LD DE,(54273) Pick up bytes 1 and 2 of buffer 212
31587 BB CP E Is there a mouse/frog at this x-coordinate?
31588 C0 RET NZ Return if not
31589 7E LD A,(HL) A=ERIC's y-coordinate
31590 BA CP D Is there a mouse/frog on this floor?
31591 C0 RET NZ Return if not
31592 3A00D4 LD A,(54272) Pick up the mouse/frog's animatory state
31595 E67F AND 127 Discard all but the "direction" bit (bit 7)
31597 FE2F CP 47 47: Is it a mouse?
31599 C2F57B JP NZ,31733 Jump if not
31602 26D4 LD H,212 H=212 (the mouse's buffer)
31604 CDB461 CALL 25012 Update SRB for mouse's current animatory state and location
31607 21FF7F LD HL,32767
31610 CD9162 CALL 25233 Collect a random number in A
31613 E607 AND 7 0≤A≤7
31615 57 LD D,A
31616 FE02 CP 2
31618 3008 JR NC,31628
31620 7E LD A,(HL) A=column of play area at far left of screen
31621 07 RLCA
31622 38F2 JR C,31610
31624 2EAA LD L,170 170=possible x-coordinate for new free mouse
31626 1817 JR 31651
31628 FE05 CP 5
31630 7E LD A,(HL) A=column of play area at far left of screen
31631 300C JR NC,31645
31633 FE38 CP 56
31635 2E58 LD L,88 88=possible x-coordinate for new free mouse
31637 380C JR C,31651
31639 FE68 CP 104
31641 38DF JR C,31610
31643 1806 JR 31651
31645 2E0A LD L,10 10=possible x-coordinate for new free mouse
31647 FE38 CP 56
31649 38D7 JR C,31610
31651 7A LD A,D
31652 D603 SUB 3
31654 30FC JR NC,31652
31656 C603 ADD A,3
31658 2611 LD H,17 17=possible y-coordinate for new free mouse (bottom floor)
31660 2807 JR Z,31669
31662 3D DEC A
31663 260A LD H,10 10=possible y-coordinate for new free mouse (middle floor)
31665 2802 JR Z,31669
31667 2603 LD H,3 3=possible y-coordinate for new free mouse (top floor)
31669 2201D4 LD (54273),HL Fill in location of new free mouse
31672 3E0A LD A,10
31674 CD1871 CALL 28952 Add 100 to score, print it and make sound effect
31677 21E17F LD HL,32737
31680 34 INC (HL) Add 1 to number of mice caught
31681 7E LD A,(HL)

Now it's time to update the mouse inventory. This entry point is used by the routine at 31462.
31682 3AE17F LD A,(32737) A=number of mice caught
31685 4F LD C,A
31686 2EA8 LD L,168
31688 79 LD A,C
31689 A7 AND A
31690 0608 LD B,8
31692 2650 LD H,80
31694 2006 JR NZ,31702
31696 77 LD (HL),A Blank out a spot in the mouse inventory
31697 24 INC H
31698 10FC DJNZ 31696
31700 180A JR 31712
31702 11E09F LD DE,40928 Point to start of graphic data for captured mouse
31705 0D DEC C
31706 1A LD A,(DE) Display a captured mouse in the inventory
31707 77 LD (HL),A
31708 24 INC H
31709 1C INC E
31710 10FA DJNZ 31706
31712 2C INC L
31713 CB65 BIT 4,L
31715 28E3 JR Z,31688
31717 26D2 LD H,210 210=ERIC
31719 C9 RET