| Routines

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

The address of this uninterruptible subcommand routine is placed into bytes 0x11 and 0x12 the frog's buffer by the routine at 7615 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.
7854 | LD A,($7FEB) | 7FEB holds the inventory flags
7857 | RRCA | Has ERIC got the safe key already?
7858 | JR C,$78A9 | Jump if so
785A | LD HL,$CC00 | Point HL at byte 0x00 of MISS TAKE's buffer
785D | LD A,(HL) | A=MISS TAKE's animatory state
785E | INC L | L=0x01
785F | LD E,(HL) | E=MISS TAKE's x-coordinate
7860 | INC L | L=0x02
7861 | CP $76 | 0x76: Is MISS TAKE sitting on the floor facing left?
7863 | JR Z,$786D | Jump if so
7865 | CP $F6 | 0xF6: Is she sitting on the floor facing right?
7867 | LD A,$FC | A=-4
7869 | JR NZ,$7870 | Jump if not
786B | DEC E |
786C | DEC E |
786D | 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
786E | LD A,$FD | A=-3
7870 | ADD A,(HL) | A=y-coordinate the frog would have to be at to be level with MISS TAKE's head
7871 | LD H,$D4 | 0xD4=frog
7873 | CP (HL) | Compare with the frog's current y-coordinate
7874 | JR NZ,$78A9 | Jump if the frog has not reached the level of MISS TAKE's head
7876 | DEC L | L=0x01
7877 | LD A,(HL) | A=frog's x-coordinate
7878 | CP E | Compare with the x-coordinate of MISS TAKE's head
7879 | JR NZ,$78A9 | 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.
787B | LD HL,$7FEB | 7FEB holds the inventory flags
787E | SET 0,(HL) | Give ERIC the safe key
7880 | LD A,$C8 | Add 2000 to the score and print it
7882 | CALL $73B5
7885 | LD HL,$0300 | Make the safe-key-getting celebratory sound effect
7888 | LD D,$01
788A | LD A,L
788B | AND $3F
788D | INC A
788E | LD B,A
788F | LD C,(HL)
7890 | SET 4,C
7892 | CALL $748C
7895 | DEC L
7896 | JR NZ,$7888
7898 | NOP |
7899 | NOP
789A | NOP
789B | CALL $7C02 | Print the inventory (which now includes the safe key)
789E | LD H,$D4 | 0xD4=frog
78A0 | CALL $61B4 | Update the SRB for the frog's current animatory state and location
78A3 | DEC E | Move the frog one space to the left
78A4 | INC A | A=0x1D: frog facing left, airborne (phase 1)
78A5 | INC D | Make the frog fall one level
78A6 | JP $6130 | 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.
78A9 | CALL $61B4 | Update the SRB for the frog's current animatory state and location
78AC | BIT 4,D | Is the frog about to hit the floor (D=16)?
78AE | JR Z,$78A5 | Jump if not (to make it fall another level)
78B0 | CP $1C | The frog's animatory state will be 0x1D if it bounced off MISS TAKE's head
78B2 | LD A,$1C | 0x1C=frog sitting still, facing left
78B4 | JR NZ,$78A6 | Jump if the frog bounced off MISS TAKE's head
78B6 | INC D | D=17 (bottom floor)
This entry point is used by the routine at 78BA.
78B7 | CALL $7746 | Update the frog's animatory state and location and then resume control at 78BA