Prev: 6C52 Up: Map Next: 6C7A
6C5D: Play normal speed engine sound
Generates the engine sound for normal speed. Called when only CONTROLS_BIT_SPEED_NOT_FAST is set (player not pressing up or down). HL points to the controls byte on entry.
  • Period = (controls_byte AND $0F), used for both on and off delays
  • Symmetric square wave: same delay for high and low phases
  • Loops 8 cycles then returns
Input
HL Pointer to state_controls (controls state byte)
beep_engine_normal 6C5D LD A,(HL) Extract period from low 4 bits of controls byte. Higher value = lower pitch.
6C5E AND $0F
6C60 LD E,A
6C61 LD C,$08 Loop counter: 8 cycles of the waveform.
beep_engine_normal_loop 6C63 LD A,$10 Speaker ON.
6C65 OUT ($FE),A
6C67 LD D,E Load period into D.
beep_engine_normal_delay_on 6C68 DEC D Delay loop for speaker ON phase.
6C69 JR NZ,beep_engine_normal_delay_on
6C6B LD A,$00 Speaker OFF.
6C6D OUT ($FE),A
6C6F LD D,E Load period into D.
beep_engine_normal_delay_off 6C70 DEC D Delay loop for speaker OFF phase.
6C71 JR NZ,beep_engine_normal_delay_off
6C73 DEC C Decrement cycle counter, loop if not zero. Return from interrupt when done.
6C74 JP NZ,beep_engine_normal_loop
6C77 JP int_return
Prev: 6C52 Up: Map Next: 6C7A