Merge branch 'NovaSquirrel:master' into master

This commit is contained in:
Perkka2 2021-11-13 20:14:53 +01:00 committed by GitHub
commit a7245cdfd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 580 additions and 752 deletions

View file

@ -2,7 +2,7 @@ name: "Linux build"
on: push
jobs:
win-build:
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -13,8 +13,8 @@ jobs:
- name: Build
run: |
make
# - name: Upload binary
# uses: actions/upload-artifact@v1
# with:
# name: Mesen-win
# path: bin/Any CPU/Release/Mesen.exe
- name: Upload binary
uses: actions/upload-artifact@v1
with:
name: Mesen-Linux
path: bin/x64/Release/Mesen.exe

View file

@ -511,10 +511,8 @@ 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, invA13Audio, invOE1Audio);
Stream(_mirroringType, chrRam, workRam, saveRam, nametableRam, prgMemoryOffset, chrMemoryOffset, prgMemoryType, chrMemoryType, prgMemoryAccess, chrMemoryAccess, epsmaudio);
if(!saving) {
RestorePrgChrState();
@ -642,8 +640,6 @@ 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();

View file

@ -11,8 +11,6 @@
#include "Console.h"
#include "CPU.h"
#include "EPSMAudio.h"
#include "InvA13Audio.h"
#include "InvOE1Audio.h"
class BaseControlDevice;
@ -161,8 +159,6 @@ 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();
@ -172,13 +168,7 @@ public:
virtual void SetNesModel(NesModel model) { }
virtual void ProcessCpuClock() { }
void ProcessMiscClock()
{
_epsmaudio->Clock();
_invA13Audio->Clock();
_invOE1Audio->Clock();
}
virtual void ProcessEPSMClock() { _epsmaudio->Clock(); }
virtual void NotifyVRAMAddressChange(uint16_t addr);
virtual void GetMemoryRanges(MemoryRanges &ranges) override;

View file

@ -465,23 +465,11 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forP
void Console::ProcessCpuClock()
{
ProcessInterferenceAudio();
_mapper->ProcessEPSMClock();
_mapper->ProcessCpuClock();
_mapper->ProcessMiscClock();
_apu->ProcessCpuClock();
}
void Console::ProcessInterferenceAudio()
{
_InvA13 = _ppu->_A13pinLowSum;
_ppu->_A13pinLowSum = 0;
_InvOE1 = !_controlManager->GetInvOE1(_controlManager->_address); // invert relative to 2A03
if (_controlManager->_strobed == true)
_controlManager->_strobed = false;
}
CPU* Console::GetCpu()
{
return _cpu.get();

View file

@ -117,9 +117,6 @@ 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();
@ -134,7 +131,6 @@ public:
bool IsMaster();
void ProcessCpuClock();
void ProcessInterferenceAudio();
CPU* GetCpu();
PPU* GetPpu();
APU* GetApu();

View file

@ -333,12 +333,10 @@ 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;
@ -351,14 +349,6 @@ void ControlManager::WriteRAM(uint16_t addr, uint8_t value)
}
}
bool ControlManager::GetInvOE1(uint16_t addr)
{
// pull low for only one clock
if (addr == 0x4016)
_OE1pinLow = !_strobed;
return _OE1pinLow;
}
void ControlManager::Reset(bool softReset)
{
ResetLagCounter();

View file

@ -43,10 +43,6 @@ protected:
virtual uint8_t GetOpenBusMask(uint8_t port);
public:
bool _OE1pinLow;
uint16_t _address;
bool _strobed;
ControlManager(shared_ptr<Console> console, shared_ptr<BaseControlDevice> systemActionManager, shared_ptr<BaseControlDevice> mapperControlDevice);
virtual ~ControlManager();
@ -84,6 +80,4 @@ public:
virtual uint8_t ReadRAM(uint16_t addr) override;
virtual void WriteRAM(uint16_t addr, uint8_t value) override;
bool GetInvOE1(uint16_t addr);
};

View file

@ -574,8 +574,6 @@
<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" />

View file

@ -1523,8 +1523,6 @@
<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">

View file

