Prev: E346 Up: Map Next: E492
E360: Process Tracked Enemy Entity
Per-frame entity handler for IX-indexed tracked wave enemies. If the wave start delay is still counting, advances the entity pointer via Process_Tracked_Enemy_Entity_Advance. Otherwise stores the entity record pointer at Entity_Pointer_Stash, rebuilds the spawn buffer via Build_Entity_Spawn_Record, and searches for a collision- free slot via Find_Colliding_Entity. Tests player contact via HitTestBounds8AtHL and triggers death via Strip_Attributes_And_Fade if touching. Decrements the animation phase, erases the sprite via Erase_Wide_Entity_Sprite, advances the animation frame within the phase mask, then re-enters movement at Process_Tracked_Enemy_Entity_Move. Updates the entity velocity with angular rate via Advance_RNG_Seed and Clamp_Entity_Velocity, clamps position to the play area, rebuilds the spawn buffer, and draws via Draw_Wide_Entity_Sprite. When the animation phase reaches zero, either removes the entity or promotes it to the next phase and spawns a cluster entity with handler Process_Cluster_Entity.
Process_Tracked_Enemy_Entity E360 LD A,($C533) Skip to Process_Tracked_Enemy_Entity_Advance if the wave start delay at C533 is still active.
E363 AND A
E364 JP NZ,Process_Tracked_Enemy_Entity_Advance
E367 LD ($C50F),HL Store the entity record pointer at Entity_Pointer_Stash and reload into IX.
E36A LD IX,($C50F)
E36E CALL Build_Entity_Spawn_Record Point HL at the spawn buffer (C512), switch to alternate registers, and search for a free entity slot via Find_Colliding_Entity; jump to Kill_Tracked_Enemy_Entity if no free slot is available.
E371 LD HL,$C512
E374 EXX
E375 CALL Find_Colliding_Entity
E378 JP NC,Kill_Tracked_Enemy_Entity Test player contact via HitTestBounds8AtHL; trigger death via Strip_Attributes_And_Fade if touching. Reload the entity pointer, decrement the animation phase, and erase the entity sprite via Erase_Wide_Entity_Sprite.
E37B LD HL,$C4D4
E37E CALL HitTestBounds8AtHL
E381 JP NC,Strip_Attributes_And_Fade
E384 LD HL,$C511
E387 CALL Erase_Wide_Entity_Sprite
E38A LD HL,($C50F)
E38D DEC (HL)
Read the animation phase and select the animation frame mask: 07 if the phase is 37 or higher, 03 otherwise.
E38E LD A,(HL) Read the phase, select the frame mask, and advance HL.
E38F LD C,A
E390 BIT 0,A
E392 JP NZ,Process_Tracked_Enemy_Entity_Move
E395 CP $37
E397 LD B,$03
E399 JP NC,Process_Tracked_Enemy_Entity_Frame
E39C LD B,$07
Process_Tracked_Enemy_Entity_Frame E39E INC HL Increment the animation frame within the mask, add the base offset 28 and write back.
E39F INC HL
E3A0 LD A,(HL)
E3A1 INC A
E3A2 AND B
E3A3 ADD A,$28
E3A5 LD (HL),A Jump to Process_Tracked_Enemy_Entity_Phase_End if the animation phase has reached zero.
E3A6 LD A,C
E3A7 AND A
E3A8 JP Z,Process_Tracked_Enemy_Entity_Phase_End
Update the entity velocity: apply the angular rate via Advance_RNG_Seed to both Y and X velocity components, clamp each via Clamp_Entity_Velocity, then add the velocities to the Y and X position and clamp to the play area.
Process_Tracked_Enemy_Entity_Move E3AB LD D,(IX+$07) Load the Y velocity from the entity record and apply the angular rate via Advance_RNG_Seed.
E3AE LD E,(IX+$08)
E3B1 CALL Advance_RNG_Seed Clamp the Y velocity via Clamp_Entity_Velocity and store it back.
E3B4 CALL Clamp_Entity_Velocity
E3B7 LD (IX+$07),H Add the clamped Y velocity to the entity Y position; load and apply the angular rate to the X velocity.
E3BA LD (IX+$08),L
E3BD LD D,(IX+$03)
E3C0 LD E,(IX+$04)
E3C3 ADD HL,DE
E3C4 LD A,H
E3C5 CP $10
E3C7 JP NC,Process_Tracked_Enemy_Entity_Clamp_Y
E3CA LD H,$10
E3CC JP Process_Tracked_Enemy_Entity_X
Process_Tracked_Enemy_Entity_Clamp_Y E3CF CP $A9 Clamp the Y position to the floor 10 or ceiling A9.
E3D1 JP C,Process_Tracked_Enemy_Entity_X
E3D4 LD H,$A9
Process_Tracked_Enemy_Entity_X E3D6 LD (IX+$03),H Store the clamped Y position and load the X velocity components.
E3D9 LD (IX+$04),L
E3DC LD D,(IX+$09)
E3DF LD E,(IX+$0A) Apply the angular rate to the X velocity and clamp via Clamp_Entity_Velocity.
E3E2 CALL Advance_RNG_Seed
E3E5 CALL Clamp_Entity_Velocity
E3E8 LD (IX+$09),H Add the clamped X velocity to the entity X position.
E3EB LD (IX+$0A),L
E3EE LD D,(IX+$05)
E3F1 LD E,(IX+$06)
E3F4 ADD HL,DE
E3F5 LD A,H
E3F6 CP $08
E3F8 JP NC,Process_Tracked_Enemy_Entity_Clamp_X
E3FB LD H,$08
E3FD JP Process_Tracked_Enemy_Entity_Draw
Process_Tracked_Enemy_Entity_Clamp_X E400 CP $E9 Clamp the X position to the floor 08 or ceiling E9.
E402 JP C,Process_Tracked_Enemy_Entity_Draw
E405 LD H,$E9
Process_Tracked_Enemy_Entity_Draw E407 LD (IX+$05),H Store the clamped X position and rebuild the spawn buffer via Build_Entity_Spawn_Record.
E40A LD (IX+$06),L
E40D CALL Build_Entity_Spawn_Record
E410 LD B,$42 Set colour INK: RED, PAPER: BLACK (BRIGHT) in B', draw the entity via Draw_Wide_Entity_Sprite, and restore HL.
E412 EXX
E413 LD HL,$C511
E416 CALL Draw_Wide_Entity_Sprite
This entry point is used by the routine at Kill_Tracked_Enemy_Entity.
Reload the entity list pointer from Entity_Pointer_Stash and advance it by 0C bytes.
Process_Tracked_Enemy_Entity_Reload E419 LD HL,($C50F) Reload HL from Entity_Pointer_Stash.
Process_Tracked_Enemy_Entity_Advance E41C LD DE,$000C Advance the entity pointer by 0C bytes and return.
E41F ADD HL,DE
E420 RET
The animation phase has reached zero. If the entity still has remaining passes, promote it to the next phase and spawn a cluster entity; otherwise remove it from the active set.
Process_Tracked_Enemy_Entity_Phase_End E421 LD A,(IX+$01) If the entity has remaining animation passes, jump to Process_Tracked_Enemy_Entity_Promote; otherwise fall through to remove it.
E424 AND A
E425 JP NZ,Process_Tracked_Enemy_Entity_Promote
E428 LD HL,$C42C Decrement the active entity count at C42C and the total wave enemy count at Active_Enemy_Count; write handler Process_Tracked_Enemy_Entity_Advance and jump to Process_Tracked_Enemy_Entity_Reload.
E42B DEC (HL)
E42C LD HL,$C41C
E42F DEC (HL)
E430 LD DE,$E41C
E433 LD (IX-$01),D
E436 LD (IX-$02),E
E439 JP Process_Tracked_Enemy_Entity_Reload
Entity still has passes remaining: increment the animation counters, spawn a cluster entity with handler Process_Cluster_Entity into the entity list, and re-enter the movement update loop at Process_Tracked_Enemy_Entity_Move.
Process_Tracked_Enemy_Entity_Promote E43C LD (IX+$00),$14 Set the animation byte to 14 decrement the remaining pass count, and increment the active count at C42C and Active_Enemy_Count.
E440 DEC (IX+$01)
E443 LD HL,$C42D
E446 INC (HL)
E447 LD HL,$C41C
E44A INC (HL)
E44B LD HL,($C509) Load the entity list write pointer from *Entity_List_Write_Pointer and write the Process_Cluster_Entity handler.
E44E LD DE,$E520
E451 LD (HL),E
E452 INC HL
E453 LD (HL),D Write the entity type (1C), Y and X coordinates from the current entity into the new cluster record.
E454 INC HL
E455 LD (HL),$1C
E457 INC HL
E458 LD B,(IX+$03)
E45B LD (HL),B
E45C INC HL
E45D LD C,(IX+$05)
E460 LD (HL),C
E461 PUSH HL Stash HL, set colour INK: CYAN, PAPER: BLACK (BRIGHT) in B', draw the entity colour slot via Draw_Entity_Sprite, and restore HL.
E462 DEC HL
E463 DEC HL
E464 EXX
E465 LD B,$45
E467 EXX
E468 CALL Draw_Entity_Sprite
E46B POP HL Write the trailing record bytes, advance HL, save the entity list pointer, write the D1A4 terminator, and jump to Process_Tracked_Enemy_Entity_Move.
E46C INC HL
E46D LD (HL),$05
E46F INC HL
E470 LD (HL),$09
E472 INC HL
E473 LD (HL),$00
E475 INC HL
E476 LD (HL),$19
E478 INC HL
E479 INC HL
E47A INC HL
E47B LD (HL),$05
E47D INC HL
E47E LD (HL),$05
E480 INC HL
E481 INC HL
E482 INC HL
E483 LD (HL),$FF
E485 INC HL
E486 LD DE,$D1A4
E489 LD ($C509),HL
E48C LD (HL),E
E48D INC HL
E48E LD (HL),D
E48F JP Process_Tracked_Enemy_Entity_Move
Prev: E346 Up: Map Next: E492