| Routines

27303: Deal with ERIC when he's been knocked over

Used by the routine at 27353 when bit 4 of ERIC's status flags at 32763 is set (by the routine at 28569, 27932 or 27543).
27303 | LD HL,32757 | 32757 holds the delay counter used when ERIC has been knocked over; pick up its value (0-40) in A
27306 | LD A,(HL)
27307 | AND A | Has ERIC just been struck (A=0)?
27308 | JR Z,27319 | Adjust his animatory state if so (and initialise the delay counter to 40)
27310 | DEC (HL) | Decrement the knockout delay counter
27311 | JP NZ,65111 | Make a knocked-out sound effect if ERIC's just been struck
The knockout delay counter at 32757 has reached zero, so ERIC can get up any time now.
27314 | LD L,251 | HL=32763 (ERIC's status flags)
27316 | LD (HL),128 | Set bit 7 (indicating that ERIC is sitting or lying down) and reset bit 4 (so that we don't visit this routine again)
27318 | RET |
ERIC has just been struck; decide whether he should be sitting on the floor or lying on his back, and adjust his animatory state accordingly.
27319 | LD (HL),40 | Initialise the knockout delay counter at 32757
27321 | LD L,233 | Set 32745 to 0, indicating that ERIC is not midstride
27323 | LD (HL),A
27324 | LD L,251 | HL=32763 (ERIC's status flags)
27326 | LD (HL),144 | Set bit 7 (indicating that ERIC is sitting or lying down) and keep bit 4 set (so that we visit this routine again)
27328 | LD H,172 | 172=ERIC
27330 | CALL 25108 | Update the SRB for ERIC's current location
27333 | CP 5 | 5=animatory state of ERIC sitting on a chair
27335 | JR Z,27341 | Jump if ERIC's sitting on a chair
27337 | AND 128 |
27339 | ADD A,6 |
27341 | INC A | A=6 (ERIC sitting on the floor) or 7/135 (ERIC lying on his back)
27342 | LD B,A | Store ERIC's new animatory state in B temporarily
27343 | LD A,D | A=ERIC's y-coordinate
27344 | CALL 31242 | Get the y-coordinate of the floor ERIC's on in D
27347 | LD A,B | Restore ERIC's new animatory state to A
27348 | JP 25008 | Update ERIC's animatory state and update the SRB