| Routines

6500: Move ERIC from the midstride position and scroll the screen if necessary

Called from the main loop at 6767 when ERIC is midstride.
6500 | LD HL,$7FE9 | Set ERIC's midstride action timer at 7FE9 to 0 to indicate that ERIC will no longer be midstride after this movement
6503 | LD A,(HL)
6504 | LD (HL),$00
6506 | DEC L | Set ERIC's main action timer at 7FE8 equal to the previous contents of 7FE9
6507 | LD (HL),A
6508 | LD HL,$AC63 | Point HL at byte 0x63 of ERIC's buffer
650B | CALL $6214 | Update the SRB for ERIC's current location
650E | LD L,$63 | Pick up ERIC's next animatory state in A (from byte 0x63 of his buffer) and his next location in DE (from bytes 0x64 and 0x65)
6510 | LD A,(HL)
6511 | INC L
6512 | LD D,(HL)
6513 | INC L
6514 | LD E,(HL)
6515 | CALL $61B0 | Update ERIC's animatory state and location and update the SRB
6518 | CALL $6992 | Update the display
651B | CALL $FE52 | Make a walking sound effect
Decide whether the screen should be scrolled left or right.
651E | LD HL,$AC60 | Point HL at byte 0x60 of ERIC's buffer
6521 | LD A,($7F00) | A=X: leftmost column of the skool on screen (0-64)
6524 | BIT 7,(HL) | Is ERIC facing left?
6526 | LD L,$62 |
6528 | JR Z,$6533 | Jump if so
652A | CP $40 | Is the far right end of the skool on screen?
652C | RET Z | Return if so
652D | SUB (HL) | A=X-x (x=ERIC's x-coordinate)
652E | CP $EA | Is ERIC's screen x-coordinate 22?
6530 | RET NZ | Return if not
6531 | JR $64DC | Otherwise scroll the screen left 8 columns
6533 | AND A | Is the far left end of the skool on screen (X=0)?
6534 | RET Z | Return if so
6535 | SUB (HL) | A=X-x (x=ERIC's x-coordinate)
6536 | CP $F7 | Is ERIC's screen x-coordinate 9?
6538 | RET NZ | Return if not
6539 | JP $64D2 | Otherwise scroll the screen right 8 columns