Prev: DE19 Up: Map Next: E3DE
E1CC: Handler: Player
Used by the routine at Dispatch_Handlers.
Moves, collides and draws the player entity at Player.
Handler_Player E1CC LD A,($646F) Return if *GameActiveFlag is set (demo / intro).
E1CF OR A
E1D0 RET NZ
E1D1 LD HL,$B5B1 Write Graphics_PlayerFont to *CHARS.
E1D4 LD ($5C36),HL
E1D7 LD IX,$64A4 IX=Player.
E1DB LD A,($6489) Erase the player while *ActionTimer is running.
E1DE OR A
E1DF PUSH AF
E1E0 CALL NZ,JumpTable_DrawEntity
E1E3 POP AF
E1E4 RET NZ
E1E5 LD A,($6435) Jump to Player_Hit if *Player_HitTimer is set.
E1E8 OR A
E1E9 JP NZ,Player_Hit
E1EC LD A,($6410) Jump to Player_JumpAnim if *Player_JumpTimer is set.
E1EF OR A
E1F0 JP NZ,Player_JumpAnim
E1F3 LD A,($648A) Call Player_ClimbStop if *ClimbRow is set.
E1F6 OR A
E1F7 CALL NZ,Player_ClimbStop
E1FA CALL Build_PlayerMask Call Build_PlayerMask.
E1FD LD A,($6434) Start a fall if *CollisionState is not a collision.
E200 CP $03
E202 JR Z,Handler_Player_Apply
E204 LD (IX+$09),$FC
E208 PUSH IY Stash IY on the stack.
E20A LD IY,($6430) IY=*ReferenceActors.
Handler_Player_ActorLoop E20E LD A,(IY+$00) Jump to Handler_Player_ActorsDone if the terminator FF is reached.
E211 CP $FF
E213 JR Z,Handler_Player_ActorsDone
E215 BIT 7,A Jump to Handler_Player_ActorNext if this actor is inactive.
E217 JR NZ,Handler_Player_ActorNext
E219 CALL Test_ActorCollision Call Test_ActorCollision.
E21C LD A,($6434) Stop scanning once *CollisionState is a collision.
E21F CP $03
E221 JR Z,Handler_Player_ActorsDone
Handler_Player_ActorNext E223 LD DE,$000D IY+=000D.
E226 ADD IY,DE
E228 JR Handler_Player_ActorLoop Jump to Handler_Player_ActorLoop.
Handler_Player_ActorsDone E22A POP IY Restore IY from the stack.
Handler_Player_Apply E22C LD A,(IX+$09) Probe the ceiling while the vertical delta is negative.
E22F OR A
E230 JR Z,Handler_Player_Stand
E232 CP $80
E234 JR C,Handler_Player_Stand
E236 CALL Probe_Ceiling
E239 LD A,($6438) Increase *Player_StandTimer and honour a collision.
E23C INC A
E23D LD ($6438),A
E240 LD A,($6434)
E243 OR A
E244 JR Z,Handler_Player_Resolve
Handler_Player_Stand E246 LD A,($6438) Start a hit if *Player_StandTimer reaches 0A.
E249 CP $0A
E24B JP NC,Player_StartHit
E24E XOR A Clear *Player_StandTimer.
E24F LD ($6438),A
E252 LD A,($647E) Jump to Controls_Kempston if Kempston is selected.
E255 OR A
E256 JP NZ,Controls_Kempston
E259 CALL $028E Call KEY_SCAN.
E25C LD A,E A=the keypress.
E25D LD IX,$64A4 IX=Player.
E261 LD HL,$647F Call Player_MoveLeft if the left key matches.
E264 CP (HL)
E265 PUSH AF
E266 CALL Z,Player_MoveLeft
E269 POP AF
E26A PUSH AF Call Player_MoveRight if the right key matches.
E26B LD HL,$6480
E26E CP (HL)
E26F CALL Z,Player_MoveRight
E272 POP AF
E273 PUSH AF Call Player_ClimbUp if the up key matches.
E274 LD HL,$6481
E277 CP (HL)
E278 CALL Z,Player_ClimbUp
E27B POP AF
E27C PUSH AF Call Player_ClimbDown if the down key matches.
E27D LD HL,$6482
E280 CP (HL)
E281 CALL Z,Player_ClimbDown
E284 POP AF
E285 LD HL,$6483 Call Player_Action if the action key matches.
E288 CP (HL)
E289 CALL Z,Player_Action
This entry point is used by the routine at Handler_Housekeeping.
Handler_Player_Resolve E28C LD A,($648A) Fall through to Handler_Player_Draw when *ClimbRow is set.
E28F OR A
E290 JR NZ,Handler_Player_Draw
This entry point is used by the routine at Handler_Combination.
Handler_Player_Draw E292 CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
Start a fall if the new row is off the bottom of the room.
E295 LD A,B Jump to Handler_Player_Collision unless the new row is 1B.
E296 CP $1B
E298 JR NZ,Handler_Player_Collision
E29A LD (IX+$09),$FC Write FC as the vertical delta.
E29E XOR A Write 00 to *CollisionState and *Player_JumpTimer.
E29F LD ($6434),A
E2A2 LD ($6410),A
E2A5 LD A,$0C Write 0C to *Player_StandTimer.
E2A7 LD ($6438),A
Handler_Player_Collision E2AA LD A,($6434) Jump to Handler_Player_Commit if *CollisionState is a collision.
E2AD CP $03
E2AF JP Z,Handler_Player_Commit
Probe the tiles above while the player is jumping.
E2B2 LD A,($6410) Jump to Handler_Player_Horizontal if *Player_JumpTimer is zero.
E2B5 OR A
E2B6 JR Z,Handler_Player_Horizontal
E2B8 LD A,B Jump to Handler_Player_Horizontal if the row has not changed.
E2B9 CP (IX+$01)
E2BC JR Z,Handler_Player_Horizontal
E2BE LD A,E A=03 or 02 when fine-Y is 07.
E2BF CP $07
E2C1 LD A,$00
E2C3 ADC A,$02
E2C5 PUSH AF
E2C6 CALL JumpTable_ConvertCoordinate Convert that cell into a Buffer_RoomTiles pointer.
E2C9 LD DE,$5DCE
E2CC ADD HL,DE
E2CD POP AF
E2CE LD B,A
Handler_Player_ProbeUp E2CF LD A,(HL) Jump to Handler_Player_ProbeUpNext if this tile is solid (10 or higher).
E2D0 CP $10
E2D2 JR NC,Handler_Player_ProbeUpNext
E2D4 XOR A Clear the vertical delta.
E2D5 LD (IX+$09),A
E2D8 INC BC Jump to Handler_Player_ProbeLeftTest until the probe count is zero, then clear the sprite.
E2D9 DJNZ Handler_Player_ProbeLeftTest
E2DB LD (IX+$06),$00
Handler_Player_ProbeUpNext E2DF INC HL Advance the tile pointer and loop back to Handler_Player_ProbeUp.
E2E0 DJNZ Handler_Player_ProbeUp
Probe the tiles to the right while moving right.
Handler_Player_Horizontal E2E2 CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
E2E5 LD A,(IX+$08) Jump to Handler_Player_Left if the horizontal delta is negative.
E2E8 CP $80
E2EA JR NC,Handler_Player_Left
E2EC LD A,C Jump to Handler_Player_Commit if the column has not changed.
E2ED CP (IX+$00)
E2F0 JR Z,Handler_Player_Commit
E2F2 LD A,D A=04 or 03 when fine-Y is 07.
E2F3 CP $07
E2F5 LD A,$00
E2F7 ADC A,$03
E2F9 PUSH AF
E2FA CALL JumpTable_ConvertCoordinate Convert that cell into a Buffer_RoomTiles pointer.
E2FD LD DE,$5DCE
E300 ADD HL,DE
E301 POP AF
E302 LD B,A
E303 LD DE,$0020
Handler_Player_ProbeRight E306 LD A,(HL) Jump to Handler_Player_ProbeRightNext if this tile is solid (10 or higher).
E307 CP $10
E309 JR NC,Handler_Player_ProbeRightNext
E30B XOR A Clear the horizontal delta.
E30C LD (IX+$08),A
E30F LD A,($6410) Jump to Handler_Player_ProbeRightNext if *Player_JumpTimer is zero.
E312 OR A
E313 JR Z,Handler_Player_ProbeRightNext
E315 XOR A Write 00 to *Player_JumpTimer and clear the sprite.
E316 LD ($6410),A
E319 LD (IX+$06),$00
Handler_Player_ProbeRightNext E31D ADD HL,DE Step down one row and loop back to Handler_Player_ProbeRight, then jump to Handler_Player_Commit.
E31E DJNZ Handler_Player_ProbeRight
E320 JR Handler_Player_Commit
Probe the tiles to the left while moving left.
Handler_Player_Left E322 LD A,C Jump to Handler_Player_Commit if the column has not changed.
E323 CP (IX+$00)
E326 JR Z,Handler_Player_Commit
E328 DEC C Point two columns left; A=04 or 03 when fine-Y is 07.
E329 DEC C
E32A LD A,D
E32B CP $07
E32D LD A,$00
E32F ADC A,$03
E331 PUSH AF
E332 CALL JumpTable_ConvertCoordinate Convert that cell into a Buffer_RoomTiles pointer.
E335 LD DE,$5DCE
E338 ADD HL,DE
E339 POP AF
E33A LD B,A
E33B LD DE,$0020
Handler_Player_ProbeLeft E33E LD A,(HL) Jump to Handler_Player_ProbeLeftNext if this tile is solid (10 or higher).
Handler_Player_ProbeLeftTest E33F CP $10
E341 JR NC,Handler_Player_ProbeLeftNext
E343 XOR A Clear the horizontal delta.
E344 LD (IX+$08),A
E347 LD A,($6410) Jump to Handler_Player_ProbeLeftNext if *Player_JumpTimer is zero.
E34A OR A
E34B JR Z,Handler_Player_ProbeLeftNext
E34D XOR A Write 00 to *Player_JumpTimer and clear the sprite.
E34E LD ($6410),A
E351 LD (IX+$06),$00
Handler_Player_ProbeLeftNext E355 ADD HL,DE Step down one row and loop back to Handler_Player_ProbeLeft.
E356 DJNZ Handler_Player_ProbeLeft
This entry point is used by the routines at Handler_Housekeeping and Handler_Combination.
Handler_Player_Commit E358 CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
E35B LD A,C Jump to Handler_Player_ClearDeltas if the new column is off-screen.
E35C CP $22
E35E JP Z,Handler_Player_ClearDeltas
E361 CP $03
E363 JP Z,Handler_Player_ClearDeltas
E366 LD A,B Start a fall if the new row is 1A.
E367 CP $1A
E369 JR NZ,Handler_Player_Paint
E36B XOR A
E36C LD ($6410),A
E36F LD (IX+$09),$FC
Store, move and draw the player.
Handler_Player_Paint E373 CALL JumpTable_StorePosition Call JumpTable_StorePosition.
E376 CALL JumpTable_MoveEntity Call JumpTable_MoveEntity.
E379 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
E37C LD A,($6434) Draw a collided actor through JumpTable_DrawActor.
E37F CP $03
E381 JR NZ,Handler_Player_Reset
E383 LD IX,($644B)
E387 CALL JumpTable_DrawActor
Handler_Player_Reset E38A LD IX,$64A4 Clear movement when the player is not jumping.
E38E XOR A
E38F LD ($6434),A
E392 LD A,($6410)
E395 OR A
E396 JR NZ,Handler_Player_Floor
Handler_Player_ClearDeltas E398 XOR A
E399 LD ($6410),A
E39C LD (IX+$08),$00
E3A0 LD (IX+$09),$00
Handler_Player_Floor E3A4 LD A,(IX+$01) Jump to Award_Action when standing on the floor.
E3A7 CP $03
E3A9 JR Z,Handler_Player_Award
E3AB LD A,($6411)
E3AE OR A
E3AF RET Z
Handler_Player_Award E3B0 JP Award_Action Jump to Award_Action.
This entry point is used by the routine at Initialise_Game.
Clear the play area and the room buffers.
Clear_PlayArea E3B3 XOR A Write BLACK to *ATTR_T.
E3B4 LD ($5C8F),A
E3B7 CALL $1CAD Call CL_ALL.
E3BA LD HL,$5DCE Write 00 to the 0320 bytes at Buffer_RoomTiles.
E3BD LD BC,$0320
Clear_PlayArea_TileLoop E3C0 XOR A
E3C1 LD (HL),A
E3C2 INC HL
E3C3 DEC BC
E3C4 LD A,B
E3C5 OR C
E3C6 JR NZ,Clear_PlayArea_TileLoop
E3C8 LD BC,$0320 Fill Buffer_RoomAttributes with *ATTR_T.
E3CB LD HL,$60EE
Clear_PlayArea_AttributeLoop E3CE LD A,($5C8F)
E3D1 LD (HL),A
E3D2 INC HL
E3D3 DEC BC
E3D4 LD A,B
E3D5 OR C
E3D6 JR NZ,Clear_PlayArea_AttributeLoop
E3D8 LD B,$18 Call CL_LINE for 18 lines.
E3DA CALL $0E44
E3DD RET Return.
View the equivalent code in Booty.
Prev: DE19 Up: Map Next: E3DE