AxibugEmuOnline/AxibugEmuOnline.Client/Assets/VirtualNes.Core/ApuEX/APU_FDS.cs

100 lines
2.9 KiB
C#
Raw Normal View History

2024-07-26 17:52:33 +08:00
using System;
namespace VirtualNes.Core
{
public class APU_FDS : APU_INTERFACE
{
private FDSSOUND fds = new FDSSOUND();
private FDSSOUND fds_sync = new FDSSOUND();
public override void Reset(float fClock, int nRate)
{
2024-07-30 11:57:09 +08:00
//todo : 实现
2024-07-26 17:52:33 +08:00
}
public override void Setup(float fClock, int nRate)
{
2024-07-30 11:57:09 +08:00
//todo : 实现
2024-07-26 17:52:33 +08:00
}
public override void Write(ushort addr, byte data)
{
2024-07-30 11:57:09 +08:00
//todo : 实现
2024-07-26 17:52:33 +08:00
}
public override int Process(int channel)
{
2024-07-30 11:57:09 +08:00
//todo : 实现
return 0;
2024-07-26 17:52:33 +08:00
}
internal void SyncWrite(ushort addr, byte data)
{
WriteSub(addr, data, fds_sync, 1789772.5d);
}
private void WriteSub(ushort addr, byte data, FDSSOUND ch, double rate)
{
2024-07-30 11:57:09 +08:00
//todo : 实现
2024-07-26 17:52:33 +08:00
}
2024-08-05 11:52:43 +08:00
internal byte SyncRead(ushort addr)
{
byte data = (byte)(addr >> 8);
if (addr >= 0x4040 && addr <= 0x407F)
{
data = (byte)(fds_sync.main_wavetable[addr & 0x3F] | 0x40);
}
else
if (addr == 0x4090)
{
data = (byte)((fds_sync.volenv_gain & 0x3F) | 0x40);
}
else
if (addr == 0x4092)
{
data = (byte)((fds_sync.swpenv_gain & 0x3F) | 0x40);
}
return data;
}
2024-07-26 17:52:33 +08:00
private class FDSSOUND
{
2024-08-05 11:52:43 +08:00
public byte[] reg = new byte[0x80];
public byte volenv_mode; // Volume Envelope
public byte volenv_gain;
public byte volenv_decay;
public double volenv_phaseacc;
public byte swpenv_mode; // Sweep Envelope
public byte swpenv_gain;
public byte swpenv_decay;
public double swpenv_phaseacc;
// For envelope unit
public byte envelope_enable; // $4083 bit6
public byte envelope_speed; // $408A
// For $4089
public byte wave_setup; // bit7
public int master_volume; // bit1-0
// For Main unit
public int[] main_wavetable = new int[64];
public byte main_enable;
public int main_frequency;
public int main_addr;
// For Effector(LFO) unit
public byte[] lfo_wavetable = new byte[64];
public byte lfo_enable; // 0:Enable 1:Wavetable setup
public int lfo_frequency;
public int lfo_addr;
public double lfo_phaseacc;
// For Sweep unit
public int sweep_bias;
// Misc
public int now_volume;
public int now_freq;
public int output;
2024-07-26 17:52:33 +08:00
}
}
}