internal protected void CopyGlobalInstrument(byte slot, Instrument dest)
{
if (slot >= 32)
return;
// Both the AdLib code and the PC Speaker code use an all zero instrument
// as default in the original, thus we do the same.
// PC Speaker instrument size is 23, while AdLib instrument size is 30.
// Thus we just use a 30 byte instrument data array as default.
var defaultInstr = new byte[PcSpeaker ? 23 : 30];
if (_global_instruments[slot].IsValid)
{
// In case we have an valid instrument set up, copy it to the part.
_global_instruments[slot].CopyTo(dest);
}
else if (PcSpeaker)
{
Debug.WriteLine("Trying to use non-existent global PC Speaker instrument {0}", slot);
dest.PcSpk(defaultInstr);
}
else
{
Debug.WriteLine("Trying to use non-existent global AdLib instrument {0}", slot);
dest.Adlib(defaultInstr);
}
}