| Routines

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

Called from the main loop at 63210 when ERIC is midstride or just about to finish an action (such as firing the water pistol or bending over to catch a mouse).
28160 | LD H,210 | 210=ERIC
28162 | CALL 25012 | Update the SRB for ERIC's current animatory state (midstride) and location
28165 | LD L,3 | A=ERIC's post-midstride/post-action animatory state
28167 | LD A,(HL)
28168 | INC L | Collect ERIC's post-midstride/post-action coordinates in DE
28169 | LD E,(HL)
28170 | INC L
28171 | LD D,(HL)
This entry point is used by the routines at 23808 and 64259 with H=210 (ERIC).
28172 | CALL 24880 | Update ERIC's animatory state and location and update the SRB
28175 | CALL 29012 | Make a sound effect
This entry point is used by the routine at 31723 with H=210 (ERIC).
28178 | LD L,0 | Point HL at byte 0 of ERIC's buffer
28180 | LD A,(32767) | A=leftmost column of the play area on screen
28183 | BIT 7,(HL) | Check the 'direction' bit of ERIC's animatory state
28185 | LD L,1 | Byte 1 of ERIC's buffer holds his x-coordinate
28187 | JR Z,28202 | Jump if ERIC's facing left
ERIC is facing right. Check whether the screen should be scrolled left.
28189 | CP 160 | Return if the whole of the girls' skool is on-screen (no need to scroll)
28191 | RET Z
28192 | 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
28193 | CP 235
28195 | RET NC
28196 | CALL 25248 | Update the display
28199 | JP 25026 | Scroll the screen to the left
ERIC is facing left. Check whether the screen should be scrolled right.
28202 | AND A | Is the far left wall of the boys' skool on-screen?
28203 | RET Z | Return if so (no need to scroll the screen)
28204 | SUB (HL) | Is ERIC more than 9 character spaces from the left edge of the screen?
28205 | CP 247
28207 | RET C | Return if so (no need to scroll the screen)
28208 | CALL 25248 | Update the display
28211 | JP 25080 | Scroll the screen to the right