コード例 #1
0
 public void Silence(IOpl opl)
 {
     foreach (IAdlibSignaller player in Players)
     {
         player.Silence(opl);
     }
 }
コード例 #2
0
        public S3mPlayer(IOpl opl)
        {
            if (opl == null)
            {
                throw new ArgumentNullException(nameof(opl));
            }
            Opl = opl;

            _channel = new S3mChannel[9];
            _orders  = new byte[256];
            for (int i = 0; i < _orders.Length; i++)
            {
                _orders[i] = 0xFF;
            }
            _inst    = new S3mInst[99];
            _pattern = new S3mPattern[99, 64, 32];
            for (int i = 0; i < 99; i++)
            {
                for (int j = 0; j < 64; j++)
                {
                    for (int k = 0; k < 32; k++)
                    {
                        _pattern[i, j, k].command = 0xFF;
                        _pattern[i, j, k].note    = 0xFF;
                        _pattern[i, j, k].oct     = 0xFF;
                        _pattern[i, j, k].volume  = 0xFF;
                    }
                }
            }
        }
コード例 #3
0
 public void Init(IOpl opl)
 {
     foreach (IAdlibSignaller player in Players)
     {
         player.Init(opl);
     }
 }
コード例 #4
0
        public float RefreshRate => 18.2f; // refresh rate is fixed at 18.2Hz

        public HscPlayer(IOpl opl)
        {
            if (opl == null)
            {
                throw new ArgumentNullException(nameof(opl));
            }
            Opl = opl;
        }
コード例 #5
0
 public XsmPlayer(IOpl opl)
 {
     if (opl == null)
     {
         throw new ArgumentNullException(nameof(opl));
     }
     Opl  = opl;
     inst = new Instrument[9];
 }
コード例 #6
0
 public AdlPlayer(IOpl opl)
 {
     if (opl == null)
     {
         throw new ArgumentNullException(nameof(opl));
     }
     Opl     = opl;
     _driver = new AdlibDriver(opl);
 }
コード例 #7
0
 public IdAdlSignaller SetInstrument(IOpl opl)
 {
     opl.WriteReg(1, 32);             // go to OPL2 mode
     for (int i = 0; i < Adl.InstrumentPorts.Count; i++)
     {
         opl?.WriteReg(Adl.InstrumentPorts[i], Adl.Instrument[i]);
     }
     opl?.WriteReg(0xC0, 0);             // WOLF3D's code ignores this value in its sound data, always setting it to zero instead.
     return(this);
 }
コード例 #8
0
 public IdAdlSignaller SetNote(bool value, IOpl opl)
 {
     if (Note = value)
     {
         opl?.WriteReg(Adl.OctavePort, (byte)(Adl.Block | Adl.KeyFlag));
     }
     else
     {
         opl?.WriteReg(Adl.OctavePort, 0);
     }
     return(this);
 }
コード例 #9
0
        public AdLibChannel(IOpl opl, byte[] musicData, ushort startOfData)
        {
            _opl                            = opl;
            _musicData                      = musicData;
            _channelData.loopPoint          = startOfData;
            _channelData.eventDataPtr       = startOfData;
            _channelData.channelActive      = true;
            _channelData.tremoVibro         = 0;
            _channelData.assignedInstrument = 0xFF;
            _channelData.channelVolume      = 0x7F;
            _channelData.nextEventTime      = GetNextEventTime();

            _channelData.adlibChannelNumber = _channelData.lastCommand = _channelData.note =
                _channelData.adlibReg1      = _channelData.adlibReg2 = _channelData.freqOffset = 0;
            _channelData.frequency          = 0;
            _channelData.instrumentData     = null;

            ushort instrumentDataLoc;

            if (SystemVars.Instance.GameVersion.Version.Minor == 109)
            {
                //instrumentDataLoc = (_musicData[0x11D0] << 8) | _musicData[0x11CF];
                //_frequenceTable = (uint16 *)(_musicData + 0x835);
                //_registerTable = _musicData + 0xE35;
                //_opOutputTable = _musicData + 0xE47;
                //_adlibRegMirror = _musicData + 0xF4A;

                instrumentDataLoc = _musicData.ToUInt16(0x1204);
                _frequenceTable   = new UShortAccess(_musicData, 0x868);
                _registerTable    = new ByteAccess(_musicData, 0xE68);
                _opOutputTable    = new ByteAccess(_musicData, 0xE7A);
                _adlibRegMirror   = new ByteAccess(_musicData, 0xF7D);
            }
            else if (SystemVars.Instance.GameVersion.Version.Minor == 267)
            {
                instrumentDataLoc = _musicData.ToUInt16(0x11FB);
                _frequenceTable   = new UShortAccess(_musicData, 0x7F4);
                _registerTable    = new ByteAccess(_musicData, 0xDF4);
                _opOutputTable    = new ByteAccess(_musicData, 0xE06);
                _adlibRegMirror   = new ByteAccess(_musicData, 0xF55);
            }
            else
            {
                instrumentDataLoc = _musicData.ToUInt16(0x1205);
                _frequenceTable   = new UShortAccess(_musicData, 0x7FE);
                _registerTable    = new ByteAccess(_musicData, 0xDFE);
                _opOutputTable    = new ByteAccess(_musicData, 0xE10);
                _adlibRegMirror   = new ByteAccess(_musicData, 0xF5F);
            }

            _instrumentMap = new ByteAccess(_musicData, instrumentDataLoc);
            _instruments   = new StructAccess <InstrumentStruct>(_musicData, instrumentDataLoc + 0x80);
        }
