Prev: 29277 Up: Map Next: 29462
29278: Deal with ERIC when he's riding the bike
Called by the routine at 63405 when bit 0 at 32749 is set (by the routine at 29462). Listens for and responds appropriately to keypresses while ERIC is sitting on the saddle of the bike.
29278 LD HL,32755 32755 holds ERIC's main action timer
29281 DEC (HL) Is it time to deal with ERIC yet?
29282 JR NZ,29402 Jump if not
29284 INC (HL) Set ERIC's action timer to 1, ensuring that we pass through the following section of code on the next call to this routine if no pedalling is detected this time (if 'left' or 'right' is pressed, the action timer will be reset to 5)
29285 CALL 29178 A=value from the keypress offset table corresponding to the key just pressed (if any)
29288 LD HL,32750 32750 holds the offset of the last key pressed while ERIC was riding the bike
29291 JR Z,29402 Jump if no keys were pressed since the last check
29293 SET 3,A We don't distinguish between fast (upper case) and slow (lower case) keypresses while ERIC is riding the bike
29295 CP 88 Was 'left' pressed?
29297 JR Z,29303 Jump if so
29299 CP 90 Was 'right' pressed?
29301 JR NZ,29333 Jump if not
29303 CP (HL) Was the key just pressed the same as the last one pressed?
29304 JR Z,29402 Jump if so
The 'left' key was pressed after a non-left key, or the 'right' key was pressed after a non-right key. In other words, ERIC pedalled.
29306 LD (HL),A Store the offset of the key just pressed in 32750
29307 LD L,243 HL=32755 (ERIC's main action timer)
29309 LD (HL),5 Reset this to 5
29311 LD L,240 HL=32752 (bike momentum)
29313 LD A,(HL) Increase the bike's momentum, but not beyond 255
29314 ADD A,12
29316 JR NC,29320
29318 LD A,255
29320 LD (HL),A
29321 LD H,210 210=ERIC
29323 CALL 25012 Update the SRB for ERIC's current animatory state and location
29326 XOR 1 Now A=ERIC's new animatory state (12, 13, 140 or 141)
29328 CALL 24880 Update ERIC's animatory state and update the SRB
29331 JR 29402
Neither 'left' nor 'right' was pressed.
29333 CP 92 Was 'up' pressed?
29335 JR NZ,29382 Jump if not
29337 LD L,237 HL=32749 (ERIC's status flags)
29339 LD (HL),128 Set bit 7: ERIC is standing on the saddle of the bike
29341 LD H,210 210=ERIC
29343 CALL 25012 Update the SRB for ERIC's current animatory state and location
29346 PUSH DE
29347 DEC D D=ERIC's new y-coordinate (up a level)
29348 NOP
29349 INC E
29350 BIT 7,A Is ERIC facing left?
29352 JR Z,29356 Jump if so
29354 DEC E
29355 DEC E
29356 AND 128 Now A=ERIC's new animatory state, E=ERIC's new x-coordinate
29358 CALL 24880 Update ERIC's animatory state and location and update the SRB
29361 LD A,(HL) A=ERIC's animatory state
29362 POP DE DE=ERIC's location before he jumped on the saddle or got off the bike
29363 ADD A,25 A=animatory state of the bike standing upright (25 or 153)
29365 INC H H=211: bike
29366 CALL 24880 Update the bike's animatory state and update the SRB
29369 LD HL,29194 Place the address of the uninterruptible subcommand routine at 29194 into bytes 17 and 18 of the bike's buffer
29372 LD (54033),HL
29375 LD HL,32755 32755 holds ERIC's main action timer
29378 LD (HL),5 Reset this to 5
29380 JR 29436 Also reset the bike's speed counter (at 32751) to 5
Not one of 'left', 'right' and 'up' was pressed.
29382 CP 94 Was 'down' pressed?
29384 JR NZ,29402 Jump if not
29386 LD L,237 HL=32749 (ERIC's status flags)
29388 LD (HL),0 Reset all bits here, signalling that ERIC has his feet back on the ground
29390 LD L,251 HL=32763 (ERIC's other status flags)
29392 RES 1,(HL) Reset bit 1 here, signalling that 32749 is empty
29394 LD H,210 210=ERIC
29396 CALL 25012 Update the SRB for ERIC's current animatory state and location
29399 PUSH DE Save ERIC's current location
29400 JR 29356 Jump back to update the animatory state and location of ERIC and the bike
The following section of code is executed on every pass through this routine while ERIC is sitting on the saddle (in other words, unless 'up' or 'down' was pressed).
29402 LD HL,32752 32752 holds the bike's momentum
29405 DEC (HL) Has the bike run out of momentum?
29406 JR NZ,29441 Jump if not
29408 LD H,210 210=ERIC, who will now fall off the bike
29410 CALL 25012 Update the SRB for ERIC's current animatory state and location
29413 PUSH DE Save ERIC's coordinates briefly
29414 AND 128 Keep only the 'direction' bit of ERIC's animatory state
29416 PUSH AF
29417 ADD A,4 A=4 or 132 (ERIC sitting on a chair)
29419 CALL 24880 Update ERIC's animatory state and update the ARB
29422 POP AF A=0 if ERIC's facing left, 128 if facing right
29423 POP DE Restore ERIC's coordinates to DE
29424 ADD A,24 A=24 or 152 (bike lying on the floor)
29426 LD H,211 211=bike
29428 CALL 24880 Update the bike's animatory state and update the SRB
29431 LD HL,32749 32749 holds ERIC's status flags
29434 LD (HL),16 Set bit 4: ERIC will not land on his feet
29436 LD L,239 HL=32751 (which holds the bike's speed counter)
29438 LD (HL),5 Reset this to 5
29440 RET
The bike still has momentum.
29441 LD L,239 HL=32751 (which holds the bike's speed counter)
29443 DEC (HL) Is it time to move the bike forward?
29444 RET NZ Return if not
29445 LD (HL),7 Reset the bike's speed counter to 7
29447 LD HL,(53760) A=ERIC's animatory state, E=ERIC's x-coordinate
29450 LD A,L
29451 LD E,H
29452 CALL 28672 Are there any walls, closed doors or ALBERTs in ERIC's path?
29455 JR C,29408 Knock ERIC off the bike if so
29457 JR Z,29408
29459 JP 29262 Otherwise move ERIC forward one space, update the SRB, and scroll the screen if necessary
Prev: 29277 Up: Map Next: 29462