At the very beginning of the intro music to Prehistorik Man, my emulator outputs an enduring high pitched tone from both Square channels. Eventually, the tone disappears and the music seems normal after that point. Below, I logged the writes to the APU control registers and the Square 2 registers.
FF26 80 (NR52 CONTROL_POWER_LENGTH_STATUSES)
FF24 77 (NR50 CONTROL_LEFT_RIGHT_VOLUME)
FF25 53 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
Audio is enabled and output volumes are maxed out.
Wave and Square 1 are enabled on the left and both Square channels are enabled on the right.
FF16 8F (NR21 SQUARE2_DUTY_LENGTH)
FF17 F0 (NR22 SQUARE2_VOLUME_ENVELOPE)
FF19 80 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
Square 2 duty is set to the 50% pattern and Square 2 length is set to 64 - 15 = 49.
The starting volume for the volume envelope is set to 15. And, the period is set to 0, which is interpreted as 8. The envelope delta is set to negative.
Finally, the tone is triggered with length disabled (why did they even bother setting the length?). Meaning, it's an enduring tone until a register write shuts it off. If the envelope volume drops to 0, that doesn't fully kill the tone...
FF17 18 (NR22 SQUARE2_VOLUME_ENVELOPE)
The starting volume is changed to 1, which shouldn't affect the currently playing volume. The period remains unchanged. However, the envelope delta toggled from minus to plus; even if the envelope volume dropped to 0, it can now rise back to max.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
The frequency of the tone is adjusted.
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
The noise channel is muted.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
That pattern repeats again and again for a while.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
...
Anyway, from what I understand of the APU, the enduring Square tones should be present. What am I interpreting incorrectly?
FF26 80 (NR52 CONTROL_POWER_LENGTH_STATUSES)
FF24 77 (NR50 CONTROL_LEFT_RIGHT_VOLUME)
FF25 53 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
Audio is enabled and output volumes are maxed out.
Wave and Square 1 are enabled on the left and both Square channels are enabled on the right.
FF16 8F (NR21 SQUARE2_DUTY_LENGTH)
FF17 F0 (NR22 SQUARE2_VOLUME_ENVELOPE)
FF19 80 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
Square 2 duty is set to the 50% pattern and Square 2 length is set to 64 - 15 = 49.
The starting volume for the volume envelope is set to 15. And, the period is set to 0, which is interpreted as 8. The envelope delta is set to negative.
Finally, the tone is triggered with length disabled (why did they even bother setting the length?). Meaning, it's an enduring tone until a register write shuts it off. If the envelope volume drops to 0, that doesn't fully kill the tone...
FF17 18 (NR22 SQUARE2_VOLUME_ENVELOPE)
The starting volume is changed to 1, which shouldn't affect the currently playing volume. The period remains unchanged. However, the envelope delta toggled from minus to plus; even if the envelope volume dropped to 0, it can now rise back to max.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
The frequency of the tone is adjusted.
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
The noise channel is muted.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
That pattern repeats again and again for a while.
FF18 F4 (NR23 SQUARE2_FREQUENCY_LSB)
FF19 01 (NR24 SQUARE2_TRIGGER_FREQUENCY_MSB)
FF25 77 (NR51 CONTROL_LEFT_RIGHT_ENABLES)
...
Anyway, from what I understand of the APU, the enduring Square tones should be present. What am I interpreting incorrectly?