public bool Update() { if (notenum >= songlen) { songend = true; notenum = last = 0; } for (var c = 0; c < 9; c++) { if (music[notenum * 9 + c] != music[last * 9 + c]) { Opl.WriteReg(0xb0 + c, 0); } } for (var c = 0; c < 9; c++) { if (music[notenum * 9 + c] != 0) { PlayNote(c, music[notenum * 9 + c] % 12, music[notenum * 9 + c] / 12); } else { PlayNote(c, 0, 0); } } last = notenum; notenum++; return(!songend); }
private void Rewind(int subsong) { // set basic variables _songend = 0; _ord = 0; _crow = 0; _tempo = _header.it; _speed = _header.@is; _del = 0; _loopstart = 0; _loopcnt = 0; Opl.WriteReg(1, 32); // Go to ym3812 mode }
public AdlPlayer SetInstrument() { for (uint i = 0; i < Adl.InstrumentPorts.Length; 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); }
private void SetVolume(byte chan) { byte op = OplHelper.op_table[chan], insnr = _channel[chan]._inst; Opl.WriteReg(0x43 + op, (int)(63 - ((63 - (_inst[insnr].d03 & 63)) / 63.0) * _channel[chan].vol) + (_inst[insnr].d03 & 192)); if ((_inst[insnr].d0a & 1) != 0) { Opl.WriteReg(0x40 + op, (int)(63 - ((63 - (_inst[insnr].d02 & 63)) / 63.0) * _channel[chan].vol) + (_inst[insnr].d02 & 192)); } }
private void PlayNote(int c, int note, int octv) { int freq = OplHelper.note_table[note]; if (note == 0 && octv == 0) { freq = 0; } Opl.WriteReg(0xa0 + c, freq & 0xff); Opl.WriteReg(0xb0 + c, (freq / 0xff) | 32 | (octv * 4)); }
private void SetFreq(byte chan) { Opl.WriteReg(0xa0 + chan, _channel[chan].freq & 255); if (_channel[chan].key != 0) { Opl.WriteReg(0xb0 + chan, (((_channel[chan].freq & 768) >> 8) + (_channel[chan].oct << 2)) | 32); } else { Opl.WriteReg(0xb0 + chan, ((_channel[chan].freq & 768) >> 8) + (_channel[chan].oct << 2)); } }
public bool Update() { while (iPos < iLength) { int iIndex = data[iPos++]; int iValue = data[iPos++]; // Short delay if (iIndex == iCmdDelayS) { iDelay = iValue + 1; return(true); // Long delay } else if (iIndex == iCmdDelayL) { iDelay = (iValue + 1) << 8; return(true); // Normal write } else { if ((iIndex & 0x80) != 0) { // High bit means use second chip in dual-OPL2 config // TODO:? //Opl.setchip(1); iIndex &= 0x7F; } else { // TODO:? //Opl.Setchip(0); } if (iIndex >= iConvTableLen) { Console.WriteLine("DRO2: Error - index beyond end of codemap table! Corrupted .dro?\n"); return(false); // EOF } int iReg = piConvTable[iIndex]; Opl.WriteReg(iReg, iValue); } } // This won't result in endless-play using Adplay, but IMHO that code belongs // in Adplay itself, not here. return(iPos < iLength); }
public bool Update() { while (_pos < _data.Length) { int iIndex = _data[_pos++]; int iValue; if (iIndex == iCmdDelayS) { // Short delay iValue = _data[_pos++]; _delay = iValue + 1; return(true); } if (iIndex == iCmdDelayL) { // Long delay iValue = _data[_pos] | (_data[_pos + 1] << 8); _pos += 2; _delay = (iValue + 1); return(true); } else if (iIndex == 0x02 || iIndex == 0x03) { // Bank switching // TODO:? //_opl.SetChip(iIndex - 0x02); // Normal write } else { if (iIndex == 0x04) { iIndex = _data[_pos++]; } iValue = _data[_pos++]; Opl.WriteReg(iIndex, iValue); } } // This won't result in endless-play using Adplay, but IMHO that code belongs // in Adplay itself, not here. return(_pos < _data.Length); }
private void Rewind(int subsong) { notenum = last = 0; songend = false; Opl.WriteReg(1, 32); for (var i = 0; i < 9; i++) { Opl.WriteReg(0x20 + OplHelper.op_table[i], inst[i].value[0]); Opl.WriteReg(0x23 + OplHelper.op_table[i], inst[i].value[1]); Opl.WriteReg(0x40 + OplHelper.op_table[i], inst[i].value[2]); Opl.WriteReg(0x43 + OplHelper.op_table[i], inst[i].value[3]); Opl.WriteReg(0x60 + OplHelper.op_table[i], inst[i].value[4]); Opl.WriteReg(0x63 + OplHelper.op_table[i], inst[i].value[5]); Opl.WriteReg(0x80 + OplHelper.op_table[i], inst[i].value[6]); Opl.WriteReg(0x83 + OplHelper.op_table[i], inst[i].value[7]); Opl.WriteReg(0xe0 + OplHelper.op_table[i], inst[i].value[8]); Opl.WriteReg(0xe3 + OplHelper.op_table[i], inst[i].value[9]); Opl.WriteReg(0xc0 + OplHelper.op_table[i], inst[i].value[10]); } }
public AdlPlayer PlayNote() { if (Adl.Notes[CurrentNote] == 0) { Note = false; } else { if (!Note) { Note = true; } Opl.WriteReg(Adl.NotePort, Adl.Notes[CurrentNote]); } CurrentNote++; if (CurrentNote >= Adl.Notes.Length) { Adl = null; } return(this); }
public bool Update() { do { Opl.WriteReg(_data[_pos].reg, _data[_pos].val); _del = _data[_pos].time; _pos++; } while (_del == 0 && _pos < _size); if (_pos >= _size) { _pos = 0; _songend = true; } else { RefreshRate = _rate / _del; } return(!_songend); }
private void Rewind(int subsong) { _delay = 0; _pos = 0; // DRO v1 assumes all registers are initialized to 0. // Registers not initialized to 0 will be corrected // in the data stream. // opl->setchip(0); for (var i = 0; i < 256; i++) { Opl.WriteReg(i, 0); } // opl->setchip(1); for (var i = 0; i < 256; i++) { Opl.WriteReg(i, 0); } // opl->setchip(0); }
private void PlayNote(byte chan) { byte op = OplHelper.op_table[chan], insnr = _channel[chan]._inst; Opl.WriteReg(0xb0 + chan, 0); // stop old note // set instrument data Opl.WriteReg(0x20 + op, _inst[insnr].d00); Opl.WriteReg(0x23 + op, _inst[insnr].d01); Opl.WriteReg(0x40 + op, _inst[insnr].d02); Opl.WriteReg(0x43 + op, _inst[insnr].d03); Opl.WriteReg(0x60 + op, _inst[insnr].d04); Opl.WriteReg(0x63 + op, _inst[insnr].d05); Opl.WriteReg(0x80 + op, _inst[insnr].d06); Opl.WriteReg(0x83 + op, _inst[insnr].d07); Opl.WriteReg(0xe0 + op, _inst[insnr].d08); Opl.WriteReg(0xe3 + op, _inst[insnr].d09); Opl.WriteReg(0xc0 + chan, _inst[insnr].d0a); // set frequency & play _channel[chan].key = 1; SetFreq(chan); }
public ImfPlayer PlayNotes(float delta) { TimeSinceLastPacket += delta; while (CurrentPacket < Song.Length && TimeSinceLastPacket >= CurrentPacketDelay) { TimeSinceLastPacket -= CurrentPacketDelay; do { CurrentPacket++; if (CurrentPacket < Song.Length) { Opl.WriteReg(Song[CurrentPacket].Register, Song[CurrentPacket].Data); } }while (CurrentPacket < Song.Length && Song[CurrentPacket].Delay == 0); CurrentPacketDelay = CurrentPacket < Song.Length ? Delay(Song[CurrentPacket].Delay) : 0; } if (CurrentPacket >= Song.Length) { Song = Mute && Loop ? Song : null; } return(this); }
public override void _Ready() { base._Ready(); Opl.WriteReg(1, 0x20); // Enable different wave type selections }
public bool Load(Stream stream) { var br = new BinaryReader(stream); long fsize, flsize, mfsize = 0; uint i; // file validation section { var header = new string(br.ReadChars(5)); var version = br.ReadByte(); if (header != "ADLIB" || version != 1) { stream.Seek(0, SeekOrigin.Begin); // It's a normal IMF file } else { // It's a IMF file with header track_name = ReadString(br); game_name = ReadString(br); br.ReadByte(); mfsize = stream.Position + 2; } } // load section if (mfsize > 0) { fsize = br.ReadInt32(); } else { fsize = br.ReadInt16(); } flsize = stream.Length; if (fsize == 0) { // footerless file (raw music data) if (mfsize != 0) { stream.Seek(-4, SeekOrigin.Current); } else { stream.Seek(-2, SeekOrigin.Current); } _size = (flsize - mfsize) / 4; } else // file has got a footer { _size = fsize / 4; } _data = new Sdata[_size]; for (i = 0; i < _size; i++) { _data[i].reg = br.ReadByte(); _data[i].val = br.ReadByte(); _data[i].time = br.ReadUInt16(); } // read footer, if any if (fsize != 0 && (fsize < flsize - 2 - mfsize)) { if (br.ReadByte() == 0x1a) { // Adam Nielsen's footer format track_name = ReadString(br); author_name = ReadString(br); remarks = ReadString(br); } else { // Generic footer long footerlen = flsize - fsize - 2 - mfsize; _footer = ReadString(br, footerlen); } } _pos = 0; _del = 0; RefreshRate = _rate; _songend = false; Opl.WriteReg(1, 32); // go to OPL2 mode return(true); }
// Write a byte to the OPL "chip" and update the current record of register states private void writeOPL(byte iRegister, byte iValue) { Opl.WriteReg(iRegister, iValue); iCurrentRegs[iRegister] = iValue; }