| Routines

FB03: Deal with ERIC when he's stepping off a plant, a plant pot, or the assembly hall stage

Used by the routine at F7AD when bit 2 at 7FED is set (by the routine at FAF2 or FB3C, or by this routine on the first pass through). On entry, bit 3 at 7FED is also set if ERIC is stepping out of an open window, over the closed skool gate, or off the assembly hall stage. On exit, ERIC's status flags at 7FED are set as follows:
Bit | Meaning
--- | ---
2 | ERIC has completed one step towards an open window, over the closed skool gate, or off the stage
3 | ERIC is now falling (but not from the top-floor window)
5 | ERIC is now falling out of the top-floor window
FB03 | LD HL,$7FF3 | 7FF3 holds ERIC's main action timer
FB06 | DEC (HL) | Is it time to deal with ERIC yet?
FB07 | RET NZ | Return if not
FB08 | LD (HL),$05 | Reset ERIC's main action timer to 5
FB0A | LD HL,$D200 | Point HL at byte 0x00 of ERIC' buffer
FB0D | BIT 0,(HL) | Is ERIC midstride?
FB0F | JR Z,$FAF7 | Make him so if not (with an accompanying sound effect)
FB11 | LD A,($7FED) | Set the zero flag if bit 3 of ERIC's secondary status flags at 7FED is also set
FB14 | CP $0C
FB16 | LD A,$04 | Set bit 2 (only) in A
FB18 | JR Z,$FB24 | Reset bit 3 at 7FED if ERIC has just stepped off a fully grown plant towards an open window or the closed skool gate, or just stepped off the stage
FB1A | INC L | L=0x01
FB1B | LD A,(HL) | A=ERIC's x-coordinate
FB1C | CP $5C | This is the x-coordinate of the plant pot on the top floor
FB1E | LD A,$20 | Set bit 5 in A
FB20 | JR Z,$FB24 | Jump if ERIC is going to fall from the top-floor window
FB22 | LD A,$08 | Set bit 3 in A
FB24 | LD ($7FED),A | Set the appropriate bit (2, 3 or 5) in ERIC's secondary status flags at 7FED
FB27 | CALL $7154 | Make a sound effect
FB2A | LD H,$D2 | 0xD2=ERIC
FB2C | CALL $61B4 | Update the SRB for ERIC's current animatory state and location
FB2F | INC A | A=ERIC's new animatory state (standing)
FB30 | AND $82
FB32 | DEC E | Decrement ERIC's x-coordinate
FB33 | BIT 7,A | Is ERIC facing left?
FB35 | JR Z,$FB39 | Jump if so
FB37 | INC E | Increment ERIC's x-coordinate (if he's facing right)
FB38 | INC E
FB39 | JP $6E0C | Update ERIC's animatory state and location, make a sound effect, and scroll the screen if necessary