public void Silence(IOpl opl) { foreach (IAdlibSignaller player in Players) { player.Silence(opl); } }
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; } } } }
public void Init(IOpl opl) { foreach (IAdlibSignaller player in Players) { player.Init(opl); } }
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; }
public XsmPlayer(IOpl opl) { if (opl == null) { throw new ArgumentNullException(nameof(opl)); } Opl = opl; inst = new Instrument[9]; }
public AdlPlayer(IOpl opl) { if (opl == null) { throw new ArgumentNullException(nameof(opl)); } Opl = opl; _driver = new AdlibDriver(opl); }
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); }
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); }
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); }
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); }
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]); }
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), }); }
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. }
public AdlPlayer(IOpl Opl) { this.Opl = Opl; }
public ImfPlayer(IOpl Opl) { this.Opl = Opl; }
public OplLogger(IOpl Opl) { this.Opl = Opl; }
public void Init(IOpl opl) => opl?.WriteReg(1, 32); // go to OPL2 mode
public void Init(IOpl opl) => opl?.WriteReg(1, 32); // go to OPL2 mode public void Silence(IOpl opl) => SetNote(false, opl);
public IdAdlPlayer(IOpl opl) => Opl = opl ?? throw new ArgumentNullException(nameof(opl));