Merge pull request #42 from Gumball2415/feature-add-2a03-interference
Add /A13 and /OE1 audio interference
This commit is contained in:
commit
f1696a90be
19 changed files with 520 additions and 256 deletions
|
@ -511,8 +511,10 @@ void BaseMapper::StreamState(bool saving)
|
|||
ArrayInfo<MemoryAccessType> prgMemoryAccess = { _prgMemoryAccess, 0x100 };
|
||||
ArrayInfo<MemoryAccessType> chrMemoryAccess = { _chrMemoryAccess, 0x40 };
|
||||
SnapshotInfo epsmaudio{ _epsmaudio.get() };
|
||||
SnapshotInfo invA13Audio{ _invA13Audio.get() };
|
||||
SnapshotInfo invOE1Audio{ _invOE1Audio.get() };
|
||||
|
||||
Stream(_mirroringType, chrRam, workRam, saveRam, nametableRam, prgMemoryOffset, chrMemoryOffset, prgMemoryType, chrMemoryType, prgMemoryAccess, chrMemoryAccess, epsmaudio);
|
||||
Stream(_mirroringType, chrRam, workRam, saveRam, nametableRam, prgMemoryOffset, chrMemoryOffset, prgMemoryType, chrMemoryType, prgMemoryAccess, chrMemoryAccess, epsmaudio, invA13Audio, invOE1Audio);
|
||||
|
||||
if(!saving) {
|
||||
RestorePrgChrState();
|
||||
|
@ -640,6 +642,8 @@ void BaseMapper::Initialize(RomData &romData)
|
|||
InitMapper();
|
||||
InitMapper(romData);
|
||||
_epsmaudio.reset(new EPSMAudio(_console));
|
||||
_invA13Audio.reset(new InvA13Audio(_console));
|
||||
_invOE1Audio.reset(new InvOE1Audio(_console));
|
||||
|
||||
//Load battery data if present
|
||||
LoadBattery();
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "Console.h"
|
||||
#include "CPU.h"
|
||||
#include "EPSMAudio.h"
|
||||
#include "InvA13Audio.h"
|
||||
#include "InvOE1Audio.h"
|
||||
|
||||
class BaseControlDevice;
|
||||
|
||||
|
@ -159,6 +161,8 @@ public:
|
|||
static constexpr uint32_t NametableCount = 0x10;
|
||||
static constexpr uint32_t NametableSize = 0x400;
|
||||
unique_ptr<EPSMAudio> _epsmaudio;
|
||||
unique_ptr<InvA13Audio> _invA13Audio;
|
||||
unique_ptr<InvOE1Audio> _invOE1Audio;
|
||||
void Initialize(RomData &romData);
|
||||
|
||||
virtual ~BaseMapper();
|
||||
|
@ -168,7 +172,13 @@ public:
|
|||
|
||||
virtual void SetNesModel(NesModel model) { }
|
||||
virtual void ProcessCpuClock() { }
|
||||
virtual void ProcessEPSMClock() { _epsmaudio->Clock(); }
|
||||
void ProcessMiscClock()
|
||||
{
|
||||
_epsmaudio->Clock();
|
||||
_invA13Audio->Clock();
|
||||
_invOE1Audio->Clock();
|
||||
}
|
||||
|
||||
virtual void NotifyVRAMAddressChange(uint16_t addr);
|
||||
virtual void GetMemoryRanges(MemoryRanges &ranges) override;
|
||||
|
||||
|
|
|
@ -465,11 +465,23 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forP
|
|||
|
||||
void Console::ProcessCpuClock()
|
||||
{
|
||||
_mapper->ProcessEPSMClock();
|
||||
ProcessInterferenceAudio();
|
||||
_mapper->ProcessCpuClock();
|
||||
_mapper->ProcessMiscClock();
|
||||
_apu->ProcessCpuClock();
|
||||
}
|
||||
|
||||
void Console::ProcessInterferenceAudio()
|
||||
{
|
||||
_InvA13 = _ppu->_A13pinLow;
|
||||
|
||||
_controlManager->GetInvOE1(_controlManager->_address);
|
||||
_InvOE1 = _controlManager->_OE1pinLow;
|
||||
|
||||
if (_controlManager->_strobed == true)
|
||||
_controlManager->_strobed = false;
|
||||
}
|
||||
|
||||
CPU* Console::GetCpu()
|
||||
{
|
||||
return _cpu.get();
|
||||
|
|
|
@ -117,6 +117,9 @@ public:
|
|||
void Init();
|
||||
void Release(bool forShutdown);
|
||||
|
||||
uint8_t _InvA13;
|
||||
uint8_t _InvOE1;
|
||||
|
||||
shared_ptr<BatteryManager> GetBatteryManager();
|
||||
shared_ptr<SaveStateManager> GetSaveStateManager();
|
||||
shared_ptr<VideoDecoder> GetVideoDecoder();
|
||||
|
@ -131,6 +134,7 @@ public:
|
|||
bool IsMaster();
|
||||
|
||||
void ProcessCpuClock();
|
||||
void ProcessInterferenceAudio();
|
||||
CPU* GetCpu();
|
||||
PPU* GetPpu();
|
||||
APU* GetApu();
|
||||
|
|
|
@ -333,10 +333,12 @@ uint8_t ControlManager::ReadRAM(uint16_t addr)
|
|||
{
|
||||
//Used for lag counter - any frame where the input is read does not count as lag
|
||||
_isLagging = false;
|
||||
_address = addr;
|
||||
|
||||
uint8_t value = _console->GetMemoryManager()->GetOpenBus(GetOpenBusMask(addr - 0x4016));
|
||||
for(shared_ptr<BaseControlDevice> &device : _controlDevices) {
|
||||
value |= device->ReadRAM(addr);
|
||||
_strobed = true;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -349,6 +351,13 @@ void ControlManager::WriteRAM(uint16_t addr, uint8_t value)
|
|||
}
|
||||
}
|
||||
|
||||
void ControlManager::GetInvOE1(uint16_t addr)
|
||||
{
|
||||
// pull low for only one clock
|
||||
if (addr == 0x4016)
|
||||
_OE1pinLow = (_strobed) ? 0 : 1;
|
||||
}
|
||||
|
||||
void ControlManager::Reset(bool softReset)
|
||||
{
|
||||
ResetLagCounter();
|
||||
|
|
|
@ -43,6 +43,10 @@ protected:
|
|||
virtual uint8_t GetOpenBusMask(uint8_t port);
|
||||
|
||||
public:
|
||||
uint8_t _OE1pinLow;
|
||||
uint16_t _address;
|
||||
bool _strobed;
|
||||
|
||||
ControlManager(shared_ptr<Console> console, shared_ptr<BaseControlDevice> systemActionManager, shared_ptr<BaseControlDevice> mapperControlDevice);
|
||||
virtual ~ControlManager();
|
||||
|
||||
|
@ -80,4 +84,6 @@ public:
|
|||
|
||||
virtual uint8_t ReadRAM(uint16_t addr) override;
|
||||
virtual void WriteRAM(uint16_t addr, uint8_t value) override;
|
||||
|
||||
void GetInvOE1(uint16_t addr);
|
||||
};
|
||||
|
|
|
@ -574,6 +574,8 @@
|
|||
<ClInclude Include="IInputProvider.h" />
|
||||
<ClInclude Include="IInputRecorder.h" />
|
||||
<ClInclude Include="InternalRamHandler.h" />
|
||||
<ClInclude Include="InvA13Audio.h" />
|
||||
<ClInclude Include="InvOE1Audio.h" />
|
||||
<ClInclude Include="Kaiser7017.h" />
|
||||
<ClInclude Include="Kaiser7031.h" />
|
||||
<ClInclude Include="KeyManager.h" />
|
||||
|
|
|
@ -1523,6 +1523,8 @@
|
|||
<ClInclude Include="fmopn_2608rom.h">
|
||||
<Filter>Nes\Mappers\EPSG</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InvA13Audio.h" />
|
||||
<ClInclude Include="InvOE1Audio.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
|
|
@ -119,6 +119,9 @@ enum class AudioChannel
|
|||
Sunsoft5B = 10,
|
||||
EPSM_L = 11,
|
||||
EPSM_R = 12,
|
||||
InvA13 = 13,
|
||||
InvOE1 = 14,
|
||||
MaxChannelCount
|
||||
};
|
||||
|
||||
enum class EqualizerFilterType
|
||||
|
@ -660,8 +663,40 @@ private:
|
|||
bool _audioSettingsChanged = false;
|
||||
uint32_t _audioLatency = 50;
|
||||
uint32_t _EPSMClockFrequency = 3579545;
|
||||
double _channelVolume[13] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
double _channelPanning[13] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 2.0 };
|
||||
double _channelVolume[15] = {
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
};
|
||||
double _channelPanning[15] = {
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
0.0,
|
||||
2.0,
|
||||
1.0,
|
||||
1.0
|
||||
};
|
||||
EqualizerFilterType _equalizerFilterType = EqualizerFilterType::None;
|
||||
vector<double> _bandGains = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
||||
vector<double> _bands = { { 40,56,80,113,160,225,320,450,600,750,1000,2000,3000,4000,5000,6000,7000,10000,12500,15000 } };
|
||||
|
|
41
Core/InvA13Audio.h
Normal file
41
Core/InvA13Audio.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Snapshotable.h"
|
||||
#include "APU.h"
|
||||
#include "BaseExpansionAudio.h"
|
||||
#include "Console.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
class InvA13Audio : public BaseExpansionAudio
|
||||
{
|
||||
private:
|
||||
int8_t _currentOutput;
|
||||
int8_t _lastOutput;
|
||||
|
||||
void UpdateOutputLevel()
|
||||
{
|
||||
if (_currentOutput != _lastOutput) {
|
||||
_console->GetApu()->AddExpansionAudioDelta(AudioChannel::InvA13, _currentOutput - _lastOutput);
|
||||
_lastOutput = _currentOutput;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void StreamState(bool saving) override
|
||||
{
|
||||
}
|
||||
|
||||
void ClockAudio() override
|
||||
{
|
||||
_currentOutput = _console->_InvA13;
|
||||
UpdateOutputLevel();
|
||||
}
|
||||
|
||||
public:
|
||||
InvA13Audio(shared_ptr<Console> console) : BaseExpansionAudio(console)
|
||||
{
|
||||
_lastOutput = 0;
|
||||
_currentOutput = 0;
|
||||
}
|
||||
};
|
41
Core/InvOE1Audio.h
Normal file
41
Core/InvOE1Audio.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Snapshotable.h"
|
||||
#include "APU.h"
|
||||
#include "BaseExpansionAudio.h"
|
||||
#include "Console.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
class InvOE1Audio : public BaseExpansionAudio
|
||||
{
|
||||
private:
|
||||
int8_t _currentOutput;
|
||||
int8_t _lastOutput;
|
||||
|
||||
void UpdateOutputLevel()
|
||||
{
|
||||
if (_currentOutput != _lastOutput) {
|
||||
_console->GetApu()->AddExpansionAudioDelta(AudioChannel::InvOE1, _currentOutput - _lastOutput);
|
||||
_lastOutput = _currentOutput;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void StreamState(bool saving) override
|
||||
{
|
||||
}
|
||||
|
||||
void ClockAudio() override
|
||||
{
|
||||
_currentOutput = _console->_InvOE1;
|
||||
UpdateOutputLevel();
|
||||
}
|
||||
|
||||
public:
|
||||
InvOE1Audio(shared_ptr<Console> console) : BaseExpansionAudio(console)
|
||||
{
|
||||
_lastOutput = 0;
|
||||
_currentOutput = 0;
|
||||
}
|
||||
};
|
|
@ -463,6 +463,12 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
|
|||
}
|
||||
}
|
||||
|
||||
void PPU::GetInvA13()
|
||||
{
|
||||
// pull level high when PPU/VRAM addr bit 13 is low
|
||||
_A13pinLow = (_ppuBusAddress & 0x2000) ? 0 : 1;
|
||||
}
|
||||
|
||||
uint8_t PPU::ReadPaletteRAM(uint16_t addr)
|
||||
{
|
||||
addr &= 0x1F;
|
||||
|
@ -1345,6 +1351,7 @@ void PPU::Exec()
|
|||
if(_needStateUpdate) {
|
||||
UpdateState();
|
||||
}
|
||||
GetInvA13();
|
||||
}
|
||||
|
||||
void PPU::UpdateState()
|
||||
|
|
|
@ -180,6 +180,8 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
static constexpr int32_t OutputBufferSize = 256*240*2;
|
||||
static constexpr int32_t OamDecayCycleCount = 3000;
|
||||
|
||||
uint8_t _A13pinLow;
|
||||
|
||||
PPU(shared_ptr<Console> console);
|
||||
virtual ~PPU();
|
||||
|
||||
|
@ -212,6 +214,8 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
void Exec();
|
||||
__forceinline void Run(uint64_t runTo);
|
||||
|
||||
void GetInvA13();
|
||||
|
||||
uint32_t GetFrameCount()
|
||||
{
|
||||
return _frameCount;
|
||||
|
|
|
@ -276,7 +276,9 @@ int16_t SoundMixer::GetOutputVolume(bool forRightChannel)
|
|||
GetChannelOutput(AudioChannel::VRC7, forRightChannel) +
|
||||
#endif
|
||||
GetChannelOutput(AudioChannel::EPSM_L, forRightChannel) * 4 +
|
||||
GetChannelOutput(AudioChannel::EPSM_R, forRightChannel) * 4
|
||||
GetChannelOutput(AudioChannel::EPSM_R, forRightChannel) * 4 +
|
||||
GetChannelOutput(AudioChannel::InvA13, forRightChannel) * 500 +
|
||||
GetChannelOutput(AudioChannel::InvOE1, forRightChannel) * 500
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
private:
|
||||
static constexpr uint32_t MaxSampleRate = 96000;
|
||||
static constexpr uint32_t MaxSamplesPerFrame = MaxSampleRate / 60 * 4 * 2; //x4 to allow CPU overclocking up to 10x, x2 for panning stereo
|
||||
static constexpr uint32_t MaxChannelCount = 13;
|
||||
static constexpr uint32_t MaxChannelCount = (uint32_t)AudioChannel::MaxChannelCount;
|
||||
|
||||
IAudioDevice* _audioDevice;
|
||||
EmulationSettings* _settings;
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace Mesen.GUI.Config
|
|||
[MinMax(0, 100)] public UInt32 Sunsoft5bVolume = 100;
|
||||
[MinMax(0, 100)] public UInt32 EPSMVolume_L = 50;
|
||||
[MinMax(0, 100)] public UInt32 EPSMVolume_R = 50;
|
||||
[MinMax(0, 100)] public UInt32 InvA13Volume = 0;
|
||||
[MinMax(0, 100)] public UInt32 InvOE1Volume = 0;
|
||||
|
||||
[MinMax(10000, 32000000)] public UInt32 EPSMClockFrequency = 3579545;
|
||||
|
||||
|
@ -42,6 +44,8 @@ namespace Mesen.GUI.Config
|
|||
[MinMax(-100, 100)] public Int32 Sunsoft5bPanning = 0;
|
||||
[MinMax(-100, 100)] public Int32 EPSMPanning_L = -100;
|
||||
[MinMax(-100, 100)] public Int32 EPSMPanning_R = 100;
|
||||
[MinMax(-100, 100)] public Int32 InvA13Panning = 0;
|
||||
[MinMax(-100, 100)] public Int32 InvOE1Panning = 0;
|
||||
|
||||
[ValidValues(11025, 22050, 44100, 48000, 96000)] public UInt32 SampleRate = 48000;
|
||||
public bool ReduceSoundInBackground = true;
|
||||
|
@ -125,6 +129,8 @@ namespace Mesen.GUI.Config
|
|||
InteropEmu.SetChannelVolume(AudioChannel.EPSM_R, ConvertVolume(audioInfo.EPSMVolume_R));
|
||||
InteropEmu.SetChannelVolume(AudioChannel.EPSM_L, audioInfo.EnableEPSM ? AudioInfo.ConvertVolume(audioInfo.EPSMVolume_L) : 0);
|
||||
InteropEmu.SetChannelVolume(AudioChannel.EPSM_R, audioInfo.EnableEPSM ? AudioInfo.ConvertVolume(audioInfo.EPSMVolume_R) : 0);
|
||||
InteropEmu.SetChannelVolume(AudioChannel.InvA13, ConvertVolume(audioInfo.InvA13Volume));
|
||||
InteropEmu.SetChannelVolume(AudioChannel.InvOE1, ConvertVolume(audioInfo.InvOE1Volume));
|
||||
|
||||
InteropEmu.SetChannelPanning(AudioChannel.Square1, ConvertPanning(audioInfo.Square1Panning));
|
||||
InteropEmu.SetChannelPanning(AudioChannel.Square2, ConvertPanning(audioInfo.Square2Panning));
|
||||
|
@ -139,6 +145,8 @@ namespace Mesen.GUI.Config
|
|||
InteropEmu.SetChannelPanning(AudioChannel.Sunsoft5B, ConvertPanning(audioInfo.Sunsoft5bPanning));
|
||||
InteropEmu.SetChannelPanning(AudioChannel.EPSM_L, ConvertPanning(audioInfo.EPSMPanning_L));
|
||||
InteropEmu.SetChannelPanning(AudioChannel.EPSM_R, ConvertPanning(audioInfo.EPSMPanning_R));
|
||||
InteropEmu.SetChannelPanning(AudioChannel.InvA13, ConvertPanning(audioInfo.InvA13Panning));
|
||||
InteropEmu.SetChannelPanning(AudioChannel.InvOE1, ConvertPanning(audioInfo.InvOE1Panning));
|
||||
|
||||
InteropEmu.SetEPSMClockFrequency(audioInfo.EPSMClockFrequency);
|
||||
|
||||
|
|
557
GUI.NET/Forms/Config/frmAudioConfig.Designer.cs
generated
557
GUI.NET/Forms/Config/frmAudioConfig.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -46,6 +46,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
AddBinding("Sunsoft5bVolume", trkSunsoft5b);
|
||||
AddBinding("EPSMVolume_L", trkEPSMVol_L);
|
||||
AddBinding("EPSMVolume_R", trkEPSMVol_R);
|
||||
AddBinding("InvA13Volume", trkInvA13Vol);
|
||||
AddBinding("InvOE1Volume", trkInvOE1Vol);
|
||||
|
||||
AddBinding("Square1Panning", trkSquare1Pan);
|
||||
AddBinding("Square2Panning", trkSquare2Pan);
|
||||
|
@ -60,6 +62,8 @@ namespace Mesen.GUI.Forms.Config
|
|||
AddBinding("Sunsoft5bPanning", trkSunsoftPan);
|
||||
AddBinding("EPSMPanning_L", trkEPSMPan_L);
|
||||
AddBinding("EPSMPanning_R", trkEPSMPan_R);
|
||||
AddBinding("InvA13Panning", trkInvA13Pan);
|
||||
AddBinding("InvOE1Panning", trkInvOE1Pan);
|
||||
|
||||
AddBinding("EPSMClockFrequency", nudEPSMClockFrequency);
|
||||
|
||||
|
|
|
@ -2301,7 +2301,9 @@ namespace Mesen.GUI
|
|||
Namco163 = 9,
|
||||
Sunsoft5B = 10,
|
||||
EPSM_L = 11,
|
||||
EPSM_R= 12
|
||||
EPSM_R = 12,
|
||||
InvA13 = 13,
|
||||
InvOE1 = 14
|
||||
}
|
||||
|
||||
public enum EqualizerFilterType
|
||||
|
|
Loading…
Add table
Reference in a new issue