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 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 void WriteReg(int r, int v) { Logger.Log("WriteReg(" + r + ", " + v + ");"); Opl.WriteReg(r, v); }
public void Init(IOpl opl) => opl?.WriteReg(1, 32); // go to OPL2 mode