Prev: E6C4 Up: Map Next: E7AF
E6F7: Process Player Tracking Enemy
Used by the routine at Process_Cluster_Entity.
Per-frame entity handler for the slow player-tracking enemy. Tests player contact via HitTestBounds8AtHL; triggers death via Strip_Attributes_And_Fade if touching. Computes the signed Y and X distance from the player at C4D4 and C4D5 halves it five times to derive a velocity nudge, and negates if the enemy is above or to the left of the player. Reads the entity facing byte; on a random 1-in-8192 chance sets it to 1A (freeze state). If the facing is 1A flips both velocity components and tests for a 1-in-256 chance to clear the freeze. Applies the computed Y and X nudge to the entity position, clamping to the play area, and draws the entity via Draw_Entity_Sprite.
Process_Player_Tracking_Enemy E6F7 LD HL,$C4D4 Set the player Y address in alternate HL and test player contact via HitTestBounds8AtHL; trigger death via Strip_Attributes_And_Fade if touching.
E6FA EXX
E6FB CALL HitTestBounds8AtHL
E6FE JP NC,Strip_Attributes_And_Fade Step back three bytes to the entity Y position and load the player Y coordinate at C4D4.
E701 DEC HL
E702 DEC HL
E703 DEC HL
E704 LD C,(HL)
E705 EX DE,HL
E706 LD A,($C4D4)
E709 LD L,A Compute the signed Y nudge: subtract the entity Y from the player Y, halve five times, and negate if the entity is above the player.
E70A LD H,$00
E70C LD B,$00
E70E AND A
E70F SBC HL,BC
E711 BIT 0,H
E713 LD A,L
E714 JP Z,Process_Player_Tracking_Enemy_Nudge_Y
E717 NEG
Process_Player_Tracking_Enemy_Nudge_Y E719 SRL A Scale the Y nudge and restore its sign.
E71B SRL A
E71D SRL A
E71F SRL A
E721 SRL A
E723 BIT 0,H
E725 JP Z,Process_Player_Tracking_Enemy_Nudge_X
E728 NEG
Process_Player_Tracking_Enemy_Nudge_X E72A EX AF,AF' Compute the signed X nudge from the player X coordinate at C4D5 in the same way.
E72B LD A,($C4D5)
E72E LD L,A
E72F LD H,$00
E731 INC DE
E732 LD A,(DE)
E733 LD C,A
E734 LD B,$00
E736 AND A
E737 SBC HL,BC
E739 BIT 0,H
E73B LD A,L
E73C JP Z,Process_Player_Tracking_Enemy_0
E73F NEG
Process_Player_Tracking_Enemy_0 E741 SRL A
E743 SRL A
E745 SRL A
E747 SRL A
E749 SRL A
E74B BIT 0,H
E74D JP Z,Process_Player_Tracking_Enemy_Face
E750 NEG
Process_Player_Tracking_Enemy_Face E752 LD B,A Store the scaled Y nudge in B and X nudge in C; step back to the entity facing byte.
E753 EX AF,AF'
E754 LD C,A
E755 EX DE,HL
E756 DEC HL
E757 DEC HL
E758 LD A,(HL)
E759 CP $1A
E75B JP Z,Process_Player_Tracking_Enemy_Freeze Read the facing byte; if 1A jump to Process_Player_Tracking_Enemy_Freeze; otherwise test a 1-in-8192 random chance (Generate_Random_Byte twice, masked to 1F and 3F) to set the facing to 1A (freeze).
E75E CALL Generate_Random_Byte
E761 AND $1F
E763 JP NZ,Process_Player_Tracking_Enemy_Move
E766 CALL Generate_Random_Byte
E769 AND $3F
E76B JP NZ,Process_Player_Tracking_Enemy_Move
E76E LD (HL),$1A
E770 JP Process_Player_Tracking_Enemy_Move
Process_Player_Tracking_Enemy_Freeze E773 LD A,B Facing is 1A (frozen): negate both velocity components; test a 1-in-256 chance to promote the facing to 1F (thaw).
E774 NEG
E776 LD B,A
E777 LD A,C
E778 NEG
E77A LD C,A
E77B CALL Generate_Random_Byte
E77E CP $F0
E780 JP NZ,Process_Player_Tracking_Enemy_Move
E783 LD (HL),$1F
Process_Player_Tracking_Enemy_Move E785 INC HL Apply the Y nudge to the entity Y position; clamp to 10-AD and write back.
E786 LD A,C
E787 ADD A,(HL)
E788 CP $10
E78A JP C,Process_Player_Tracking_Enemy_Move_X
E78D CP $AD
E78F JP NC,Process_Player_Tracking_Enemy_Move_X
E792 LD (HL),A
Process_Player_Tracking_Enemy_Move_X E793 INC HL Apply the X nudge to the entity X position; clamp to 08-EF and write back.
E794 LD A,B
E795 ADD A,(HL)
E796 CP $08
E798 JP C,Process_Player_Tracking_Enemy_Draw
E79B CP $EF
E79D JP NC,Process_Player_Tracking_Enemy_Draw
E7A0 LD (HL),A
Process_Player_Tracking_Enemy_Draw E7A1 PUSH HL Stash HL, step back two bytes, set colour INK: CYAN, PAPER: BLACK (BRIGHT) in alternate B, draw the entity via Draw_Entity_Sprite, restore HL, and advance via Process_Cluster_Entity_Next.
E7A2 DEC HL
E7A3 DEC HL
E7A4 EXX
E7A5 LD B,$45
E7A7 EXX
E7A8 CALL Draw_Entity_Sprite
E7AB POP HL
E7AC JP Process_Cluster_Entity_Next
Prev: E6C4 Up: Map Next: E7AF