Prev: 6C7A Up: Map Next: 6CAD
6C7B: Play explosion sound effect
Generates an explosion sound that plays over 24 interrupts ($18). Called once per interrupt while CONTROLS_BIT_EXPLODING is set. The ON delay is derived from (DE)&7, but DE is not set up by the caller - it retains whatever value the interrupted main loop code had, making the pitch vary semi-randomly between interrupts and giving the explosion its noisy character.
  • Counter decrements from $18 (24) to 0 over successive interrupts
  • ON delay = ((DE) AND $07) << 3 + $10, range $10-$48 (16-72)
  • OFF delay = counter value, decreasing each interrupt (sound speeds up)
  • 4 cycles of waveform per interrupt
  • As counter decreases, OFF delay shortens, making sound more rapid/urgent
Input
DE Not intentionally set - residual value from interrupted code, read as (DE)&7 to derive ON delay
beep_explosion 6C7B LD A,($6C7A) Decrement explosion counter.
6C7E DEC A
6C7F LD ($6C7A),A
6C82 CP $00 If counter reached 0, jump to explosion_render_finish to finish.
6C84 JP Z,explosion_render_finish
6C87 LD A,(DE) Calculate ON delay: ((DE) AND $07) << 3 + $10. Gives value $10-$48 based on low 3 bits of (DE).
6C88 AND $07
6C8A SLA A
6C8C SLA A
6C8E SLA A
6C90 ADD A,$10
6C92 LD E,A Set ON delay in E, loop counter = 4 cycles.
6C93 LD C,$04
beep_explosion_loop 6C95 LD A,$10 Speaker ON.
6C97 OUT ($FE),A
6C99 LD D,E Load ON delay into D.
beep_explosion_delay_on 6C9A DEC D Delay loop for speaker ON phase.
6C9B JR NZ,beep_explosion_delay_on
6C9D LD A,$00 Speaker OFF.
6C9F OUT ($FE),A
6CA1 LD A,($6C7A) Load counter value as OFF delay.
6CA4 LD D,A
beep_explosion_delay_off 6CA5 DEC D Delay loop for speaker OFF phase (speeds up as counter decreases).
6CA6 JR NZ,beep_explosion_delay_off
6CA8 DEC C Decrement cycle counter, loop for 4 cycles per interrupt.
6CA9 JP NZ,beep_explosion_loop
6CAC RET
Prev: 6C7A Up: Map Next: 6CAD