| Routines

6E00: Move ERIC from the midstride or mid-action position and scroll the screen if necessary

Called from the main loop at F6EA when ERIC is midstride or just about to finish an action (such as firing the water pistol or bending over to catch a mouse).
6E00 | LD H,$D2 | 0xD2=ERIC
6E02 | CALL $61B4 | Update the SRB for ERIC's current animatory state (midstride) and location
6E05 | LD L,$03 | A=ERIC's post-midstride/post-action animatory state
6E07 | LD A,(HL)
6E08 | INC L | Collect ERIC's post-midstride/post-action coordinates in DE
6E09 | LD E,(HL)
6E0A | INC L
6E0B | LD D,(HL)
This entry point is used by the routines at 5D00 and FB03 with H=0xD2 (ERIC).
6E0C | CALL $6130 | Update ERIC's animatory state and location and update the SRB
6E0F | CALL $7154 | Make a sound effect
This entry point is used by the routine at 7BEB with H=0xD2 (ERIC).
6E12 | LD L,$00 | Point HL at byte 0x00 of ERIC's buffer
6E14 | LD A,($7FFF) | A=leftmost column of the play area on screen
6E17 | BIT 7,(HL) | Check the 'direction' bit of ERIC's animatory state
6E19 | LD L,$01 | Byte 0x01 of ERIC's buffer holds his x-coordinate
6E1B | JR Z,$6E2A | Jump if ERIC's facing left
ERIC is facing right. Check whether the screen should be scrolled left.
6E1D | CP $A0 | Return if the whole of the girls' skool is on-screen (no need to scroll)
6E1F | RET Z
6E20 | SUB (HL) | Return if ERIC is 1-21 spaces from the left edge of the screen (no need to scroll); note that this doesn't handle the case where ERIC's x-coordinate is 0, which is a bug
6E21 | CP $EB
6E23 | RET NC
6E24 | CALL $62A0 | Update the display
6E27 | JP $61C2 | Scroll the screen to the left
ERIC is facing left. Check whether the screen should be scrolled right.
6E2A | AND A | Is the far left wall of the boys' skool on-screen?
6E2B | RET Z | Return if so (no need to scroll the screen)
6E2C | SUB (HL) | Is ERIC more than 9 character spaces from the left edge of the screen?
6E2D | CP $F7
6E2F | RET C | Return if so (no need to scroll the screen)
6E30 | CALL $62A0 | Update the display
6E33 | JP $61F8 | Scroll the screen to the right