Prev: 59491 Up: Map Next: 59692
59521: Process Wall Bouncing Enemy
Per-frame handler for the wall-bouncing enemy. If the wave start delay is still counting down, advances to the next entity record without processing. Otherwise checks for player contact via Find_Colliding_Entity and triggers player death via Strip_Attributes_And_Fade if the bouncer is touching. If the bouncer is already dying, skips to the draw step. Searches the wave enemy list for a collision via Find_Colliding_Wave_Enemy; if none is found, defers to Handle_Enemy_Collision_Chain. On a hit, decrements a countdown timer; when it expires the bouncer erases itself, nudges one step toward the player, picks a new heading, and redraws.
Input
HL Entity record pointer
If the wave is still warming up, skip ahead without processing.
Process_Wall_Bouncing_Enemy 59521 LD A,(50483) If the wave start delay at Wave_Start_Delay is non-zero, skip to Process_Wall_Bouncing_Enemy_Advance.
59524 AND A
59525 JP NZ,Process_Wall_Bouncing_Enemy_Advance
Check whether the player is touching the bouncer and kill them if so.
59528 INC HL Advance to the velocity pair.
59529 INC HL
59530 EXX Switch to alternate registers.
59531 CALL Find_Colliding_Entity Search for a contact slot via Find_Colliding_Entity.
59534 JP NC,Kill_Wall_Bouncing_Enemy Jump to Kill_Wall_Bouncing_Enemy if player contact is confirmed.
59537 LD HL,50388 Load the player position from Player_Y_Position and test overlap via HitTestBounds8AtHL.
59540 CALL HitTestBounds8AtHL
59543 JP NC,Strip_Attributes_And_Fade Kill the player via Strip_Attributes_And_Fade if the overlap test confirmed contact.
59546 EXX Switch back and step three bytes toward the entity record start.
59547 DEC HL
59548 DEC HL
59549 DEC HL
If the bouncer is already dying, skip directly to the draw step.
59550 DEC HL If the bouncer is already dying (bit 0 of active flag), skip to Process_Wall_Bouncing_Enemy_Advance.
59551 DEC HL
59552 LD A,(HL)
59553 SRL A
59555 JR C,Process_Wall_Bouncing_Enemy_Advance
Search the wave enemy list for an enemy the bouncer has hit.
59557 INC HL Step ahead and search the wave enemy list for a collision via Find_Colliding_Wave_Enemy.
59558 INC HL
59559 CALL Find_Colliding_Wave_Enemy
59562 JP NC,Handle_Enemy_Collision_Chain Jump to Handle_Enemy_Collision_Chain if no wave enemy collision was detected.
59565 EXX Switch to alternate registers and step back to the bounce timer.
59566 DEC HL
Tick down the bounce countdown; erase and redirect when it expires.
59567 DEC HL Step to the bounce timer and subtract 4.
59568 LD A,(HL)
59569 SUB 4
59571 LD (HL),A
59572 JR NZ,Process_Wall_Bouncing_Enemy_Advance If the countdown has not reached zero, skip to Process_Wall_Bouncing_Enemy_Advance.
59574 LD (HL),12 Reset the bounce countdown to 12.
59576 INC HL Erase the bouncer sprite via Erase_Wide_Entity_Sprite, preserving the entity pointer.
59577 PUSH HL
59578 CALL Erase_Wide_Entity_Sprite
59581 POP HL
59582 INC HL
Step the bouncer one pixel toward the player and pick a new heading.
59583 LD A,(50388) Measure the signed Y distance to the player at Player_Y_Position.
59586 SUB (HL)
59587 JR Z,Process_Wall_Bouncing_Enemy_Step_Y Set the Y step: 1 (player below), 255 (player above), or 0.
59589 LD A,1
59591 JR NC,Process_Wall_Bouncing_Enemy_Step_Y
59593 LD A,255
Process_Wall_Bouncing_Enemy_Step_Y 59595 LD B,A Store the Y step in B, apply it to the Y position, and advance.
59596 ADD A,(HL)
59597 LD (HL),A
59598 INC HL
59599 LD A,(50389) Measure the signed X distance to the player at Player_X_Position.
59602 SUB (HL)
59603 JR Z,Process_Wall_Bouncing_Enemy_Step_X Set the X step: 1 (player right), 255 (player left), or 0.
59605 LD A,1
59607 JR NC,Process_Wall_Bouncing_Enemy_Step_X
59609 LD A,255
Process_Wall_Bouncing_Enemy_Step_X 59611 LD C,A Store the X step in C, apply it to the X position, and pack both step signs into a 4-bit direction code.
59612 ADD A,(HL)
59613 LD (HL),A
59614 LD A,C
59615 AND 3
59617 RLA
59618 RLA
Apply the new heading: look up the direction colour and redraw.
59619 LD C,A Pack the Y and X step signs into a 4-bit direction code.
59620 LD A,B
59621 AND 3
59623 OR C
59624 LD C,A
59625 LD B,0
59627 EX DE,HL Look up the heading colour from the direction table at Enemy_Direction_Code_Table.
59628 LD HL,60151
59631 ADD HL,BC
59632 LD A,(HL)
59633 PUSH DE
59634 DEC DE
59635 DEC DE Write the heading colour to the entity record.
59636 LD (DE),A
59637 LD A,(50405) Look up the animation frame colour from the cycle table at Enemy_Colour_Cycle_Table.
59640 AND 7
59642 LD C,A
59643 LD B,0
59645 LD HL,59919
59648 ADD HL,BC
59649 LD A,(HL)
59650 EX DE,HL Restore the entity pointer, set the frame colour in B', and respawn the bouncer via Draw_Wide_Entity_Sprite.
59651 EXX
59652 LD B,A
59653 EXX
59654 CALL Draw_Wide_Entity_Sprite
59657 POP HL Restore the entity pointer from the stack.
59658 INC HL Advance four bytes to the next entity record.
59659 INC HL
59660 INC HL
59661 INC HL
59662 RET Return.
This entry point is used by the routine at Handle_Enemy_Collision_Chain.
Bouncer skipped: look up the animation colour and redraw without moving.
Process_Wall_Bouncing_Enemy_Advance 59663 INC HL Advance one byte, stash the pointer, and read the frame index from Colour_Cycle_Table_Pointer.
59664 PUSH HL
59665 LD A,(50405)
59668 AND 7
59670 LD C,A
59671 LD B,0
59673 EX DE,HL Look up the animation colour from Enemy_Colour_Cycle_Table and set it in B'.
59674 LD HL,59919
59677 ADD HL,BC
59678 LD A,(HL)
59679 EX DE,HL
59680 EXX
59681 LD B,A
59682 EXX
59683 CALL Paint_Wide_Entity_Attributes Draw the bouncer in its current position via Paint_Wide_Entity_Attributes.
59686 POP HL Restore the entity pointer from the stack.
59687 LD DE,6 Step six bytes to the next entity record.
59690 ADD HL,DE
59691 RET Return.
Prev: 59491 Up: Map Next: 59692