A | Value from descent table (see 64460) |
B | 0 if ERIC's facing left, 128 if facing right |
C | Same as A |
D | ERIC's y-coordinate |
E | ERIC's x-coordinate |
23808 | E60F | AND 15 | Retain only bits 0-3 |
23810 | 80 | ADD A,B | Now A=ERIC's new animatory state |
23811 | 47 | LD B,A | Store this in B for now |
23812 | 79 | LD A,C | Retrieve descent table data byte from C |
23813 | 07 | RLCA | Is ERIC ascending (bit 7 of C set)? |
23814 | 3001 | JR NC,23817 | Jump if not |
23816 | 15 | DEC D | Move ERIC up a level |
23817 | 07 | RLCA | Is ERIC descending (bit 6 of C set)? |
23818 | 3001 | JR NC,23821 | Jump if not |
23820 | 14 | INC D | Move ERIC down a level |
23821 | 07 | RLCA | Must ERIC move forward one space (bit 5 of C set)? |
23822 | 3005 | JR NC,23829 | Jump if not |
23824 | CB78 | BIT 7,B | Is ERIC facing right? |
23826 | 200A | JR NZ,23838 | Jump if so |
23828 | 1D | DEC E | |
23829 | 07 | RLCA | Must ERIC move backwards one space (bit 4 of C set)? |
23830 | 3007 | JR NC,23839 | Jump if not |
23832 | 1D | DEC E | |
23833 | CB78 | BIT 7,B | Is ERIC facing right? |
23835 | 2002 | JR NZ,23839 | Jump if so |
23837 | 1C | INC E | |
23838 | 1C | INC E | Now E=ERIC's new x-coordinate, D=ERIC's new y-coordinate |
23839 | 78 | LD A,B | A = ERIC's new animatory state |
23840 | C30C6E | JP 28172 | Update SRB for ERIC's new animatory state and location, make sound effect, and scroll screen if necessary |