| Routines

F7AD: Deal with ERIC

Used by the routine at F6EA. Deals with ERIC when any of the bits at 7FFB (ERIC's primary status flags) are set, indicating that ERIC is doing something other than standing or walking:
Bit | Set by | Meaning if set | Handler
--- | --- | --- | ---
0 | 5D4F | ERIC is jumping | 5D63
1 | 5D63, 6E91, 7386 | Examine the secondary status flags at 7FED |
2 | F28E, F3D7, FBCC | ERIC is sitting or lying down | F2E2
3 | E125 | ERIC is bending over, dropping a stinkbomb etc. | E145
4 | 5E45 | ERIC is writing on a blackboard | 5E6F
5 | 5EB7 | ERIC is firing, hitting or kissing | 5EAD
6 | F55F, FBCC | MR WACKER is expelling ERIC |
7 | 663F, 74C8 | ERIC has been knocked over | F28E
If bit 1 at 7FFB is set, we examine ERIC's secondary status flags at 7FED:
Bit | Set by | Meaning if set | Handler
--- | --- | --- | ---
0 | 7316 | ERIC is riding the bike | 725E
1 | 5D63 | ERIC is standing on a plant or plant pot | FB3C
2 | FAF2, FB03, FB3C | ERIC is stepping off a plant, a plant pot, or the stage | FB03
3 | FB03, FB3C | ERIC is falling and will land on his feet | FBA0
4 | 720A, 725E, FA4D | ERIC is falling and will not land on his feet | FBCC
5 | FB03 | ERIC has stepped out of the top-floor window | 5D33
6 | 720A | ERIC is falling from the saddle of the bike | 5D23
7 | 725E | ERIC is standing on the saddle of the bike | 7316
Input
H | 0x7F
F7AD | LD L,$ED | HL=7FED (ERIC's secondary status flags)
F7AF | BIT 5,(HL) | Has ERIC stepped out of the top-floor window?
F7B1 | JR Z,$F7BA | Jump if not
F7B3 | LD A,($D200) | A=ERIC's animatory state
F7B6 | CP $86 | 0x86: Is ERIC lying on his back, facing right?
F7B8 | JR NZ,$F7C7 | Jump if not
F7BA | LD L,$FB | HL=7FFB (ERIC's status flags)
F7BC | BIT 6,(HL) | Is MR WACKER expelling ERIC?
F7BE | RET NZ | Return if so (ERIC is incapacitated)
F7BF | BIT 1,(HL) | Bit 1 at 7FFB is set if we need to look at 7FED
F7C1 | LD D,$D3 |
F7C3 | JR Z,$F7C9 | Jump unless we need to look at 7FED
F7C5 | LD L,$ED | HL=7FED (ERIC's secondary status flags)
F7C7 | LD D,$D5 |
F7C9 | LD A,(HL) | Copy the contents of 7FFB or 7FED to A
Now D=0xD3 and A=(7FFB) if bit 1 at 7FFB is reset; otherwise D=0xD5 and A=(7FED).
F7CA | LD E,$44 | Point DE at the appropriate entry in the table of handler routine address LSBs (at D33C or D53C), depending on which bit of A is set
F7CC | DEC E
F7CD | RRCA
F7CE | JR NC,$F7CC
F7D0 | EX DE,HL | Transfer the table entry address to HL
F7D1 | LD E,(HL) | Collect the handler routine address from the table entry into DE
F7D2 | INC H
F7D3 | LD D,(HL)
F7D4 | EX DE,HL | Transfer this handler routine address to HL
F7D5 | JP (HL) | Jump to the handler routine