@ -1003,8 +1003,16 @@ bool Debugger::SleepUntilResume(BreakSource source, uint32_t breakpointId, Break
_executionStopped = true;
_pausedForDebugHelper = breakRequested;
int whilePausedRunCounter = 0;
while((((stepCount == 0 || _breakRequested) && _suspendCount == 0) || _preventResume > 0) && !_stopFlag) {
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(10));
if (preventResume == 0) {
whilePausedRunCounter++;
if (whilePausedRunCounter > 10) {
ProcessEvent(EventType::WhilePaused);
whilePausedRunCounter = 0;
}
}
if(stepCount == 0) {
_console->ResetRunTimers();
}

View file

@ -203,6 +203,7 @@ enum class EventType
SpriteZeroHit = 9,
ScriptEnded = 10,
BusConflict = 11,
WhilePaused = 12,
EventTypeSize
};

View file

@ -119,9 +119,6 @@ enum class AudioChannel
Sunsoft5B = 10,
EPSM_L = 11,
EPSM_R = 12,
InvA13 = 13,
InvOE1 = 14,
MaxChannelCount
};
enum class EqualizerFilterType
@ -663,40 +660,8 @@ private:
bool _audioSettingsChanged = false;
uint32_t _audioLatency = 50;
uint32_t _EPSMClockFrequency = 3579545;
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
};
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 };
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 } };

View file

@ -1,41 +0,0 @@
#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;
}
};

View file

@ -1,41 +0,0 @@
#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;
}
};

View file

@ -87,6 +87,8 @@ int LuaApi::GetLibrary(lua_State *lua)
{ "reset", LuaApi::Reset },
{ "stop", LuaApi::Stop },
{ "breakExecution", LuaApi::Break },
{ "stepOver", LuaApi::StepOver },
{ "stepOut", LuaApi::StepOut },
{ "resume", LuaApi::Resume },
{ "execute", LuaApi::Execute },
{ "rewind", LuaApi::Rewind },
@ -168,6 +170,7 @@ int LuaApi::GetLibrary(lua_State *lua)
lua_pushintvalue(stateSaved, EventType::StateSaved);
lua_pushintvalue(inputPolled, EventType::InputPolled);
lua_pushintvalue(scriptEnded, EventType::ScriptEnded);
lua_pushintvalue(whilePaused, EventType::WhilePaused);
lua_settable(lua, -3);
lua_pushliteral(lua, "executeCountType");
@ -584,6 +587,24 @@ int LuaApi::Execute(lua_State *lua)
return l.ReturnCount();
}
int LuaApi::StepOut(lua_State* lua)
{
LuaCallHelper l(lua);
checkparams();
checkinitdone();
_debugger->StepOut();
return l.ReturnCount();
}
int LuaApi::StepOver(lua_State* lua)
{
LuaCallHelper l(lua);
checkparams();
checkinitdone();
_debugger->StepOver();
return l.ReturnCount();
}
int LuaApi::Rewind(lua_State *lua)
{
LuaCallHelper l(lua);

View file

@ -49,6 +49,8 @@ public:
static int Break(lua_State *lua);
static int Resume(lua_State *lua);
static int Execute(lua_State *lua);
static int StepOut(lua_State* lua);
static int StepOver(lua_State* lua);
static int Rewind(lua_State *lua);
static int TakeScreenshot(lua_State *lua);

View file

@ -463,12 +463,6 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
}
}
void PPU::GetInvA13()
{
// pull level high when PPU/VRAM addr bit 13 is low
_A13pinLowSum += (bool)(_ppuBusAddress & 0x2000); // invert relative to 2A03
}
uint8_t PPU::ReadPaletteRAM(uint16_t addr)
{
addr &= 0x1F;
@ -1351,7 +1345,6 @@ void PPU::Exec()
if(_needStateUpdate) {
UpdateState();
}
GetInvA13();
}
void PPU::UpdateState()

View file

@ -179,8 +179,6 @@ class PPU : public IMemoryHandler, public Snapshotable
static constexpr int32_t PixelCount = 256*240;
static constexpr int32_t OutputBufferSize = 256*240*2;
static constexpr int32_t OamDecayCycleCount = 3000;
uint8_t _A13pinLowSum;
PPU(shared_ptr<Console> console);
virtual ~PPU();
@ -214,8 +212,6 @@ class PPU : public IMemoryHandler, public Snapshotable
void Exec();
__forceinline void Run(uint64_t runTo);
void GetInvA13();
uint32_t GetFrameCount()
{
return _frameCount;

View file

@ -276,9 +276,7 @@ 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::InvA13, forRightChannel) * 20) / 3.0 + // 3 PPU samples per CPU clock
GetChannelOutput(AudioChannel::InvOE1, forRightChannel) * 100
GetChannelOutput(AudioChannel::EPSM_R, forRightChannel) * 4
);
}

