Routines

29278: Deal with ERIC when he's riding the bike


This routine is called by the routine at 63405 when bit 0 at 32749 is set

29278 21F37F LD HL,32755
29281 35 DEC (HL) Is it time to deal with ERIC yet?
29282 2076 JR NZ,29402 Jump if not
29284 34 INC (HL) (HL)=1
29285 CDFA71 CALL 29178 Get offset from keypress table into A
29288 21EE7F LD HL,32750
29291 286D JR Z,29402 Jump if no keys were pressed
29293 CBDF SET 3,A
29295 FE58 CP 88 Was "left" pressed?
29297 2804 JR Z,29303 Jump if so
29299 FE5A CP 90 Was "right" pressed?
29301 201E JR NZ,29333 Jump if not
29303 BE CP (HL) Was key pressed same as last one pressed?
29304 2860 JR Z,29402 Jump if so
29306 77 LD (HL),A
29307 2EF3 LD L,243 HL=32755
29309 3605 LD (HL),5
29311 2EF0 LD L,240 HL=32752
29313 7E LD A,(HL)
29314 C60C ADD A,12
29316 3002 JR NC,29320
29318 3EFF LD A,255
29320 77 LD (HL),A
29321 26D2 LD H,210 210=ERIC
29323 CDB461 CALL 25012 Update SRB for ERIC's current animatory state and location
29326 EE01 XOR 1 Now A=ERIC's new animatory state (12, 13, 140 or 141)
29328 CD3061 CALL 24880 Update SRB for ERIC's new animatory state
29331 1845 JR 29402

We come here if neither "left" nor "right" was pressed to check for other keypresses:
29333 FE5C CP 92 Was "up" pressed?
29335 202D JR NZ,29382 Jump if not
29337 2EED LD L,237 HL=32749
29339 3680 LD (HL),128 Signal: ERIC is standing on saddle of bike
29341 26D2 LD H,210 210=ERIC
29343 CDB461 CALL 25012 Update SRB for ERIC's current animatory state and location
29346 D5 PUSH DE
29347 15 DEC D Raise ERIC a level
29348 00 NOP
29349 1C INC E
29350 CB7F BIT 7,A Is ERIC facing left?
29352 2802 JR Z,29356 Jump if so
29354 1D DEC E
29355 1D DEC E
29356 E680 AND 128 Now A=ERIC's new animatory state, (E,D)=ERIC's new (x,y)-coordinates
29358 CD3061 CALL 24880 Update SRB for ERIC's new animatory state and location
29361 7E LD A,(HL) A=ERIC's animatory state
29362 D1 POP DE DE=ERIC's location before he jumped on the saddle or got off the bike
29363 C619 ADD A,25 A=animatory state of bike standing upright (25 or 153)
29365 24 INC H H=211: bike
29366 CD3061 CALL 24880 Update SRB for bike
29369 210A72 LD HL,29194 Place the address of the routine at 29194 into bytes 17 and 18 of the bike's buffer
29372 2211D3 LD (54033),HL
29375 21F37F LD HL,32755
29378 3605 LD (HL),5
29380 1836 JR 29436

We come here if not one of "left", "right" and "up" was pressed.
29382 FE5E CP 94 Was "down" pressed?
29384 2010 JR NZ,29402 Jump if not
29386 2EED LD L,237 HL=32749
29388 3600 LD (HL),0 Reset all bits here, signalling that ERIC is off the bike
29390 2EFB LD L,251 HL=32763
29392 CB8E RES 1,(HL) Reset bit 1 here, signalling that 32749 is empty
29394 26D2 LD H,210 210=ERIC
29396 CDB461 CALL 25012 Update SRB for ERIC's current animatory state and location
29399 D5 PUSH DE
29400 18D2 JR 29356 Jump back to update SRB for new animatory state and location of ERIC

We reach this point if it wasn't time to deal with ERIC, or no relevant keys were pressed.
29402 21F07F LD HL,32752
29405 35 DEC (HL) Has too much time passed since the last relevant keypress?
29406 2021 JR NZ,29441 Jump if not
29408 26D2 LD H,210 210=ERIC, who will now fall off the bike
29410 CDB461 CALL 25012 Update SRB for ERIC's current animatory state and location
29413 D5 PUSH DE Save ERIC's coordinates briefly
29414 E680 AND 128
29416 F5 PUSH AF
29417 C604 ADD A,4 A=4 or 132 (ERIC sitting on chair)
29419 CD3061 CALL 24880 Update SRB for this new animatory state of ERIC
29422 F1 POP AF
29423 D1 POP DE Restore ERIC's coordinates to DE
29424 C618 ADD A,24 A=24 or 152 (bike lying on floor)
29426 26D3 LD H,211 211=bike
29428 CD3061 CALL 24880 Update SRB for this new animatory state of bike
29431 21ED7F LD HL,32749
29434 3610 LD (HL),16 Set bit 4: ERIC will not land on his feet
29436 2EEF LD L,239 HL=32751
29438 3605 LD (HL),5
29440 C9 RET

We come here if no relevant key was pressed, but it's too soon for ERIC to fall off the bike through lack of pedal power.
29441 2EEF LD L,239 HL=32751
29443 35 DEC (HL)
29444 C0 RET NZ
29445 3607 LD (HL),7
29447 2A00D2 LD HL,(53760)
29450 7D LD A,L A=ERIC's animatory state
29451 5C LD E,H E=ERIC's x-coordinate
29452 CD0070 CALL 28672 Are there any walls or closed doors in ERIC's path?
29455 38CF JR C,29408 Jump back to knock ERIC
off the bike if so
29457 28CD JR Z,29408
29459 C34E72 JP 29262 Otherwise move ERIC forward one space, update SRB, and scroll screen if necessary