| Routines

5D00: Deal with ERIC while he's falling (2)

Continues from FBCC.
Input
A | Descent table entry (see FBCC)
B | 0x00 if ERIC's facing left, 0x80 if he's facing right
C | Same as A
D | ERIC's y-coordinate
E | ERIC's x-coordinate
H | 0xD2 (ERIC)
5D00 | AND $0F | Retain only bits 0-3 (the animatory state)
5D02 | ADD A,B | Now A=ERIC's new animatory state
5D03 | LD B,A | Store this in B for now
5D04 | LD A,C | A=descent table entry
5D05 | RLCA | Is ERIC ascending (bit 7 of C set)?
5D06 | JR NC,$5D09 | Jump if not
5D08 | DEC D | Move ERIC up a level
5D09 | RLCA | Is ERIC descending (bit 6 of C set)?
5D0A | JR NC,$5D0D | Jump if not
5D0C | INC D | Move ERIC down a level
5D0D | RLCA | Should ERIC move forward one space (bit 5 of C set)?
5D0E | JR NC,$5D15 | Jump if not
5D10 | BIT 7,B | Is ERIC facing right?
5D12 | JR NZ,$5D1E | Jump if so
5D14 | DEC E |
5D15 | RLCA | Should ERIC move backwards one space (bit 4 of C set)?
5D16 | JR NC,$5D1F | Jump if not
5D18 | DEC E |
5D19 | BIT 7,B | Is ERIC facing right?
5D1B | JR NZ,$5D1F | Jump if so
5D1D | INC E |
5D1E | INC E | Now E=ERIC's new x-coordinate, D=ERIC's new y-coordinate
5D1F | LD A,B | A=ERIC's new animatory state
5D20 | JP $6E0C | Update ERIC's animatory state and location, update the SRB make a sound effect, and scroll the screen if necessary