Prev: E974 Up: Map Next: EA0F
E9CC: Animate Wall Bouncing Enemy Death
Per-frame death handler for a wall-bouncing enemy, written by Kill_Wall_Bouncing_Enemy. Each frame, XOR-draws the entity using the stored animation colour, then increments the death animation counter. When it reaches 0F writes Process_Entity_Record_Next7 as the retire handler and jumps to it. Otherwise loads the counter into B', reads the entity Y position, selects a scroll offset (F8 within the play area, F0 near the ceiling), updates the Y position, XOR-erases the entity, and jumps to Process_Entity_Record_Next6.
Input
HL Entity record pointer
XOR-draw the entity with the stored animation colour.
Animate_Wall_Bouncing_Enemy_Death E9CC LD A,(HL) Load the animation colour from the entity record into B'.
E9CD EXX
E9CE LD B,A
E9CF EXX
E9D0 PUSH HL Stash the entity pointer on the stack.
E9D1 INC HL Step to the draw position and call Draw_Wide_Entity_Sprite_Pixels_Only to XOR-draw the entity.
E9D2 CALL Draw_Wide_Entity_Sprite_Pixels_Only
E9D5 POP HL Restore the entity pointer from the stack.
Increment the death counter and retire when it reaches 0F.
E9D6 INC (HL) Increment the counter and jump to Animate_Wall_Bouncing_Enemy_Death_End when it reaches 0F.
E9D7 LD A,(HL)
E9D8 CP $0F
E9DA JR Z,Animate_Wall_Bouncing_Enemy_Death_End
Load the new frame colour and read the entity Y position.
E9DC EXX Set the frame colour in B' and read the entity Y position.
E9DD LD B,A
E9DE EXX
E9DF INC HL
E9E0 INC HL
E9E1 LD A,(HL)
Select the scroll offset based on the Y position.
E9E2 CP $18 Jump to Animate_Wall_Bouncing_Enemy_Death_Scroll if the entity is within the play area.
E9E4 JR NC,Animate_Wall_Bouncing_Enemy_Death_Scroll
E9E6 CP $AB Load zero scroll offset and jump to Animate_Wall_Bouncing_Enemy_Death_Ceil if the ceiling boundary is exceeded.
E9E8 LD A,$00
E9EA JR NC,Animate_Wall_Bouncing_Enemy_Death_Ceil
E9EC JR Animate_Wall_Bouncing_Enemy_Death_Apply Jump to Animate_Wall_Bouncing_Enemy_Death_Apply to apply the scroll offset.
Choose the scroll speed based on distance from the ceiling.
Animate_Wall_Bouncing_Enemy_Death_Scroll E9EE CP $AE Select scroll offset F8 if within bounds, or F0 if near the ceiling.
E9F0 LD A,$F8
E9F2 JR C,Animate_Wall_Bouncing_Enemy_Death_Apply
E9F4 LD A,$F0
Apply the scroll offset, XOR-erase the entity, and advance.
Animate_Wall_Bouncing_Enemy_Death_Apply E9F6 ADD A,(HL) Apply the scroll offset to the Y position and call Draw_Wide_Entity_Sprite_Pixels_Only to XOR-erase the entity.
E9F7 LD (HL),A
E9F8 DEC HL
E9F9 PUSH HL
E9FA CALL Draw_Wide_Entity_Sprite_Pixels_Only
E9FD POP HL Restore the entity pointer from the stack.
E9FE JP Process_Entity_Record_Next6 Jump to Process_Entity_Record_Next6 to advance the entity pointer.
Animate_Wall_Bouncing_Enemy_Death_Ceil EA01 DEC HL Step back to the entity handler field.
EA02 DEC HL
Write the retire handler and jump to it.
Animate_Wall_Bouncing_Enemy_Death_End EA03 LD DE,$E02C Write the retire handler address Process_Entity_Record_Next7 into the entity record.
EA06 DEC HL
EA07 LD (HL),D
EA08 DEC HL
EA09 LD (HL),E
EA0A INC HL
EA0B INC HL
EA0C JP Process_Entity_Record_Next7 Jump to Process_Entity_Record_Next7.
Prev: E974 Up: Map Next: EA0F