| ← B79B | Map | B803 → |
B7D2: Sound effect: inhabitant spawns
|
The sound when an inhabitant spawns, a 9-step sequence.
|
||||
| spawn_counter | B7D2 | DEFB $00 | Step counter: 0 when the effect is disarmed, otherwise the step it has reached, 1 to 10 | |
| spawn_periods | B7D3 | DEFB $FA,$E6 | Never read | |
| B7D5 | DEFB $C8,$AA,$82,$C8,$64,$50,$32,$14 | Pitch period for each step | ||
| B7DD | DEFB $14 | |||
| B7DE | DEFB $14 | Never read | ||
|
|
||||
| sfx_spawn | B7DF | LD A,(spawn_counter) | Read the step counter; a disarmed effect has nothing to play. | |
| B7E2 | OR A | |||
| B7E3 | RET Z | |||
| B7E4 | CP $0A | The counter past its last step: clear it and return. That disarms the effect. | ||
| B7E6 | JR NZ,spawn_step | |||
| B7E8 | XOR A | |||
| B7E9 | LD (spawn_counter),A | |||
| B7EC | RET | |||
| spawn_step | B7ED | INC A | Advance to the next step and save the counter. | |
| B7EE | LD (spawn_counter),A | |||
|
Each step's pitch comes from the spawn table.
|
||||
| B7F1 | LD E,A | Take this step's period byte into D. The counter reaches this point only at 2 to 10, so only those offsets of the table are played. | ||
| B7F2 | LD D,$00 | |||
| B7F4 | LD HL,spawn_periods | |||
| B7F7 | ADD HL,DE | |||
| B7F8 | LD D,(HL) | |||
| B7F9 | LD C,$02 | Two cycles make up each step of this sweep too. | ||
| spawn_emit | B7FB | CALL sound_blip | Emit one cycle at the current period. | |
| B7FE | DEC D | Raise the pitch between the two cycles, then repeat until both are done. The death burst lowers it instead. | ||
| B7FF | DEC C | |||
| B800 | JR NZ,spawn_emit | |||
| B802 | RET | |||
| ← B79B | Map | B803 → |
