Prev: 59764 Up: Map Next: 59919
59852: 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 15 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 (248 within the play area, 240 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 59852 LD A,(HL) Load the animation colour from the entity record into B'.
59853 EXX
59854 LD B,A
59855 EXX
59856 PUSH HL Stash the entity pointer on the stack.
59857 INC HL Step to the draw position and call Draw_Wide_Entity_Sprite_Pixels_Only to XOR-draw the entity.
59858 CALL Draw_Wide_Entity_Sprite_Pixels_Only
59861 POP HL Restore the entity pointer from the stack.
Increment the death counter and retire when it reaches 15.
59862 INC (HL) Increment the counter and jump to Animate_Wall_Bouncing_Enemy_Death_End when it reaches 15.
59863 LD A,(HL)
59864 CP 15
59866 JR Z,Animate_Wall_Bouncing_Enemy_Death_End
Load the new frame colour and read the entity Y position.
59868 EXX Set the frame colour in B' and read the entity Y position.
59869 LD B,A
59870 EXX
59871 INC HL
59872 INC HL
59873 LD A,(HL)
Select the scroll offset based on the Y position.
59874 CP 24 Jump to Animate_Wall_Bouncing_Enemy_Death_Scroll if the entity is within the play area.
59876 JR NC,Animate_Wall_Bouncing_Enemy_Death_Scroll
59878 CP 171 Load zero scroll offset and jump to Animate_Wall_Bouncing_Enemy_Death_Ceil if the ceiling boundary is exceeded.
59880 LD A,0
59882 JR NC,Animate_Wall_Bouncing_Enemy_Death_Ceil
59884 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 59886 CP 174 Select scroll offset 248 if within bounds, or 240 if near the ceiling.
59888 LD A,248
59890 JR C,Animate_Wall_Bouncing_Enemy_Death_Apply
59892 LD A,240
Apply the scroll offset, XOR-erase the entity, and advance.
Animate_Wall_Bouncing_Enemy_Death_Apply 59894 ADD A,(HL) Apply the scroll offset to the Y position and call Draw_Wide_Entity_Sprite_Pixels_Only to XOR-erase the entity.
59895 LD (HL),A
59896 DEC HL
59897 PUSH HL
59898 CALL Draw_Wide_Entity_Sprite_Pixels_Only
59901 POP HL Restore the entity pointer from the stack.
59902 JP Process_Entity_Record_Next6 Jump to Process_Entity_Record_Next6 to advance the entity pointer.
Animate_Wall_Bouncing_Enemy_Death_Ceil 59905 DEC HL Step back to the entity handler field.
59906 DEC HL
Write the retire handler and jump to it.
Animate_Wall_Bouncing_Enemy_Death_End 59907 LD DE,57388 Write the retire handler address Process_Entity_Record_Next7 into the entity record.
59910 DEC HL
59911 LD (HL),D
59912 DEC HL
59913 LD (HL),E
59914 INC HL
59915 INC HL
59916 JP Process_Entity_Record_Next7 Jump to Process_Entity_Record_Next7.
Prev: 59764 Up: Map Next: 59919