コード例 #10
0
ファイル: AdLibChannel.cs プロジェクト: scemino/nscumm
        public AdLibChannel(IOpl opl, byte[] musicData, ushort startOfData)
        {
            _opl = opl;
            _musicData = musicData;
            _channelData.loopPoint = startOfData;
            _channelData.eventDataPtr = startOfData;
            _channelData.channelActive = true;
            _channelData.tremoVibro = 0;
            _channelData.assignedInstrument = 0xFF;
            _channelData.channelVolume = 0x7F;
            _channelData.nextEventTime = GetNextEventTime();

            _channelData.adlibChannelNumber = _channelData.lastCommand = _channelData.note =
            _channelData.adlibReg1 = _channelData.adlibReg2 = _channelData.freqOffset = 0;
            _channelData.frequency = 0;
            _channelData.instrumentData = null;

            ushort instrumentDataLoc;

            if (SystemVars.Instance.GameVersion.Version.Minor == 109)
            {
                //instrumentDataLoc = (_musicData[0x11D0] << 8) | _musicData[0x11CF];
                //_frequenceTable = (uint16 *)(_musicData + 0x835);
                //_registerTable = _musicData + 0xE35;
                //_opOutputTable = _musicData + 0xE47;
                //_adlibRegMirror = _musicData + 0xF4A;

                instrumentDataLoc = _musicData.ToUInt16(0x1204);
                _frequenceTable = new UShortAccess(_musicData, 0x868);
                _registerTable = new ByteAccess(_musicData, 0xE68);
                _opOutputTable = new ByteAccess(_musicData, 0xE7A);
                _adlibRegMirror = new ByteAccess(_musicData, 0xF7D);
            }
            else if (SystemVars.Instance.GameVersion.Version.Minor == 267)
            {
                instrumentDataLoc = _musicData.ToUInt16(0x11FB);
                _frequenceTable = new UShortAccess(_musicData, 0x7F4);
                _registerTable = new ByteAccess(_musicData, 0xDF4);
                _opOutputTable = new ByteAccess(_musicData, 0xE06);
                _adlibRegMirror = new ByteAccess(_musicData, 0xF55);
            }
            else
            {
                instrumentDataLoc = _musicData.ToUInt16(0x1205);
                _frequenceTable = new UShortAccess(_musicData, 0x7FE);
                _registerTable = new ByteAccess(_musicData, 0xDFE);
                _opOutputTable = new ByteAccess(_musicData, 0xE10);
                _adlibRegMirror = new ByteAccess(_musicData, 0xF5F);
            }

            _instrumentMap = new ByteAccess(_musicData, instrumentDataLoc);
            _instruments = new StructAccess<InstrumentStruct>(_musicData, instrumentDataLoc + 0x80);
        }
コード例 #11
0
 public uint Update(IOpl opl)
 {
     do
     {
         int soonest = Soonest, subtract = TimeLeft[soonest];
         TimeLeft[soonest] = (int)Players[soonest].Update(opl);
         for (int i = 0; i < Players.Length; i++)
         {
             if (i != soonest)
             {
                 TimeLeft[i] -= subtract;
             }
         }
     } while (TimeLeft.Where(f => f <= 0).Any());
     return((uint)TimeLeft[Soonest]);
 }
コード例 #12
0
 public static IMusicPlayer[] GetPlayers(IOpl opl)
 {
     return(new IMusicPlayer[]
     {
         new HscPlayer(opl),
         new KsmPlayer(opl),
         new CmfPlayer(opl),
         new MidPlayer(opl),
         new DroPlayer(opl),
         new Dro2Player(opl),
         new ImfPlayer(opl),
         new SngPlayer(opl),
         new XsmPlayer(opl),
         new S3mPlayer(opl),
         new AdlPlayer(opl),
         new MkjPlayer(opl),
         new BamPlayer(opl),
         new LdsPlayer(opl),
         new IdAdlPlayer(opl),
     });
 }
コード例 #13
0
 public uint Update(IOpl opl)
 {
     if (IdAdlQueue.TryDequeue(out Adl adl) &&
         (Adl == null || adl == null || Adl == adl || adl.Priority >= Adl.Priority))
     {
         CurrentNote = 0;
         if (opl != null)
         {
             SetNote(false, opl);                     // Must send a signal to stop the previous sound before starting a new sound
             if ((Adl = adl) != null)
             {
                 SetInstrument(opl);
                 SetNote(true, opl);
             }
         }
     }
     if (Adl != null)
     {
         if (Adl.Notes[CurrentNote] == 0)
         {
             SetNote(false, opl);
         }
         else
         {
             if (!Note)
             {
                 SetNote(true, opl);
             }
             opl?.WriteReg(Adl.NotePort, Adl.Notes[CurrentNote]);
         }
         CurrentNote++;
         if (CurrentNote >= Adl.Notes.Length)
         {
             Adl = null;
             SetNote(false, opl);
         }
     }
     return(5);            // These sound effects play back at 140 Hz.
 }
コード例 #14
0
 public AdlPlayer(IOpl Opl)
 {
     this.Opl = Opl;
 }
コード例 #15
0
ファイル: ImfPlayer.cs プロジェクト: BenMcLean/OPL-in-Godot
 public ImfPlayer(IOpl Opl)
 {
     this.Opl = Opl;
 }
コード例 #16
0
 public OplLogger(IOpl Opl)
 {
     this.Opl = Opl;
 }
コード例 #17
0
 public void Init(IOpl opl) => opl?.WriteReg(1, 32);         // go to OPL2 mode
コード例 #18
0
 public void Init(IOpl opl) => opl?.WriteReg(1, 32);         // go to OPL2 mode
 public void Silence(IOpl opl) => SetNote(false, opl);
コード例 #19
0
 public IdAdlPlayer(IOpl opl) => Opl = opl ?? throw new ArgumentNullException(nameof(opl));