Prev: 56727 Up: Map Next: 57804
56857: Handler: Combination
Used by the routine at Dispatch_Handlers.
Prints the four CollectionSlots digits on room 0.
Handler_Combination 56857 LD A,(25725) Return if *GameCompleteFlag is set.
56860 OR A
56861 RET NZ Return if *CurrentRoom is not zero.
56862 LD A,(25762)
56865 OR A Write 15360 to *CHARS.
56866 RET NZ
56867 LD HL,15360
56870 LD (23606),HL
56873 LD A,23 Write WHITE to *ATTR_T.
56875 LD (23695),A
56878 LD BC,5139 Call JumpTable_SetPrintPosition at column 20 row 19.
56881 CALL JumpTable_SetPrintPosition HL=CollectionSlots.
56884 LD HL,25793 B=4.
56887 LD B,4
Handler_Combination_Loop 56889 LD A,(HL) Print *(HL) as a decimal digit.
56890 ADD A,48
56892 CALL JumpTable_PrintCharacter
56895 INC HL Increase HL and loop back to Handler_Combination_Loop.
56896 DJNZ Handler_Combination_Loop
56898 RET Return.
This entry point is used by the routine at Handler_Player.
Probe the three tiles above the player for a solid.
Probe_Ceiling 56899 LD A,(IX+3) Keep the player's fine-Y in range 0-3.
56902 INC A
56903 AND 7
56905 CP 4
56907 RET NC
56908 LD C,A
56909 XOR A
56910 SUB C
56911 LD (56963),A Call JumpTable_SetPrintPosition for the cell above the player.
56914 LD C,(IX+0)
56917 LD B,(IX+1)
56920 DEC B
56921 DEC B
56922 DEC B
56923 LD A,7
56925 CP (IX+3)
56928 JR Z,Probe_Ceiling_Ready
56930 DEC B
Probe_Ceiling_Ready 56931 CALL JumpTable_SetPrintPosition Point HL at that Buffer_RoomTiles tile and DE at Player_Mask.
56934 LD HL,(25618)
56937 LD DE,24014
56940 ADD HL,DE
56941 LD DE,25658 DE=Player_Mask.
56944 LD B,3 B=3.
Probe_Ceiling_Loop 56946 LD A,(DE) Jump to Probe_Ceiling_Next if this mask byte is zero.
56947 OR A
56948 JR Z,Probe_Ceiling_Next
56950 LD A,(HL) Stop the jump if the tile is solid (16 or higher).
56951 CP 16
56953 JR NC,Probe_Ceiling_Next
56955 LD A,2
56957 LD (25652),A
56960 LD (IX+9),0 Write 0 to *IX+9.
56964 RET Return.
Probe_Ceiling_Next 56965 INC DE Increase both pointers and loop back to Probe_Ceiling_Loop.
56966 INC HL
56967 DJNZ Probe_Ceiling_Loop
56969 RET Return.
Mirror the DE bitmask into E.
Mirror_Mask 56970 LD B,8 Reverse the eight bits of D into E.
56972 XOR A
Mirror_Mask_Loop 56973 RR D
56975 RL E
56977 DJNZ Mirror_Mask_Loop
56979 RR D
56981 RET Return.
This entry point is used by the routines at Handler_Player and Handler_Actors.
Build the player's shifted collision mask.
Build_PlayerMask 56982 LD DE,(25770) HL=Data_PlayerMasks+(*Player_SpriteFrame)*8.
56986 XOR A
56987 LD D,A
56988 SLA E
56990 RL D
56992 SLA E
56994 RL D
56996 SLA E
56998 RL D
57000 LD HL,46552
57003 ADD HL,DE
57004 LD A,(HL) Mirror the mask when the player is facing left.
57005 LD DE,8
57008 ADD HL,DE
57009 LD D,(HL)
57010 LD E,A
57011 LD A,(25771)
57014 BIT 7,A
57016 CALL NZ,Mirror_Mask
57019 LD BC,(25765) Shift the mask down by the player's fine-Y.
57023 INC B
57024 XOR A
Build_PlayerMask_Shift 57025 SLA D
57027 RL E
57029 RL A
57031 DJNZ Build_PlayerMask_Shift
57033 LD (25658),A
57036 LD (25659),DE
57040 LD A,(25764) Walk left from the player column until a set bit is found.
57043 DEC A
57044 ADD A,A
57045 ADD A,A
57046 ADD A,A
57047 LD C,A
57048 LD B,24
57050 LD A,(25658)
Build_PlayerMask_Scan 57053 DEC C
57054 SLA D
57056 RL E
57058 RLA
57059 JR C,Build_PlayerMask_Width
57061 DJNZ Build_PlayerMask_Scan
57063 XOR A Write 0000 to *Player_Footprint.
57064 LD (25672),A
57067 LD (25673),A
57070 RET Return.
Build_PlayerMask_Width 57071 LD B,0 Count the run of set bits into *Player_Footprint.
Build_PlayerMask_Count 57073 SLA A
57075 INC B
57076 JR C,Build_PlayerMask_Count
57078 LD (25672),BC
57082 RET Return.
This entry point is used by the routine at Handler_Player.
Award points and flash the player after a successful action.
Award_Action 57083 LD A,(25737) Return if *ActionTimer is already running.
57086 OR A
57087 RET NZ
57088 LD BC,150 Call Sound_Square (score sound).
57091 LD DE,100
57094 CALL Sound_Square
57097 LD BC,1 Call Sound_Pickup (pickup sound).
57100 LD DE,100
57103 CALL Sound_Pickup
57106 LD A,18 Write 18 to *ActionTimer.
57108 LD (25737),A
57111 LD A,(25771) Set the player flash bits in *Player_Facing.
57114 AND 128
57116 OR 66
57118 LD (25771),A
57121 RET Return.
This entry point is used by the routine at Handler_Housekeeping.
Lose a life and restart the room.
Lose_Life 57122 LD A,(25759) Force any pending event to fire first.
57125 OR A
57126 JR Z,Lose_Life_Apply
57128 LD A,1
57130 LD (25759),A
57133 CALL Handler_EventTimer
Lose_Life_Apply 57136 POP BC Restore BC from the stack.
57137 LD A,1 Write 1 to *RestartRoomFlag.
57139 LD (25617),A
57142 LD A,(25780) Jump to Reset_Introduction if *Player_Lives is 1.
57145 DEC A
57146 JP Z,Reset_Introduction
57149 LD (25780),A Decrease *Player_Lives by one.
57152 XOR A Jump to Change_Room with A=0.
57153 JP Change_Room
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Walk left, or start a left-facing walk.
Player_MoveLeft 57156 BIT 7,(IX+7) Jump to Player_MoveLeft_Step if already facing left.
57160 JR NZ,Player_MoveLeft_Step
57162 SET 7,(IX+7) Face left.
57166 LD (IX+6),96 Set frame 96.
57170 RET Return.
Player_MoveLeft_Step 57171 LD A,(IX+6) Advance the walk frame, wrapping at 48.
57174 ADD A,6
57176 CP 48
57178 JR C,Player_MoveLeft_StoreFrame
57180 XOR A
Player_MoveLeft_StoreFrame 57181 LD (IX+6),A
57184 LD A,(IX+8) Increase the horizontal delta by 2.
57187 ADD A,2
57189 LD (IX+8),A
57192 RET Return.
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Walk right, or start a right-facing walk.
Player_MoveRight 57193 BIT 7,(IX+7) Jump to Player_MoveRight_Step if already facing right.
57197 JR Z,Player_MoveRight_Step
57199 LD (IX+6),96 Set frame 96.
57203 RES 7,(IX+7) Face right.
57207 RET Return.
Player_MoveRight_Step 57208 LD A,(IX+6) Advance the walk frame, wrapping at 48.
57211 ADD A,6
57213 CP 48
57215 JR C,Player_MoveRight_StoreFrame
57217 XOR A
Player_MoveRight_StoreFrame 57218 LD (IX+6),A
57221 LD A,(IX+8) Decrease the horizontal delta by 2.
57224 SUB 2
57226 LD (IX+8),A
57229 RET Return.
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Fire / use the furniture in front of the player.
Player_Action 57230 LD HL,(25632) HL=*ReferenceFurniture.
Player_Action_Loop 57233 LD A,(HL) Jump to Player_Action_Doors if the terminator 255 is reached.
57234 CP 255
57236 JR Z,Player_Action_Doors
57238 BIT 7,A Jump to Player_Action_Next if this record is inactive.
57240 JR NZ,Player_Action_Next
57242 CP (IX+0) Jump to Player_Action_Next unless it matches the player cell.
57245 JR NZ,Player_Action_Next
57247 INC HL
57248 LD A,(HL)
57249 DEC HL
57250 DEC A
57251 CP (IX+1)
57254 JR NZ,Player_Action_Next
57256 LD A,(25759) Fire any pending event before using this furniture.
57259 OR A
57260 JR Z,Player_Action_Use
57262 LD A,1
57264 LD (25759),A
57267 PUSH HL
57268 CALL Handler_EventTimer
57271 POP HL
Player_Action_Use 57272 INC HL Jump to Change_Room with the furniture event ID.
57273 INC HL
57274 INC HL
57275 INC HL
57276 LD A,(HL)
57277 POP BC
57278 POP BC
57279 JP Change_Room
Player_Action_Next 57282 LD DE,5 HL+=0005.
57285 ADD HL,DE
57286 JR Player_Action_Loop Jump to Player_Action_Loop.
Player_Action_Doors 57288 LD A,(25759) Return if *EventTimer is running.
57291 OR A
57292 RET NZ
57293 LD HL,(25634) HL=*ReferenceDoors.
Player_Action_DoorLoop 57296 LD A,(HL) Return if the terminator 255 is reached.
57297 CP 255
57299 RET Z
57300 BIT 7,A Jump to Player_Action_DoorNext if this door is inactive.
57302 JR NZ,Player_Action_DoorNext
57304 CP (IX+0) Jump to Player_Action_DoorNext unless the door column matches.
57307 JR Z,Player_Action_DoorMatch
57309 INC A
57310 CP (IX+0)
57313 JR NZ,Player_Action_DoorNext
Player_Action_DoorMatch 57315 INC HL Jump to Player_Action_DoorNext unless the door row matches.
57316 LD A,(HL)
57317 DEC HL
57318 CP (IX+1)
57321 JR Z,Player_Action_DoorUse
57323 DEC A
57324 CP (IX+1)
57327 JR NZ,Player_Action_DoorNext
Player_Action_DoorUse 57329 LD DE,3 Bump the door use count when it is not 255.
57332 ADD HL,DE
57333 LD A,(HL)
57334 OR A
57335 JR Z,Player_Action_DoorEvent
57337 INC A
57338 RET Z
57339 LD (HL),A
Player_Action_DoorEvent 57340 INC HL Jump to Dispatch_Events unless the event is 42.
57341 LD A,(HL)
57342 CP 42
57344 JP NZ,Dispatch_Events
57347 LD HL,1 Write 0001 to *Table_RoomPause.
57350 LD (59434),HL
57353 JP Dispatch_Events Jump to Dispatch_Events.
Player_Action_DoorNext 57356 LD DE,5 HL+=0005.
57359 ADD HL,DE
57360 JR Player_Action_DoorLoop Jump to Player_Action_DoorLoop.
57362 RET Return.
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Climb down a ladder from *ReferenceLadders.
Player_ClimbDown 57363 LD A,(IX+3) Return unless the player fine-Y is 7.
57366 CP 7
57368 RET NZ
57369 LD HL,(25640) HL=*ReferenceLadders.
Player_ClimbDown_Loop 57372 LD A,(HL) Return if the terminator 255 is reached.
57373 CP 255
57375 RET Z
57376 BIT 7,A Jump to Player_ClimbDown_Next if this ladder is hidden.
57378 JR NZ,Player_ClimbDown_Next
57380 CP (IX+0) Jump to Player_ClimbDown_Start if the ladder column matches.
57383 JR Z,Player_ClimbDown_Start
57385 INC A Jump to Player_ClimbDown_Next unless the player is on the right-hand half.
57386 CP (IX+0)
57389 JR NZ,Player_ClimbDown_Next
57391 LD A,(IX+2)
57394 CP 4
57396 JR NC,Player_ClimbDown_Next
Player_ClimbDown_Start 57398 INC HL Jump to Player_ClimbDown_Next unless the player is three rows below the ladder.
57399 LD A,(HL)
57400 DEC HL
57401 ADD A,3
57403 CP (IX+1)
57406 JR NZ,Player_ClimbDown_Next
57408 SUB 3 Write the ladder row to *ClimbRow and start climbing down.
57410 LD (25738),A
57413 LD (IX+6),90
57417 LD (IX+9),254
57421 LD A,(HL) Jump to Player_ClimbDown_Offset unless the ladder column matches.
57422 CP (IX+0)
57425 JR NZ,Player_ClimbDown_Offset
57427 LD A,7 Write the remaining fine-X as the horizontal delta.
57429 SUB (IX+2)
57432 LD (IX+8),A
57435 RET Return.
Player_ClimbDown_Offset 57436 LD A,255 Write the opposite climb delta.
57438 SUB (IX+2)
57441 LD (IX+8),A
57444 RET Return.
Player_ClimbDown_Next 57445 INC HL Increase HL by three.
57446 INC HL
57447 INC HL
57448 JR Player_ClimbDown_Loop Jump to Player_ClimbDown_Loop.
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Climb up a ladder, or start a jump.
Player_ClimbUp 57450 LD A,(25616) Return if *Player_JumpTimer is set.
57453 OR A
57454 RET NZ
57455 LD A,(IX+3) Jump to Player_Jump unless the player fine-Y is 7.
57458 CP 7
57460 JR NZ,Player_Jump
57462 LD HL,(25640) HL=*ReferenceLadders.
Player_ClimbUp_Loop 57465 LD A,(HL) Jump to Player_Jump if the terminator 255 is reached.
57466 CP 255
57468 JR Z,Player_Jump
57470 BIT 7,A Jump to Player_ClimbUp_Next if this ladder is hidden.
57472 JR NZ,Player_ClimbUp_Next
57474 CP (IX+0) Jump to Player_ClimbUp_Start if the ladder column matches.
57477 JR Z,Player_ClimbUp_Start
57479 INC A Jump to Player_ClimbUp_Next unless the player is on the right-hand half.
57480 CP (IX+0)
57483 JR NZ,Player_ClimbUp_Next
57485 LD A,(IX+2)
57488 CP 4
57490 JR NC,Player_ClimbUp_Next
Player_ClimbUp_Start 57492 INC HL Return if the player is already at the top.
57493 LD A,(HL)
57494 ADD A,3
57496 CP (IX+1)
57499 RET Z
57500 DEC HL Jump to Player_ClimbUp_Next unless the player is two rows below the top.
57501 SUB 5
57503 CP (IX+1)
57506 JR NZ,Player_ClimbUp_Next
57508 ADD A,2 Write the ladder row to *ClimbRow and start climbing up.
57510 LD (25738),A
57513 LD (IX+6),90
57517 LD (IX+9),2
57521 LD A,(HL) Jump to Player_ClimbUp_Offset unless the ladder column matches.
57522 CP (IX+0)
57525 JR NZ,Player_ClimbUp_Offset
57527 LD A,7 Write the remaining fine-X as the horizontal delta.
57529 SUB (IX+2)
57532 LD (IX+8),A
57535 RET Return.
Player_ClimbUp_Offset 57536 LD A,255 Write the opposite climb delta.
57538 SUB (IX+2)
57541 LD (IX+8),A
57544 RET Return.
Player_ClimbUp_Next 57545 INC HL Increase HL by three.
57546 INC HL
57547 INC HL
57548 JR Player_ClimbUp_Loop Jump to Player_ClimbUp_Loop.
Player_Jump 57550 LD A,7 Write 7 to *Player_JumpTimer and start the jump.
57552 LD (25616),A
57555 LD (IX+9),3
57559 BIT 7,(IX+7) Choose a left-facing jump frame.
57563 JR NZ,Player_Jump_Right
57565 LD (IX+6),48
57569 LD (IX+8),254
57573 RET
Player_Jump_Right 57574 LD (IX+6),48 Choose a right-facing jump frame.
57578 LD (IX+8),2
57582 RET
This entry point is used by the routine at Handler_Player.
Stop climbing when the stored ladder row is left.
Player_ClimbStop 57583 LD A,(IX+3) Jump to Player_ReadKeys unless the fine-Y is 7.
57586 CP 7
57588 JR NZ,Player_ReadKeys
57590 LD A,(25738) Jump to Player_ClimbStop_Clear if the player is two rows below *ClimbRow.
57593 SUB 2
57595 CP (IX+1)
57598 JR Z,Player_ClimbStop_Clear
57600 ADD A,5 Jump to Player_ReadKeys unless the player is three rows above that point.
57602 CP (IX+1)
57605 JR NZ,Player_ReadKeys
Player_ClimbStop_Clear 57607 XOR A Return after restoring the walk frame.
57608 LD (25738),A
57611 LD (IX+6),96
57615 RET
Player_ReadKeys 57616 POP BC Restore BC from the stack.
57617 LD A,(25726) Jump to Controls_Kempston_Climb if Kempston is selected.
57620 OR A
57621 JP NZ,Controls_Kempston_Climb
57624 CALL 654 Call KEY_SCAN.
57627 LD IX,25764 IX=Player.
57631 LD A,E Jump to Handler_Player_Commit if no key is pressed.
57632 CP 255
57634 JP Z,Handler_Player_Commit
57637 LD HL,25729 Jump to Player_ClimbUp_Anim if the up key matches.
57640 CP (HL)
57641 JR Z,Player_ClimbUp_Anim
57643 INC HL Jump to Handler_Player_Commit unless the down key matches.
57644 CP (HL)
57645 JP NZ,Handler_Player_Commit
This entry point is used by the routine at Handler_Housekeeping.
Animate climbing down.
Player_ClimbDown_Anim 57648 LD A,(IX+6) Step the climb frame down.
57651 SUB 6
57653 CP 66
57655 JR NZ,Player_ClimbDown_StoreFrame
57657 LD A,90
Player_ClimbDown_StoreFrame 57659 LD (IX+6),A Store the frame, write 254 as the vertical delta and jump to Handler_Player_Commit.
57662 LD (IX+9),254
57666 JP Handler_Player_Commit
This entry point is used by the routine at Handler_Housekeeping.
Animate climbing up.
Player_ClimbUp_Anim 57669 LD A,(IX+6) Step the climb frame up.
57672 ADD A,6
57674 CP 96
57676 JR NZ,Player_ClimbUp_StoreFrame
57678 LD A,72
Player_ClimbUp_StoreFrame 57680 LD (IX+6),A Store the frame, write 2 as the vertical delta and jump to Handler_Player_Commit.
57683 LD (IX+9),2
57687 JP Handler_Player_Commit
This entry point is used by the routine at Handler_Player.
Flash and drop the player after a hit.
Player_Hit 57690 LD A,(25653) Award a bonus if the hit timer is still 50.
57693 CP 50
57695 JR NZ,Player_Hit_Fall
57697 LD BC,100
57700 LD DE,200
57703 CALL Sound_Pickup
Advance, store and erase the falling player.
Player_Hit_Fall 57706 LD (IX+9),255 Write 255 as the vertical delta.
57710 CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
57713 CALL JumpTable_StorePosition Call JumpTable_StorePosition.
57716 CALL JumpTable_MoveEntity Call JumpTable_MoveEntity.
Clip the draw against *HitCeilingRow.
57719 LD A,(25626) A=*ClipWindow_MaximumRow.
57722 PUSH AF Stash it on the stack.
57723 LD A,(25674) Write *HitCeilingRow to *ClipWindow_MaximumRow.
57726 LD (25626),A
57729 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
57732 POP AF Restore *ClipWindow_MaximumRow from the stack.
57733 LD (25626),A Write it back to *ClipWindow_MaximumRow.
57736 LD A,(25653) Decrease *Player_HitTimer.
57739 DEC A
57740 JP Z,Lose_Life Jump to Lose_Life if it is now zero.
57743 LD (25653),A Write the new count back.
57746 RET Return.
This entry point is used by the routine at Handler_Player.
Animate the jump frames from *Player_JumpTimer.
Player_JumpAnim 57747 DEC A Decrease *Player_JumpTimer and point at Handler_Player_Draw.
57748 LD (25616),A
57751 LD HL,58002
57754 PUSH HL
57755 LD (IX+6),48 Use frame 48 while the timer is 6 or higher.
57759 CP 6
57761 RET NC Use frame 54 while the timer is 4 or higher.
57762 LD (IX+6),54
57766 CP 4
57768 RET NC Use frame 60 while the timer is 3 or higher.
57769 LD (IX+6),60
57773 CP 3
57775 RET NC Use frame 66 while the timer is 1 or higher.
57776 LD (IX+6),66
57780 CP 1
57782 RET NC Use frame 18 for the last tick.
57783 LD (IX+6),18
57787 RET Return.
This entry point is used by the routine at Handler_Player.
Start the hit sequence.
Player_StartHit 57788 LD A,50 Write 50 to *Player_HitTimer and store the ceiling row.
57790 LD (25653),A
57793 LD A,(IX+1)
57796 SUB 3
57798 LD (25674),A
57801 JP Handler_Player_Draw Jump to Handler_Player_Draw.
Prev: 56727 Up: Map Next: 57804