View file

@ -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 = (uint32_t)AudioChannel::MaxChannelCount;
static constexpr uint32_t MaxChannelCount = 13;
IAudioDevice* _audioDevice;
EmulationSettings* _settings;

View file

@ -26,8 +26,6 @@ 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;
@ -44,8 +42,6 @@ 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;
@ -129,8 +125,6 @@ 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));
@ -145,8 +139,6 @@ 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);

View file

@ -535,6 +535,8 @@ namespace Mesen.GUI.Debugger
new List<string> {"func","emu.breakExecution","emu.breakExecution()","","","Breaks the execution of the game and displays the debugger window."},
new List<string> {"func","emu.stop","emu.stop()","","","Stops execution of the game."},
new List<string> {"func","emu.execute","emu.execute(count, type)","count - *Integer* The number of cycles or instructions to run before breaking\ntype - *Enum* See executeCountType","","Runs the emulator for the specified number of cycles/instructions and then breaks the execution."},
new List<string> {"func","emu.stepOver", "emu.stepOver()", "","","Step over the next instruction."},
new List<string> {"func","emu.stepOut", "emu.stepOut()", "","","Step out of the subroutine."},
new List<string> {"func","emu.reset","emu.reset()","","","Resets the current game."},
new List<string> {"func","emu.resume","emu.resume()","","","Resumes execution after breaking."},
new List<string> {"func","emu.rewind","emu.rewind(seconds)","seconds - *Integer* The number of seconds to rewind","","Instantly rewinds the emulation by the number of seconds specified.\n Note: this can only be called from within a 'StartFrame' event callback."},
@ -578,6 +580,7 @@ namespace Mesen.GUI.Debugger
new List<string> {"enum","emu.eventType.inputPolled","Triggered when the emulation core polls the state of the input devices for the next frame","","",""},
new List<string> {"enum","emu.eventType.spriteZeroHit","Triggered when the PPU sets the sprite zero hit flag","","",""},
new List<string> {"enum","emu.eventType.scriptEnded","Triggered when the current Lua script ends (script window closed, execution stopped, etc.)","","",""},
new List<string> {"enum","emu.eventType.whilePaused","Triggered repeatedly while execution is paused","","",""},
new List<string> {"enum","emu.executeCountType","emu.executeCountType.[value]","","","Values:\ncpuCycles = 0,\nppuCycles = 1,\ncpuInstructions = 2\n\nUsed by execute calls." },
new List<string> {"enum","emu.executeCountType.cpuCycles","Count the number of CPU cycles","","",""},
new List<string> {"enum","emu.executeCountType.ppuCycles","Count the number of PPU cycles","","",""},

File diff suppressed because it is too large Load diff

View file

@ -46,8 +46,6 @@ 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);
@ -62,8 +60,6 @@ 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);

View file

@ -691,7 +691,7 @@ namespace Mesen.GUI.Forms
this.StartEmuThread();
this.BeginInvoke((MethodInvoker)(() => {
if(DebugWindowManager.HasOpenedWindow) {
if(DebugWindowManager.HasOpenedWindow || _luaScriptsToLoad.Count > 0) {
DebugWorkspaceManager.GetWorkspace();
DebugWorkspaceManager.AutoLoadDbgFiles(true);
}

View file

@ -2303,10 +2303,8 @@ namespace Mesen.GUI
Namco163 = 9,
Sunsoft5B = 10,
EPSM_L = 11,
EPSM_R = 12,
InvA13 = 13,
InvOE1 = 14
}
EPSM_R= 12
}
public enum EqualizerFilterType
{
@ -2563,10 +2561,10 @@ namespace Mesen.GUI
SortByUsageFrequency = 2,
GroupBlankTiles = 4,
IgnoreOverscan = 8,
SaveFrame = 16,
}
SaveFrame = 16,
}
[StructLayout(LayoutKind.Sequential)]
[StructLayout(LayoutKind.Sequential)]
public class AddressTypeInfo
{
public Int32 Address;