| ← C5C4 | Map | C73D → |
C61D: Spawn objects from the current level's wave script
|
Spawns at most one object per frame from one slot of the current level's wave script. That object is the ball gem as the secondary object, or an inhabitant in a free inhabitant record.
|
|||
| process_wave_script | C61D | LD A,(move_freeze) | Spawn nothing while the global move-freeze holds. |
| C620 | OR A | ||
| C621 | RET NZ | ||
| C622 | LD A,(death_pause_timer) | Spawn nothing while the death pause runs. | |
| C625 | OR A | ||
| C626 | RET NZ | ||
| C627 | LD A,(level) | Index this level's wave script, 8 bytes per level. | |
| C62A | LD L,A | ||
| C62B | LD H,$00 | ||
| C62D | ADD HL,HL | ||
| C62E | ADD HL,HL | ||
| C62F | ADD HL,HL | ||
| C630 | LD DE,wave_scripts | ||
| C633 | ADD HL,DE | ||
| C634 | CALL next_random | Draw a random byte; a value 0–7 (a 1-in-2 chance) selects the script slot, otherwise bail this frame. | |
| C637 | AND $0F | ||
| C639 | CP $08 | ||
| C63B | RET NC | ||
| C63C | LD D,$00 | ||
| C63E | LD E,A | ||
| C63F | ADD HL,DE | Read the selected slot's value (the type to spawn). | |
| C640 | LD A,(HL) | ||
| C641 | OR A | ||
| C642 | RET Z | Empty slot – spawn nothing. | |
| C643 | PUSH AF | ||
| C644 | CP $11 | The comet is the one type that skips the throttle. | |
| C646 | JR Z,process_wave_script_1 | ||
| C648 | LD HL,spawn_throttle | Throttle normal spawns: bump the spawn throttle, and spawn only when it reaches its limit. Short of that, return without a spawn. | |
| C64B | INC (HL) | ||
| C64C | LD A,(HL) | ||
| C64D | CP $32 | ||
| C64F | JR Z,process_wave_script_0 | ||
| C651 | POP AF | ||
| C652 | RET | ||
| process_wave_script_0 | C653 | XOR A | On the fiftieth, reset the counter and let the spawn through. |
| C654 | LD (HL),A | ||
| process_wave_script_1 | C655 | POP AF | Recover the slot value the throttle test pushed aside. |
| C656 | CP $01 | Dispatch on the slot value: the lowest spawns the ball gem, and anything else spawns a generic inhabitant. | |
| C658 | JP NZ,process_wave_script_2 | ||
|
The ball-gem entry spawns the ball gem as the secondary object. It refuses while any ball or gem state that would conflict is active: ball_gem_frame, prize_on_field_latched, ball_b_in_play, double_bat_active, missile_active, missile_shot, fx_bomb_arm, fx_spawn_ball_arm, fx_despawn_arm.
|
|||
| C65B | LD A,(ball_gem_frame) | Abort the spawn if any ball or gem state flag that would conflict is set. | |
| C65E | OR A | ||
| C65F | RET NZ | ||
| C660 | LD A,(prize_on_field_latched) | ||
| C663 | OR A | ||
| C664 | RET NZ | ||
| C665 | LD A,(ball_b_in_play) | ||
| C668 | OR A | ||
| C669 | RET NZ | ||
| C66A | LD A,(double_bat_active) | ||
| C66D | OR A | ||
| C66E | RET NZ | ||
| C66F | LD A,(missile_active) | ||
| C672 | OR A | ||
| C673 | RET NZ | ||
| C674 | LD A,(missile_shot) | ||
| C677 | OR A | ||
| C678 | RET NZ | ||
| C679 | LD A,(fx_bomb_arm) | ||
| C67C | OR A | ||
| C67D | RET NZ | ||
| C67E | LD A,(fx_spawn_ball_arm) | ||
| C681 | OR A | ||
| C682 | RET NZ | ||
| C683 | LD A,(fx_despawn_arm) | ||
| C686 | OR A | ||
| C687 | RET NZ | ||
| C688 | LD A,$01 | Mark the ball gem out and request a fixed-position spawn. | |
| C68A | LD (ball_gem_frame),A | ||
| C68D | LD (spawn_fixed_pos),A | ||
| C690 | CALL calc_spawn_coords | ||
| C693 | LD IX,obj2_object | Write the computed position into the ball gem's sprite record. | |
| C697 | LD A,(work_x) | ||
| C69A | LD (IX+$00),A | ||
| C69D | LD A,(work_y) | ||
| C6A0 | LD (IX+$01),A | ||
| C6A3 | LD IY,obj2_record | ||
| C6A7 | LD (IY+$00),$01 | Initialize the ball gem's logic record: an up-right heading, speed 1, and a cleared travel counter, then return. | |
| C6AB | LD (IY+$01),$01 | ||
| C6AF | LD (IY+$09),$00 | ||
| C6B3 | LD (IY+$0A),$00 | ||
| C6B7 | RET | ||
|
Generic spawn for any type other than the ball gem. Reject a duplicate singleton and claim a free inhabitant record. Choose the position mode by type, then fall through to the logic-record initialization.
|
|||
| process_wave_script_2 | C6B8 | LD B,A | Scan the five inhabitant records for one that already holds this type. |
| C6B9 | LD C,$03 | ||
| C6BB | LD IY,inhabitant_records | ||
| process_wave_script_3 | C6BF | LD A,(IY+$08) | |
| C6C2 | CP B | ||
| C6C3 | JR Z,process_wave_script_4 | ||
| C6C5 | LD DE,$0010 | ||
| C6C8 | ADD IY,DE | ||
| C6CA | INC C | ||
| C6CB | LD A,C | ||
| C6CC | CP $08 | ||
| C6CE | JR NZ,process_wave_script_3 | ||
| C6D0 | JR process_wave_script_5 | ||
| process_wave_script_4 | C6D2 | LD A,(IY+$0D) | Matched: if that instance is a singleton refuse to spawn a second. |
| C6D5 | OR A | ||
| C6D6 | RET NZ | ||
| process_wave_script_5 | C6D7 | LD C,$03 | Find a free inhabitant record – one whose type is 0; none free means abort. |
| C6D9 | LD IY,inhabitant_records | ||
| process_wave_script_6 | C6DD | LD A,(IY+$08) | |
| C6E0 | OR A | ||
| C6E1 | JR Z,process_wave_script_7 | ||
| C6E3 | LD DE,$0010 | ||
| C6E6 | ADD IY,DE | ||
| C6E8 | INC C | ||
| C6E9 | LD A,C | ||
| C6EA | CP $08 | ||
| C6EC | JR NZ,process_wave_script_6 | ||
| C6EE | RET | ||
| process_wave_script_7 | C6EF | LD A,B | The orb only: skip the spawn while the capture slide runs. |
| C6F0 | CP $09 | ||
| C6F2 | JR NZ,process_wave_script_8 | ||
| C6F4 | LD A,(capture_slide) | ||
| C6F7 | OR A | ||
| C6F8 | RET NZ | ||
| process_wave_script_8 | C6F9 | LD A,B | Claim the free record: store the type into it. |
| C6FA | LD (IY+$08),A | ||
| C6FD | CP $0D | The wheel also arms the wheel swarm trigger. | |
| C6FF | JR NZ,process_wave_script_9 | ||
| C701 | LD A,$01 | ||
| C703 | LD (wheel_swarm_trigger),A | ||
| process_wave_script_9 | C706 | LD A,(IY+$08) | Types 6, 9 and $0D spawn at the fixed table entry 0; all others at a random entry. |
| C709 | CP $06 | ||
| C70B | JR Z,process_wave_script_10 | ||
| C70D | CP $09 | ||
| C70F | JR Z,process_wave_script_10 | ||
| C711 | CP $0D | ||
| C713 | JR Z,process_wave_script_10 | ||
| C715 | XOR A | Clear the fixed-position flag to request a random spawn position. | |
| C716 | LD (spawn_fixed_pos),A | ||
| C719 | JR process_wave_script_11 | ||
| process_wave_script_10 | C71B | LD A,$01 | Raise the fixed-position flag to request the fixed entry-0 spawn position. |
| C71D | LD (spawn_fixed_pos),A | ||
| process_wave_script_11 | C720 | CALL calc_spawn_coords | Either way, pick the spawn cell. |
| C723 | PUSH BC | Point IX at this slot's sprite record, 9 bytes per slot. | |
| C724 | LD B,C | ||
| C725 | LD DE,$0009 | ||
| C728 | LD IX,object_table | ||
| process_wave_script_12 | C72C | ADD IX,DE | |
| C72E | DJNZ process_wave_script_12 | ||
| C730 | POP BC | ||
| C731 | LD A,(work_x) | Write the spawn position into the sprite record from the work X and work Y. Then fall through into the logic-record initialization. | |
| C734 | LD (IX+$00),A | ||
| C737 | LD A,(work_y) | ||
| C73A | LD (IX+$01),A | ||
| ← C5C4 | Map | C73D → |
