There is ome thing that I don't understand here: wouldn't implementing a custom square wave generator as an AudioWorkletProcessor be a more straightforward approach in this case?
But I overlooked the point that the GP mentions that the processor source code must be loaded from a separate JS file. That's some quite annoying overhead.
The sound created by that generator passes through a fairly complicated filter known as The game boy's speaker. To properly create a game boy sound, you need to find or take an impulse response of that speaker and convolve it with the output of your oscillator.
I know all of that. But I just didn't want to get into these details in this thread.