Routines
 Prev: 64416 Up: Map Next: 64560
64460: Deal with ERIC while he's falling (1)
Used by the routine at 63405 when bit 4 at 32749 is set (by the routine at 29194, 29278 or 64077). On entry, bit 6 at 32749 is also set if ERIC has already begun his descent (i.e. we've already made the first pass through this routine).
64460 LD HL,32749 32749 holds ERIC's secondary status flags
64463 BIT 6,(HL) Has ERIC already begun his descent?
64465 JR NZ,64513 Jump if so
ERIC has not begun his descent yet, which means we need to figure out what his trajectory will be first.
64467 LD H,210 210=ERIC
64469 CALL 25012 Update the SRB for ERIC's current animatory state and location
64472 AND 128 A=0 if ERIC's facing left, 128 if facing right
This entry point is used by the routine at 29462 when ERIC has jumped from the saddle of the bike (with A=2 or 130, and D holding the y-coordinate of the spot above ERIC's hand).
64474 LD B,A Now B=0 (or 2) if ERIC's facing left, 128 (or 130) if facing right
64475 LD A,D A=y-coordinate of ERIC (or the spot above his hand)
64476 CP 17 Is ERIC on the bottom floor?
64478 JR NZ,64482 Jump if not
64480 DEC D D=16
64481 DEC A A=16
64482 ADD A,4 Set A=-7+(y-3)%7 if y<17, or -1 if y=17 (where y is ERIC's y-coordinate); this is the distance (negated) left to travel till ERIC reaches the floor
64484 SUB 7
64486 JR NC,64484
64488 ADD A,166 A=159-165 (normal descent table entry pointer)
64490 PUSH AF Save this briefly
64491 LD A,5 Now A=animatory state of ERIC sitting on the floor (5/133) or with his arm up (7/135)
64494 CALL 24880 Update ERIC's animatory state and location and update the SRB
64497 POP AF Restore the normal descent table entry pointer to A
64498 LD H,A Point HL at the appropriate entry (H=159-165) in the normal descent table (L=252) for ERIC's current height above the floor
64499 LD L,252
This entry point is used by the routines at 23843 (with H=159, L=253 or 254) and 23859 (with H=159, L=255).
64501 LD (32727),HL Store the descent table pointer at 32727
64504 LD HL,32749 32749 holds ERIC's secondary status flags
64507 LD (HL),80 Set bits 4 (ERIC is still falling) and 6 (ERIC has begun his descent)
64509 LD L,243 Set ERIC's main action timer at 32755 to 7
64511 LD (HL),7
Deal with the next phase of ERIC's descent.
64513 LD L,243 HL=32755 (which holds ERIC's main action timer)
64515 DEC (HL) Is it time to deal with ERIC yet?
64516 RET NZ Return if not
64517 LD (HL),3 Reset ERIC's action timer to 3
64519 LD L,216 HL=32727 (which holds the descent table pointer)
64521 INC (HL) Collect the descent table pointer into DE
64522 LD D,(HL)
64523 DEC L
64524 LD E,(HL)
64525 LD A,(DE) Pick up an entry from the descent table in A
64526 AND A Has ERIC landed yet?
64527 JR NZ,64546 Jump if not
ERIC has landed. Time to set ERIC's status flags at 32763 and 32749 appropriately.
64529 LD L,251 HL=32763 (ERIC's main status flags)
64531 INC D Collect the first set of flags from the descent table
64532 LD A,(DE)
64533 LD (HL),A Copy them into 32763
64534 INC D Collect the second set of flags from the descent table
64535 LD A,(DE)
64536 LD L,237 Copy them into 32749
64538 LD (HL),A
64539 AND A Did ERIC jump from the top floor window (bit 5 set)?
64540 CALL NZ,62770 Set MR WACKER on his way to expel ERIC if so
64543 JP 62147 Make a sound effect for ERIC's landing
ERIC hasn't landed yet. Determine his next move through the air.
64546 PUSH AF Save the descent table entry briefly
64547 LD H,210 210=ERIC
64549 CALL 25012 Update the SRB for ERIC's current animatory state and location
64552 AND 128 B=0 if ERIC's facing left, 128 if facing right
64554 LD B,A
64555 POP AF Restore the descent table entry to A
64556 LD C,A Copy it to C
64557 JP 23808 The routine continues at 23808
This routine uses a descent table to guide ERIC to the floor. The bits in each table entry have the following significance:
Bit(s) Meaning
0-3 ERIC's next animatory state
4 If set, move backwards one space
5 If set, move forwards one space
6 If set, descend one level
7 If set, ascend one level
The descent tables themselves contain the following entries:
E=252 (normal descent)
D DE (DE) Meaning
160 41212 69 Animatory state 5 or 133; descend
161 41468 69 Animatory state 5 or 133; descend
162 41724 69 Animatory state 5 or 133; descend
163 41980 69 Animatory state 5 or 133; descend
164 42236 69 Animatory state 5 or 133; descend
165 42492 69 Animatory state 5 or 133; descend
166 42748 69 Animatory state 5 or 133; descend
167 43004 0 ERIC has landed
168 43260 4 Set bit 2 at 32763 (ERIC is sitting)
169 43516 0 Reset all bits at 32749 (ERIC landed safely)
E=253 (from the bike saddle over the closed skool gate)
D DE (DE) Meaning
160 41213 160 Animatory state 0 or 128; ascend; move forward
161 41469 160 Animatory state 0 or 128; ascend; move forward
162 41725 160 Animatory state 0 or 128; ascend; move forward
163 41981 96 Animatory state 0 or 128; descend; move forward
164 42237 100 Animatory state 4 or 132; descend; move forward
165 42493 37 Animatory state 5 or 133; move forward
166 42749 69 Animatory state 5 or 133; descend
167 43005 69 Animatory state 5 or 133; descend
168 43261 0 ERIC has landed
169 43517 4 Set bit 2 at 32763 (ERIC is sitting)
170 43773 0 Reset all bits at 32749 (ERIC landed safely)
E=254 (from the bike saddle into a wall or closed door)
D DE (DE) Meaning
160 41214 160 Animatory state 0 or 128; ascend; move forward
161 41470 160 Animatory state 0 or 128; ascend; move forward
162 41726 2 Animatory state 2 or 130; ascend
163 41982 64 Animatory state 0 or 128; descend
164 42238 64 Animatory state 0 or 128; descend
165 42494 64 Animatory state 0 or 128; descend
166 42750 22 Animatory state 6 or 134; move backwards
167 43006 0 ERIC has landed
168 43262 4 Set bit 2 at 32763 (ERIC is sitting)
169 43518 0 Reset all bits at 32749 (ERIC landed safely)
E=255 (from the top-floor window)
D DE (DE) Meaning
160 41215 96 Animatory state 0 or 128; descend; move forwards
161 41471 96 Animatory state 0 or 128; descend; move forwards
162 41727 96 Animatory state 0 or 128; descend; move forwards
163 41983 96 Animatory state 0 or 128; descend; move forwards
164 42239 64 Animatory state 0 or 128; descend
165 42495 64 Animatory state 0 or 128; descend
166 42751 64 Animatory state 0 or 128; descend
167 43007 64 Animatory state 0 or 128; descend
168 43263 64 Animatory state 0 or 128; descend
169 43519 64 Animatory state 0 or 128; descend
170 43775 68 Animatory state 4 or 132; descend
171 44031 68 Animatory state 4 or 132; descend
172 44287 68 Animatory state 4 or 132; descend
173 44543 5 Animatory state 5 or 133
174 44799 69 Animatory state 5 or 133; descend
175 45055 69 Animatory state 5 or 133; descend
176 45311 69 Animatory state 5 or 133; descend
177 45567 70 Animatory state 6 or 134; descend
178 45823 0 ERIC has landed
179 46079 64 Set bit 6 at 32763 (MR WACKER should expel ERIC)
180 46335 32 Set bit 5 at 32749 (ERIC fell out of the top-floor window)
 Prev: 64416 Up: Map Next: 64560