I have seen this issue with a few tracks in the game, but it seems to happen randomly, but when it does, it's kinda annoying.
I like to use the echoing of square waves as it has a nice sound, but don't like that square 2 cancels square 1's sound.
Can anything be done about this?
Change the frequency by a small amount on the 2nd channel, or perhaps use a light vibrato on one of them. Instead of canceling out, you'll get a really cool phasing effect.
If you do some writes in $4003/$4007 to both square waves to the start of the note, they will be always sync'd, since writing to these registers reset the phase, so no wave cancelling is possible.
Yeah but if they almost cancel, a very annoying sound is heard. One solution is to use a different duty cycle for the echo, or do what memblers says if your sound engine is complex enough to support that. (when 50% square echoes a 75% or 87.5% rectangle wave it sounds cool).
It could be as simple as raising square 2's period by 1 if it equals that of square1.
Also it's kind of interesting that this phasing effect is present in the hardware, if you hit the sweep registers it automatically adds 1 to the 2nd pulse channel. The only thing that really shows that effect, that I can think of, is The Guardian Legend - the "alarm sound" before you fight a boss. It used to sound canceled on emulators before that was discovered.