← D27E Starburst behavior handler Map D44B → Comet behavior handler
D398: Hockey-mask behavior handler
Runs the hockey mask, which travels in a straight line that turns only at walls and bricks. While the player holds fire, the mask drops a comet.
Input
IX the mask's sprite record (object_table)
IY the mask's logic record (obj2_record)
C the mask's pool-slot index
hockey_mask D398 CALL inhabitant_react_state Reaction-state machine first; while a spawn or death animation plays it returns carry and skips the rest.
D39B RET C
D39C CALL object_avoid_walls Run the shared wall-avoid, step and off-edge despawn.
D39F CALL move_object
D3A2 CALL inhabitant_offscreen
D3A5 RET C
D3A6 LD B,$14 A ball kill removes it for 200 points, banked into the pending score.
D3A8 CALL ball_kill
D3AB RET C
D3AC CALL overlap_sweep The sweep kills it.
D3AF OR A
D3B0 JR Z,comet_scan_inflight
D3B2 LD (IY+$0B),$00
D3B6 LD (IY+$0C),$02
D3BA RET
comet_scan_inflight D3BB PUSH IY No hit: scan the five inhabitant records for a comet already in flight.
D3BD LD IY,inhabitant_records
D3C1 LD B,$05
comet_scan_loop D3C3 LD A,(IY+$08) Walk the records, one stride each. A record of the comet's type means a comet is already in flight.
D3C6 CP $11
D3C8 JR Z,comet_busy_frame
D3CA LD DE,$0010
D3CD ADD IY,DE
D3CF DJNZ comet_scan_loop
D3D1 JR comet_ready
comet_busy_frame D3D3 POP IY A comet is already in flight: show the mask unarmed and do not fire.
D3D5 LD HL,slot_hockey_mask_unarmed
D3D8 LD (IX+$06),L
D3DB LD (IX+$07),H
D3DE RET
The fire read is level-triggered. Held fire therefore drops a fresh comet as soon as the last one clears the field.
comet_ready D3DF POP IY None in flight: show the mask armed with a comet. Return unless fire is pressed.
D3E1 LD HL,slot_hockey_mask_armed
D3E4 LD (IX+$06),L
D3E7 LD (IX+$07),H
D3EA LD HL,controls
D3ED BIT 4,(HL)
D3EF RET Z
D3F0 LD HL,slot_hockey_mask_unarmed Fire pressed: show the mask unarmed, then scan the inhabitant records and their sprite records for a free slot.
D3F3 LD (IX+$06),L
D3F6 LD (IX+$07),H
D3F9 PUSH IY
D3FB PUSH IX
D3FD LD IX,inhabitant_objects
D401 LD IY,inhabitant_records
D405 LD B,$05
comet_free_scan D407 LD A,(IY+$08) Walk the five records, one stride of each per step, for the first free slot; none free means no comet this press.
D40A OR A
D40B JR Z,comet_spawn
D40D LD DE,$0009
D410 ADD IX,DE
D412 LD DE,$0010
D415 ADD IY,DE
D417 DJNZ comet_free_scan
D419 POP IX
D41B POP IY
D41D RET
comet_spawn D41E LD (IY+$08),$11 Free slot found: arm it as a comet. Copy the mask's X and set its Y just below the mask. Initialize its record from the type. Clear its state so it skips the spawn animation. Give it the comet frame, and set its active flag.
D422 POP HL
D423 LD A,(HL)
D424 LD (IX+$00),A
D427 INC HL
D428 LD A,(HL)
D429 ADD A,$10
D42B LD (IX+$01),A
D42E DEC HL
D42F PUSH HL
D430 LD B,$11
D432 CALL spawn_object_init
D435 LD (IY+$0C),$00
D439 LD HL,slot_comet_1
D43C LD (IX+$06),L
D43F LD (IX+$07),H
D442 SET 0,(IX+$08)
D446 POP IX
D448 POP IY
D44A RET
← D27E Starburst behavior handler Map D44B → Comet behavior handler
Fork me on GitHub