예제 #1
0
        protected override void StopAllSounds(bool volumeOff)
        {
            if (comPortDCSG != null)
            {
                comPortDCSG.ClearDeferredWriteData();

                switch (comPortDCSG?.SoundModuleType)
                {
                case VsifSoundModuleType.Genesis:
                case VsifSoundModuleType.Genesis_Low:
                case VsifSoundModuleType.Genesis_FTDI:
                    for (int i = 0; i < 3; i++)
                    {
                        comPortDCSG.WriteData(0, 0x14, (byte)(0x80 | i << 5 | 0x1f), (int)Settings.Default.BitBangWaitDCSG);
                    }
                    comPortDCSG.WriteData(0, 0x14, (byte)(0x80 | 3 << 5 | 0x1f), (int)Settings.Default.BitBangWaitDCSG);
                    break;

                case VsifSoundModuleType.SMS:
                    for (int i = 0; i < 3; i++)
                    {
                        comPortDCSG.WriteData(0, 0xFF, (byte)(0x80 | i << 5 | 0x1f), (int)Settings.Default.BitBangWaitOPNA2);
                    }
                    comPortDCSG.WriteData(0, 0xFF, (byte)(0x80 | 3 << 5 | 0x1f), (int)Settings.Default.BitBangWaitOPNA2);
                    break;
                }
                comPortDCSG.FlushDeferredWriteData();
            }
            if (comPortOPNA2 != null)
            {
                comPortOPNA2.ClearDeferredWriteData();

                for (int i = 0; i < 3; i++)
                {
                    comPortOPNA2.DeferredWriteData(0, 4, (byte)(0xB4 | i), (int)Settings.Default.BitBangWaitOPNA2);
                    comPortOPNA2.DeferredWriteData(0, 8, 0xC0, (int)Settings.Default.BitBangWaitOPNA2);
                    comPortOPNA2.DeferredWriteData(0, 12, (byte)(0xB4 | i), (int)Settings.Default.BitBangWaitOPNA2);
                    comPortOPNA2.DeferredWriteData(0, 16, 0xC0, (int)Settings.Default.BitBangWaitOPNA2);
                }

                // disable LFO
                comPortOPNA2.DeferredWriteData(0, 4, 0x22, (int)Settings.Default.BitBangWaitOPNA2);
                comPortOPNA2.DeferredWriteData(0, 8, 0x00, (int)Settings.Default.BitBangWaitOPNA2);

                // disable timer & set channel 6 to normal mode
                comPortOPNA2.DeferredWriteData(0, 4, 0x27, (int)Settings.Default.BitBangWaitOPNA2);
                comPortOPNA2.DeferredWriteData(0, 8, 0x00, (int)Settings.Default.BitBangWaitOPNA2);

                // ALL KEY OFF
                comPortOPNA2.DeferredWriteData(0, 4, 0x28, (int)Settings.Default.BitBangWaitOPNA2);
                for (int i = 0; i < 3; i++)
                {
                    comPortOPNA2.DeferredWriteData(0, 8, (byte)(0x00 | i), (int)Settings.Default.BitBangWaitOPNA2);
                    comPortOPNA2.DeferredWriteData(0, 8, (byte)(0x04 | i), (int)Settings.Default.BitBangWaitOPNA2);
                }

                // disable DAC
                comPortOPNA2.DeferredWriteData(0, 4, 0x2B, (int)Settings.Default.BitBangWaitOPNA2);
                comPortOPNA2.DeferredWriteData(0, 8, 0x00, (int)Settings.Default.BitBangWaitOPNA2);

                for (int slot = 0; slot < 6; slot++)
                {
                    uint reg = (uint)(slot / 3) * 2;
                    Ym2612WriteData(0x28, 0, 0, (byte)(0x00 | (reg << 1) | (byte)(slot % 3)));

                    //TL
                    if (volumeOff)
                    {
                        for (int op = 0; op < 4; op++)
                        {
                            Ym2612WriteData(0x40, op, slot, 127);
                        }
                    }
                }

                //if (volumeOff)
                //    for (int slot = 0; slot < 6; slot++)
                //        for (int op = 0; op < 4; op++)
                //            Ym2612WriteData(0x80, op, slot, 0x0ff);

                comPortOPNA2.FlushDeferredWriteData();
            }

            Thread.Sleep(50);
        }
예제 #2
0
 private void flushDeferredWriteData()
 {
     comPortOPNA2?.FlushDeferredWriteData();
     comPortDCSG?.FlushDeferredWriteData();
 }