Prev: DD97 Up: Map Next: E1CC
DE19: Handler: Combination
Used by the routine at Dispatch_Handlers.
Prints the four CollectionSlots digits on room 00.
Handler_Combination DE19 LD A,($647D) Return if *GameCompleteFlag is set.
DE1C OR A
DE1D RET NZ Return if *CurrentRoom is not zero.
DE1E LD A,($64A2)
DE21 OR A Write 3C00 to *CHARS.
DE22 RET NZ
DE23 LD HL,$3C00
DE26 LD ($5C36),HL
DE29 LD A,$17 Write WHITE to *ATTR_T.
DE2B LD ($5C8F),A
DE2E LD BC,$1413 Call JumpTable_SetPrintPosition at column 14 row 13.
DE31 CALL JumpTable_SetPrintPosition HL=CollectionSlots.
DE34 LD HL,$64C1 B=04.
DE37 LD B,$04
Handler_Combination_Loop DE39 LD A,(HL) Print *(HL) as a decimal digit.
DE3A ADD A,$30
DE3C CALL JumpTable_PrintCharacter
DE3F INC HL Increase HL and loop back to Handler_Combination_Loop.
DE40 DJNZ Handler_Combination_Loop
DE42 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 DE43 LD A,(IX+$03) Keep the player's fine-Y in range 00-03.
DE46 INC A
DE47 AND $07
DE49 CP $04
DE4B RET NC
DE4C LD C,A
DE4D XOR A
DE4E SUB C
DE4F LD ($DE83),A Call JumpTable_SetPrintPosition for the cell above the player.
DE52 LD C,(IX+$00)
DE55 LD B,(IX+$01)
DE58 DEC B
DE59 DEC B
DE5A DEC B
DE5B LD A,$07
DE5D CP (IX+$03)
DE60 JR Z,Probe_Ceiling_Ready
DE62 DEC B
Probe_Ceiling_Ready DE63 CALL JumpTable_SetPrintPosition Point HL at that Buffer_RoomTiles tile and DE at Player_Mask.
DE66 LD HL,($6412)
DE69 LD DE,$5DCE
DE6C ADD HL,DE
DE6D LD DE,$643A DE=Player_Mask.
DE70 LD B,$03 B=03.
Probe_Ceiling_Loop DE72 LD A,(DE) Jump to Probe_Ceiling_Next if this mask byte is zero.
DE73 OR A
DE74 JR Z,Probe_Ceiling_Next
DE76 LD A,(HL) Stop the jump if the tile is solid (10 or higher).
DE77 CP $10
DE79 JR NC,Probe_Ceiling_Next
DE7B LD A,$02
DE7D LD ($6434),A
DE80 LD (IX+$09),$00 Write 00 to *IX+09.
DE84 RET Return.
Probe_Ceiling_Next DE85 INC DE Increase both pointers and loop back to Probe_Ceiling_Loop.
DE86 INC HL
DE87 DJNZ Probe_Ceiling_Loop
DE89 RET Return.
Mirror the DE bitmask into E.
Mirror_Mask DE8A LD B,$08 Reverse the eight bits of D into E.
DE8C XOR A
Mirror_Mask_Loop DE8D RR D
DE8F RL E
DE91 DJNZ Mirror_Mask_Loop
DE93 RR D
DE95 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 DE96 LD DE,($64AA) HL=Data_PlayerMasks+(*Player_SpriteFrame)*08.
DE9A XOR A
DE9B LD D,A
DE9C SLA E
DE9E RL D
DEA0 SLA E
DEA2 RL D
DEA4 SLA E
DEA6 RL D
DEA8 LD HL,$B5D8
DEAB ADD HL,DE
DEAC LD A,(HL) Mirror the mask when the player is facing left.
DEAD LD DE,$0008
DEB0 ADD HL,DE
DEB1 LD D,(HL)
DEB2 LD E,A
DEB3 LD A,($64AB)
DEB6 BIT 7,A
DEB8 CALL NZ,Mirror_Mask
DEBB LD BC,($64A5) Shift the mask down by the player's fine-Y.
DEBF INC B
DEC0 XOR A
Build_PlayerMask_Shift DEC1 SLA D
DEC3 RL E
DEC5 RL A
DEC7 DJNZ Build_PlayerMask_Shift
DEC9 LD ($643A),A
DECC LD ($643B),DE
DED0 LD A,($64A4) Walk left from the player column until a set bit is found.
DED3 DEC A
DED4 ADD A,A
DED5 ADD A,A
DED6 ADD A,A
DED7 LD C,A
DED8 LD B,$18
DEDA LD A,($643A)
Build_PlayerMask_Scan DEDD DEC C
DEDE SLA D
DEE0 RL E
DEE2 RLA
DEE3 JR C,Build_PlayerMask_Width
DEE5 DJNZ Build_PlayerMask_Scan
DEE7 XOR A Write 0000 to *Player_Footprint.
DEE8 LD ($6448),A
DEEB LD ($6449),A
DEEE RET Return.
Build_PlayerMask_Width DEEF LD B,$00 Count the run of set bits into *Player_Footprint.
Build_PlayerMask_Count DEF1 SLA A
DEF3 INC B
DEF4 JR C,Build_PlayerMask_Count
DEF6 LD ($6448),BC
DEFA 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 DEFB LD A,($6489) Return if *ActionTimer is already running.
DEFE OR A
DEFF RET NZ
DF00 LD BC,$0096 Call Sound_Square (score sound).
DF03 LD DE,$0064
DF06 CALL Sound_Square
DF09 LD BC,$0001 Call Sound_Pickup (pickup sound).
DF0C LD DE,$0064
DF0F CALL Sound_Pickup
DF12 LD A,$12 Write 12 to *ActionTimer.
DF14 LD ($6489),A
DF17 LD A,($64AB) Set the player flash bits in *Player_Facing.
DF1A AND $80
DF1C OR $42
DF1E LD ($64AB),A
DF21 RET Return.
This entry point is used by the routine at Handler_Housekeeping.
Lose a life and restart the room.
Lose_Life DF22 LD A,($649F) Force any pending event to fire first.
DF25 OR A
DF26 JR Z,Lose_Life_Apply
DF28 LD A,$01
DF2A LD ($649F),A
DF2D CALL Handler_EventTimer
Lose_Life_Apply DF30 POP BC Restore BC from the stack.
DF31 LD A,$01 Write 01 to *RestartRoomFlag.
DF33 LD ($6411),A
DF36 LD A,($64B4) Jump to Reset_Introduction if *Player_Lives is 01.
DF39 DEC A
DF3A JP Z,Reset_Introduction
DF3D LD ($64B4),A Decrease *Player_Lives by one.
DF40 XOR A Jump to Change_Room with A=00.
DF41 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 DF44 BIT 7,(IX+$07) Jump to Player_MoveLeft_Step if already facing left.
DF48 JR NZ,Player_MoveLeft_Step
DF4A SET 7,(IX+$07) Face left.
DF4E LD (IX+$06),$60 Set frame 60.
DF52 RET Return.
Player_MoveLeft_Step DF53 LD A,(IX+$06) Advance the walk frame, wrapping at 30.
DF56 ADD A,$06
DF58 CP $30
DF5A JR C,Player_MoveLeft_StoreFrame
DF5C XOR A
Player_MoveLeft_StoreFrame DF5D LD (IX+$06),A
DF60 LD A,(IX+$08) Increase the horizontal delta by 02.
DF63 ADD A,$02
DF65 LD (IX+$08),A
DF68 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 DF69 BIT 7,(IX+$07) Jump to Player_MoveRight_Step if already facing right.
DF6D JR Z,Player_MoveRight_Step
DF6F LD (IX+$06),$60 Set frame 60.
DF73 RES 7,(IX+$07) Face right.
DF77 RET Return.
Player_MoveRight_Step DF78 LD A,(IX+$06) Advance the walk frame, wrapping at 30.
DF7B ADD A,$06
DF7D CP $30
DF7F JR C,Player_MoveRight_StoreFrame
DF81 XOR A
Player_MoveRight_StoreFrame DF82 LD (IX+$06),A
DF85 LD A,(IX+$08) Decrease the horizontal delta by 02.
DF88 SUB $02
DF8A LD (IX+$08),A
DF8D 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 DF8E LD HL,($6420) HL=*ReferenceFurniture.
Player_Action_Loop DF91 LD A,(HL) Jump to Player_Action_Doors if the terminator FF is reached.
DF92 CP $FF
DF94 JR Z,Player_Action_Doors
DF96 BIT 7,A Jump to Player_Action_Next if this record is inactive.
DF98 JR NZ,Player_Action_Next
DF9A CP (IX+$00) Jump to Player_Action_Next unless it matches the player cell.
DF9D JR NZ,Player_Action_Next
DF9F INC HL
DFA0 LD A,(HL)
DFA1 DEC HL
DFA2 DEC A
DFA3 CP (IX+$01)
DFA6 JR NZ,Player_Action_Next
DFA8 LD A,($649F) Fire any pending event before using this furniture.
DFAB OR A
DFAC JR Z,Player_Action_Use
DFAE LD A,$01
DFB0 LD ($649F),A
DFB3 PUSH HL
DFB4 CALL Handler_EventTimer
DFB7 POP HL
Player_Action_Use DFB8 INC HL Jump to Change_Room with the furniture event ID.
DFB9 INC HL
DFBA INC HL
DFBB INC HL
DFBC LD A,(HL)
DFBD POP BC
DFBE POP BC
DFBF JP Change_Room
Player_Action_Next DFC2 LD DE,$0005 HL+=0005.
DFC5 ADD HL,DE
DFC6 JR Player_Action_Loop Jump to Player_Action_Loop.
Player_Action_Doors DFC8 LD A,($649F) Return if *EventTimer is running.
DFCB OR A
DFCC RET NZ
DFCD LD HL,($6422) HL=*ReferenceDoors.
Player_Action_DoorLoop DFD0 LD A,(HL) Return if the terminator FF is reached.
DFD1 CP $FF
DFD3 RET Z
DFD4 BIT 7,A Jump to Player_Action_DoorNext if this door is inactive.
DFD6 JR NZ,Player_Action_DoorNext
DFD8 CP (IX+$00) Jump to Player_Action_DoorNext unless the door column matches.
DFDB JR Z,Player_Action_DoorMatch
DFDD INC A
DFDE CP (IX+$00)
DFE1 JR NZ,Player_Action_DoorNext
Player_Action_DoorMatch DFE3 INC HL Jump to Player_Action_DoorNext unless the door row matches.
DFE4 LD A,(HL)
DFE5 DEC HL
DFE6 CP (IX+$01)
DFE9 JR Z,Player_Action_DoorUse
DFEB DEC A
DFEC CP (IX+$01)
DFEF JR NZ,Player_Action_DoorNext
Player_Action_DoorUse DFF1 LD DE,$0003 Bump the door use count when it is not FF.
DFF4 ADD HL,DE
DFF5 LD A,(HL)
DFF6 OR A
DFF7 JR Z,Player_Action_DoorEvent
DFF9 INC A
DFFA RET Z
DFFB LD (HL),A
Player_Action_DoorEvent DFFC INC HL Jump to Dispatch_Events unless the event is 2A.
DFFD LD A,(HL)
DFFE CP $2A
E000 JP NZ,Dispatch_Events
E003 LD HL,$0001 Write 0001 to *Table_RoomPause.
E006 LD ($E82A),HL
E009 JP Dispatch_Events Jump to Dispatch_Events.
Player_Action_DoorNext E00C LD DE,$0005 HL+=0005.
E00F ADD HL,DE
E010 JR Player_Action_DoorLoop Jump to Player_Action_DoorLoop.
E012 RET Return.
This entry point is used by the routines at Handler_Housekeeping and Handler_Player.
Climb down a ladder from *ReferenceLadders.
Player_ClimbDown E013 LD A,(IX+$03) Return unless the player fine-Y is 07.
E016 CP $07
E018 RET NZ
E019 LD HL,($6428) HL=*ReferenceLadders.
Player_ClimbDown_Loop E01C LD A,(HL) Return if the terminator FF is reached.
E01D CP $FF
E01F RET Z
E020 BIT 7,A Jump to Player_ClimbDown_Next if this ladder is hidden.
E022 JR NZ,Player_ClimbDown_Next
E024 CP (IX+$00) Jump to Player_ClimbDown_Start if the ladder column matches.
E027 JR Z,Player_ClimbDown_Start
E029 INC A Jump to Player_ClimbDown_Next unless the player is on the right-hand half.
E02A CP (IX+$00)
E02D JR NZ,Player_ClimbDown_Next
E02F LD A,(IX+$02)
E032 CP $04
E034 JR NC,Player_ClimbDown_Next
Player_ClimbDown_Start E036 INC HL Jump to Player_ClimbDown_Next unless the player is three rows below the ladder.
E037 LD A,(HL)
E038 DEC HL
E039 ADD A,$03
E03B CP (IX+$01)
E03E JR NZ,Player_ClimbDown_Next
E040 SUB $03 Write the ladder row to *ClimbRow and start climbing down.
E042 LD ($648A),A
E045 LD (IX+$06),$5A
E049 LD (IX+$09),$FE
E04D LD A,(HL) Jump to Player_ClimbDown_Offset unless the ladder column matches.
E04E CP (IX+$00)
E051 JR NZ,Player_ClimbDown_Offset
E053 LD A,$07 Write the remaining fine-X as the horizontal delta.
E055 SUB (IX+$02)
E058 LD (IX+$08),A
E05B RET Return.
Player_ClimbDown_Offset E05C LD A,$FF Write the opposite climb delta.
E05E SUB (IX+$02)
E061 LD (IX+$08),A
E064 RET Return.
Player_ClimbDown_Next E065 INC HL Increase HL by three.
E066 INC HL
E067 INC HL
E068 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 E06A LD A,($6410) Return if *Player_JumpTimer is set.
E06D OR A
E06E RET NZ
E06F LD A,(IX+$03) Jump to Player_Jump unless the player fine-Y is 07.
E072 CP $07
E074 JR NZ,Player_Jump
E076 LD HL,($6428) HL=*ReferenceLadders.
Player_ClimbUp_Loop E079 LD A,(HL) Jump to Player_Jump if the terminator FF is reached.
E07A CP $FF
E07C JR Z,Player_Jump
E07E BIT 7,A Jump to Player_ClimbUp_Next if this ladder is hidden.
E080 JR NZ,Player_ClimbUp_Next
E082 CP (IX+$00) Jump to Player_ClimbUp_Start if the ladder column matches.
E085 JR Z,Player_ClimbUp_Start
E087 INC A Jump to Player_ClimbUp_Next unless the player is on the right-hand half.
E088 CP (IX+$00)
E08B JR NZ,Player_ClimbUp_Next
E08D LD A,(IX+$02)
E090 CP $04
E092 JR NC,Player_ClimbUp_Next
Player_ClimbUp_Start E094 INC HL Return if the player is already at the top.
E095 LD A,(HL)
E096 ADD A,$03
E098 CP (IX+$01)
E09B RET Z
E09C DEC HL Jump to Player_ClimbUp_Next unless the player is two rows below the top.
E09D SUB $05
E09F CP (IX+$01)
E0A2 JR NZ,Player_ClimbUp_Next
E0A4 ADD A,$02 Write the ladder row to *ClimbRow and start climbing up.
E0A6 LD ($648A),A
E0A9 LD (IX+$06),$5A
E0AD LD (IX+$09),$02
E0B1 LD A,(HL) Jump to Player_ClimbUp_Offset unless the ladder column matches.
E0B2 CP (IX+$00)
E0B5 JR NZ,Player_ClimbUp_Offset
E0B7 LD A,$07 Write the remaining fine-X as the horizontal delta.
E0B9 SUB (IX+$02)
E0BC LD (IX+$08),A
E0BF RET Return.
Player_ClimbUp_Offset E0C0 LD A,$FF Write the opposite climb delta.
E0C2 SUB (IX+$02)
E0C5 LD (IX+$08),A
E0C8 RET Return.
Player_ClimbUp_Next E0C9 INC HL Increase HL by three.
E0CA INC HL
E0CB INC HL
E0CC JR Player_ClimbUp_Loop Jump to Player_ClimbUp_Loop.
Player_Jump E0CE LD A,$07 Write 07 to *Player_JumpTimer and start the jump.
E0D0 LD ($6410),A
E0D3 LD (IX+$09),$03
E0D7 BIT 7,(IX+$07) Choose a left-facing jump frame.
E0DB JR NZ,Player_Jump_Right
E0DD LD (IX+$06),$30
E0E1 LD (IX+$08),$FE
E0E5 RET
Player_Jump_Right E0E6 LD (IX+$06),$30 Choose a right-facing jump frame.
E0EA LD (IX+$08),$02
E0EE RET
This entry point is used by the routine at Handler_Player.
Stop climbing when the stored ladder row is left.
Player_ClimbStop E0EF LD A,(IX+$03) Jump to Player_ReadKeys unless the fine-Y is 07.
E0F2 CP $07
E0F4 JR NZ,Player_ReadKeys
E0F6 LD A,($648A) Jump to Player_ClimbStop_Clear if the player is two rows below *ClimbRow.
E0F9 SUB $02
E0FB CP (IX+$01)
E0FE JR Z,Player_ClimbStop_Clear
E100 ADD A,$05 Jump to Player_ReadKeys unless the player is three rows above that point.
E102 CP (IX+$01)
E105 JR NZ,Player_ReadKeys
Player_ClimbStop_Clear E107 XOR A Return after restoring the walk frame.
E108 LD ($648A),A
E10B LD (IX+$06),$60
E10F RET
Player_ReadKeys E110 POP BC Restore BC from the stack.
E111 LD A,($647E) Jump to Controls_Kempston_Climb if Kempston is selected.
E114 OR A
E115 JP NZ,Controls_Kempston_Climb
E118 CALL $028E Call KEY_SCAN.
E11B LD IX,$64A4 IX=Player.
E11F LD A,E Jump to Handler_Player_Commit if no key is pressed.
E120 CP $FF
E122 JP Z,Handler_Player_Commit
E125 LD HL,$6481 Jump to Player_ClimbUp_Anim if the up key matches.
E128 CP (HL)
E129 JR Z,Player_ClimbUp_Anim
E12B INC HL Jump to Handler_Player_Commit unless the down key matches.
E12C CP (HL)
E12D JP NZ,Handler_Player_Commit
This entry point is used by the routine at Handler_Housekeeping.
Animate climbing down.
Player_ClimbDown_Anim E130 LD A,(IX+$06) Step the climb frame down.
E133 SUB $06
E135 CP $42
E137 JR NZ,Player_ClimbDown_StoreFrame
E139 LD A,$5A
Player_ClimbDown_StoreFrame E13B LD (IX+$06),A Store the frame, write FE as the vertical delta and jump to Handler_Player_Commit.
E13E LD (IX+$09),$FE
E142 JP Handler_Player_Commit
This entry point is used by the routine at Handler_Housekeeping.
Animate climbing up.
Player_ClimbUp_Anim E145 LD A,(IX+$06) Step the climb frame up.
E148 ADD A,$06
E14A CP $60
E14C JR NZ,Player_ClimbUp_StoreFrame
E14E LD A,$48
Player_ClimbUp_StoreFrame E150 LD (IX+$06),A Store the frame, write 02 as the vertical delta and jump to Handler_Player_Commit.
E153 LD (IX+$09),$02
E157 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 E15A LD A,($6435) Award a bonus if the hit timer is still 32.
E15D CP $32
E15F JR NZ,Player_Hit_Fall
E161 LD BC,$0064
E164 LD DE,$00C8
E167 CALL Sound_Pickup
Advance, store and erase the falling player.
Player_Hit_Fall E16A LD (IX+$09),$FF Write FF as the vertical delta.
E16E CALL JumpTable_AdvanceEntity Call JumpTable_AdvanceEntity.
E171 CALL JumpTable_StorePosition Call JumpTable_StorePosition.
E174 CALL JumpTable_MoveEntity Call JumpTable_MoveEntity.
Clip the draw against *HitCeilingRow.
E177 LD A,($641A) A=*ClipWindow_MaximumRow.
E17A PUSH AF Stash it on the stack.
E17B LD A,($644A) Write *HitCeilingRow to *ClipWindow_MaximumRow.
E17E LD ($641A),A
E181 CALL JumpTable_DrawEntity Call JumpTable_DrawEntity.
E184 POP AF Restore *ClipWindow_MaximumRow from the stack.
E185 LD ($641A),A Write it back to *ClipWindow_MaximumRow.
E188 LD A,($6435) Decrease *Player_HitTimer.
E18B DEC A
E18C JP Z,Lose_Life Jump to Lose_Life if it is now zero.
E18F LD ($6435),A Write the new count back.
E192 RET Return.
This entry point is used by the routine at Handler_Player.
Animate the jump frames from *Player_JumpTimer.
Player_JumpAnim E193 DEC A Decrease *Player_JumpTimer and point at Handler_Player_Draw.
E194 LD ($6410),A
E197 LD HL,$E292
E19A PUSH HL
E19B LD (IX+$06),$30 Use frame 30 while the timer is 06 or higher.
E19F CP $06
E1A1 RET NC Use frame 36 while the timer is 04 or higher.
E1A2 LD (IX+$06),$36
E1A6 CP $04
E1A8 RET NC Use frame 3C while the timer is 03 or higher.
E1A9 LD (IX+$06),$3C
E1AD CP $03
E1AF RET NC Use frame 42 while the timer is 01 or higher.
E1B0 LD (IX+$06),$42
E1B4 CP $01
E1B6 RET NC Use frame 12 for the last tick.
E1B7 LD (IX+$06),$12
E1BB RET Return.
This entry point is used by the routine at Handler_Player.
Start the hit sequence.
Player_StartHit E1BC LD A,$32 Write 32 to *Player_HitTimer and store the ceiling row.
E1BE LD ($6435),A
E1C1 LD A,(IX+$01)
E1C4 SUB $03
E1C6 LD ($644A),A
E1C9 JP Handler_Player_Draw Jump to Handler_Player_Draw.
Prev: DD97 Up: Map Next: E1CC