| Routines

5F1C: 'K' pressed - kiss

The address of this routine is found in the table of keypress handling routines at E550. It is called from the main loop at F6EA when 'K' is pressed.
Input
A | ERIC's animatory state
D | ERIC's y-coordinate
E | ERIC's x-coordinate
5F1C | LD HL,$D100 | Point HL at byte 0x00 of HAYLEY's buffer
5F1F | XOR (HL) | Are ERIC and HAYLEY facing the same way?
5F20 | RLCA
5F21 | JR NC,$5F3A | Jump if so
5F23 | BIT 2,(HL) | Is HAYLEY standing up?
5F25 | JR NZ,$5F3A | Jump if not
5F27 | LD A,(HL) | A=HAYLEY's animatory state
5F28 | RLCA | A=x-coordinate of the position two spaces in front of HAYLEY
5F29 | SBC A,A
5F2A | ADD A,A
5F2B | CPL
5F2C | ADD A,A
5F2D | INC L
5F2E | ADD A,(HL)
5F2F | CP E | Does ERIC's x-coordinate match this?
5F30 | JR NZ,$5F3A | Jump if not
5F32 | INC L | L=0x02
5F33 | LD A,(HL) | A=HAYLEY's y-coordinate
5F34 | SUB D | Jump if ERIC's y-coordinate does not match HAYLEY's, or ERIC has used up all his kisses
5F35 | JR NZ,$5F3A
5F37 | LD L,$12 | Set the zero flag if there is no uninterruptible subcommand routine address in HAYLEY's buffer (A=0)
5F39 | CP (HL)
At this point the zero flag is set if HAYLEY is kissable (i.e. ERIC and HAYLEY are standing and facing each other at close proximity, and ERIC hasn't already used up all his kisses), and reset otherwise.
5F3A | LD A,$01 | 0x01: ERIC midstride
5F3C | LD HL,$D224 | At D224 lies a RET instruction
5F3F | JP NZ,$E12A | Jump if HAYLEY is not kissable at this time
5F42 | LD A,($7FE2) | 7FE2 holds HAYLEY's kiss counter
5F45 | AND A | Has ERIC used up all his kisses?
5F46 | JR NZ,$5F4B | Jump if not
5F48 | LD HL,$5F08 | 5F08: hit ERIC
5F4B | LD ($D111),HL | Place the appropriate uninterruptible subcommand routine address (5F08: hit ERIC, or D224: do nothing) into bytes 0x11 and 0x12 of HAYLEY's buffer
5F4E | JR Z,$5F34 | Make HAYLEY hit ERIC if he's used up all his kisses
ERIC has scored a kiss.
5F50 | SUB $07 | Subtract 7 from the kiss counter
5F52 | JR NC,$5F55 | Jump if that doesn't take it below zero
5F54 | XOR A | Set it to zero otherwise
5F55 | LD ($7FE2),A | Store the new kiss count at 7FE2
5F58 | LD HL,($7FE7) | 7FE7 holds the lines total (divided by 10)
5F5B | LD BC,$FF9C | BC=-100
5F5E | XOR A |
5F5F | ADD HL,BC | Subtract 1000 from the lines total
5F60 | JR C,$5F64 | Jump if the lines total (in HL) is still positive
5F62 | LD H,A | Otherwise set HL=0
5F63 | LD L,A
5F64 | LD ($7FE7),HL | Decrease ERIC's lines total by 1000 (or to 0)
5F67 | CALL $73CB | Print the number of lines
5F6A | LD H,$D1 | 0xD1=HAYLEY
5F6C | CALL $61B4 | Update the SRB for HAYLEY's current animatory state and location
5F6F | LD L,$14 | Save HAYLEY's current animatory state in byte 0x14 of her buffer for later retrieval
5F71 | LD (HL),A
5F72 | DEC L | Save HAYLEY's current x-coordinate in byte 0x13 of her buffer for later retrieval
5F73 | LD (HL),E
5F74 | LD L,$01 | Set HAYLEY's x-coordinate to 224 (out of sight) briefly
5F76 | LD (HL),$E0
5F78 | LD H,$D2 | 0xD2=ERIC
5F7A | CALL $61B4 | Update the SRB for ERIC's current animatory state and location
5F7D | LD L,$01 | Point HL at byte 0x01 of ERIC's buffer
5F7F | RLCA | Is ERIC facing right (bit 7 set)?
5F80 | JR C,$5F84 | Jump if so
5F82 | DEC (HL) |
5F83 | DEC (HL) |
5F84 | INC (HL) | Move ERIC one space forward for the snog (which pushes ERIC through the closed skool gate if he kisses HAYLEY from behind it; this is a bug)
5F85 | LD A,$0F | 0x0F: ERIC and HAYLEY kissing
5F87 | CALL $5EB7 | Adjust ERIC's animatory state, update the SRB, and return to 5F8A (below) next time
5F8A | CALL $F3C4 | Make a sound effect
5F8D | LD HL,$D113 | Point HL at byte 0x13 of HAYLEY's buffer
5F90 | LD E,(HL) | Pick up HAYLEY's pre-kiss x-coordinate in E
5F91 | LD L,$02 | Point HL at byte 0x02 of HAYLEY's buffer
5F93 | LD D,(HL) | D=HAYLEY's y-coordinate
5F94 | CALL $77BD | Restore HAYLEY's pre-kiss coordinates and animatory state and update the SRB
5F97 | LD H,$D2 | 0xD2=ERIC
5F99 | JP $5EE2 | Detach ERIC from HAYLEY's embrace