| Routines

30804: Deal with the frog when it has been knocked out of a cup

The address of this uninterruptible subcommand routine is placed into bytes 17 and 18 the frog's buffer by the routine at 30229 when a catapult pellet has knocked the frog out of a cup. It controls the frog up to the point where it hits the floor, and deals with any collision with MISS TAKE's head on the way.
30804 | LD A,(32747) | 32747 holds the inventory flags
30807 | RRCA | Has ERIC got the safe key already?
30808 | JR C,30889 | Jump if so
30810 | LD HL,52224 | Point HL at byte 0 of MISS TAKE's buffer
30813 | LD A,(HL) | A=MISS TAKE's animatory state
30814 | INC L | L=1
30815 | LD E,(HL) | E=MISS TAKE's x-coordinate
30816 | INC L | L=2
30817 | CP 118 | 118: Is MISS TAKE sitting on the floor facing left?
30819 | JR Z,30829 | Jump if so
30821 | CP 246 | 246: Is she sitting on the floor facing right?
30823 | LD A,252 | A=-4
30825 | JR NZ,30832 | Jump if not
30827 | DEC E |
30828 | DEC E |
30829 | INC E | Now E=x-coordinate the frog would have to be at to be in line with MISS TAKE's head as she sits on the floor
30830 | LD A,253 | A=-3
30832 | ADD A,(HL) | A=y-coordinate the frog would have to be at to be level with MISS TAKE's head
30833 | LD H,212 | 212=frog
30835 | CP (HL) | Compare with the frog's current y-coordinate
30836 | JR NZ,30889 | Jump if the frog has not reached the level of MISS TAKE's head
30838 | DEC L | L=1
30839 | LD A,(HL) | A=frog's x-coordinate
30840 | CP E | Compare with the x-coordinate of MISS TAKE's head
30841 | JR NZ,30889 | Jump if they don't match
ERIC's pellet has knocked the frog out of the cup and onto MISS TAKE's head. Celebrate! Your browser doesn't support HTML5 audio. Here is a link to the audio instead.
30843 | LD HL,32747 | 32747 holds the inventory flags
30846 | SET 0,(HL) | Give ERIC the safe key
30848 | LD A,200 | Add 2000 to the score and print it
30850 | CALL 29621
30853 | LD HL,768 | Make the safe-key-getting celebratory sound effect
30856 | LD D,1
30858 | LD A,L
30859 | AND 63
30861 | INC A
30862 | LD B,A
30863 | LD C,(HL)
30864 | SET 4,C
30866 | CALL 29836
30869 | DEC L
30870 | JR NZ,30856
30872 | NOP |
30873 | NOP
30874 | NOP
30875 | CALL 31746 | Print the inventory (which now includes the safe key)
30878 | LD H,212 | 212=frog
30880 | CALL 25012 | Update the SRB for the frog's current animatory state and location
30883 | DEC E | Move the frog one space to the left
30884 | INC A | A=29: frog facing left, airborne (phase 1)
30885 | INC D | Make the frog fall one level
30886 | JP 24880 | Update the frog's animatory state and location and update the SRB
The frog is still above the floor, but not in contact with MISS TAKE's head.
30889 | CALL 25012 | Update the SRB for the frog's current animatory state and location
30892 | BIT 4,D | Is the frog about to hit the floor (D=16)?
30894 | JR Z,30885 | Jump if not (to make it fall another level)
30896 | CP 28 | The frog's animatory state will be 29 if it bounced off MISS TAKE's head
30898 | LD A,28 | 28=frog sitting still, facing left
30900 | JR NZ,30886 | Jump if the frog bounced off MISS TAKE's head
30902 | INC D | D=17 (bottom floor)
This entry point is used by the routine at 30906.
30903 | CALL 30534 | Update the frog's animatory state and location and then resume control at 30906