Prev: 59060 Up: Map Next: 59127
59076: Apply Entity Velocity
Used by the routine at Process_Cluster_Entity.
Applies a pre-computed velocity nudge (BC) to the Y and X position bytes of the entity record, clamping each to the play area bounds, and redraws the entity via Draw_Narrow_Entity_Sprite. Called as the contact handler from Process_Cluster_Entity when a cluster entity reaches the player.
Apply_Entity_Velocity 59076 EXX Switch to alternate registers, save the entity position pointer, and load the Y and X position bytes.
59077 LD D,H
59078 LD E,L
59079 INC DE
59080 INC DE
59081 INC DE
59082 INC DE
59083 LD A,(DE)
59084 ADD A,(HL)
59085 CP 16 Test and apply the Y nudge; clamp Y to 16-179 and write back.
59087 JP C,Apply_Entity_Velocity_X
59090 CP 179
59092 JP NC,Apply_Entity_Velocity_X
59095 LD (HL),A
Apply_Entity_Velocity_X 59096 INC HL Test and apply the X nudge; clamp X to 8-243 and write back.
59097 INC DE
59098 LD A,(DE)
59099 ADD A,(HL)
59100 CP 8
59102 JP C,Apply_Entity_Velocity_Draw
59105 CP 243
59107 JP NC,Apply_Entity_Velocity_Draw
59110 LD (HL),A
Apply_Entity_Velocity_Draw 59111 DEC HL Step back two bytes, set colour INK: WHITE, PAPER: BLACK (BRIGHT) in B', and draw the entity via Draw_Narrow_Entity_Sprite.
59112 DEC HL
59113 PUSH DE
59114 EXX
59115 LD B,71
59117 EXX
59118 CALL Draw_Narrow_Entity_Sprite Restore DE, copy to HL, advance two bytes, and return.
59121 POP DE
59122 LD H,D
59123 LD L,E
59124 INC HL
59125 INC HL
59126 RET
Prev: 59060 Up: Map Next: 59127