Refactoring - removed statics from EmulationSettings
This commit is contained in:
parent
57e509c606
commit
15373016d0
131 changed files with 1235 additions and 1249 deletions
|
@ -17,6 +17,7 @@ APU::APU(shared_ptr<Console> console)
|
|||
|
||||
_console = console;
|
||||
_mixer = _console->GetSoundMixer();
|
||||
_settings = _console->GetSettings();
|
||||
|
||||
_squareChannel[0].reset(new SquareChannel(AudioChannel::Square1, _console, _mixer.get(), true));
|
||||
_squareChannel[1].reset(new SquareChannel(AudioChannel::Square2, _console, _mixer.get(), false));
|
||||
|
@ -197,10 +198,10 @@ void APU::EndFrame()
|
|||
void APU::ProcessCpuClock()
|
||||
{
|
||||
if(_apuEnabled) {
|
||||
if(EmulationSettings::GetOverclockRate() == 100 || !EmulationSettings::GetOverclockAdjustApu()) {
|
||||
if(_settings->GetOverclockRate() == 100 || !_settings->GetOverclockAdjustApu()) {
|
||||
Exec();
|
||||
} else {
|
||||
_cyclesNeeded += 1.0 / ((double)EmulationSettings::GetOverclockRate() / 100.0);
|
||||
_cyclesNeeded += 1.0 / ((double)_settings->GetOverclockRate() / 100.0);
|
||||
while(_cyclesNeeded >= 1.0) {
|
||||
Exec();
|
||||
_cyclesNeeded--;
|
||||
|
|
|
@ -36,6 +36,7 @@ class APU : public Snapshotable, public IMemoryHandler
|
|||
|
||||
shared_ptr<Console> _console;
|
||||
shared_ptr<SoundMixer> _mixer;
|
||||
EmulationSettings* _settings;
|
||||
|
||||
NesModel _nesModel;
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ protected:
|
|||
|
||||
void InternalSetStateFromInput() override
|
||||
{
|
||||
if(EmulationSettings::InputEnabled()) {
|
||||
if(_console->GetSettings()->InputEnabled()) {
|
||||
SetPressedState(Buttons::Fire, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
SetMovement(KeyManager::GetMouseMovement(EmulationSettings::GetMouseSensitivity(MouseDevice::ArkanoidController)));
|
||||
SetMovement(KeyManager::GetMouseMovement(_console->GetSettings()->GetMouseSensitivity(MouseDevice::ArkanoidController)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
ArkanoidController(uint8_t port) : BaseControlDevice(port)
|
||||
ArkanoidController(shared_ptr<Console> console, uint8_t port) : BaseControlDevice(console, port)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
AsciiTurboFile() : BaseControlDevice(BaseControlDevice::ExpDevicePort)
|
||||
AsciiTurboFile(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
|
||||
{
|
||||
BatteryManager::LoadBattery(".tf", _data, AsciiTurboFile::FileSize);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ AutoSaveManager::AutoSaveManager(shared_ptr<Console> console)
|
|||
_autoSaveThread = std::thread([=]() {
|
||||
while(!_stopThread) {
|
||||
bool showMessage = false;
|
||||
uint32_t autoSaveDelay = EmulationSettings::GetAutoSaveDelay(showMessage) * 60 * 1000;
|
||||
uint32_t autoSaveDelay = console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
|
||||
if(autoSaveDelay > 0) {
|
||||
if(_timer.GetElapsedMS() > autoSaveDelay) {
|
||||
if(!console->IsDebuggerAttached()) {
|
||||
|
|
|
@ -103,25 +103,26 @@ void AutomaticRomTest::ProcessNotification(ConsoleNotificationType type, void* p
|
|||
|
||||
int32_t AutomaticRomTest::Run(string filename)
|
||||
{
|
||||
EmulationSettings::SetMasterVolume(0);
|
||||
_console.reset(new Console());
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
settings->SetMasterVolume(0);
|
||||
_console->GetNotificationManager()->RegisterNotificationListener(shared_from_this());
|
||||
if(_console->Initialize(filename)) {
|
||||
_console->GetControlManager()->RegisterInputProvider(this);
|
||||
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
settings->SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
settings->ClearFlags(EmulationFlags::Paused);
|
||||
_signal.Wait();
|
||||
|
||||
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
||||
settings->SetFlags(EmulationFlags::Paused);
|
||||
|
||||
if(_console->GetFrameCount() < 1800) {
|
||||
//Finished early
|
||||
_errorCode |= 0x10;
|
||||
}
|
||||
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(1.0);
|
||||
settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
settings->SetMasterVolume(1.0);
|
||||
|
||||
_console->GetControlManager()->UnregisterInputProvider(this);
|
||||
_console->Stop();
|
||||
|
|
|
@ -29,9 +29,9 @@ AviRecorder::~AviRecorder()
|
|||
uint32_t AviRecorder::GetFps()
|
||||
{
|
||||
if(_console->GetModel() == NesModel::NTSC) {
|
||||
return EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 60000000 : 60098812;
|
||||
return _console->GetSettings()->CheckFlag(EmulationFlags::IntegerFpsMode) ? 60000000 : 60098812;
|
||||
} else {
|
||||
return EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 50000000 : 50006978;
|
||||
return _console->GetSettings()->CheckFlag(EmulationFlags::IntegerFpsMode) ? 50000000 : 50006978;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
|||
{
|
||||
StandardController::InternalSetStateFromInput();
|
||||
|
||||
if(EmulationSettings::InputEnabled()) {
|
||||
if(_console->GetSettings()->InputEnabled()) {
|
||||
SetPressedState(ZapperButtons::Fire, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
|
||||
MousePosition pos = KeyManager::GetMousePosition();
|
||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
|||
SelectPRGPage(1, 0x07);
|
||||
SelectCHRPage(0, 0);
|
||||
|
||||
_mapperControlDevice.reset(new BandaiMicrophone(_console, EmulationSettings::GetControllerKeys(0)));
|
||||
_mapperControlDevice.reset(new BandaiMicrophone(_console, _console->GetSettings()->GetControllerKeys(0)));
|
||||
}
|
||||
|
||||
uint8_t ReadRegister(uint16_t addr) override
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
class BandaiMicrophone : public BaseControlDevice
|
||||
{
|
||||
protected:
|
||||
shared_ptr<Console> _console;
|
||||
|
||||
enum Buttons { A, B, Microphone };
|
||||
|
||||
string GetKeyNames() override
|
||||
|
@ -18,7 +16,7 @@ protected:
|
|||
void InternalSetStateFromInput() override
|
||||
{
|
||||
//Make sure the key bindings are properly updated (not ideal, but good enough)
|
||||
_keyMappings = EmulationSettings::GetControllerKeys(0).GetKeyMappingArray();
|
||||
_keyMappings = _console->GetSettings()->GetControllerKeys(0).GetKeyMappingArray();
|
||||
|
||||
for(KeyMapping keyMapping : _keyMappings) {
|
||||
SetPressedState(Buttons::A, keyMapping.BandaiMicrophoneButtons[0]);
|
||||
|
@ -31,7 +29,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
BandaiMicrophone(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::MapperInputPort, keyMappings)
|
||||
BandaiMicrophone(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::MapperInputPort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ class BarcodeBattlerReader : public BaseControlDevice, public IBarcodeReader
|
|||
{
|
||||
private:
|
||||
static constexpr int StreamSize = 200;
|
||||
shared_ptr<Console> _console;
|
||||
uint64_t _newBarcode = 0;
|
||||
uint32_t _newBarcodeDigitCount = 0;
|
||||
|
||||
|
@ -51,9 +50,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
BarcodeBattlerReader(shared_ptr<Console> console) : BaseControlDevice(BaseControlDevice::ExpDevicePort)
|
||||
BarcodeBattlerReader(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
|
||||
{
|
||||
_console = console;
|
||||
}
|
||||
|
||||
void InternalSetStateFromInput() override
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
#include "BaseControlDevice.h"
|
||||
#include "KeyManager.h"
|
||||
#include "../Utilities/StringUtilities.h"
|
||||
#include "Console.h"
|
||||
#include "EmulationSettings.h"
|
||||
|
||||
BaseControlDevice::BaseControlDevice(uint8_t port, KeyMappingSet keyMappingSet)
|
||||
BaseControlDevice::BaseControlDevice(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappingSet)
|
||||
{
|
||||
_console = console;
|
||||
_port = port;
|
||||
_strobe = false;
|
||||
_keyMappings = keyMappingSet.GetKeyMappingArray();
|
||||
|
@ -212,12 +215,12 @@ void BaseControlDevice::InvertBit(uint8_t bit)
|
|||
|
||||
void BaseControlDevice::SetPressedState(uint8_t bit, uint32_t keyCode)
|
||||
{
|
||||
if(IsKeyboard() && keyCode < 0x200 && !EmulationSettings::IsKeyboardMode()) {
|
||||
if(IsKeyboard() && keyCode < 0x200 && !_console->GetSettings()->IsKeyboardMode()) {
|
||||
//Prevent keyboard device input when keyboard mode is off
|
||||
return;
|
||||
}
|
||||
|
||||
if(EmulationSettings::InputEnabled() && (!EmulationSettings::IsKeyboardMode() || keyCode >= 0x200 || IsKeyboard()) && KeyManager::IsKeyPressed(keyCode)) {
|
||||
if(_console->GetSettings()->InputEnabled() && (!_console->GetSettings()->IsKeyboardMode() || keyCode >= 0x200 || IsKeyboard()) && KeyManager::IsKeyPressed(keyCode)) {
|
||||
SetBit(bit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,15 @@
|
|||
#include "ControlDeviceState.h"
|
||||
#include "../Utilities/SimpleLock.h"
|
||||
|
||||
class Console;
|
||||
|
||||
class BaseControlDevice : public Snapshotable
|
||||
{
|
||||
private:
|
||||
ControlDeviceState _state;
|
||||
|
||||
protected:
|
||||
shared_ptr<Console> _console;
|
||||
vector<KeyMapping> _keyMappings;
|
||||
bool _strobe;
|
||||
uint8_t _port;
|
||||
|
@ -49,7 +52,7 @@ public:
|
|||
static constexpr uint8_t ExpDevicePort2 = 7;
|
||||
static constexpr uint8_t PortCount = ExpDevicePort2 + 1;
|
||||
|
||||
BaseControlDevice(uint8_t port, KeyMappingSet keyMappingSet = KeyMappingSet());
|
||||
BaseControlDevice(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappingSet = KeyMappingSet());
|
||||
virtual ~BaseControlDevice();
|
||||
|
||||
uint8_t GetPort();
|
||||
|
|
|
@ -16,10 +16,10 @@ void BaseExpansionAudio::StreamState(bool saving)
|
|||
void BaseExpansionAudio::Clock()
|
||||
{
|
||||
if(_console->GetApu()->IsApuEnabled()) {
|
||||
if(EmulationSettings::GetOverclockRate() == 100 || !EmulationSettings::GetOverclockAdjustApu()) {
|
||||
if(_console->GetSettings()->GetOverclockRate() == 100 || !_console->GetSettings()->GetOverclockAdjustApu()) {
|
||||
ClockAudio();
|
||||
} else {
|
||||
_clocksNeeded += 1.0 / ((double)EmulationSettings::GetOverclockRate() / 100);
|
||||
_clocksNeeded += 1.0 / ((double)_console->GetSettings()->GetOverclockRate() / 100);
|
||||
while(_clocksNeeded >= 1.0) {
|
||||
ClockAudio();
|
||||
_clocksNeeded--;
|
||||
|
|
|
@ -318,7 +318,7 @@ void BaseMapper::SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memor
|
|||
|
||||
void BaseMapper::InitializeRam(void* data, uint32_t length)
|
||||
{
|
||||
switch(EmulationSettings::GetRamPowerOnState()) {
|
||||
switch(_console->GetSettings()->GetRamPowerOnState()) {
|
||||
default:
|
||||
case RamPowerOnState::AllZeros: memset(data, 0, length); break;
|
||||
case RamPowerOnState::AllOnes: memset(data, 0xFF, length); break;
|
||||
|
@ -335,7 +335,7 @@ void BaseMapper::InitializeRam(void* data, uint32_t length)
|
|||
|
||||
uint8_t BaseMapper::GetPowerOnByte(uint8_t defaultValue)
|
||||
{
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::RandomizeMapperPowerOnState)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::RandomizeMapperPowerOnState)) {
|
||||
std::random_device rd;
|
||||
std::mt19937 mt(rd());
|
||||
std::uniform_int_distribution<> dist(0, 255);
|
||||
|
@ -398,7 +398,7 @@ void BaseMapper::InitializeChrRam(int32_t chrRamSize)
|
|||
_chrRamSize = chrRamSize >= 0 ? chrRamSize : defaultRamSize;
|
||||
if(_chrRamSize > 0) {
|
||||
_chrRam = new uint8_t[_chrRamSize];
|
||||
BaseMapper::InitializeRam(_chrRam, _chrRamSize);
|
||||
InitializeRam(_chrRam, _chrRamSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,8 +540,8 @@ void BaseMapper::Initialize(RomData &romData)
|
|||
_saveRam = new uint8_t[_saveRamSize];
|
||||
_workRam = new uint8_t[_workRamSize];
|
||||
|
||||
BaseMapper::InitializeRam(_saveRam, _saveRamSize);
|
||||
BaseMapper::InitializeRam(_workRam, _workRamSize);
|
||||
InitializeRam(_saveRam, _saveRamSize);
|
||||
InitializeRam(_workRam, _workRamSize);
|
||||
|
||||
memset(_prgPageNumbers, 0xEE, sizeof(_prgPageNumbers));
|
||||
memset(_chrPageNumbers, 0xEE, sizeof(_chrPageNumbers));
|
||||
|
@ -669,11 +669,11 @@ void BaseMapper::SetNametable(uint8_t index, uint8_t nametableIndex)
|
|||
{
|
||||
if(nametableIndex == 2 && _cartNametableRam[0] == nullptr) {
|
||||
_cartNametableRam[0] = new uint8_t[0x400];
|
||||
BaseMapper::InitializeRam(_cartNametableRam[0], 0x400);
|
||||
InitializeRam(_cartNametableRam[0], 0x400);
|
||||
}
|
||||
if(nametableIndex == 3 && _cartNametableRam[1] == nullptr) {
|
||||
_cartNametableRam[1] = new uint8_t[0x400];
|
||||
BaseMapper::InitializeRam(_cartNametableRam[1], 0x400);
|
||||
InitializeRam(_cartNametableRam[1], 0x400);
|
||||
}
|
||||
|
||||
_nametableIndexes[index] = nametableIndex;
|
||||
|
|
|
@ -186,7 +186,7 @@ public:
|
|||
|
||||
uint8_t DebugReadVRAM(uint16_t addr, bool disableSideEffects = true);
|
||||
|
||||
static void InitializeRam(void* data, uint32_t length);
|
||||
void InitializeRam(void* data, uint32_t length);
|
||||
|
||||
void CopyChrRamTile(uint32_t address, uint8_t *dest);
|
||||
|
||||
|
|
|
@ -173,16 +173,17 @@ void BaseRenderer::ShowFrameCounter(int lineNumber)
|
|||
void BaseRenderer::DrawCounters()
|
||||
{
|
||||
int lineNumber = 0;
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowGameTimer)) {
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
if(settings->CheckFlag(EmulationFlags::ShowGameTimer)) {
|
||||
ShowGameTimer(lineNumber++);
|
||||
}
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowFPS)) {
|
||||
if(settings->CheckFlag(EmulationFlags::ShowFPS)) {
|
||||
ShowFpsCounter(lineNumber++);
|
||||
}
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowLagCounter)) {
|
||||
if(settings->CheckFlag(EmulationFlags::ShowLagCounter)) {
|
||||
ShowLagCounter(lineNumber++);
|
||||
}
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ShowFrameCounter)) {
|
||||
if(settings->CheckFlag(EmulationFlags::ShowFrameCounter)) {
|
||||
ShowFrameCounter(lineNumber++);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
#include "StandardController.h"
|
||||
#include "ScaleFilter.h"
|
||||
#include "RotateFilter.h"
|
||||
#include "Console.h"
|
||||
|
||||
BaseVideoFilter::BaseVideoFilter()
|
||||
BaseVideoFilter::BaseVideoFilter(shared_ptr<Console> console)
|
||||
{
|
||||
_overscan = EmulationSettings::GetOverscanDimensions();
|
||||
_console = console;
|
||||
_overscan = _console->GetSettings()->GetOverscanDimensions();
|
||||
}
|
||||
|
||||
BaseVideoFilter::~BaseVideoFilter()
|
||||
|
@ -53,7 +55,7 @@ bool BaseVideoFilter::IsOddFrame()
|
|||
void BaseVideoFilter::SendFrame(uint16_t *ppuOutputBuffer, uint32_t frameNumber)
|
||||
{
|
||||
_frameLock.Acquire();
|
||||
_overscan = EmulationSettings::GetOverscanDimensions();
|
||||
_overscan = _console->GetSettings()->GetOverscanDimensions();
|
||||
_isOddFrame = frameNumber % 2;
|
||||
UpdateBufferSize();
|
||||
OnBeforeApplyFilter();
|
||||
|
@ -67,7 +69,7 @@ uint32_t* BaseVideoFilter::GetOutputBuffer()
|
|||
return _outputBuffer;
|
||||
}
|
||||
|
||||
void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, VideoFilterType filterType, string filename, std::stringstream *stream)
|
||||
void BaseVideoFilter::TakeScreenshot(VideoFilterType filterType, string filename, std::stringstream *stream)
|
||||
{
|
||||
uint32_t* pngBuffer;
|
||||
FrameInfo frameInfo;
|
||||
|
@ -85,7 +87,7 @@ void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, VideoFilterTyp
|
|||
|
||||
pngBuffer = frameBuffer;
|
||||
|
||||
uint32_t rotationAngle = EmulationSettings::GetScreenRotation();
|
||||
uint32_t rotationAngle = _console->GetSettings()->GetScreenRotation();
|
||||
shared_ptr<RotateFilter> rotateFilter;
|
||||
if(rotationAngle > 0) {
|
||||
rotateFilter.reset(new RotateFilter(rotationAngle));
|
||||
|
@ -95,12 +97,12 @@ void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, VideoFilterTyp
|
|||
|
||||
shared_ptr<ScaleFilter> scaleFilter = ScaleFilter::GetScaleFilter(filterType);
|
||||
if(scaleFilter) {
|
||||
pngBuffer = scaleFilter->ApplyFilter(pngBuffer, frameInfo.Width, frameInfo.Height);
|
||||
pngBuffer = scaleFilter->ApplyFilter(pngBuffer, frameInfo.Width, frameInfo.Height, _console->GetSettings()->GetPictureSettings().ScanlineIntensity);
|
||||
frameInfo = scaleFilter->GetFrameInfo(frameInfo);
|
||||
}
|
||||
|
||||
VideoHud hud;
|
||||
hud.DrawHud(console, pngBuffer, frameInfo, EmulationSettings::GetOverscanDimensions());
|
||||
hud.DrawHud(_console, pngBuffer, frameInfo, _console->GetSettings()->GetOverscanDimensions());
|
||||
|
||||
if(!filename.empty()) {
|
||||
PNGHelper::WritePNG(filename, pngBuffer, frameInfo.Width, frameInfo.Height);
|
||||
|
@ -111,7 +113,7 @@ void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, VideoFilterTyp
|
|||
delete[] frameBuffer;
|
||||
}
|
||||
|
||||
void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, string romName, VideoFilterType filterType)
|
||||
void BaseVideoFilter::TakeScreenshot(string romName, VideoFilterType filterType)
|
||||
{
|
||||
string romFilename = FolderUtilities::GetFilename(romName, false);
|
||||
|
||||
|
@ -133,7 +135,7 @@ void BaseVideoFilter::TakeScreenshot(shared_ptr<Console> console, string romName
|
|||
counter++;
|
||||
}
|
||||
|
||||
TakeScreenshot(console, filterType, ssFilename);
|
||||
TakeScreenshot(filterType, ssFilename);
|
||||
|
||||
MessageManager::DisplayMessage("ScreenshotSaved", FolderUtilities::GetFilename(ssFilename, true));
|
||||
}
|
||||
|
|
|
@ -19,18 +19,20 @@ private:
|
|||
void UpdateBufferSize();
|
||||
|
||||
protected:
|
||||
shared_ptr<Console> _console;
|
||||
|
||||
virtual void ApplyFilter(uint16_t *ppuOutputBuffer) = 0;
|
||||
virtual void OnBeforeApplyFilter();
|
||||
bool IsOddFrame();
|
||||
|
||||
public:
|
||||
BaseVideoFilter();
|
||||
BaseVideoFilter(shared_ptr<Console> console);
|
||||
virtual ~BaseVideoFilter();
|
||||
|
||||
uint32_t* GetOutputBuffer();
|
||||
void SendFrame(uint16_t *ppuOutputBuffer, uint32_t frameNumber);
|
||||
void TakeScreenshot(shared_ptr<Console> console, string romName, VideoFilterType filterType);
|
||||
void TakeScreenshot(shared_ptr<Console> console, VideoFilterType filterType, string filename, std::stringstream *stream = nullptr);
|
||||
void TakeScreenshot(string romName, VideoFilterType filterType);
|
||||
void TakeScreenshot(VideoFilterType filterType, string filename, std::stringstream *stream = nullptr);
|
||||
|
||||
virtual OverscanDimensions GetOverscan();
|
||||
virtual FrameInfo GetFrameInfo() = 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
BattleBox() : BaseControlDevice(BaseControlDevice::ExpDevicePort)
|
||||
BattleBox(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
|
||||
{
|
||||
BatteryManager::LoadBattery(".bb", (uint8_t*)_data, BattleBox::FileSize);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#include "BisqwitNtscFilter.h"
|
||||
#include "PPU.h"
|
||||
#include "EmulationSettings.h"
|
||||
#include "Console.h"
|
||||
|
||||
BisqwitNtscFilter::BisqwitNtscFilter(int resDivider)
|
||||
BisqwitNtscFilter::BisqwitNtscFilter(shared_ptr<Console> console, int resDivider) : BaseVideoFilter(console)
|
||||
{
|
||||
_resDivider = resDivider;
|
||||
_stopThread = false;
|
||||
|
@ -84,8 +85,8 @@ FrameInfo BisqwitNtscFilter::GetFrameInfo()
|
|||
|
||||
void BisqwitNtscFilter::OnBeforeApplyFilter()
|
||||
{
|
||||
PictureSettings pictureSettings = EmulationSettings::GetPictureSettings();
|
||||
NtscFilterSettings ntscSettings = EmulationSettings::GetNtscFilterSettings();
|
||||
PictureSettings pictureSettings = _console->GetSettings()->GetPictureSettings();
|
||||
NtscFilterSettings ntscSettings = _console->GetSettings()->GetNtscFilterSettings();
|
||||
|
||||
_keepVerticalRes = ntscSettings.KeepVerticalResolution;
|
||||
|
||||
|
@ -117,7 +118,7 @@ void BisqwitNtscFilter::RecursiveBlend(int iterationCount, uint64_t *output, uin
|
|||
//Blend 2 pixels at once
|
||||
uint32_t width = GetOverscan().GetScreenWidth() * pixelsPerCycle / 2;
|
||||
|
||||
double scanlineIntensity = 1.0 - EmulationSettings::GetPictureSettings().ScanlineIntensity;
|
||||
double scanlineIntensity = 1.0 - _console->GetSettings()->GetPictureSettings().ScanlineIntensity;
|
||||
if(scanlineIntensity < 1.0 && (iterationCount == 2 || _resDivider == 4)) {
|
||||
//Most likely extremely inefficient scanlines, but works
|
||||
for(uint32_t x = 0; x < width; x++) {
|
||||
|
@ -219,7 +220,7 @@ void BisqwitNtscFilter::DecodeFrame(int startRow, int endRow, uint16_t *ppuOutpu
|
|||
//Generate the missing vertical lines
|
||||
outputBuffer = orgBuffer;
|
||||
int lastRow = 239 - GetOverscan().Bottom;
|
||||
bool verticalBlend = EmulationSettings::GetNtscFilterSettings().VerticalBlend;
|
||||
bool verticalBlend = _console->GetSettings()->GetNtscFilterSettings().VerticalBlend;
|
||||
for(int y = startRow; y <= endRow; y++) {
|
||||
uint64_t* currentLine = (uint64_t*)outputBuffer;
|
||||
uint64_t* nextLine = y == lastRow ? currentLine : (uint64_t*)(outputBuffer + rowPixelGap);
|
||||
|
@ -268,7 +269,7 @@ void BisqwitNtscFilter::NtscDecodeLine(int width, const int8_t* signal, uint32_t
|
|||
auto Cos = [=](int pos) -> char { return _sinetable[(pos + 36) % 12 + phase0]; };
|
||||
auto Sin = [=](int pos) -> char { return _sinetable[(pos + 36) % 12 + 3 + phase0]; };
|
||||
|
||||
int brightness = (int)(EmulationSettings::GetPictureSettings().Brightness * 750);
|
||||
int brightness = (int)(_console->GetSettings()->GetPictureSettings().Brightness * 750);
|
||||
int ysum = brightness, isum = 0, qsum = 0;
|
||||
int leftOverscan = GetOverscan().Left * 8;
|
||||
int rightOverscan = width - GetOverscan().Right * 8;
|
||||
|
|
|
@ -43,14 +43,13 @@ private:
|
|||
void RecursiveBlend(int iterationCount, uint64_t *output, uint64_t *currentLine, uint64_t *nextLine, int pixelsPerCycle, bool verticalBlend);
|
||||
|
||||
void NtscDecodeLine(int width, const int8_t* signal, uint32_t* target, int phase0);
|
||||
void NtscDecodeLineCustomRes(int width, const int8_t* signal, uint32_t* target, int phase0, int resDivider);
|
||||
|
||||
void GenerateNtscSignal(int8_t *ntscSignal, int &phase, int rowNumber);
|
||||
void DecodeFrame(int startRow, int endRow, uint16_t *ppuOutputBuffer, uint32_t* outputBuffer, int startPhase);
|
||||
void OnBeforeApplyFilter();
|
||||
|
||||
public:
|
||||
BisqwitNtscFilter(int resDivider);
|
||||
BisqwitNtscFilter(shared_ptr<Console> console, int resDivider);
|
||||
virtual ~BisqwitNtscFilter();
|
||||
|
||||
virtual void ApplyFilter(uint16_t *ppuOutputBuffer);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
BizhawkMovie::BizhawkMovie(shared_ptr<Console> console)
|
||||
{
|
||||
_console = console;
|
||||
_originalPowerOnState = EmulationSettings::GetRamPowerOnState();
|
||||
_originalPowerOnState = _console->GetSettings()->GetRamPowerOnState();
|
||||
}
|
||||
|
||||
BizhawkMovie::~BizhawkMovie()
|
||||
|
@ -22,8 +22,14 @@ BizhawkMovie::~BizhawkMovie()
|
|||
void BizhawkMovie::Stop()
|
||||
{
|
||||
if(_isPlaying) {
|
||||
EndMovie();
|
||||
EmulationSettings::SetRamPowerOnState(_originalPowerOnState);
|
||||
MessageManager::DisplayMessage("Movies", "MovieEnded");
|
||||
|
||||
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::MovieEnded);
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::PauseOnMovieEnd)) {
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::Paused);
|
||||
}
|
||||
|
||||
_console->GetSettings()->SetRamPowerOnState(_originalPowerOnState);
|
||||
_isPlaying = false;
|
||||
}
|
||||
_console->GetControlManager()->UnregisterInputProvider(this);
|
||||
|
@ -190,7 +196,7 @@ bool BizhawkMovie::Play(VirtualFile &file)
|
|||
reader.LoadArchive(ss);
|
||||
|
||||
_console->GetNotificationManager()->RegisterNotificationListener(shared_from_this());
|
||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllOnes);
|
||||
_console->GetSettings()->SetRamPowerOnState(RamPowerOnState::AllOnes);
|
||||
if(InitializeInputData(reader) && InitializeGameData(reader)) {
|
||||
//NesHawk initializes memory to 1s
|
||||
_isPlaying = true;
|
||||
|
|
13
Core/CPU.cpp
13
Core/CPU.cpp
|
@ -346,17 +346,18 @@ uint32_t CPU::GetClockRate(NesModel model)
|
|||
|
||||
void CPU::StreamState(bool saving)
|
||||
{
|
||||
uint32_t overclockRate = EmulationSettings::GetOverclockRateSetting();
|
||||
bool overclockAdjustApu = EmulationSettings::GetOverclockAdjustApu();
|
||||
uint32_t extraScanlinesBeforeNmi = EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
uint32_t extraScanlinesAfterNmi = EmulationSettings::GetPpuExtraScanlinesAfterNmi();
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
uint32_t overclockRate = settings->GetOverclockRateSetting();
|
||||
bool overclockAdjustApu = settings->GetOverclockAdjustApu();
|
||||
uint32_t extraScanlinesBeforeNmi = settings->GetPpuExtraScanlinesBeforeNmi();
|
||||
uint32_t extraScanlinesAfterNmi = settings->GetPpuExtraScanlinesAfterNmi();
|
||||
|
||||
Stream(_state.PC, _state.SP, _state.PS, _state.A, _state.X, _state.Y, _cycleCount, _state.NMIFlag,
|
||||
_state.IRQFlag, _dmcCounter, _dmcDmaRunning, _spriteDmaCounter, _spriteDmaTransfer,
|
||||
overclockRate, overclockAdjustApu, extraScanlinesBeforeNmi, extraScanlinesBeforeNmi);
|
||||
|
||||
if(!saving) {
|
||||
EmulationSettings::SetOverclockRate(overclockRate, overclockAdjustApu);
|
||||
EmulationSettings::SetPpuNmiConfig(extraScanlinesBeforeNmi, extraScanlinesAfterNmi);
|
||||
settings->SetOverclockRate(overclockRate, overclockAdjustApu);
|
||||
settings->SetPpuNmiConfig(extraScanlinesBeforeNmi, extraScanlinesAfterNmi);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ protected:
|
|||
AddRegisterRange(0x7000, 0x7FFF, MemoryOperation::Write);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
_extraNametables[i] = new uint8_t[0x400];
|
||||
BaseMapper::InitializeRam(_extraNametables[i], 0x400);
|
||||
InitializeRam(_extraNametables[i], 0x400);
|
||||
AddNametable(4 + i, _extraNametables[i]);
|
||||
}
|
||||
_reg = GetPowerOnByte();
|
||||
|
|
|
@ -46,9 +46,22 @@
|
|||
#include "NotificationManager.h"
|
||||
#include "HistoryViewer.h"
|
||||
|
||||
Console::Console(shared_ptr<Console> master)
|
||||
Console::Console(shared_ptr<Console> master, EmulationSettings* initialSettings)
|
||||
{
|
||||
_master = master;
|
||||
|
||||
if(_master) {
|
||||
//Slave console should use the same settings as the master
|
||||
_settings = _master->_settings;
|
||||
} else {
|
||||
if(initialSettings) {
|
||||
_settings.reset(new EmulationSettings(*initialSettings));
|
||||
} else {
|
||||
_settings.reset(new EmulationSettings());
|
||||
}
|
||||
KeyManager::SetSettings(_settings.get());
|
||||
}
|
||||
|
||||
_model = NesModel::NTSC;
|
||||
}
|
||||
|
||||
|
@ -295,17 +308,17 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
|
|||
|
||||
switch(romInfo.System) {
|
||||
case GameSystem::FDS:
|
||||
EmulationSettings::SetPpuModel(PpuModel::Ppu2C02);
|
||||
_settings->SetPpuModel(PpuModel::Ppu2C02);
|
||||
_systemActionManager.reset(new FdsSystemActionManager(shared_from_this(), _mapper));
|
||||
break;
|
||||
|
||||
case GameSystem::VsSystem:
|
||||
EmulationSettings::SetPpuModel(romInfo.VsPpuModel);
|
||||
_settings->SetPpuModel(romInfo.VsPpuModel);
|
||||
_systemActionManager.reset(new VsSystemActionManager(shared_from_this()));
|
||||
break;
|
||||
|
||||
default:
|
||||
EmulationSettings::SetPpuModel(PpuModel::Ppu2C02);
|
||||
_settings->SetPpuModel(PpuModel::Ppu2C02);
|
||||
_systemActionManager.reset(new SystemActionManager(shared_from_this())); break;
|
||||
}
|
||||
|
||||
|
@ -381,10 +394,10 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
|
|||
string modelName = _model == NesModel::PAL ? "PAL" : (_model == NesModel::Dendy ? "Dendy" : "NTSC");
|
||||
string messageTitle = MessageManager::Localize("GameLoaded") + " (" + modelName + ")";
|
||||
MessageManager::DisplayMessage(messageTitle, FolderUtilities::GetFilename(GetRomInfo().RomName, false));
|
||||
if(EmulationSettings::GetOverclockRate() != 100) {
|
||||
MessageManager::DisplayMessage("ClockRate", std::to_string(EmulationSettings::GetOverclockRate()) + "%");
|
||||
if(_settings->GetOverclockRate() != 100) {
|
||||
MessageManager::DisplayMessage("ClockRate", std::to_string(_settings->GetOverclockRate()) + "%");
|
||||
}
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
|
||||
if(_slave) {
|
||||
_notificationManager->SendNotification(ConsoleNotificationType::VsDualSystemStarted);
|
||||
|
@ -438,6 +451,11 @@ shared_ptr<NotificationManager> Console::GetNotificationManager()
|
|||
return _notificationManager;
|
||||
}
|
||||
|
||||
EmulationSettings* Console::GetSettings()
|
||||
{
|
||||
return _settings.get();
|
||||
}
|
||||
|
||||
bool Console::IsDualSystem()
|
||||
{
|
||||
return _slave != nullptr || _master != nullptr;
|
||||
|
@ -552,7 +570,7 @@ void Console::ResetComponents(bool softReset)
|
|||
_soundMixer->StopAudio(true);
|
||||
|
||||
_memoryManager->Reset(softReset);
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::DisablePpuReset) || !softReset) {
|
||||
if(!_settings->CheckFlag(EmulationFlags::DisablePpuReset) || !softReset) {
|
||||
_ppu->Reset();
|
||||
}
|
||||
_apu->Reset(softReset);
|
||||
|
@ -638,7 +656,7 @@ void Console::RunSingleFrame()
|
|||
}
|
||||
}
|
||||
|
||||
EmulationSettings::DisableOverclocking(_disableOcNextFrame || NsfMapper::GetInstance());
|
||||
_settings->DisableOverclocking(_disableOcNextFrame || NsfMapper::GetInstance());
|
||||
_disableOcNextFrame = false;
|
||||
|
||||
_systemActionManager->ProcessSystemActions();
|
||||
|
@ -704,7 +722,7 @@ void Console::Run()
|
|||
_slave->_soundMixer->ProcessEndOfFrame();
|
||||
}
|
||||
|
||||
bool displayDebugInfo = EmulationSettings::CheckFlag(EmulationFlags::DisplayDebugInfo);
|
||||
bool displayDebugInfo = _settings->CheckFlag(EmulationFlags::DisplayDebugInfo);
|
||||
if(displayDebugInfo) {
|
||||
DisplayDebugInformation(clockTimer, lastFrameTimer, lastFrameMin, lastFrameMax, timeLagData);
|
||||
if(_slave) {
|
||||
|
@ -717,7 +735,7 @@ void Console::Run()
|
|||
_historyViewer->ProcessEndOfFrame();
|
||||
}
|
||||
_rewindManager->ProcessEndOfFrame();
|
||||
EmulationSettings::DisableOverclocking(_disableOcNextFrame || NsfMapper::GetInstance());
|
||||
_settings->DisableOverclocking(_disableOcNextFrame || NsfMapper::GetInstance());
|
||||
_disableOcNextFrame = false;
|
||||
|
||||
//Sleep until we're ready to start the next frame
|
||||
|
@ -733,8 +751,8 @@ void Console::Run()
|
|||
_runLock.Acquire();
|
||||
}
|
||||
|
||||
bool paused = EmulationSettings::IsPaused() || _paused;
|
||||
if(paused && !_stop) {
|
||||
bool pausedRequired = _settings->NeedsPause();
|
||||
if(pausedRequired && !_stop && !_settings->CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
_notificationManager->SendNotification(ConsoleNotificationType::GamePaused);
|
||||
|
||||
//Prevent audio from looping endlessly while game is paused
|
||||
|
@ -747,16 +765,13 @@ void Console::Run()
|
|||
|
||||
PlatformUtilities::EnableScreensaver();
|
||||
PlatformUtilities::RestoreTimerResolution();
|
||||
while(paused && !_stop) {
|
||||
while(pausedRequired && !_stop && !_settings->CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
//Sleep until emulation is resumed
|
||||
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(30));
|
||||
paused = EmulationSettings::IsPaused() || _paused;
|
||||
}
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
//Prevent pausing when debugger is active
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
pausedRequired = _settings->NeedsPause();
|
||||
_paused = true;
|
||||
}
|
||||
_paused = false;
|
||||
|
||||
PlatformUtilities::DisableScreensaver();
|
||||
_runLock.Acquire();
|
||||
|
@ -764,7 +779,7 @@ void Console::Run()
|
|||
lastFrameTimer.Reset();
|
||||
}
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::UseHighResolutionTimer)) {
|
||||
if(_settings->CheckFlag(EmulationFlags::UseHighResolutionTimer)) {
|
||||
PlatformUtilities::EnableHighResolutionTimer();
|
||||
} else {
|
||||
PlatformUtilities::RestoreTimerResolution();
|
||||
|
@ -773,7 +788,7 @@ void Console::Run()
|
|||
_systemActionManager->ProcessSystemActions();
|
||||
|
||||
//Get next target time, and adjust based on whether we are ahead or behind
|
||||
double timeLag = EmulationSettings::GetEmulationSpeed() == 0 ? 0 : clockTimer.GetElapsedMS() - targetTime;
|
||||
double timeLag = _settings->GetEmulationSpeed() == 0 ? 0 : clockTimer.GetElapsedMS() - targetTime;
|
||||
if(displayDebugInfo) {
|
||||
timeLagData[timeLagDataIndex] = timeLag;
|
||||
timeLagDataIndex = (timeLagDataIndex + 1) & 0x0F;
|
||||
|
@ -820,8 +835,7 @@ void Console::Run()
|
|||
PlatformUtilities::EnableScreensaver();
|
||||
PlatformUtilities::RestoreTimerResolution();
|
||||
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
|
||||
_initialized = false;
|
||||
|
||||
|
@ -853,7 +867,7 @@ bool Console::IsRunning()
|
|||
}
|
||||
}
|
||||
|
||||
bool Console::IsPaused()
|
||||
bool Console::IsExecutionStopped()
|
||||
{
|
||||
if(_master) {
|
||||
//For slave CPU, return the master's state
|
||||
|
@ -863,25 +877,24 @@ bool Console::IsPaused()
|
|||
}
|
||||
}
|
||||
|
||||
bool Console::GetPauseStatus()
|
||||
bool Console::IsPaused()
|
||||
{
|
||||
return _paused;
|
||||
}
|
||||
|
||||
void Console::SetPauseStatus(bool paused)
|
||||
{
|
||||
_paused = paused;
|
||||
if(_master) {
|
||||
return _master->_paused;
|
||||
} else {
|
||||
return _paused;
|
||||
}
|
||||
}
|
||||
|
||||
void Console::UpdateNesModel(bool sendNotification)
|
||||
{
|
||||
bool configChanged = false;
|
||||
if(EmulationSettings::NeedControllerUpdate()) {
|
||||
if(_settings->NeedControllerUpdate()) {
|
||||
_controlManager->UpdateControlDevices();
|
||||
configChanged = true;
|
||||
}
|
||||
|
||||
NesModel model = EmulationSettings::GetNesModel();
|
||||
NesModel model = _settings->GetNesModel();
|
||||
if(model == NesModel::Auto) {
|
||||
switch(_mapper->GetRomInfo().System) {
|
||||
case GameSystem::NesPal: model = NesModel::PAL; break;
|
||||
|
@ -909,7 +922,7 @@ void Console::UpdateNesModel(bool sendNotification)
|
|||
|
||||
double Console::GetFrameDelay()
|
||||
{
|
||||
uint32_t emulationSpeed = EmulationSettings::GetEmulationSpeed();
|
||||
uint32_t emulationSpeed = _settings->GetEmulationSpeed();
|
||||
double frameDelay;
|
||||
if(emulationSpeed == 0) {
|
||||
frameDelay = 0;
|
||||
|
@ -917,9 +930,9 @@ double Console::GetFrameDelay()
|
|||
//60.1fps (NTSC), 50.01fps (PAL/Dendy)
|
||||
switch(_model) {
|
||||
default:
|
||||
case NesModel::NTSC: frameDelay = EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 16.6666666666666666667 : 16.63926405550947; break;
|
||||
case NesModel::NTSC: frameDelay = _settings->CheckFlag(EmulationFlags::IntegerFpsMode) ? 16.6666666666666666667 : 16.63926405550947; break;
|
||||
case NesModel::PAL:
|
||||
case NesModel::Dendy: frameDelay = EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 20 : 19.99720920217466; break;
|
||||
case NesModel::Dendy: frameDelay = _settings->CheckFlag(EmulationFlags::IntegerFpsMode) ? 20 : 19.99720920217466; break;
|
||||
}
|
||||
frameDelay /= (double)emulationSpeed / 100.0;
|
||||
}
|
||||
|
@ -999,7 +1012,7 @@ void Console::BreakIfDebugging()
|
|||
shared_ptr<Debugger> debugger = _debugger;
|
||||
if(debugger) {
|
||||
debugger->BreakImmediately();
|
||||
} else if(EmulationSettings::CheckFlag(EmulationFlags::BreakOnCrash)) {
|
||||
} else if(_settings->CheckFlag(EmulationFlags::BreakOnCrash)) {
|
||||
//When "Break on Crash" is enabled, open the debugger and break immediately if a crash occurs
|
||||
debugger = GetDebugger(true);
|
||||
debugger->BreakImmediately();
|
||||
|
@ -1072,7 +1085,7 @@ void Console::LoadHdPack(VirtualFile &romFile, VirtualFile &patchFile)
|
|||
{
|
||||
_hdData.reset();
|
||||
_hdAudioDevice.reset();
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::UseHdPacks)) {
|
||||
if(_settings->CheckFlag(EmulationFlags::UseHdPacks)) {
|
||||
_hdData.reset(new HdPackData());
|
||||
if(!HdPackLoader::LoadHdNesPack(romFile, *_hdData.get())) {
|
||||
_hdData.reset();
|
||||
|
@ -1378,7 +1391,7 @@ void Console::DisplayDebugInformation(Timer &clockTimer, Timer &lastFrameTimer,
|
|||
_debugHud->DrawString(10, 10, "Audio Stats", 0xFFFFFF, 0xFF000000, 1, startFrame);
|
||||
_debugHud->DrawString(10, 21, "Latency: ", 0xFFFFFF, 0xFF000000, 1, startFrame);
|
||||
|
||||
int color = (stats.AverageLatency > 0 && std::abs(stats.AverageLatency - EmulationSettings::GetAudioLatency()) > 3) ? 0xFF0000 : 0xFFFFFF;
|
||||
int color = (stats.AverageLatency > 0 && std::abs(stats.AverageLatency - _settings->GetAudioLatency()) > 3) ? 0xFF0000 : 0xFFFFFF;
|
||||
std::stringstream ss;
|
||||
ss << std::fixed << std::setprecision(2) << stats.AverageLatency << " ms";
|
||||
_debugHud->DrawString(54, 21, ss.str(), color, 0xFF000000, 1, startFrame);
|
||||
|
|
|
@ -26,6 +26,7 @@ class DebugHud;
|
|||
class SoundMixer;
|
||||
class NotificationManager;
|
||||
class Debugger;
|
||||
class EmulationSettings;
|
||||
|
||||
struct HdPackData;
|
||||
struct HashInfo;
|
||||
|
@ -71,6 +72,7 @@ private:
|
|||
shared_ptr<DebugHud> _debugHud;
|
||||
shared_ptr<SoundMixer> _soundMixer;
|
||||
shared_ptr<NotificationManager> _notificationManager;
|
||||
shared_ptr<EmulationSettings> _settings;
|
||||
|
||||
shared_ptr<HdPackBuilder> _hdPackBuilder;
|
||||
shared_ptr<HdPackData> _hdData;
|
||||
|
@ -98,7 +100,7 @@ private:
|
|||
void DisplayDebugInformation(Timer &clockTimer, Timer &lastFrameTimer, double &lastFrameMin, double &lastFrameMax, double *timeLagData);
|
||||
|
||||
public:
|
||||
Console(shared_ptr<Console> master = nullptr);
|
||||
Console(shared_ptr<Console> master = nullptr, EmulationSettings* initialSettings = nullptr);
|
||||
~Console();
|
||||
|
||||
void Init();
|
||||
|
@ -110,6 +112,7 @@ public:
|
|||
shared_ptr<DebugHud> GetDebugHud();
|
||||
shared_ptr<SoundMixer> GetSoundMixer();
|
||||
shared_ptr<NotificationManager> GetNotificationManager();
|
||||
EmulationSettings* GetSettings();
|
||||
|
||||
bool IsDualSystem();
|
||||
shared_ptr<Console> GetDualConsole();
|
||||
|
@ -191,10 +194,9 @@ public:
|
|||
void ResetLagCounter();
|
||||
|
||||
bool IsRunning();
|
||||
bool IsPaused();
|
||||
bool IsExecutionStopped();
|
||||
|
||||
bool GetPauseStatus();
|
||||
void SetPauseStatus(bool paused);
|
||||
bool IsPaused();
|
||||
|
||||
void SetNextFrameOverclockStatus(bool disabled);
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void ControlManager::RegisterControlDevice(shared_ptr<BaseControlDevice> control
|
|||
|
||||
ControllerType ControlManager::GetControllerType(uint8_t port)
|
||||
{
|
||||
return EmulationSettings::GetControllerType(port);
|
||||
return _console->GetSettings()->GetControllerType(port);
|
||||
}
|
||||
|
||||
shared_ptr<BaseControlDevice> ControlManager::CreateControllerDevice(ControllerType type, uint8_t port, shared_ptr<Console> console)
|
||||
|
@ -115,13 +115,13 @@ shared_ptr<BaseControlDevice> ControlManager::CreateControllerDevice(ControllerT
|
|||
|
||||
switch(type) {
|
||||
case ControllerType::None: break;
|
||||
case ControllerType::StandardController: device.reset(new StandardController(console, port, EmulationSettings::GetControllerKeys(port))); break;
|
||||
case ControllerType::StandardController: device.reset(new StandardController(console, port, console->GetSettings()->GetControllerKeys(port))); break;
|
||||
case ControllerType::Zapper: device.reset(new Zapper(console, port)); break;
|
||||
case ControllerType::ArkanoidController: device.reset(new ArkanoidController(port)); break;
|
||||
case ControllerType::SnesController: device.reset(new SnesController(port, EmulationSettings::GetControllerKeys(port))); break;
|
||||
case ControllerType::PowerPad: device.reset(new PowerPad(port, EmulationSettings::GetControllerKeys(port))); break;
|
||||
case ControllerType::SnesMouse: device.reset(new SnesMouse(port)); break;
|
||||
case ControllerType::SuborMouse: device.reset(new SuborMouse(port)); break;
|
||||
case ControllerType::ArkanoidController: device.reset(new ArkanoidController(console, port)); break;
|
||||
case ControllerType::SnesController: device.reset(new SnesController(console, port, console->GetSettings()->GetControllerKeys(port))); break;
|
||||
case ControllerType::PowerPad: device.reset(new PowerPad(console, port, console->GetSettings()->GetControllerKeys(port))); break;
|
||||
case ControllerType::SnesMouse: device.reset(new SnesMouse(console, port)); break;
|
||||
case ControllerType::SuborMouse: device.reset(new SuborMouse(console, port)); break;
|
||||
case ControllerType::VsZapper: device.reset(new VsZapper(console, port)); break;
|
||||
}
|
||||
|
||||
|
@ -134,21 +134,21 @@ shared_ptr<BaseControlDevice> ControlManager::CreateExpansionDevice(ExpansionPor
|
|||
|
||||
switch(type) {
|
||||
case ExpansionPortDevice::Zapper: device.reset(new Zapper(console, BaseControlDevice::ExpDevicePort)); break;
|
||||
case ExpansionPortDevice::ArkanoidController: device.reset(new ArkanoidController(BaseControlDevice::ExpDevicePort)); break;
|
||||
case ExpansionPortDevice::OekaKidsTablet: device.reset(new OekaKidsTablet()); break;
|
||||
case ExpansionPortDevice::FamilyTrainerMat: device.reset(new FamilyMatTrainer(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::KonamiHyperShot: device.reset(new KonamiHyperShot(console, EmulationSettings::GetControllerKeys(0), EmulationSettings::GetControllerKeys(1))); break;
|
||||
case ExpansionPortDevice::FamilyBasicKeyboard: device.reset(new FamilyBasicKeyboard(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::PartyTap: device.reset(new PartyTap(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::Pachinko: device.reset(new PachinkoController(console, EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::ExcitingBoxing: device.reset(new ExcitingBoxingController(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::JissenMahjong: device.reset(new JissenMahjongController(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::SuborKeyboard: device.reset(new SuborKeyboard(EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::ArkanoidController: device.reset(new ArkanoidController(console, BaseControlDevice::ExpDevicePort)); break;
|
||||
case ExpansionPortDevice::OekaKidsTablet: device.reset(new OekaKidsTablet(console)); break;
|
||||
case ExpansionPortDevice::FamilyTrainerMat: device.reset(new FamilyMatTrainer(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::KonamiHyperShot: device.reset(new KonamiHyperShot(console, console->GetSettings()->GetControllerKeys(0), console->GetSettings()->GetControllerKeys(1))); break;
|
||||
case ExpansionPortDevice::FamilyBasicKeyboard: device.reset(new FamilyBasicKeyboard(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::PartyTap: device.reset(new PartyTap(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::Pachinko: device.reset(new PachinkoController(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::ExcitingBoxing: device.reset(new ExcitingBoxingController(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::JissenMahjong: device.reset(new JissenMahjongController(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::SuborKeyboard: device.reset(new SuborKeyboard(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::BarcodeBattler: device.reset(new BarcodeBattlerReader(console)); break;
|
||||
case ExpansionPortDevice::HoriTrack: device.reset(new HoriTrack(console, EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::BandaiHyperShot: device.reset(new BandaiHyperShot(console, EmulationSettings::GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::AsciiTurboFile: device.reset(new AsciiTurboFile()); break;
|
||||
case ExpansionPortDevice::BattleBox: device.reset(new BattleBox()); break;
|
||||
case ExpansionPortDevice::HoriTrack: device.reset(new HoriTrack(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::BandaiHyperShot: device.reset(new BandaiHyperShot(console, console->GetSettings()->GetControllerKeys(0))); break;
|
||||
case ExpansionPortDevice::AsciiTurboFile: device.reset(new AsciiTurboFile(console)); break;
|
||||
case ExpansionPortDevice::BattleBox: device.reset(new BattleBox(console)); break;
|
||||
|
||||
case ExpansionPortDevice::FourPlayerAdapter:
|
||||
default: break;
|
||||
|
@ -160,9 +160,10 @@ shared_ptr<BaseControlDevice> ControlManager::CreateExpansionDevice(ExpansionPor
|
|||
void ControlManager::UpdateControlDevices()
|
||||
{
|
||||
auto lock = _deviceLock.AcquireSafe();
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
|
||||
//Reset update flag
|
||||
EmulationSettings::NeedControllerUpdate();
|
||||
settings->NeedControllerUpdate();
|
||||
|
||||
bool hadKeyboard = HasKeyboard();
|
||||
|
||||
|
@ -170,9 +171,9 @@ void ControlManager::UpdateControlDevices()
|
|||
|
||||
RegisterControlDevice(_systemActionManager);
|
||||
|
||||
bool fourScore = EmulationSettings::CheckFlag(EmulationFlags::HasFourScore);
|
||||
ConsoleType consoleType = EmulationSettings::GetConsoleType();
|
||||
ExpansionPortDevice expansionDevice = EmulationSettings::GetExpansionDevice();
|
||||
bool fourScore = settings->CheckFlag(EmulationFlags::HasFourScore);
|
||||
ConsoleType consoleType = settings->GetConsoleType();
|
||||
ExpansionPortDevice expansionDevice = settings->GetExpansionDevice();
|
||||
|
||||
if(consoleType != ConsoleType::Famicom) {
|
||||
expansionDevice = ExpansionPortDevice::None;
|
||||
|
@ -189,7 +190,7 @@ void ControlManager::UpdateControlDevices()
|
|||
|
||||
if(fourScore && consoleType == ConsoleType::Nes) {
|
||||
//FourScore is only used to provide the signature for reads past the first 16 reads
|
||||
RegisterControlDevice(shared_ptr<FourScore>(new FourScore()));
|
||||
RegisterControlDevice(shared_ptr<FourScore>(new FourScore(_console)));
|
||||
}
|
||||
|
||||
shared_ptr<BaseControlDevice> expDevice = CreateExpansionDevice(expansionDevice, _console);
|
||||
|
@ -199,9 +200,9 @@ void ControlManager::UpdateControlDevices()
|
|||
|
||||
bool hasKeyboard = HasKeyboard();
|
||||
if(!hasKeyboard) {
|
||||
EmulationSettings::DisableKeyboardMode();
|
||||
settings->DisableKeyboardMode();
|
||||
} else if(!hadKeyboard && hasKeyboard) {
|
||||
EmulationSettings::EnableKeyboardMode();
|
||||
settings->EnableKeyboardMode();
|
||||
}
|
||||
|
||||
if(_mapperControlDevice) {
|
||||
|
@ -226,17 +227,17 @@ uint8_t ControlManager::GetOpenBusMask(uint8_t port)
|
|||
//Usually this is the most significant byte of the address of the controller port - 0x40.
|
||||
//Paperboy relies on this behavior and requires that reads from the controller ports return exactly $40 or $41 as appropriate."
|
||||
|
||||
switch(EmulationSettings::GetConsoleType()) {
|
||||
switch(_console->GetSettings()->GetConsoleType()) {
|
||||
default:
|
||||
case ConsoleType::Nes:
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::UseNes101Hvc101Behavior)) {
|
||||
return port == 0 ? 0xE4 : 0xE0;
|
||||
} else {
|
||||
return 0xE0;
|
||||
}
|
||||
|
||||
case ConsoleType::Famicom:
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::UseNes101Hvc101Behavior)) {
|
||||
return port == 0 ? 0xF8 : 0xE0;
|
||||
} else {
|
||||
return port == 0 ? 0xF8 : 0xE0;
|
||||
|
@ -348,6 +349,7 @@ void ControlManager::StreamState(bool saving)
|
|||
{
|
||||
//Restore controllers that were being used at the time the snapshot was made
|
||||
//This is particularely important to ensure proper sync during NetPlay
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
ControllerType controllerTypes[4];
|
||||
NesModel nesModel;
|
||||
ExpansionPortDevice expansionDevice;
|
||||
|
@ -357,13 +359,13 @@ void ControlManager::StreamState(bool saving)
|
|||
uint32_t zapperDetectionRadius = 0;
|
||||
if(saving) {
|
||||
nesModel = _console->GetModel();
|
||||
expansionDevice = EmulationSettings::GetExpansionDevice();
|
||||
consoleType = EmulationSettings::GetConsoleType();
|
||||
hasFourScore = EmulationSettings::CheckFlag(EmulationFlags::HasFourScore);
|
||||
useNes101Hvc101Behavior = EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior);
|
||||
zapperDetectionRadius = EmulationSettings::GetZapperDetectionRadius();
|
||||
expansionDevice = settings->GetExpansionDevice();
|
||||
consoleType = settings->GetConsoleType();
|
||||
hasFourScore = settings->CheckFlag(EmulationFlags::HasFourScore);
|
||||
useNes101Hvc101Behavior = settings->CheckFlag(EmulationFlags::UseNes101Hvc101Behavior);
|
||||
zapperDetectionRadius = settings->GetZapperDetectionRadius();
|
||||
for(int i = 0; i < 4; i++) {
|
||||
controllerTypes[i] = EmulationSettings::GetControllerType(i);
|
||||
controllerTypes[i] = settings->GetControllerType(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,16 +377,16 @@ void ControlManager::StreamState(bool saving)
|
|||
Stream(unusedRefreshState, unusedMousePositionX, unusedMousePositionY, nesModel, expansionDevice, consoleType, types, hasFourScore, useNes101Hvc101Behavior, zapperDetectionRadius, _lagCounter, _pollCounter);
|
||||
|
||||
if(!saving) {
|
||||
EmulationSettings::SetNesModel(nesModel);
|
||||
EmulationSettings::SetExpansionDevice(expansionDevice);
|
||||
EmulationSettings::SetConsoleType(consoleType);
|
||||
settings->SetNesModel(nesModel);
|
||||
settings->SetExpansionDevice(expansionDevice);
|
||||
settings->SetConsoleType(consoleType);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
EmulationSettings::SetControllerType(i, controllerTypes[i]);
|
||||
settings->SetControllerType(i, controllerTypes[i]);
|
||||
}
|
||||
|
||||
EmulationSettings::SetZapperDetectionRadius(zapperDetectionRadius);
|
||||
EmulationSettings::SetFlagState(EmulationFlags::HasFourScore, hasFourScore);
|
||||
EmulationSettings::SetFlagState(EmulationFlags::UseNes101Hvc101Behavior, useNes101Hvc101Behavior);
|
||||
settings->SetZapperDetectionRadius(zapperDetectionRadius);
|
||||
settings->SetFlagState(EmulationFlags::HasFourScore, hasFourScore);
|
||||
settings->SetFlagState(EmulationFlags::UseNes101Hvc101Behavior, useNes101Hvc101Behavior);
|
||||
|
||||
UpdateControlDevices();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
class DatachBarcodeReader : public BaseControlDevice, public IBarcodeReader
|
||||
{
|
||||
private:
|
||||
shared_ptr<Console> _console;
|
||||
vector<uint8_t> _data;
|
||||
int32_t _insertCycle = 0;
|
||||
uint64_t _newBarcode = 0;
|
||||
|
@ -29,9 +28,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
DatachBarcodeReader(shared_ptr<Console> console) : BaseControlDevice(BaseControlDevice::MapperInputPort)
|
||||
DatachBarcodeReader(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::MapperInputPort)
|
||||
{
|
||||
_console = console;
|
||||
}
|
||||
|
||||
void InternalSetStateFromInput() override
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
#include "CodeDataLogger.h"
|
||||
#include "NotificationManager.h"
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX ((uint32_t)-1)
|
||||
#endif
|
||||
|
||||
const int Debugger::BreakpointTypeCount;
|
||||
string Debugger::_disassemblerOutput = "";
|
||||
|
||||
|
@ -253,7 +249,7 @@ void Debugger::SetBreakpoints(Breakpoint breakpoints[], uint32_t length)
|
|||
for(uint32_t j = 0; j < length; j++) {
|
||||
Breakpoint &bp = breakpoints[j];
|
||||
for(int i = 0; i < Debugger::BreakpointTypeCount; i++) {
|
||||
bool isEnabled = bp.IsEnabled() && EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled);
|
||||
bool isEnabled = bp.IsEnabled() && _console->GetSettings()->CheckFlag(EmulationFlags::DebuggerWindowEnabled);
|
||||
if((bp.IsMarked() || isEnabled) && bp.HasBreakpointType((BreakpointType)i)) {
|
||||
_breakpoints[i].push_back(bp);
|
||||
vector<int> *rpnList = expEval.GetRpnList(bp.GetCondition());
|
||||
|
@ -897,7 +893,7 @@ const char* Debugger::GetCode(uint32_t &length)
|
|||
{
|
||||
string previousCode = _disassemblerOutput;
|
||||
GenerateCodeOutput();
|
||||
bool forceRefresh = length == UINT32_MAX;
|
||||
bool forceRefresh = length == (uint32_t)-1;
|
||||
length = (uint32_t)_disassemblerOutput.size();
|
||||
if(!forceRefresh && previousCode.compare(_disassemblerOutput) == 0) {
|
||||
//Return null pointer if the code is identical to last call
|
||||
|
@ -1009,7 +1005,7 @@ shared_ptr<MemoryAccessCounter> Debugger::GetMemoryAccessCounter()
|
|||
|
||||
bool Debugger::IsExecutionStopped()
|
||||
{
|
||||
return _executionStopped || _console->IsPaused();
|
||||
return _executionStopped || _console->IsExecutionStopped();
|
||||
}
|
||||
|
||||
bool Debugger::IsPauseIconShown()
|
||||
|
@ -1150,7 +1146,7 @@ void Debugger::StopCodeRunner()
|
|||
//Break debugger when code has finished executing
|
||||
SetNextStatement(_returnToAddress);
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
Step(1);
|
||||
} else {
|
||||
Run();
|
||||
|
@ -1378,7 +1374,7 @@ void Debugger::GetDebugEvents(uint32_t* pictureBuffer, DebugEventInfo *infoArray
|
|||
DebugBreakHelper helper(this);
|
||||
|
||||
uint16_t *buffer = new uint16_t[PPU::PixelCount];
|
||||
uint32_t *palette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *palette = _console->GetSettings()->GetRgbPalette();
|
||||
_ppu->DebugCopyOutputBuffer(buffer);
|
||||
|
||||
for(int i = 0; i < PPU::PixelCount; i++) {
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#include <algorithm>
|
||||
#include "PPU.h"
|
||||
#include "DebugHud.h"
|
||||
#include "Console.h"
|
||||
|
||||
DefaultVideoFilter::DefaultVideoFilter()
|
||||
DefaultVideoFilter::DefaultVideoFilter(shared_ptr<Console> console) : BaseVideoFilter(console)
|
||||
{
|
||||
InitDecodeTables();
|
||||
|
||||
|
@ -45,7 +46,7 @@ FrameInfo DefaultVideoFilter::GetFrameInfo()
|
|||
|
||||
void DefaultVideoFilter::OnBeforeApplyFilter()
|
||||
{
|
||||
PictureSettings currentSettings = EmulationSettings::GetPictureSettings();
|
||||
PictureSettings currentSettings = _console->GetSettings()->GetPictureSettings();
|
||||
if(_pictureSettings.Hue != currentSettings.Hue || _pictureSettings.Saturation != currentSettings.Saturation) {
|
||||
InitConversionMatrix(currentSettings.Hue, currentSettings.Saturation);
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ void DefaultVideoFilter::DecodePpuBuffer(uint16_t *ppuOutputBuffer, uint32_t* ou
|
|||
{
|
||||
uint32_t* out = outputBuffer;
|
||||
OverscanDimensions overscan = GetOverscan();
|
||||
double scanlineIntensity = 1.0 - EmulationSettings::GetPictureSettings().ScanlineIntensity;
|
||||
double scanlineIntensity = 1.0 - _console->GetSettings()->GetPictureSettings().ScanlineIntensity;
|
||||
for(uint32_t i = overscan.Top, iMax = 240 - overscan.Bottom; i < iMax; i++) {
|
||||
if(displayScanlines && (i + overscan.Top) % 2 == 0) {
|
||||
for(uint32_t j = overscan.Left, jMax = 256 - overscan.Right; j < jMax; j++) {
|
||||
|
@ -75,7 +76,7 @@ void DefaultVideoFilter::DecodePpuBuffer(uint16_t *ppuOutputBuffer, uint32_t* ou
|
|||
|
||||
void DefaultVideoFilter::ApplyFilter(uint16_t *ppuOutputBuffer)
|
||||
{
|
||||
DecodePpuBuffer(ppuOutputBuffer, GetOutputBuffer(), EmulationSettings::GetVideoFilterType() <= VideoFilterType::BisqwitNtsc);
|
||||
DecodePpuBuffer(ppuOutputBuffer, GetOutputBuffer(), _console->GetSettings()->GetVideoFilterType() <= VideoFilterType::BisqwitNtsc);
|
||||
}
|
||||
|
||||
void DefaultVideoFilter::RgbToYiq(double r, double g, double b, double &y, double &i, double &q)
|
||||
|
@ -131,7 +132,7 @@ void DefaultVideoFilter::InitDecodeTables()
|
|||
|
||||
uint32_t DefaultVideoFilter::ProcessIntensifyBits(uint16_t ppuPixel, double scanlineIntensity)
|
||||
{
|
||||
uint32_t pixelOutput = EmulationSettings::GetRgbPalette()[ppuPixel & 0x3F];
|
||||
uint32_t pixelOutput = _console->GetSettings()->GetRgbPalette()[ppuPixel & 0x3F];
|
||||
uint32_t intensifyBits = (ppuPixel >> 6) & 0x07;
|
||||
|
||||
if(intensifyBits || _needToProcess || scanlineIntensity < 1.0) {
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
void OnBeforeApplyFilter();
|
||||
|
||||
public:
|
||||
DefaultVideoFilter();
|
||||
DefaultVideoFilter(shared_ptr<Console> console);
|
||||
void ApplyFilter(uint16_t *ppuOutputBuffer);
|
||||
FrameInfo GetFrameInfo();
|
||||
};
|
|
@ -156,7 +156,7 @@ void DeltaModulationChannel::WriteRAM(uint16_t addr, uint8_t value)
|
|||
uint8_t previousLevel = _outputLevel;
|
||||
_outputLevel = newValue;
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ReduceDmcPopping) && abs(_outputLevel - previousLevel) > 50) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::ReduceDmcPopping) && abs(_outputLevel - previousLevel) > 50) {
|
||||
//Reduce popping sounds for 4011 writes
|
||||
_outputLevel -= (_outputLevel - previousLevel) / 2;
|
||||
}
|
||||
|
|
|
@ -8,121 +8,13 @@ uint16_t EmulationSettings::_versionMajor = 0;
|
|||
uint8_t EmulationSettings::_versionMinor = 9;
|
||||
uint8_t EmulationSettings::_versionRevision = 5;
|
||||
|
||||
Language EmulationSettings::_displayLanguage = Language::English;
|
||||
SimpleLock EmulationSettings::_lock;
|
||||
SimpleLock EmulationSettings::_shortcutLock;
|
||||
SimpleLock EmulationSettings::_equalizerLock;
|
||||
|
||||
const vector<uint32_t> EmulationSettings::_speedValues = { { 1, 3, 6, 12, 25, 50, 75, 100, 150, 200, 250, 300, 350, 400, 450, 500, 750, 1000, 2000, 4000 } };
|
||||
|
||||
string EmulationSettings::_pauseScreenMessage;
|
||||
|
||||
SimpleLock EmulationSettings::_lock;
|
||||
uint64_t EmulationSettings::_flags = 0;
|
||||
|
||||
bool EmulationSettings::_audioSettingsChanged = true;
|
||||
uint32_t EmulationSettings::_audioLatency = 50;
|
||||
double EmulationSettings::_channelVolume[11] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
double EmulationSettings::_channelPanning[11] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
EqualizerFilterType EmulationSettings::_equalizerFilterType = EqualizerFilterType::None;
|
||||
vector<double> EmulationSettings::_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> EmulationSettings::_bands = { { 40,56,80,113,160,225,320,450,600,750,1000,2000,3000,4000,5000,6000,7000,10000,12500,15000 } };
|
||||
double EmulationSettings::_masterVolume = 1.0;
|
||||
double EmulationSettings::_volumeReduction = 0.75;
|
||||
uint32_t EmulationSettings::_sampleRate = 44100;
|
||||
StereoFilter EmulationSettings::_stereoFilter = StereoFilter::None;
|
||||
int32_t EmulationSettings::_stereoDelay = 0;
|
||||
double EmulationSettings::_stereoAngle = 0;
|
||||
double EmulationSettings::_reverbStrength = 0;
|
||||
double EmulationSettings::_reverbDelay = 0;
|
||||
uint32_t EmulationSettings::_crossFeedRatio = 0;
|
||||
SimpleLock EmulationSettings::_equalizerLock;
|
||||
|
||||
NesModel EmulationSettings::_model = NesModel::Auto;
|
||||
PpuModel EmulationSettings::_ppuModel = PpuModel::Ppu2C02;
|
||||
|
||||
uint32_t EmulationSettings::_emulationSpeed = 100;
|
||||
uint32_t EmulationSettings::_turboSpeed = 300;
|
||||
uint32_t EmulationSettings::_rewindSpeed = 100;
|
||||
|
||||
uint32_t EmulationSettings::_rewindBufferSize = 300;
|
||||
|
||||
bool EmulationSettings::_hasOverclock = false;
|
||||
uint32_t EmulationSettings::_overclockRate = 100;
|
||||
uint32_t EmulationSettings::_extraScanlinesBeforeNmi = 0;
|
||||
uint32_t EmulationSettings::_extraScanlinesAfterNmi = 0;
|
||||
double EmulationSettings::_effectiveOverclockRate = 100;
|
||||
bool EmulationSettings::_overclockAdjustApu = true;
|
||||
bool EmulationSettings::_disableOverclocking = false;
|
||||
|
||||
int32_t EmulationSettings::_nsfAutoDetectSilenceDelay = 3000;
|
||||
int32_t EmulationSettings::_nsfMoveToNextTrackTime = 120;
|
||||
bool EmulationSettings::_nsfDisableApuIrqs = true;
|
||||
|
||||
uint32_t EmulationSettings::_autoSaveDelay = 5;
|
||||
bool EmulationSettings::_autoSaveNotify = false;
|
||||
|
||||
bool EmulationSettings::_keyboardModeEnabled = false;
|
||||
|
||||
SimpleLock EmulationSettings::_shortcutLock;
|
||||
std::unordered_map<uint32_t, KeyCombination> EmulationSettings::_emulatorKeys[3];
|
||||
std::unordered_map<uint32_t, vector<KeyCombination>> EmulationSettings::_shortcutSupersets[3];
|
||||
|
||||
RamPowerOnState EmulationSettings::_ramPowerOnState = RamPowerOnState::AllZeros;
|
||||
uint32_t EmulationSettings::_dipSwitches = 0;
|
||||
|
||||
InputDisplaySettings EmulationSettings::_inputDisplaySettings = { 0, InputDisplayPosition::TopLeft, false };
|
||||
|
||||
OverscanDimensions EmulationSettings::_overscan;
|
||||
VideoFilterType EmulationSettings::_videoFilterType = VideoFilterType::None;
|
||||
VideoResizeFilter EmulationSettings::_resizeFilter = VideoResizeFilter::NearestNeighbor;
|
||||
double EmulationSettings::_videoScale = 1;
|
||||
VideoAspectRatio EmulationSettings::_aspectRatio = VideoAspectRatio::NoStretching;
|
||||
double EmulationSettings::_customAspectRatio = 1.0;
|
||||
PictureSettings EmulationSettings::_pictureSettings;
|
||||
NtscFilterSettings EmulationSettings::_ntscFilterSettings;
|
||||
bool EmulationSettings::_backgroundEnabled = true;
|
||||
bool EmulationSettings::_spritesEnabled = true;
|
||||
uint32_t EmulationSettings::_screenRotation = 0;
|
||||
uint32_t EmulationSettings::_exclusiveRefreshRate = 60;
|
||||
|
||||
ConsoleType EmulationSettings::_consoleType = ConsoleType::Nes;
|
||||
ExpansionPortDevice EmulationSettings::_expansionDevice = ExpansionPortDevice::None;
|
||||
ControllerType EmulationSettings::_controllerTypes[4] = { ControllerType::None, ControllerType::None, ControllerType::None, ControllerType::None };
|
||||
KeyMappingSet EmulationSettings::_controllerKeys[4] = { KeyMappingSet(), KeyMappingSet(), KeyMappingSet(), KeyMappingSet() };
|
||||
bool EmulationSettings::_needControllerUpdate = false;
|
||||
uint32_t EmulationSettings::_zapperDetectionRadius = 0;
|
||||
std::unordered_map<int, double> EmulationSettings::_mouseSensitivity;
|
||||
int32_t EmulationSettings::_inputPollScanline = 241;
|
||||
|
||||
uint32_t EmulationSettings::_defaultPpuPalette[64] = { /* 2C02 */ 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 };
|
||||
|
||||
uint32_t EmulationSettings::_currentPalette[64] = { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 };
|
||||
|
||||
uint32_t EmulationSettings::_ppuPaletteArgb[11][64] = {
|
||||
/* 2C02 */ { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 },
|
||||
/* 2C03 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 },
|
||||
/* 2C04-0001 */ { 0xFFFFB6B6, 0xFFDA6DFF, 0xFFFF0000, 0xFF9191FF, 0xFF009191, 0xFF244800, 0xFF484848, 0xFFFF0091, 0xFFFFFFFF, 0xFF6D6D6D, 0xFFFFB600, 0xFFB6006D, 0xFF91006D, 0xFFDADA00, 0xFF6D4800, 0xFFFFFFFF, 0xFF6DB6FF, 0xFFDAB66D, 0xFF6D2400, 0xFF6DDA00, 0xFF91DAFF, 0xFFDAB6FF, 0xFFFFDA91, 0xFF0048FF, 0xFFFFDA00, 0xFF48FFDA, 0xFF000000, 0xFF480000, 0xFFDADADA, 0xFF919191, 0xFFFF00FF, 0xFF002491, 0xFF00006D, 0xFFB6DAFF, 0xFFFFB6FF, 0xFF00FF00, 0xFF00FFFF, 0xFF004848, 0xFF00B66D, 0xFFB600FF, 0xFF000000, 0xFF914800, 0xFFFF91FF, 0xFFB62400, 0xFF9100FF, 0xFF0000DA, 0xFFFF9100, 0xFF000000, 0xFF000000, 0xFF249100, 0xFFB6B6B6, 0xFF006D24, 0xFFB6FF48, 0xFF6D48DA, 0xFFFFFF00, 0xFFDA6D00, 0xFF004800, 0xFF006DDA, 0xFF009100, 0xFF242424, 0xFFFFFF6D, 0xFFFF6DFF, 0xFF916D00, 0xFF91FF6D },
|
||||
/* 2C04-0002 */ { 0xFF000000, 0xFFFFB600, 0xFF916D00, 0xFFB6FF48, 0xFF91FF6D, 0xFFFF6DFF, 0xFF009191, 0xFFB6DAFF, 0xFFFF0000, 0xFF9100FF, 0xFFFFFF6D, 0xFFFF91FF, 0xFFFFFFFF, 0xFFDA6DFF, 0xFF91DAFF, 0xFF009100, 0xFF004800, 0xFF6DB6FF, 0xFFB62400, 0xFFDADADA, 0xFF00B66D, 0xFF6DDA00, 0xFF480000, 0xFF9191FF, 0xFF484848, 0xFFFF00FF, 0xFF00006D, 0xFF48FFDA, 0xFFDAB6FF, 0xFF6D4800, 0xFF000000, 0xFF6D48DA, 0xFF91006D, 0xFFFFDA91, 0xFFFF9100, 0xFFFFB6FF, 0xFF006DDA, 0xFF6D2400, 0xFFB6B6B6, 0xFF0000DA, 0xFFB600FF, 0xFFFFDA00, 0xFF6D6D6D, 0xFF244800, 0xFF0048FF, 0xFF000000, 0xFFDADA00, 0xFFFFFFFF, 0xFFDAB66D, 0xFF242424, 0xFF00FF00, 0xFFDA6D00, 0xFF004848, 0xFF002491, 0xFFFF0091, 0xFF249100, 0xFF000000, 0xFF00FFFF, 0xFF914800, 0xFFFFFF00, 0xFFFFB6B6, 0xFFB6006D, 0xFF006D24, 0xFF919191 },
|
||||
/* 2C04-0003 */ { 0xFFB600FF, 0xFFFF6DFF, 0xFF91FF6D, 0xFFB6B6B6, 0xFF009100, 0xFFFFFFFF, 0xFFB6DAFF, 0xFF244800, 0xFF002491, 0xFF000000, 0xFFFFDA91, 0xFF6D4800, 0xFFFF0091, 0xFFDADADA, 0xFFDAB66D, 0xFF91DAFF, 0xFF9191FF, 0xFF009191, 0xFFB6006D, 0xFF0048FF, 0xFF249100, 0xFF916D00, 0xFFDA6D00, 0xFF00B66D, 0xFF6D6D6D, 0xFF6D48DA, 0xFF000000, 0xFF0000DA, 0xFFFF0000, 0xFFB62400, 0xFFFF91FF, 0xFFFFB6B6, 0xFFDA6DFF, 0xFF004800, 0xFF00006D, 0xFFFFFF00, 0xFF242424, 0xFFFFB600, 0xFFFF9100, 0xFFFFFFFF, 0xFF6DDA00, 0xFF91006D, 0xFF6DB6FF, 0xFFFF00FF, 0xFF006DDA, 0xFF919191, 0xFF000000, 0xFF6D2400, 0xFF00FFFF, 0xFF480000, 0xFFB6FF48, 0xFFFFB6FF, 0xFF914800, 0xFF00FF00, 0xFFDADA00, 0xFF484848, 0xFF006D24, 0xFF000000, 0xFFDAB6FF, 0xFFFFFF6D, 0xFF9100FF, 0xFF48FFDA, 0xFFFFDA00, 0xFF004848 },
|
||||
/* 2C04-0004 */ { 0xFF916D00, 0xFF6D48DA, 0xFF009191, 0xFFDADA00, 0xFF000000, 0xFFFFB6B6, 0xFF002491, 0xFFDA6D00, 0xFFB6B6B6, 0xFF6D2400, 0xFF00FF00, 0xFF00006D, 0xFFFFDA91, 0xFFFFFF00, 0xFF009100, 0xFFB6FF48, 0xFFFF6DFF, 0xFF480000, 0xFF0048FF, 0xFFFF91FF, 0xFF000000, 0xFF484848, 0xFFB62400, 0xFFFF9100, 0xFFDAB66D, 0xFF00B66D, 0xFF9191FF, 0xFF249100, 0xFF91006D, 0xFF000000, 0xFF91FF6D, 0xFF6DB6FF, 0xFFB6006D, 0xFF006D24, 0xFF914800, 0xFF0000DA, 0xFF9100FF, 0xFFB600FF, 0xFF6D6D6D, 0xFFFF0091, 0xFF004848, 0xFFDADADA, 0xFF006DDA, 0xFF004800, 0xFF242424, 0xFFFFFF6D, 0xFF919191, 0xFFFF00FF, 0xFFFFB6FF, 0xFFFFFFFF, 0xFF6D4800, 0xFFFF0000, 0xFFFFDA00, 0xFF48FFDA, 0xFFFFFFFF, 0xFF91DAFF, 0xFF000000, 0xFFFFB600, 0xFFDA6DFF, 0xFFB6DAFF, 0xFF6DDA00, 0xFFDAB6FF, 0xFF00FFFF, 0xFF244800 },
|
||||
/* 2C05-01 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 },
|
||||
/* 2C05-02 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 },
|
||||
/* 2C05-03 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 },
|
||||
/* 2C05-04 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 },
|
||||
/* 2C05-05 */ { 0xFF6D6D6D, 0xFF002491, 0xFF0000DA, 0xFF6D48DA, 0xFF91006D, 0xFFB6006D, 0xFFB62400, 0xFF914800, 0xFF6D4800, 0xFF244800, 0xFF006D24, 0xFF009100, 0xFF004848, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFB6B6B6, 0xFF006DDA, 0xFF0048FF, 0xFF9100FF, 0xFFB600FF, 0xFFFF0091, 0xFFFF0000, 0xFFDA6D00, 0xFF916D00, 0xFF249100, 0xFF009100, 0xFF00B66D, 0xFF009191, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFF6DB6FF, 0xFF9191FF, 0xFFDA6DFF, 0xFFFF00FF, 0xFFFF6DFF, 0xFFFF9100, 0xFFFFB600, 0xFFDADA00, 0xFF6DDA00, 0xFF00FF00, 0xFF48FFDA, 0xFF00FFFF, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFFFF, 0xFFB6DAFF, 0xFFDAB6FF, 0xFFFFB6FF, 0xFFFF91FF, 0xFFFFB6B6, 0xFFFFDA91, 0xFFFFFF48, 0xFFFFFF6D, 0xFFB6FF48, 0xFF91FF6D, 0xFF48FFDA, 0xFF91DAFF, 0xFF000000, 0xFF000000, 0xFF000000 }
|
||||
};
|
||||
|
||||
uint8_t EmulationSettings::_paletteLut[11][64] = {
|
||||
/* 2C02 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63 },
|
||||
/* 2C03 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
/* 2C04-0001 */ { 53,35,22,34,28,9,29,21,32,0,39,5,4,40,8,32,33,62,31,41,60,50,54,18,63,43,46,30,61,45,36,1,14,49,51,42,44,12,27,20,46,7,52,6,19,2,38,46,46,25,16,10,57,3,55,23,15,17,11,13,56,37,24,58 },
|
||||
/* 2C04-0002 */ { 46,39,24,57,58,37,28,49,22,19,56,52,32,35,60,11,15,33,6,61,27,41,30,34,29,36,14,43,50,8,46,3,4,54,38,51,17,31,16,2,20,63,0,9,18,46,40,32,62,13,42,23,12,1,21,25,46,44,7,55,53,5,10,45 },
|
||||
/* 2C04-0003 */ { 20,37,58,16,11,32,49,9,1,46,54,8,21,61,62,60,34,28,5,18,25,24,23,27,0,3,46,2,22,6,52,53,35,15,14,55,13,39,38,32,41,4,33,36,17,45,46,31,44,30,57,51,7,42,40,29,10,46,50,56,19,43,63,12 },
|
||||
/* 2C04-0004 */ { 24,3,28,40,46,53,1,23,16,31,42,14,54,55,11,57,37,30,18,52,46,29,6,38,62,27,34,25,4,46,58,33,5,10,7,2,19,20,0,21,12,61,17,15,13,56,45,36,51,32,8,22,63,43,32,60,46,39,35,49,41,50,44,9 },
|
||||
/* 2C05-01 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
/* 2C05-02 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
/* 2C05-03 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
/* 2C05-04 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
/* 2C05-05 */ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,15,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,15,62,63 },
|
||||
};
|
||||
Language EmulationSettings::_displayLanguage = Language::English;
|
||||
|
||||
uint32_t EmulationSettings::GetEmulationSpeed(bool ignoreTurbo)
|
||||
{
|
||||
|
@ -162,6 +54,120 @@ double EmulationSettings::GetAspectRatio(shared_ptr<Console> console)
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
void EmulationSettings::InitializeInputDevices(GameInputType inputType, GameSystem system, bool silent)
|
||||
{
|
||||
ControllerType controllers[4] = { ControllerType::StandardController, ControllerType::StandardController, ControllerType::None, ControllerType::None };
|
||||
ExpansionPortDevice expDevice = ExpansionPortDevice::None;
|
||||
ClearFlags(EmulationFlags::HasFourScore);
|
||||
|
||||
auto log = [silent](string text) {
|
||||
if(!silent) {
|
||||
MessageManager::Log(text);
|
||||
}
|
||||
};
|
||||
|
||||
bool isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy);
|
||||
|
||||
if(inputType == GameInputType::VsZapper) {
|
||||
//VS Duck Hunt, etc. need the zapper in the first port
|
||||
log("[Input] VS Zapper connected");
|
||||
controllers[0] = ControllerType::Zapper;
|
||||
} else if(inputType == GameInputType::Zapper) {
|
||||
log("[Input] Zapper connected");
|
||||
if(isFamicom) {
|
||||
expDevice = ExpansionPortDevice::Zapper;
|
||||
} else {
|
||||
controllers[1] = ControllerType::Zapper;
|
||||
}
|
||||
} else if(inputType == GameInputType::FourScore) {
|
||||
log("[Input] Four score connected");
|
||||
SetFlags(EmulationFlags::HasFourScore);
|
||||
controllers[2] = controllers[3] = ControllerType::StandardController;
|
||||
} else if(inputType == GameInputType::FourPlayerAdapter) {
|
||||
log("[Input] Four player adapter connected");
|
||||
SetFlags(EmulationFlags::HasFourScore);
|
||||
expDevice = ExpansionPortDevice::FourPlayerAdapter;
|
||||
controllers[2] = controllers[3] = ControllerType::StandardController;
|
||||
} else if(inputType == GameInputType::ArkanoidControllerFamicom) {
|
||||
log("[Input] Arkanoid controller (Famicom) connected");
|
||||
expDevice = ExpansionPortDevice::ArkanoidController;
|
||||
} else if(inputType == GameInputType::ArkanoidControllerNes) {
|
||||
log("[Input] Arkanoid controller (NES) connected");
|
||||
controllers[1] = ControllerType::ArkanoidController;
|
||||
} else if(inputType == GameInputType::OekaKidsTablet) {
|
||||
log("[Input] Oeka Kids Tablet connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::OekaKidsTablet;
|
||||
} else if(inputType == GameInputType::KonamiHyperShot) {
|
||||
log("[Input] Konami Hyper Shot connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::KonamiHyperShot;
|
||||
} else if(inputType == GameInputType::FamilyBasicKeyboard) {
|
||||
log("[Input] Family Basic Keyboard connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::FamilyBasicKeyboard;
|
||||
} else if(inputType == GameInputType::PartyTap) {
|
||||
log("[Input] Party Tap connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::PartyTap;
|
||||
} else if(inputType == GameInputType::PachinkoController) {
|
||||
log("[Input] Pachinko controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::Pachinko;
|
||||
} else if(inputType == GameInputType::ExcitingBoxing) {
|
||||
log("[Input] Exciting Boxing controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::ExcitingBoxing;
|
||||
} else if(inputType == GameInputType::SuborKeyboardMouse1) {
|
||||
log("[Input] Subor mouse connected");
|
||||
log("[Input] Subor keyboard connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::SuborKeyboard;
|
||||
controllers[1] = ControllerType::SuborMouse;
|
||||
} else if(inputType == GameInputType::JissenMahjong) {
|
||||
log("[Input] Jissen Mahjong controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::JissenMahjong;
|
||||
} else if(inputType == GameInputType::BarcodeBattler) {
|
||||
log("[Input] Barcode Battler barcode reader connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BarcodeBattler;
|
||||
} else if(inputType == GameInputType::BandaiHypershot) {
|
||||
log("[Input] Bandai Hyper Shot gun connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BandaiHyperShot;
|
||||
} else if(inputType == GameInputType::BattleBox) {
|
||||
log("[Input] Battle Box connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BattleBox;
|
||||
} else if(inputType == GameInputType::TurboFile) {
|
||||
log("[Input] Ascii Turbo File connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::AsciiTurboFile;
|
||||
} else if(inputType == GameInputType::FamilyTrainerSideA || inputType == GameInputType::FamilyTrainerSideB) {
|
||||
log("[Input] Family Trainer mat connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::FamilyTrainerMat;
|
||||
} else if(inputType == GameInputType::PowerPadSideA || inputType == GameInputType::PowerPadSideB) {
|
||||
log("[Input] Power Pad connected");
|
||||
system = GameSystem::NesNtsc;
|
||||
controllers[1] = ControllerType::PowerPad;
|
||||
} else if(inputType == GameInputType::SnesControllers) {
|
||||
log("[Input] 2 SNES controllers connected");
|
||||
controllers[0] = ControllerType::SnesController;
|
||||
controllers[1] = ControllerType::SnesController;
|
||||
} else {
|
||||
log("[Input] 2 standard controllers connected");
|
||||
}
|
||||
|
||||
isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy);
|
||||
SetConsoleType(isFamicom ? ConsoleType::Famicom : ConsoleType::Nes);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
SetControllerType(i, controllers[i]);
|
||||
}
|
||||
SetExpansionDevice(expDevice);
|
||||
}
|
||||
|
||||
const vector<string> NesModelNames = {
|
||||
"Auto",
|
||||
"NTSC",
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,7 +30,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
ExcitingBoxingController(KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
ExcitingBoxingController(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
20
Core/FDS.cpp
20
Core/FDS.cpp
|
@ -10,6 +10,8 @@
|
|||
|
||||
void FDS::InitMapper()
|
||||
{
|
||||
_settings = _console->GetSettings();
|
||||
|
||||
//FDS BIOS
|
||||
SetCpuMemoryMapping(0xE000, 0xFFFF, 0, PrgMemoryType::PrgRom, MemoryAccessType::Read);
|
||||
|
||||
|
@ -171,7 +173,7 @@ uint8_t FDS::ReadRAM(uint16_t addr)
|
|||
void FDS::ProcessAutoDiskInsert()
|
||||
{
|
||||
if(IsAutoInsertDiskEnabled()) {
|
||||
bool fastForwardEnabled = EmulationSettings::CheckFlag(EmulationFlags::FdsFastForwardOnLoad);
|
||||
bool fastForwardEnabled = _settings->CheckFlag(EmulationFlags::FdsFastForwardOnLoad);
|
||||
uint32_t currentFrame = _console->GetPpu()->GetFrameCount();
|
||||
if(_previousFrame != currentFrame) {
|
||||
_previousFrame = currentFrame;
|
||||
|
@ -179,11 +181,11 @@ void FDS::ProcessAutoDiskInsert()
|
|||
//After reading a disk, wait until this counter reaches 0 before
|
||||
//automatically ejecting the disk the next time $4032 is read
|
||||
_autoDiskEjectCounter--;
|
||||
EmulationSettings::SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _autoDiskEjectCounter != 0);
|
||||
_settings->SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _autoDiskEjectCounter != 0);
|
||||
} else if(_autoDiskSwitchCounter > 0) {
|
||||
//After ejecting the disk, wait a bit before we insert a new one
|
||||
_autoDiskSwitchCounter--;
|
||||
EmulationSettings::SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _autoDiskSwitchCounter != 0);
|
||||
_settings->SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _autoDiskSwitchCounter != 0);
|
||||
if(_autoDiskSwitchCounter == 0) {
|
||||
//Insert a disk (real disk/side will be selected when game executes $E445
|
||||
MessageManager::Log("[FDS] Auto-inserted dummy disk.");
|
||||
|
@ -195,7 +197,7 @@ void FDS::ProcessAutoDiskInsert()
|
|||
} else if(_restartAutoInsertCounter > 0) {
|
||||
//After ejecting the disk, wait a bit before we insert a new one
|
||||
_restartAutoInsertCounter--;
|
||||
EmulationSettings::SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _restartAutoInsertCounter != 0);
|
||||
_settings->SetFlagState(EmulationFlags::ForceMaxSpeed, fastForwardEnabled && _restartAutoInsertCounter != 0);
|
||||
if(_restartAutoInsertCounter == 0) {
|
||||
//Wait a bit before ejecting the disk (eject in ~34 frames)
|
||||
MessageManager::Log("[FDS] Game failed to load disk, try again.");
|
||||
|
@ -210,10 +212,10 @@ void FDS::ProcessAutoDiskInsert()
|
|||
|
||||
void FDS::ProcessCpuClock()
|
||||
{
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::FdsFastForwardOnLoad)) {
|
||||
EmulationSettings::SetFlagState(EmulationFlags::ForceMaxSpeed, _scanningDisk || !_gameStarted);
|
||||
if(_settings->CheckFlag(EmulationFlags::FdsFastForwardOnLoad)) {
|
||||
_settings->SetFlagState(EmulationFlags::ForceMaxSpeed, _scanningDisk || !_gameStarted);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
|
||||
ProcessAutoDiskInsert();
|
||||
|
@ -506,7 +508,7 @@ void FDS::StreamState(bool saving)
|
|||
FDS::~FDS()
|
||||
{
|
||||
//Restore emulation speed to normal when closing
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
|
||||
ConsoleFeatures FDS::GetAvailableFeatures()
|
||||
|
@ -543,5 +545,5 @@ bool FDS::IsDiskInserted()
|
|||
|
||||
bool FDS::IsAutoInsertDiskEnabled()
|
||||
{
|
||||
return !_disableAutoInsertDisk && EmulationSettings::CheckFlag(EmulationFlags::FdsAutoInsertDisk) && !MovieManager::Playing() && !MovieManager::Recording();
|
||||
return !_disableAutoInsertDisk && _settings->CheckFlag(EmulationFlags::FdsAutoInsertDisk) && !MovieManager::Playing() && !MovieManager::Recording();
|
||||
}
|
|
@ -16,6 +16,7 @@ private:
|
|||
bool _disableAutoInsertDisk;
|
||||
|
||||
unique_ptr<FdsAudio> _audio;
|
||||
EmulationSettings* _settings = nullptr;
|
||||
|
||||
//Write registers
|
||||
uint16_t _irqReloadValue = 0;
|
||||
|
|
|
@ -9,7 +9,6 @@ class FamilyBasicDataRecorder : public BaseControlDevice
|
|||
{
|
||||
private:
|
||||
static constexpr int32_t SamplingRate = 88;
|
||||
shared_ptr<Console> _console;
|
||||
vector<uint8_t> _data;
|
||||
vector<uint8_t> _fileData;
|
||||
bool _enabled = false;
|
||||
|
@ -46,9 +45,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
FamilyBasicDataRecorder(shared_ptr<Console> console) : BaseControlDevice(BaseControlDevice::ExpDevicePort2)
|
||||
FamilyBasicDataRecorder(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort2)
|
||||
{
|
||||
_console = console;
|
||||
}
|
||||
|
||||
~FamilyBasicDataRecorder()
|
||||
|
|
|
@ -83,7 +83,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
FamilyBasicKeyboard(KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
FamilyBasicKeyboard(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
FamilyMatTrainer(KeyMappingSet keyMappings) : PowerPad(BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
FamilyMatTrainer(shared_ptr<Console> console, KeyMappingSet keyMappings) : PowerPad(console, BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ bool FceuxMovie::InitializeData(stringstream &filestream)
|
|||
vector<uint8_t> md5array = Base64::Decode(line.substr(19, line.size() - 20));
|
||||
HashInfo hashInfo;
|
||||
hashInfo.PrgChrMd5 = HexUtilities::ToHex(md5array);
|
||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros);
|
||||
_console->GetSettings()->SetRamPowerOnState(RamPowerOnState::AllZeros);
|
||||
if(_console->LoadMatchingRom("", hashInfo)) {
|
||||
result = true;
|
||||
} else {
|
||||
|
|
|
@ -151,10 +151,5 @@ RomData FdsLoader::LoadRom(vector<uint8_t>& romFile, string filename)
|
|||
romData.BiosMissing = true;
|
||||
}
|
||||
|
||||
//Setup default controllers
|
||||
if(!_checkOnly && EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput)) {
|
||||
GameDatabase::InitializeInputDevices(GameInputType::FamicomControllers, GameSystem::FDS);
|
||||
}
|
||||
|
||||
return romData;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
_mapper = std::dynamic_pointer_cast<FDS>(mapper);
|
||||
_sideCount = std::dynamic_pointer_cast<FDS>(mapper)->GetSideCount();
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::FdsAutoLoadDisk)) {
|
||||
if(console->GetSettings()->CheckFlag(EmulationFlags::FdsAutoLoadDisk)) {
|
||||
InsertDisk(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
FourScore() : BaseControlDevice(BaseControlDevice::ExpDevicePort)
|
||||
FourScore(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void GameClientConnection::Shutdown()
|
|||
_console->GetControlManager()->UnregisterInputProvider(this);
|
||||
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::DisconnectedFromServer);
|
||||
MessageManager::DisplayMessage("NetPlay", "ConnectionLost");
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,9 +122,9 @@ void GameClientConnection::ProcessMessage(NetMessage* message)
|
|||
|
||||
_gameLoaded = AttemptLoadGame(gameInfo->GetRomFilename(), gameInfo->GetCrc32Hash());
|
||||
if(gameInfo->IsPaused()) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::Paused);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::Paused);
|
||||
}
|
||||
_console->Resume();
|
||||
break;
|
||||
|
@ -193,10 +193,10 @@ bool GameClientConnection::SetInput(BaseControlDevice *device)
|
|||
|
||||
if(_inputData[port].size() > _minimumQueueSize) {
|
||||
//Too much data, catch up
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_console->GetSettings()->SetEmulationSpeed(100);
|
||||
}
|
||||
|
||||
device->SetRawState(state);
|
||||
|
@ -207,10 +207,10 @@ bool GameClientConnection::SetInput(BaseControlDevice *device)
|
|||
void GameClientConnection::InitControlDevice()
|
||||
{
|
||||
if(_controllerPort == BaseControlDevice::ExpDevicePort) {
|
||||
_newControlDevice = ControlManager::CreateExpansionDevice(EmulationSettings::GetExpansionDevice(), _console);
|
||||
_newControlDevice = ControlManager::CreateExpansionDevice(_console->GetSettings()->GetExpansionDevice(), _console);
|
||||
} else {
|
||||
//Pretend we are using port 0 (to use player 1's keybindings during netplay)
|
||||
_newControlDevice = ControlManager::CreateControllerDevice(EmulationSettings::GetControllerType(_controllerPort), 0, _console);
|
||||
_newControlDevice = ControlManager::CreateControllerDevice(_console->GetSettings()->GetControllerType(_controllerPort), 0, _console);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "UnifLoader.h"
|
||||
|
||||
std::unordered_map<uint32_t, GameInfo> GameDatabase::_gameDatabase;
|
||||
bool GameDatabase::_enabled = true;
|
||||
|
||||
template<typename T>
|
||||
T GameDatabase::ToInt(string value)
|
||||
|
@ -217,130 +218,14 @@ GameInputType GameDatabase::GetInputType(GameSystem system, string inputType)
|
|||
}
|
||||
}
|
||||
|
||||
void GameDatabase::InitializeInputDevices(RomInfo &romInfo)
|
||||
void GameDatabase::SetGameDatabaseState(bool enabled)
|
||||
{
|
||||
InitDatabase();
|
||||
|
||||
auto result = _gameDatabase.find(romInfo.Hash.PrgChrCrc32);
|
||||
if(romInfo.IsNes20Header || result != _gameDatabase.end()) {
|
||||
InitializeInputDevices(romInfo.InputType, romInfo.System, true);
|
||||
} else {
|
||||
InitializeInputDevices(GameInputType::Default, GameSystem::NesNtsc, true);
|
||||
}
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
void GameDatabase::InitializeInputDevices(GameInputType inputType, GameSystem system, bool silent)
|
||||
bool GameDatabase::IsEnabled()
|
||||
{
|
||||
ControllerType controllers[4] = { ControllerType::StandardController, ControllerType::StandardController, ControllerType::None, ControllerType::None };
|
||||
ExpansionPortDevice expDevice = ExpansionPortDevice::None;
|
||||
EmulationSettings::ClearFlags(EmulationFlags::HasFourScore);
|
||||
|
||||
auto log = [silent](string text) {
|
||||
if(!silent) {
|
||||
MessageManager::Log(text);
|
||||
}
|
||||
};
|
||||
|
||||
bool isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy);
|
||||
|
||||
if(inputType == GameInputType::VsZapper) {
|
||||
//VS Duck Hunt, etc. need the zapper in the first port
|
||||
log("[Input] VS Zapper connected");
|
||||
controllers[0] = ControllerType::Zapper;
|
||||
} else if(inputType == GameInputType::Zapper) {
|
||||
log("[Input] Zapper connected");
|
||||
if(isFamicom) {
|
||||
expDevice = ExpansionPortDevice::Zapper;
|
||||
} else {
|
||||
controllers[1] = ControllerType::Zapper;
|
||||
}
|
||||
} else if(inputType == GameInputType::FourScore) {
|
||||
log("[Input] Four score connected");
|
||||
EmulationSettings::SetFlags(EmulationFlags::HasFourScore);
|
||||
controllers[2] = controllers[3] = ControllerType::StandardController;
|
||||
} else if(inputType == GameInputType::FourPlayerAdapter) {
|
||||
log("[Input] Four player adapter connected");
|
||||
EmulationSettings::SetFlags(EmulationFlags::HasFourScore);
|
||||
expDevice = ExpansionPortDevice::FourPlayerAdapter;
|
||||
controllers[2] = controllers[3] = ControllerType::StandardController;
|
||||
} else if(inputType == GameInputType::ArkanoidControllerFamicom) {
|
||||
log("[Input] Arkanoid controller (Famicom) connected");
|
||||
expDevice = ExpansionPortDevice::ArkanoidController;
|
||||
} else if(inputType == GameInputType::ArkanoidControllerNes) {
|
||||
log("[Input] Arkanoid controller (NES) connected");
|
||||
controllers[1] = ControllerType::ArkanoidController;
|
||||
} else if(inputType == GameInputType::OekaKidsTablet) {
|
||||
log("[Input] Oeka Kids Tablet connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::OekaKidsTablet;
|
||||
} else if(inputType == GameInputType::KonamiHyperShot) {
|
||||
log("[Input] Konami Hyper Shot connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::KonamiHyperShot;
|
||||
} else if(inputType == GameInputType::FamilyBasicKeyboard) {
|
||||
log("[Input] Family Basic Keyboard connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::FamilyBasicKeyboard;
|
||||
} else if(inputType == GameInputType::PartyTap) {
|
||||
log("[Input] Party Tap connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::PartyTap;
|
||||
} else if(inputType == GameInputType::PachinkoController) {
|
||||
log("[Input] Pachinko controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::Pachinko;
|
||||
} else if(inputType == GameInputType::ExcitingBoxing) {
|
||||
log("[Input] Exciting Boxing controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::ExcitingBoxing;
|
||||
} else if(inputType == GameInputType::SuborKeyboardMouse1) {
|
||||
log("[Input] Subor mouse connected");
|
||||
log("[Input] Subor keyboard connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::SuborKeyboard;
|
||||
controllers[1] = ControllerType::SuborMouse;
|
||||
} else if(inputType == GameInputType::JissenMahjong) {
|
||||
log("[Input] Jissen Mahjong controller connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::JissenMahjong;
|
||||
} else if(inputType == GameInputType::BarcodeBattler) {
|
||||
log("[Input] Barcode Battler barcode reader connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BarcodeBattler;
|
||||
} else if(inputType == GameInputType::BandaiHypershot) {
|
||||
log("[Input] Bandai Hyper Shot gun connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BandaiHyperShot;
|
||||
} else if(inputType == GameInputType::BattleBox) {
|
||||
log("[Input] Battle Box connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::BattleBox;
|
||||
} else if(inputType == GameInputType::TurboFile) {
|
||||
log("[Input] Ascii Turbo File connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::AsciiTurboFile;
|
||||
} else if(inputType == GameInputType::FamilyTrainerSideA || inputType == GameInputType::FamilyTrainerSideB) {
|
||||
log("[Input] Family Trainer mat connected");
|
||||
system = GameSystem::Famicom;
|
||||
expDevice = ExpansionPortDevice::FamilyTrainerMat;
|
||||
} else if(inputType == GameInputType::PowerPadSideA || inputType == GameInputType::PowerPadSideB) {
|
||||
log("[Input] Power Pad connected");
|
||||
system = GameSystem::NesNtsc;
|
||||
controllers[1] = ControllerType::PowerPad;
|
||||
} else if(inputType == GameInputType::SnesControllers) {
|
||||
log("[Input] 2 SNES controllers connected");
|
||||
controllers[0] = ControllerType::SnesController;
|
||||
controllers[1] = ControllerType::SnesController;
|
||||
} else {
|
||||
log("[Input] 2 standard controllers connected");
|
||||
}
|
||||
|
||||
isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy);
|
||||
EmulationSettings::SetConsoleType(isFamicom ? ConsoleType::Famicom : ConsoleType::Nes);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
EmulationSettings::SetControllerType(i, controllers[i]);
|
||||
}
|
||||
EmulationSettings::SetExpansionDevice(expDevice);
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
uint8_t GameDatabase::GetSubMapper(GameInfo &info)
|
||||
|
@ -591,6 +476,7 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom
|
|||
|
||||
if(updateRomData) {
|
||||
MessageManager::Log("[DB] Database info will be used instead of file header.");
|
||||
romData.Info.IsInDatabase = true;
|
||||
UpdateRomData(info, romData);
|
||||
}
|
||||
|
||||
|
@ -601,13 +487,6 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom
|
|||
MessageManager::Log("[DB] Game not found in database");
|
||||
}
|
||||
|
||||
if(foundInDatabase || romData.Info.IsNes20Header) {
|
||||
//If in DB or a NES 2.0 file, auto-configure the inputs
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput)) {
|
||||
InitializeInputDevices(romData.Info.InputType, romData.Info.System);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LIBRETRO
|
||||
SetVsSystemDefaults(romData.Info.Hash.PrgCrc32);
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@ class GameDatabase
|
|||
{
|
||||
private:
|
||||
static std::unordered_map<uint32_t, GameInfo> _gameDatabase;
|
||||
static bool _enabled;
|
||||
|
||||
template<typename T> static T ToInt(string value);
|
||||
|
||||
|
@ -24,8 +25,9 @@ private:
|
|||
public:
|
||||
static void LoadGameDb(vector<string> data);
|
||||
|
||||
static void InitializeInputDevices(GameInputType inputType, GameSystem system, bool silent = false);
|
||||
static void InitializeInputDevices(RomInfo &romInfo);
|
||||
static void SetGameDatabaseState(bool enabled);
|
||||
static bool IsEnabled();
|
||||
|
||||
static void SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRomData, bool forHeaderlessRom);
|
||||
static bool GetiNesHeader(uint32_t romCrc, NESHeader &nesHeader);
|
||||
static bool GetDbRomSize(uint32_t romCrc, uint32_t &prgSize, uint32_t &chrSize);
|
||||
|
|
|
@ -59,7 +59,7 @@ void GameServerConnection::SendGameInformation()
|
|||
{
|
||||
_console->Pause();
|
||||
RomInfo romInfo = _console->GetRomInfo();
|
||||
GameInformationMessage gameInfo(romInfo.RomName, romInfo.Hash.Crc32, _controllerPort, EmulationSettings::CheckFlag(EmulationFlags::Paused));
|
||||
GameInformationMessage gameInfo(romInfo.RomName, romInfo.Hash.Crc32, _controllerPort, _console->GetSettings()->CheckFlag(EmulationFlags::Paused));
|
||||
SendNetMessage(gameInfo);
|
||||
SaveStateMessage saveState(_console);
|
||||
SendNetMessage(saveState);
|
||||
|
|
|
@ -207,10 +207,9 @@ struct HdPackTileInfo : public HdTileKey
|
|||
return true;
|
||||
}
|
||||
|
||||
vector<uint32_t> ToRgb()
|
||||
vector<uint32_t> ToRgb(uint32_t* palette)
|
||||
{
|
||||
vector<uint32_t> rgbBuffer;
|
||||
uint32_t* palette = EmulationSettings::GetRgbPalette();
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
uint8_t lowByte = TileData[i];
|
||||
uint8_t highByte = TileData[i + 8];
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
#include "../Utilities/FolderUtilities.h"
|
||||
#include "../Utilities/PNGHelper.h"
|
||||
|
||||
HdNesPack::HdNesPack(shared_ptr<HdPackData> hdData)
|
||||
HdNesPack::HdNesPack(shared_ptr<HdPackData> hdData, EmulationSettings* settings)
|
||||
{
|
||||
_hdData = hdData;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
HdNesPack::~HdNesPack()
|
||||
|
@ -162,12 +163,12 @@ void HdNesPack::OnLineStart(HdPpuPixelInfo &lineFirstPixel)
|
|||
|
||||
void HdNesPack::OnBeforeApplyFilter()
|
||||
{
|
||||
_palette = _hdData->Palette.size() == 0x40 ? _hdData->Palette.data() : EmulationSettings::GetRgbPalette();
|
||||
_palette = _hdData->Palette.size() == 0x40 ? _hdData->Palette.data() : _settings->GetRgbPalette();
|
||||
_contoursEnabled = (_hdData->OptionFlags & (int)HdPackOptions::NoContours) == 0;
|
||||
_cacheEnabled = (_hdData->OptionFlags & (int)HdPackOptions::DisableCache) == 0;
|
||||
|
||||
if(_hdData->OptionFlags & (int)HdPackOptions::NoSpriteLimit) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::RemoveSpriteLimit | EmulationFlags::AdaptiveSpriteLimit);
|
||||
_settings->SetFlags(EmulationFlags::RemoveSpriteLimit | EmulationFlags::AdaptiveSpriteLimit);
|
||||
}
|
||||
|
||||
_backgroundIndex = -1;
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
#include "stdafx.h"
|
||||
#include "HdData.h"
|
||||
|
||||
class EmulationSettings;
|
||||
|
||||
class HdNesPack
|
||||
{
|
||||
private:
|
||||
shared_ptr<HdPackData> _hdData;
|
||||
EmulationSettings *_settings;
|
||||
|
||||
int32_t _backgroundIndex = -1;
|
||||
HdScreenInfo *_hdScreenInfo = nullptr;
|
||||
|
@ -37,7 +40,7 @@ private:
|
|||
public:
|
||||
static constexpr uint32_t CurrentVersion = 102;
|
||||
|
||||
HdNesPack(shared_ptr<HdPackData> hdData);
|
||||
HdNesPack(shared_ptr<HdPackData> hdData, EmulationSettings* settings);
|
||||
~HdNesPack();
|
||||
|
||||
uint32_t GetScale();
|
||||
|
|
|
@ -86,7 +86,7 @@ void HdPackBuilder::AddTile(HdPackTileInfo *tile, uint32_t usageCount)
|
|||
void HdPackBuilder::ProcessTile(uint32_t x, uint32_t y, uint16_t tileAddr, HdPpuTileInfo &tile, BaseMapper *mapper, bool isSprite, uint32_t chrBankHash, bool transparencyRequired)
|
||||
{
|
||||
if(_flags & HdPackRecordFlags::IgnoreOverscan) {
|
||||
OverscanDimensions overscan = EmulationSettings::GetOverscanDimensions();
|
||||
OverscanDimensions overscan = _console->GetSettings()->GetOverscanDimensions();
|
||||
if(x < overscan.Left || y < overscan.Top || (PPU::ScreenWidth - x - 1) < overscan.Right || (PPU::ScreenHeight - y - 1) < overscan.Bottom) {
|
||||
//Ignore tiles inside overscan
|
||||
return;
|
||||
|
@ -133,7 +133,7 @@ void HdPackBuilder::GenerateHdTile(HdPackTileInfo *tile)
|
|||
{
|
||||
uint32_t hdScale = _hdData.Scale;
|
||||
|
||||
vector<uint32_t> originalTile = tile->ToRgb();
|
||||
vector<uint32_t> originalTile = tile->ToRgb(_console->GetSettings()->GetRgbPalette());
|
||||
vector<uint32_t> hdTile(8 * 8 * hdScale*hdScale, 0);
|
||||
|
||||
switch(_filterType) {
|
||||
|
@ -224,7 +224,7 @@ void HdPackBuilder::SaveHdPack()
|
|||
ss << "<scale>" << _hdData.Scale << std::endl;
|
||||
ss << "<supportedRom>" << _console->GetRomInfo().Hash.Sha1 << std::endl;
|
||||
if(_flags & HdPackRecordFlags::IgnoreOverscan) {
|
||||
OverscanDimensions overscan = EmulationSettings::GetOverscanDimensions();
|
||||
OverscanDimensions overscan = _console->GetSettings()->GetOverscanDimensions();
|
||||
ss << "<overscan>" << overscan.Top << "," << overscan.Right << "," << overscan.Bottom << "," << overscan.Left << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include "HdVideoFilter.h"
|
||||
#include "Console.h"
|
||||
|
||||
HdVideoFilter::HdVideoFilter(shared_ptr<HdPackData> hdData)
|
||||
HdVideoFilter::HdVideoFilter(shared_ptr<Console> console, shared_ptr<HdPackData> hdData) : BaseVideoFilter(console)
|
||||
{
|
||||
_hdData = hdData;
|
||||
_hdNesPack.reset(new HdNesPack(hdData));
|
||||
_hdNesPack.reset(new HdNesPack(hdData, console->GetSettings()));
|
||||
}
|
||||
|
||||
FrameInfo HdVideoFilter::GetFrameInfo()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "BaseVideoFilter.h"
|
||||
|
||||
class HdNesPack;
|
||||
class Console;
|
||||
struct HdScreenInfo;
|
||||
struct HdPackData;
|
||||
|
||||
|
@ -15,7 +16,7 @@ private:
|
|||
unique_ptr<HdNesPack> _hdNesPack = nullptr;
|
||||
|
||||
public:
|
||||
HdVideoFilter(shared_ptr<HdPackData> hdData);
|
||||
HdVideoFilter(shared_ptr<Console> console, shared_ptr<HdPackData> hdData);
|
||||
|
||||
void ApplyFilter(uint16_t *ppuOutputBuffer) override;
|
||||
FrameInfo GetFrameInfo() override;
|
||||
|
|
|
@ -41,15 +41,18 @@ void HistoryViewer::SeekTo(uint32_t seekPosition)
|
|||
if(index < _history.size()) {
|
||||
_console->Pause();
|
||||
|
||||
bool wasPaused = _console->GetPauseStatus();
|
||||
_console->SetPauseStatus(false);
|
||||
bool wasPaused = _console->GetSettings()->CheckFlag(EmulationFlags::Paused);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::Paused);
|
||||
_position = index;
|
||||
RewindData rewindData = _history[_position];
|
||||
rewindData.LoadState(_console);
|
||||
|
||||
_console->GetSoundMixer()->StopAudio(true);
|
||||
_pollCounter = 0;
|
||||
_console->SetPauseStatus(wasPaused);
|
||||
|
||||
if(wasPaused) {
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::Paused);
|
||||
}
|
||||
|
||||
_console->Resume();
|
||||
}
|
||||
|
@ -77,7 +80,7 @@ void HistoryViewer::ProcessEndOfFrame()
|
|||
|
||||
if(_position >= _history.size()) {
|
||||
//Reached the end of history data
|
||||
_console->SetPauseStatus(true);
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::Paused);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ protected:
|
|||
StandardController::InternalSetStateFromInput();
|
||||
SetPressedState(StandardController::Buttons::A, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
SetPressedState(StandardController::Buttons::B, KeyManager::IsMouseButtonPressed(MouseButton::RightButton));
|
||||
SetMovement(KeyManager::GetMouseMovement(EmulationSettings::GetMouseSensitivity(MouseDevice::HoriTrack)));
|
||||
SetMovement(KeyManager::GetMouseMovement(_console->GetSettings()->GetMouseSensitivity(MouseDevice::HoriTrack)));
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
JissenMahjongController(KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
JissenMahjongController(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
#include "EmulationSettings.h"
|
||||
#include "PPU.h"
|
||||
|
||||
IKeyManager* KeyManager::_keyManager;
|
||||
MousePosition KeyManager::_mousePosition;
|
||||
atomic<int16_t> KeyManager::_xMouseMovement;
|
||||
atomic<int16_t> KeyManager::_yMouseMovement;
|
||||
IKeyManager* KeyManager::_keyManager = nullptr;
|
||||
MousePosition KeyManager::_mousePosition = { 0, 0 };
|
||||
atomic<int16_t> KeyManager::_xMouseMovement = 0;
|
||||
atomic<int16_t> KeyManager::_yMouseMovement = 0;
|
||||
EmulationSettings* KeyManager::_settings = nullptr;
|
||||
|
||||
void KeyManager::RegisterKeyManager(IKeyManager* keyManager)
|
||||
{
|
||||
|
@ -22,10 +23,15 @@ void KeyManager::RefreshKeyState()
|
|||
}
|
||||
}
|
||||
|
||||
void KeyManager::SetSettings(EmulationSettings* settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
bool KeyManager::IsKeyPressed(uint32_t keyCode)
|
||||
{
|
||||
if(_keyManager != nullptr) {
|
||||
return EmulationSettings::InputEnabled() && _keyManager->IsKeyPressed(keyCode);
|
||||
return _settings->InputEnabled() && _keyManager->IsKeyPressed(keyCode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +39,7 @@ bool KeyManager::IsKeyPressed(uint32_t keyCode)
|
|||
bool KeyManager::IsMouseButtonPressed(MouseButton button)
|
||||
{
|
||||
if(_keyManager != nullptr) {
|
||||
return EmulationSettings::InputEnabled() && _keyManager->IsMouseButtonPressed(button);
|
||||
return _settings->InputEnabled() && _keyManager->IsMouseButtonPressed(button);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -77,7 +83,7 @@ void KeyManager::SetMouseMovement(int16_t x, int16_t y)
|
|||
|
||||
MouseMovement KeyManager::GetMouseMovement(double mouseSensitivity)
|
||||
{
|
||||
double factor = EmulationSettings::GetVideoScale() / mouseSensitivity;
|
||||
double factor = _settings->GetVideoScale() / mouseSensitivity;
|
||||
MouseMovement mov;
|
||||
mov.dx = (int16_t)(_xMouseMovement / factor);
|
||||
mov.dy = (int16_t)(_yMouseMovement / factor);
|
||||
|
@ -93,7 +99,7 @@ void KeyManager::SetMousePosition(double x, double y)
|
|||
_mousePosition.X = -1;
|
||||
_mousePosition.Y = -1;
|
||||
} else {
|
||||
OverscanDimensions overscan = EmulationSettings::GetOverscanDimensions();
|
||||
OverscanDimensions overscan = _settings->GetOverscanDimensions();
|
||||
_mousePosition.X = (int32_t)(x * (PPU::ScreenWidth - overscan.Left - overscan.Right) + overscan.Left);
|
||||
_mousePosition.Y = (int32_t)(y * (PPU::ScreenHeight - overscan.Top - overscan.Bottom) + overscan.Top);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "Types.h"
|
||||
|
||||
class IKeyManager;
|
||||
class EmulationSettings;
|
||||
enum class MouseButton;
|
||||
|
||||
class KeyManager
|
||||
|
@ -12,9 +13,12 @@ private:
|
|||
static MousePosition _mousePosition;
|
||||
static atomic<int16_t> _xMouseMovement;
|
||||
static atomic<int16_t> _yMouseMovement;
|
||||
static EmulationSettings* _settings;
|
||||
|
||||
public:
|
||||
static void RegisterKeyManager(IKeyManager* keyManager);
|
||||
static void SetSettings(EmulationSettings* settings);
|
||||
|
||||
static void RefreshKeyState();
|
||||
static bool IsKeyPressed(uint32_t keyCode);
|
||||
static bool IsMouseButtonPressed(MouseButton button);
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
class KonamiHyperShot : public BaseControlDevice
|
||||
{
|
||||
private:
|
||||
shared_ptr<Console> _console;
|
||||
|
||||
bool _enableP1 = true;
|
||||
bool _enableP2 = true;
|
||||
uint32_t _p1TurboSpeed;
|
||||
|
@ -56,9 +54,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
KonamiHyperShot(shared_ptr<Console> console, KeyMappingSet p1, KeyMappingSet p2) : BaseControlDevice(BaseControlDevice::ExpDevicePort, p1)
|
||||
KonamiHyperShot(shared_ptr<Console> console, KeyMappingSet p1, KeyMappingSet p2) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort, p1)
|
||||
{
|
||||
_console = console;
|
||||
_p1TurboSpeed = p1.TurboSpeed;
|
||||
_p2TurboSpeed = p2.TurboSpeed;
|
||||
_p2KeyMappings = p2.GetKeyMappingArray();
|
||||
|
|
|
@ -399,7 +399,7 @@ int LuaApi::GetScreenBuffer(lua_State *lua)
|
|||
{
|
||||
LuaCallHelper l(lua);
|
||||
|
||||
uint32_t *palette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *palette = _console->GetSettings()->GetRgbPalette();
|
||||
lua_newtable(lua);
|
||||
for(int y = 0; y < PPU::ScreenHeight; y++) {
|
||||
for(int x = 0; x < PPU::ScreenWidth; x++) {
|
||||
|
@ -437,7 +437,7 @@ int LuaApi::GetPixel(lua_State *lua)
|
|||
errorCond(x < 0 || x > 255 || y < 0 || y > 239, "invalid x,y coordinates (must be between 0-255, 0-239)");
|
||||
|
||||
//Ignores intensify & grayscale bits
|
||||
l.Return(EmulationSettings::GetRgbPalette()[_debugger->GetScreenPixel(x, y) & 0x3F] & 0xFFFFFF);
|
||||
l.Return(_console->GetSettings()->GetRgbPalette()[_debugger->GetScreenPixel(x, y) & 0x3F] & 0xFFFFFF);
|
||||
return l.ReturnCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ class MMC3 : public BaseMapper
|
|||
}
|
||||
|
||||
//SubMapper 2 = MC-ACC (Acclaim MMC3 clone)
|
||||
if(!IsMcAcc() && (ForceMmc3RevAIrqs() || EmulationSettings::CheckFlag(EmulationFlags::Mmc3IrqAltBehavior))) {
|
||||
if(!IsMcAcc() && (ForceMmc3RevAIrqs() || _console->GetSettings()->CheckFlag(EmulationFlags::Mmc3IrqAltBehavior))) {
|
||||
//MMC3 Revision A behavior
|
||||
if((count > 0 || _irqReload) && _irqCounter == 0 && _irqEnabled) {
|
||||
TriggerIrq();
|
||||
|
|
|
@ -667,6 +667,14 @@ shared_ptr<BaseMapper> MapperFactory::InitializeFromFile(shared_ptr<Console> con
|
|||
|
||||
if(loader.LoadFile(romFilename, fileData)) {
|
||||
RomData romData = loader.GetRomData();
|
||||
|
||||
if(romData.Info.IsInDatabase || romData.Info.IsNes20Header) {
|
||||
//If in DB or a NES 2.0 file, auto-configure the inputs
|
||||
if(console->GetSettings()->CheckFlag(EmulationFlags::AutoConfigureInput)) {
|
||||
console->GetSettings()->InitializeInputDevices(romData.Info.InputType, romData.Info.System, false);
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<BaseMapper> mapper(GetMapperFromID(romData));
|
||||
|
||||
if(mapper) {
|
||||
|
|
|
@ -270,7 +270,7 @@ uint8_t MemoryDumper::GetMemoryValue(DebugMemoryType memoryType, uint32_t addres
|
|||
void MemoryDumper::GetNametable(int nametableIndex, bool useGrayscalePalette, uint32_t* frameBuffer, uint8_t* tileData, uint8_t* paletteData)
|
||||
{
|
||||
shared_ptr<MMC5> mmc5 = std::dynamic_pointer_cast<MMC5>(_mapper);
|
||||
uint32_t *rgbPalette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *rgbPalette = _debugger->GetConsole()->GetSettings()->GetRgbPalette();
|
||||
PPUDebugState state;
|
||||
_ppu->GetState(state);
|
||||
uint16_t bgAddr = state.ControlFlags.BackgroundPatternAddr;
|
||||
|
@ -418,7 +418,7 @@ void MemoryDumper::GetChrBank(int bankIndex, uint32_t* frameBuffer, uint8_t pale
|
|||
(_ppu->ReadPaletteRAM(paletteBaseAddr + 3) << 24);
|
||||
}
|
||||
|
||||
uint32_t *rgbPalette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *rgbPalette = _debugger->GetConsole()->GetSettings()->GetRgbPalette();
|
||||
uint8_t chrBuffer[0x1000];
|
||||
bool chrIsDrawn[0x1000];
|
||||
bool isChrRam = _mapper->GetMemorySize(DebugMemoryType::ChrRam) > 0;
|
||||
|
@ -502,7 +502,7 @@ void MemoryDumper::GetSprites(uint32_t* frameBuffer)
|
|||
memset(frameBuffer, 0, 64*128*sizeof(uint32_t));
|
||||
|
||||
uint8_t *spriteRam = _ppu->GetSpriteRam();
|
||||
uint32_t *rgbPalette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *rgbPalette = _debugger->GetConsole()->GetSettings()->GetRgbPalette();
|
||||
|
||||
PPUDebugState state;
|
||||
_ppu->GetState(state);
|
||||
|
@ -562,7 +562,7 @@ void MemoryDumper::GetSprites(uint32_t* frameBuffer)
|
|||
|
||||
void MemoryDumper::GetPalette(uint32_t* frameBuffer)
|
||||
{
|
||||
uint32_t *rgbPalette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t *rgbPalette = _debugger->GetConsole()->GetSettings()->GetRgbPalette();
|
||||
for(uint8_t i = 0; i < 32; i++) {
|
||||
frameBuffer[i] = rgbPalette[_ppu->ReadPaletteRAM(i) & 0x3F];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ MemoryManager::MemoryManager(shared_ptr<Console> console)
|
|||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
_nametableRAM[i] = new uint8_t[NameTableScreenSize];
|
||||
BaseMapper::InitializeRam(_nametableRAM[i], NameTableScreenSize);
|
||||
_console->GetMapper()->InitializeRam(_nametableRAM[i], NameTableScreenSize);
|
||||
}
|
||||
|
||||
_ramReadHandlers = new IMemoryHandler*[RAMSize];
|
||||
|
@ -47,7 +47,7 @@ void MemoryManager::SetMapper(shared_ptr<BaseMapper> mapper)
|
|||
void MemoryManager::Reset(bool softReset)
|
||||
{
|
||||
if(!softReset) {
|
||||
BaseMapper::InitializeRam(_internalRAM, InternalRAMSize);
|
||||
_mapper->InitializeRam(_internalRAM, InternalRAMSize);
|
||||
}
|
||||
|
||||
_mapper->Reset(softReset);
|
||||
|
|
|
@ -28,10 +28,16 @@ MesenMovie::~MesenMovie()
|
|||
void MesenMovie::Stop()
|
||||
{
|
||||
if(_playing) {
|
||||
EndMovie();
|
||||
MessageManager::DisplayMessage("Movies", "MovieEnded");
|
||||
|
||||
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::MovieEnded);
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::PauseOnMovieEnd)) {
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::Paused);
|
||||
}
|
||||
|
||||
_playing = false;
|
||||
}
|
||||
EmulationSettings::SetInputPollScanline(241);
|
||||
_console->GetSettings()->SetInputPollScanline(241);
|
||||
_console->GetControlManager()->UnregisterInputProvider(this);
|
||||
}
|
||||
|
||||
|
@ -111,11 +117,11 @@ bool MesenMovie::Play(VirtualFile &file)
|
|||
ApplySettings();
|
||||
|
||||
//Disable auto-configure input option (otherwise the movie file's input types are ignored)
|
||||
bool autoConfigureInput = EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::AutoConfigureInput);
|
||||
bool autoConfigureInput = _console->GetSettings()->CheckFlag(EmulationFlags::AutoConfigureInput);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::AutoConfigureInput);
|
||||
_console->GetControlManager()->SetPollCounter(0);
|
||||
bool gameLoaded = LoadGame();
|
||||
EmulationSettings::SetFlagState(EmulationFlags::AutoConfigureInput, autoConfigureInput);
|
||||
_console->GetSettings()->SetFlagState(EmulationFlags::AutoConfigureInput, autoConfigureInput);
|
||||
|
||||
if(!gameLoaded) {
|
||||
_console->Resume();
|
||||
|
@ -181,7 +187,7 @@ bool MesenMovie::LoadGame()
|
|||
//string patchFileSha1 = LoadString(_settings, MovieKeys::PatchFileSha1);
|
||||
//string patchedRomSha1 = LoadString(_settings, MovieKeys::PatchedRomSha1);
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::AllowMismatchingSaveState) && _console->GetRomInfo().RomName == gameFile) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::AllowMismatchingSaveState) && _console->GetRomInfo().RomName == gameFile) {
|
||||
//Loaded game has the right name, and we don't want to validate the hash values
|
||||
_console->PowerCycle();
|
||||
return true;
|
||||
|
@ -206,6 +212,8 @@ bool MesenMovie::LoadGame()
|
|||
|
||||
void MesenMovie::ApplySettings()
|
||||
{
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
|
||||
NesModel region = FromString(LoadString(_settings, MovieKeys::Region), NesModelNames, NesModel::NTSC);
|
||||
ConsoleType consoleType = FromString(LoadString(_settings, MovieKeys::ConsoleType), ConsoleTypeNames, ConsoleType::Nes);
|
||||
ControllerType controller1 = FromString(LoadString(_settings, MovieKeys::Controller1), ControllerTypeNames, ControllerType::None);
|
||||
|
@ -214,47 +222,47 @@ void MesenMovie::ApplySettings()
|
|||
ControllerType controller4 = FromString(LoadString(_settings, MovieKeys::Controller4), ControllerTypeNames, ControllerType::None);
|
||||
ExpansionPortDevice expansionDevice = FromString<ExpansionPortDevice>(LoadString(_settings, MovieKeys::ExpansionDevice), ExpansionPortDeviceNames, ExpansionPortDevice::None);
|
||||
|
||||
EmulationSettings::SetNesModel(region);
|
||||
EmulationSettings::SetConsoleType(consoleType);
|
||||
EmulationSettings::SetControllerType(0, controller1);
|
||||
EmulationSettings::SetControllerType(1, controller2);
|
||||
EmulationSettings::SetControllerType(2, controller3);
|
||||
EmulationSettings::SetControllerType(3, controller4);
|
||||
EmulationSettings::SetExpansionDevice(expansionDevice);
|
||||
settings->SetNesModel(region);
|
||||
settings->SetConsoleType(consoleType);
|
||||
settings->SetControllerType(0, controller1);
|
||||
settings->SetControllerType(1, controller2);
|
||||
settings->SetControllerType(2, controller3);
|
||||
settings->SetControllerType(3, controller4);
|
||||
settings->SetExpansionDevice(expansionDevice);
|
||||
|
||||
uint32_t ramPowerOnState = LoadInt(_settings, MovieKeys::RamPowerOnState);
|
||||
if(ramPowerOnState == 0xFF) {
|
||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllOnes);
|
||||
settings->SetRamPowerOnState(RamPowerOnState::AllOnes);
|
||||
} else {
|
||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros);
|
||||
settings->SetRamPowerOnState(RamPowerOnState::AllZeros);
|
||||
}
|
||||
|
||||
EmulationSettings::SetInputPollScanline(LoadInt(_settings, MovieKeys::InputPollScanline, 240));
|
||||
settings->SetInputPollScanline(LoadInt(_settings, MovieKeys::InputPollScanline, 240));
|
||||
|
||||
EmulationSettings::SetZapperDetectionRadius(LoadInt(_settings, MovieKeys::ZapperDetectionRadius));
|
||||
settings->SetZapperDetectionRadius(LoadInt(_settings, MovieKeys::ZapperDetectionRadius));
|
||||
|
||||
uint32_t cpuClockRate = LoadInt(_settings, MovieKeys::CpuClockRate);
|
||||
if(cpuClockRate != 100) {
|
||||
bool adjustApu = LoadBool(_settings, MovieKeys::OverclockAdjustApu);
|
||||
EmulationSettings::SetOverclockRate(cpuClockRate, adjustApu);
|
||||
settings->SetOverclockRate(cpuClockRate, adjustApu);
|
||||
} else {
|
||||
EmulationSettings::SetOverclockRate(100, true);
|
||||
settings->SetOverclockRate(100, true);
|
||||
}
|
||||
|
||||
EmulationSettings::SetPpuNmiConfig(
|
||||
settings->SetPpuNmiConfig(
|
||||
LoadInt(_settings, MovieKeys::ExtraScanlinesBeforeNmi),
|
||||
LoadInt(_settings, MovieKeys::ExtraScanlinesAfterNmi)
|
||||
);
|
||||
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisablePpu2004Reads, LoadBool(_settings, MovieKeys::DisablePpu2004Reads));
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisablePaletteRead, LoadBool(_settings, MovieKeys::DisablePaletteRead));
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisableOamAddrBug, LoadBool(_settings, MovieKeys::DisableOamAddrBug));
|
||||
EmulationSettings::SetFlagState(EmulationFlags::UseNes101Hvc101Behavior, LoadBool(_settings, MovieKeys::UseNes101Hvc101Behavior));
|
||||
EmulationSettings::SetFlagState(EmulationFlags::EnableOamDecay, LoadBool(_settings, MovieKeys::EnableOamDecay));
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisablePpuReset, LoadBool(_settings, MovieKeys::DisablePpuReset));
|
||||
settings->SetFlagState(EmulationFlags::DisablePpu2004Reads, LoadBool(_settings, MovieKeys::DisablePpu2004Reads));
|
||||
settings->SetFlagState(EmulationFlags::DisablePaletteRead, LoadBool(_settings, MovieKeys::DisablePaletteRead));
|
||||
settings->SetFlagState(EmulationFlags::DisableOamAddrBug, LoadBool(_settings, MovieKeys::DisableOamAddrBug));
|
||||
settings->SetFlagState(EmulationFlags::UseNes101Hvc101Behavior, LoadBool(_settings, MovieKeys::UseNes101Hvc101Behavior));
|
||||
settings->SetFlagState(EmulationFlags::EnableOamDecay, LoadBool(_settings, MovieKeys::EnableOamDecay));
|
||||
settings->SetFlagState(EmulationFlags::DisablePpuReset, LoadBool(_settings, MovieKeys::DisablePpuReset));
|
||||
|
||||
//VS System flags
|
||||
EmulationSettings::SetDipSwitches(HexUtilities::FromHex(LoadString(_settings, MovieKeys::DipSwitches)));
|
||||
settings->SetDipSwitches(HexUtilities::FromHex(LoadString(_settings, MovieKeys::DipSwitches)));
|
||||
|
||||
LoadCheats();
|
||||
}
|
||||
|
|
|
@ -605,6 +605,7 @@ std::unordered_map<string, string> MessageManager::_caResources = {
|
|||
|
||||
std::list<string> MessageManager::_log;
|
||||
SimpleLock MessageManager::_logLock;
|
||||
bool MessageManager::_osdEnabled = false;
|
||||
IMessageManager* MessageManager::_messageManager = nullptr;
|
||||
|
||||
void MessageManager::RegisterMessageManager(IMessageManager* messageManager)
|
||||
|
@ -612,6 +613,11 @@ void MessageManager::RegisterMessageManager(IMessageManager* messageManager)
|
|||
MessageManager::_messageManager = messageManager;
|
||||
}
|
||||
|
||||
void MessageManager::SetOsdState(bool enabled)
|
||||
{
|
||||
_osdEnabled = enabled;
|
||||
}
|
||||
|
||||
string MessageManager::Localize(string key)
|
||||
{
|
||||
std::unordered_map<string, string> *resources = nullptr;
|
||||
|
@ -656,10 +662,10 @@ void MessageManager::DisplayMessage(string title, string message, string param1,
|
|||
message.replace(startPos, 2, param2);
|
||||
}
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::DisableOsd)) {
|
||||
MessageManager::Log("[" + title + "] " + message);
|
||||
} else {
|
||||
if(_osdEnabled) {
|
||||
MessageManager::_messageManager->DisplayMessage(title, message);
|
||||
} else {
|
||||
MessageManager::Log("[" + title + "] " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,13 @@ private:
|
|||
static std::unordered_map<string, string> _ptResources;
|
||||
static std::unordered_map<string, string> _caResources;
|
||||
|
||||
static bool _osdEnabled;
|
||||
static SimpleLock _logLock;
|
||||
static std::list<string> _log;
|
||||
|
||||
public:
|
||||
static void SetOsdState(bool enabled);
|
||||
|
||||
static string Localize(string key);
|
||||
|
||||
static void RegisterMessageManager(IMessageManager* messageManager);
|
||||
|
|
|
@ -11,19 +11,6 @@ class Console;
|
|||
|
||||
class IMovie : public IInputProvider
|
||||
{
|
||||
protected:
|
||||
void EndMovie()
|
||||
{
|
||||
MessageManager::DisplayMessage("Movies", "MovieEnded");
|
||||
|
||||
//TODOCONSOLE
|
||||
//MessageManager::SendNotification(ConsoleNotificationType::MovieEnded);
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::PauseOnMovieEnd)) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool Play(VirtualFile &file) = 0;
|
||||
virtual bool IsPlaying() = 0;
|
||||
|
|
|
@ -65,9 +65,10 @@ bool MovieRecorder::Record(RecordMovieOptions options)
|
|||
|
||||
void MovieRecorder::GetGameSettings(stringstream &out)
|
||||
{
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
NesModel model = _console->GetModel();
|
||||
|
||||
WriteString(out, MovieKeys::MesenVersion, EmulationSettings::GetMesenVersionString());
|
||||
WriteString(out, MovieKeys::MesenVersion, settings->GetMesenVersionString());
|
||||
WriteInt(out, MovieKeys::MovieFormatVersion, MovieRecorder::MovieFormatVersion);
|
||||
|
||||
VirtualFile romFile = _console->GetRomPath();
|
||||
|
@ -88,40 +89,40 @@ void MovieRecorder::GetGameSettings(stringstream &out)
|
|||
case NesModel::Dendy: WriteString(out, MovieKeys::Region, "Dendy"); break;
|
||||
}
|
||||
|
||||
switch(EmulationSettings::GetConsoleType()) {
|
||||
switch(settings->GetConsoleType()) {
|
||||
case ConsoleType::Nes: WriteString(out, MovieKeys::ConsoleType, "NES"); break;
|
||||
case ConsoleType::Famicom: WriteString(out, MovieKeys::ConsoleType, "Famicom"); break;
|
||||
}
|
||||
|
||||
WriteString(out, MovieKeys::Controller1, ControllerTypeNames[(int)EmulationSettings::GetControllerType(0)]);
|
||||
WriteString(out, MovieKeys::Controller2, ControllerTypeNames[(int)EmulationSettings::GetControllerType(1)]);
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::HasFourScore)) {
|
||||
WriteString(out, MovieKeys::Controller3, ControllerTypeNames[(int)EmulationSettings::GetControllerType(2)]);
|
||||
WriteString(out, MovieKeys::Controller4, ControllerTypeNames[(int)EmulationSettings::GetControllerType(3)]);
|
||||
WriteString(out, MovieKeys::Controller1, ControllerTypeNames[(int)settings->GetControllerType(0)]);
|
||||
WriteString(out, MovieKeys::Controller2, ControllerTypeNames[(int)settings->GetControllerType(1)]);
|
||||
if(settings->CheckFlag(EmulationFlags::HasFourScore)) {
|
||||
WriteString(out, MovieKeys::Controller3, ControllerTypeNames[(int)settings->GetControllerType(2)]);
|
||||
WriteString(out, MovieKeys::Controller4, ControllerTypeNames[(int)settings->GetControllerType(3)]);
|
||||
}
|
||||
|
||||
if(EmulationSettings::GetConsoleType() == ConsoleType::Famicom) {
|
||||
WriteString(out, MovieKeys::ExpansionDevice, ExpansionPortDeviceNames[(int)EmulationSettings::GetExpansionDevice()]);
|
||||
if(settings->GetConsoleType() == ConsoleType::Famicom) {
|
||||
WriteString(out, MovieKeys::ExpansionDevice, ExpansionPortDeviceNames[(int)settings->GetExpansionDevice()]);
|
||||
}
|
||||
|
||||
WriteInt(out, MovieKeys::CpuClockRate, EmulationSettings::GetOverclockRateSetting());
|
||||
WriteInt(out, MovieKeys::ExtraScanlinesBeforeNmi, EmulationSettings::GetPpuExtraScanlinesBeforeNmi());
|
||||
WriteInt(out, MovieKeys::ExtraScanlinesAfterNmi, EmulationSettings::GetPpuExtraScanlinesAfterNmi());
|
||||
WriteInt(out, MovieKeys::InputPollScanline, EmulationSettings::GetInputPollScanline());
|
||||
WriteInt(out, MovieKeys::CpuClockRate, settings->GetOverclockRateSetting());
|
||||
WriteInt(out, MovieKeys::ExtraScanlinesBeforeNmi, settings->GetPpuExtraScanlinesBeforeNmi());
|
||||
WriteInt(out, MovieKeys::ExtraScanlinesAfterNmi, settings->GetPpuExtraScanlinesAfterNmi());
|
||||
WriteInt(out, MovieKeys::InputPollScanline, settings->GetInputPollScanline());
|
||||
|
||||
if(EmulationSettings::GetOverclockRateSetting() != 100) {
|
||||
WriteBool(out, MovieKeys::OverclockAdjustApu, EmulationSettings::GetOverclockAdjustApu());
|
||||
if(settings->GetOverclockRateSetting() != 100) {
|
||||
WriteBool(out, MovieKeys::OverclockAdjustApu, settings->GetOverclockAdjustApu());
|
||||
}
|
||||
WriteBool(out, MovieKeys::DisablePpu2004Reads, EmulationSettings::CheckFlag(EmulationFlags::DisablePpu2004Reads));
|
||||
WriteBool(out, MovieKeys::DisablePaletteRead, EmulationSettings::CheckFlag(EmulationFlags::DisablePaletteRead));
|
||||
WriteBool(out, MovieKeys::DisableOamAddrBug, EmulationSettings::CheckFlag(EmulationFlags::DisableOamAddrBug));
|
||||
WriteBool(out, MovieKeys::UseNes101Hvc101Behavior, EmulationSettings::CheckFlag(EmulationFlags::UseNes101Hvc101Behavior));
|
||||
WriteBool(out, MovieKeys::EnableOamDecay, EmulationSettings::CheckFlag(EmulationFlags::EnableOamDecay));
|
||||
WriteBool(out, MovieKeys::DisablePpuReset, EmulationSettings::CheckFlag(EmulationFlags::DisablePpuReset));
|
||||
WriteBool(out, MovieKeys::DisablePpu2004Reads, settings->CheckFlag(EmulationFlags::DisablePpu2004Reads));
|
||||
WriteBool(out, MovieKeys::DisablePaletteRead, settings->CheckFlag(EmulationFlags::DisablePaletteRead));
|
||||
WriteBool(out, MovieKeys::DisableOamAddrBug, settings->CheckFlag(EmulationFlags::DisableOamAddrBug));
|
||||
WriteBool(out, MovieKeys::UseNes101Hvc101Behavior, settings->CheckFlag(EmulationFlags::UseNes101Hvc101Behavior));
|
||||
WriteBool(out, MovieKeys::EnableOamDecay, settings->CheckFlag(EmulationFlags::EnableOamDecay));
|
||||
WriteBool(out, MovieKeys::DisablePpuReset, settings->CheckFlag(EmulationFlags::DisablePpuReset));
|
||||
|
||||
WriteInt(out, MovieKeys::ZapperDetectionRadius, EmulationSettings::GetZapperDetectionRadius());
|
||||
WriteInt(out, MovieKeys::ZapperDetectionRadius, settings->GetZapperDetectionRadius());
|
||||
|
||||
switch(EmulationSettings::GetRamPowerOnState()) {
|
||||
switch(settings->GetRamPowerOnState()) {
|
||||
case RamPowerOnState::AllZeros: WriteInt(out, MovieKeys::RamPowerOnState, 0x00); break;
|
||||
case RamPowerOnState::AllOnes: WriteInt(out, MovieKeys::RamPowerOnState, 0xFF); break;
|
||||
case RamPowerOnState::Random: WriteInt(out, MovieKeys::RamPowerOnState, -1); break; //TODO: Shouldn't be used for movies
|
||||
|
@ -129,7 +130,7 @@ void MovieRecorder::GetGameSettings(stringstream &out)
|
|||
|
||||
//VS System flags
|
||||
if(_console->GetAvailableFeatures() == ConsoleFeatures::VsSystem) {
|
||||
WriteString(out, MovieKeys::DipSwitches, HexUtilities::ToHex(EmulationSettings::GetDipSwitches()));
|
||||
WriteString(out, MovieKeys::DipSwitches, HexUtilities::ToHex(settings->GetDipSwitches()));
|
||||
}
|
||||
|
||||
for(CodeInfo &code : _console->GetCheatManager()->GetCheats()) {
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
void Clock() override
|
||||
{
|
||||
//Feedback is calculated as the exclusive-OR of bit 0 and one other bit: bit 6 if Mode flag is set, otherwise bit 1.
|
||||
bool mode = EmulationSettings::CheckFlag(EmulationFlags::DisableNoiseModeFlag) ? false : _modeFlag;
|
||||
bool mode = _console->GetSettings()->CheckFlag(EmulationFlags::DisableNoiseModeFlag) ? false : _modeFlag;
|
||||
|
||||
uint16_t feedback = (_shiftRegister & 0x01) ^ ((_shiftRegister >> (mode ? 6 : 1)) & 0x01);
|
||||
_shiftRegister >>= 1;
|
||||
|
|
|
@ -10,17 +10,17 @@ NsfMapper* NsfMapper::_instance;
|
|||
NsfMapper::NsfMapper()
|
||||
{
|
||||
_instance = this;
|
||||
EmulationSettings::DisableOverclocking(true);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
EmulationSettings::SetFlags(EmulationFlags::NsfPlayerEnabled);
|
||||
_console->GetSettings()->DisableOverclocking(true);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::Paused);
|
||||
_console->GetSettings()->SetFlags(EmulationFlags::NsfPlayerEnabled);
|
||||
}
|
||||
|
||||
NsfMapper::~NsfMapper()
|
||||
{
|
||||
if(_instance == this) {
|
||||
_instance = nullptr;
|
||||
EmulationSettings::DisableOverclocking(false);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::NsfPlayerEnabled);
|
||||
_console->GetSettings()->DisableOverclocking(false);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::NsfPlayerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void NsfMapper::ClockLengthAndFadeCounters()
|
|||
}
|
||||
}
|
||||
|
||||
if((_trackEndCounter < 0 || _allowSilenceDetection) && EmulationSettings::GetNsfAutoDetectSilenceDelay() > 0) {
|
||||
if((_trackEndCounter < 0 || _allowSilenceDetection) && _console->GetSettings()->GetNsfAutoDetectSilenceDelay() > 0) {
|
||||
//No track length specified
|
||||
if(_console->GetSoundMixer()->GetMuteFrameCount() * SoundMixer::CycleLength > _silenceDetectDelay) {
|
||||
//Auto detect end of track after AutoDetectSilenceDelay (in ms) has gone by without sound
|
||||
|
@ -213,8 +213,8 @@ void NsfMapper::ClockLengthAndFadeCounters()
|
|||
|
||||
void NsfMapper::SelectNextTrack()
|
||||
{
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::NsfRepeat)) {
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::NsfShuffle)) {
|
||||
if(!_console->GetSettings()->CheckFlag(EmulationFlags::NsfRepeat)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::NsfShuffle)) {
|
||||
std::random_device rd;
|
||||
std::mt19937 mt(rd());
|
||||
std::uniform_int_distribution<> dist(0, _nsfHeader.TotalSongs - 1);
|
||||
|
@ -229,7 +229,7 @@ void NsfMapper::SelectNextTrack()
|
|||
|
||||
void NsfMapper::ProcessCpuClock()
|
||||
{
|
||||
_console->GetCpu()->SetIrqMask(EmulationSettings::GetNsfDisableApuIrqs() ? (uint8_t)IRQSource::External : 0xFF);
|
||||
_console->GetCpu()->SetIrqMask(_console->GetSettings()->GetNsfDisableApuIrqs() ? (uint8_t)IRQSource::External : 0xFF);
|
||||
|
||||
if(_needInit) {
|
||||
TriggerIrq(NsfIrqType::Init);
|
||||
|
@ -422,7 +422,7 @@ void NsfMapper::InternalSelectTrack(uint8_t trackNumber, bool requestReset)
|
|||
//Only apply a maximum duration to multi-track NSFs
|
||||
//Single track NSFs will loop or restart after a portion of silence
|
||||
//Substract 1 sec from default track time to account for 1 sec default fade time
|
||||
_trackEndCounter = (EmulationSettings::GetNsfMoveToNextTrackTime() - 1) * GetClockRate();
|
||||
_trackEndCounter = (_console->GetSettings()->GetNsfMoveToNextTrackTime() - 1) * GetClockRate();
|
||||
_allowSilenceDetection = true;
|
||||
}
|
||||
if(_nsfHeader.TrackFade[trackNumber] >= 0) {
|
||||
|
@ -432,7 +432,7 @@ void NsfMapper::InternalSelectTrack(uint8_t trackNumber, bool requestReset)
|
|||
_trackFadeCounter = GetClockRate();
|
||||
}
|
||||
|
||||
_silenceDetectDelay = (uint32_t)((double)EmulationSettings::GetNsfAutoDetectSilenceDelay() / 1000.0 * GetClockRate());
|
||||
_silenceDetectDelay = (uint32_t)((double)_console->GetSettings()->GetNsfAutoDetectSilenceDelay() / 1000.0 * GetClockRate());
|
||||
|
||||
_fadeLength = _trackFadeCounter;
|
||||
TriggerIrq(NsfIrqType::Init);
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include "NtscFilter.h"
|
||||
#include "PPU.h"
|
||||
#include "EmulationSettings.h"
|
||||
#include "Console.h"
|
||||
|
||||
NtscFilter::NtscFilter()
|
||||
NtscFilter::NtscFilter(shared_ptr<Console> console) : BaseVideoFilter(console)
|
||||
{
|
||||
memset(_basePalette, 0, 64 * 3);
|
||||
_ntscData = new nes_ntsc_t();
|
||||
|
@ -39,7 +40,7 @@ FrameInfo NtscFilter::GetFrameInfo()
|
|||
void NtscFilter::OnBeforeApplyFilter()
|
||||
{
|
||||
bool paletteChanged = false;
|
||||
uint32_t* palette = EmulationSettings::GetRgbPalette();
|
||||
uint32_t* palette = _console->GetSettings()->GetRgbPalette();
|
||||
for(int i = 0; i < 64; i++) {
|
||||
uint8_t r = (palette[i] >> 16) & 0xFF;
|
||||
uint8_t g = (palette[i] >> 8) & 0xFF;
|
||||
|
@ -54,8 +55,8 @@ void NtscFilter::OnBeforeApplyFilter()
|
|||
}
|
||||
}
|
||||
|
||||
PictureSettings pictureSettings = EmulationSettings::GetPictureSettings();
|
||||
NtscFilterSettings ntscSettings = EmulationSettings::GetNtscFilterSettings();
|
||||
PictureSettings pictureSettings = _console->GetSettings()->GetPictureSettings();
|
||||
NtscFilterSettings ntscSettings = _console->GetSettings()->GetNtscFilterSettings();
|
||||
|
||||
_keepVerticalRes = ntscSettings.KeepVerticalResolution;
|
||||
|
||||
|
@ -76,7 +77,7 @@ void NtscFilter::OnBeforeApplyFilter()
|
|||
_ntscSetup.resolution = ntscSettings.Resolution;
|
||||
_ntscSetup.sharpness = ntscSettings.Sharpness;
|
||||
|
||||
_ntscSetup.base_palette = EmulationSettings::IsDefaultPalette() ? nullptr : _basePalette;
|
||||
_ntscSetup.base_palette = _console->GetSettings()->IsDefaultPalette() ? nullptr : _basePalette;
|
||||
|
||||
nes_ntsc_init(_ntscData, &_ntscSetup);
|
||||
}
|
||||
|
@ -105,8 +106,8 @@ void NtscFilter::GenerateArgbFrame(uint32_t *ntscBuffer)
|
|||
ntscBuffer += rowWidth;
|
||||
}
|
||||
} else {
|
||||
double scanlineIntensity = 1.0 - EmulationSettings::GetPictureSettings().ScanlineIntensity;
|
||||
bool verticalBlend = EmulationSettings::GetNtscFilterSettings().VerticalBlend;
|
||||
double scanlineIntensity = 1.0 - _console->GetSettings()->GetPictureSettings().ScanlineIntensity;
|
||||
bool verticalBlend = _console->GetSettings()->GetNtscFilterSettings().VerticalBlend;
|
||||
|
||||
for(int y = PPU::ScreenHeight - 1 - overscan.Bottom; y >= (int)overscan.Top; y--) {
|
||||
uint32_t const* in = ntscBuffer + y * rowWidth;
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "BaseVideoFilter.h"
|
||||
#include "../Utilities/nes_ntsc.h"
|
||||
|
||||
class Console;
|
||||
|
||||
class NtscFilter : public BaseVideoFilter
|
||||
{
|
||||
private:
|
||||
|
@ -18,7 +20,7 @@ protected:
|
|||
void OnBeforeApplyFilter();
|
||||
|
||||
public:
|
||||
NtscFilter();
|
||||
NtscFilter(shared_ptr<Console> console);
|
||||
virtual ~NtscFilter();
|
||||
|
||||
virtual void ApplyFilter(uint16_t *ppuOutputBuffer);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseControlDevice.h"
|
||||
#include "Console.h"
|
||||
#include "EmulationSettings.h"
|
||||
|
||||
class OekaKidsTablet : public BaseControlDevice
|
||||
{
|
||||
|
@ -20,7 +22,7 @@ protected:
|
|||
|
||||
void InternalSetStateFromInput() override
|
||||
{
|
||||
if(EmulationSettings::InputEnabled()) {
|
||||
if(_console->GetSettings()->InputEnabled()) {
|
||||
MousePosition pos = KeyManager::GetMousePosition();
|
||||
SetPressedState(Buttons::Click, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
SetPressedState(Buttons::Touch, pos.Y >= 48 || KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
|
@ -35,7 +37,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
OekaKidsTablet() : BaseControlDevice(BaseControlDevice::ExpDevicePort)
|
||||
OekaKidsTablet(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -10,17 +10,16 @@ enum class OggPlaybackOptions
|
|||
|
||||
OggMixer::OggMixer()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void OggMixer::Reset()
|
||||
void OggMixer::Reset(uint32_t sampleRate)
|
||||
{
|
||||
_bgm.reset();
|
||||
_sfx.clear();
|
||||
_sfxVolume = 128;
|
||||
_bgmVolume = 128;
|
||||
_options = 0;
|
||||
_sampleRate = EmulationSettings::GetSampleRate();
|
||||
_sampleRate = sampleRate;
|
||||
_paused = false;
|
||||
}
|
||||
|
||||
|
@ -95,16 +94,16 @@ bool OggMixer::Play(string filename, bool isSfx, uint32_t startOffset)
|
|||
return false;
|
||||
}
|
||||
|
||||
void OggMixer::ApplySamples(int16_t * buffer, size_t sampleCount)
|
||||
void OggMixer::ApplySamples(int16_t * buffer, size_t sampleCount, double masterVolumne)
|
||||
{
|
||||
if(_bgm && !_paused) {
|
||||
_bgm->ApplySamples(buffer, sampleCount, _bgmVolume);
|
||||
_bgm->ApplySamples(buffer, sampleCount, _bgmVolume, masterVolumne);
|
||||
if(_bgm->IsPlaybackOver()) {
|
||||
_bgm.reset();
|
||||
}
|
||||
}
|
||||
for(shared_ptr<OggReader> &sfx : _sfx) {
|
||||
sfx->ApplySamples(buffer, sampleCount, _sfxVolume);
|
||||
sfx->ApplySamples(buffer, sampleCount, _sfxVolume, masterVolumne);
|
||||
}
|
||||
_sfx.erase(std::remove_if(_sfx.begin(), _sfx.end(), [](const shared_ptr<OggReader>& o) { return o->IsPlaybackOver(); }), _sfx.end());
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ public:
|
|||
OggMixer();
|
||||
|
||||
void SetSampleRate(int sampleRate);
|
||||
void ApplySamples(int16_t* buffer, size_t sampleCount);
|
||||
void ApplySamples(int16_t* buffer, size_t sampleCount, double masterVolumne);
|
||||
|
||||
void Reset();
|
||||
void Reset(uint32_t sampleRate);
|
||||
bool Play(string filename, bool isSfx, uint32_t startOffset);
|
||||
void SetPlaybackOptions(uint8_t options);
|
||||
void SetPausedFlag(bool paused);
|
||||
|
|
|
@ -88,7 +88,7 @@ bool OggReader::LoadSamples()
|
|||
return samplesReturned > 0;
|
||||
}
|
||||
|
||||
void OggReader::ApplySamples(int16_t * buffer, size_t sampleCount, uint8_t volume)
|
||||
void OggReader::ApplySamples(int16_t * buffer, size_t sampleCount, uint8_t volume, double masterVolume)
|
||||
{
|
||||
while(blip_samples_avail(_blipLeft) < (int)sampleCount) {
|
||||
if(!LoadSamples()) {
|
||||
|
@ -100,7 +100,7 @@ void OggReader::ApplySamples(int16_t * buffer, size_t sampleCount, uint8_t volum
|
|||
blip_read_samples(_blipRight, _outputBuffer + 1, (int)sampleCount, 1);
|
||||
|
||||
for(size_t i = 0, len = samplesRead * 2; i < len; i++) {
|
||||
buffer[i] += (int16_t)(_outputBuffer[i] * (EmulationSettings::GetMasterVolume() * volume / 255 / 10));
|
||||
buffer[i] += (int16_t)(_outputBuffer[i] * (masterVolume * volume / 255 / 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "../Utilities/stb_vorbis.h"
|
||||
#include "../Utilities/blip_buf.h"
|
||||
#include "VirtualFile.h"
|
||||
#include "EmulationSettings.h"
|
||||
|
||||
class OggReader
|
||||
{
|
||||
|
@ -35,6 +34,6 @@ public:
|
|||
bool IsPlaybackOver();
|
||||
void SetSampleRate(int sampleRate);
|
||||
void SetLoopFlag(bool loop);
|
||||
void ApplySamples(int16_t* buffer, size_t sampleCount, uint8_t volume);
|
||||
void ApplySamples(int16_t* buffer, size_t sampleCount, uint8_t volume, double masterVolume);
|
||||
uint32_t GetOffset();
|
||||
};
|
||||
|
|
69
Core/PPU.cpp
69
Core/PPU.cpp
|
@ -15,6 +15,7 @@
|
|||
PPU::PPU(shared_ptr<Console> console)
|
||||
{
|
||||
_console = console;
|
||||
_settings = _console->GetSettings();
|
||||
|
||||
_outputBuffers[0] = new uint16_t[256 * 240];
|
||||
_outputBuffers[1] = new uint16_t[256 * 240];
|
||||
|
@ -27,8 +28,8 @@ PPU::PPU(shared_ptr<Console> console)
|
|||
0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, 0x08, 0x3A, 0x00, 0x02, 0x00, 0x20, 0x2C, 0x08 };
|
||||
memcpy(_paletteRAM, paletteRamBootValues, sizeof(_paletteRAM));
|
||||
|
||||
BaseMapper::InitializeRam(_spriteRAM, 0x100);
|
||||
BaseMapper::InitializeRam(_secondarySpriteRAM, 0x20);
|
||||
_console->GetMapper()->InitializeRam(_spriteRAM, 0x100);
|
||||
_console->GetMapper()->InitializeRam(_secondarySpriteRAM, 0x20);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ void PPU::Reset()
|
|||
_updateVramAddr = 0;
|
||||
|
||||
memset(_oamDecayCycles, 0, sizeof(_oamDecayCycles));
|
||||
_enableOamDecay = EmulationSettings::CheckFlag(EmulationFlags::EnableOamDecay);
|
||||
_enableOamDecay = _settings->CheckFlag(EmulationFlags::EnableOamDecay);
|
||||
|
||||
UpdateMinimumDrawCycles();
|
||||
}
|
||||
|
@ -132,10 +133,10 @@ void PPU::SetNesModel(NesModel model)
|
|||
break;
|
||||
}
|
||||
|
||||
_nmiScanline += EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
_nmiScanline += _settings->GetPpuExtraScanlinesBeforeNmi();
|
||||
_palSpriteEvalScanline = _nmiScanline + 24;
|
||||
_standardVblankEnd += EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
_vblankEnd += EmulationSettings::GetPpuExtraScanlinesAfterNmi() + EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
_standardVblankEnd += _settings->GetPpuExtraScanlinesBeforeNmi();
|
||||
_vblankEnd += _settings->GetPpuExtraScanlinesAfterNmi() + _settings->GetPpuExtraScanlinesBeforeNmi();
|
||||
}
|
||||
|
||||
void PPU::GetState(PPUDebugState &state)
|
||||
|
@ -236,7 +237,7 @@ uint8_t PPU::ReadRAM(uint16_t addr)
|
|||
returnValue = _state.Status;
|
||||
openBusMask = 0x1F;
|
||||
|
||||
switch(EmulationSettings::GetPpuModel()) {
|
||||
switch(_settings->GetPpuModel()) {
|
||||
case PpuModel::Ppu2C05A: openBusMask = 0x00; returnValue |= 0x1B; break;
|
||||
case PpuModel::Ppu2C05B: openBusMask = 0x00; returnValue |= 0x3D; break;
|
||||
case PpuModel::Ppu2C05C: openBusMask = 0x00; returnValue |= 0x1C; break;
|
||||
|
@ -247,7 +248,7 @@ uint8_t PPU::ReadRAM(uint16_t addr)
|
|||
break;
|
||||
|
||||
case PPURegisters::SpriteData:
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::DisablePpu2004Reads)) {
|
||||
if(!_settings->CheckFlag(EmulationFlags::DisablePpu2004Reads)) {
|
||||
if(_scanline <= 239 && IsRenderingEnabled()) {
|
||||
//While the screen is begin drawn
|
||||
if(_cycle >= 257 && _cycle <= 320) {
|
||||
|
@ -275,7 +276,7 @@ uint8_t PPU::ReadRAM(uint16_t addr)
|
|||
returnValue = _memoryReadBuffer;
|
||||
_memoryReadBuffer = ReadVram(_ppuBusAddress & 0x3FFF, MemoryOperationType::Read);
|
||||
|
||||
if((_state.VideoRamAddr & 0x3FFF) >= 0x3F00 && !EmulationSettings::CheckFlag(EmulationFlags::DisablePaletteRead)) {
|
||||
if((_state.VideoRamAddr & 0x3FFF) >= 0x3F00 && !_settings->CheckFlag(EmulationFlags::DisablePaletteRead)) {
|
||||
returnValue = ReadPaletteRAM(_state.VideoRamAddr) | (_openBus & 0xC0);
|
||||
_console->DebugProcessVramReadOperation(MemoryOperationType::Read, _state.VideoRamAddr & 0x3FFF, returnValue);
|
||||
openBusMask = 0xC0;
|
||||
|
@ -303,14 +304,14 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value)
|
|||
|
||||
switch(GetRegisterID(addr)) {
|
||||
case PPURegisters::Control:
|
||||
if(EmulationSettings::GetPpuModel() >= PpuModel::Ppu2C05A && EmulationSettings::GetPpuModel() <= PpuModel::Ppu2C05E) {
|
||||
if(_settings->GetPpuModel() >= PpuModel::Ppu2C05A && _settings->GetPpuModel() <= PpuModel::Ppu2C05E) {
|
||||
SetMaskRegister(value);
|
||||
} else {
|
||||
SetControlRegister(value);
|
||||
}
|
||||
break;
|
||||
case PPURegisters::Mask:
|
||||
if(EmulationSettings::GetPpuModel() >= PpuModel::Ppu2C05A && EmulationSettings::GetPpuModel() <= PpuModel::Ppu2C05E) {
|
||||
if(_settings->GetPpuModel() >= PpuModel::Ppu2C05A && _settings->GetPpuModel() <= PpuModel::Ppu2C05E) {
|
||||
SetControlRegister(value);
|
||||
} else {
|
||||
SetMaskRegister(value);
|
||||
|
@ -438,8 +439,8 @@ void PPU::SetControlRegister(uint8_t value)
|
|||
|
||||
void PPU::UpdateMinimumDrawCycles()
|
||||
{
|
||||
_minimumDrawBgCycle = _flags.BackgroundEnabled ? ((_flags.BackgroundMask || EmulationSettings::CheckFlag(EmulationFlags::ForceBackgroundFirstColumn)) ? 0 : 8) : 300;
|
||||
_minimumDrawSpriteCycle = _flags.SpritesEnabled ? ((_flags.SpriteMask || EmulationSettings::CheckFlag(EmulationFlags::ForceSpritesFirstColumn)) ? 0 : 8) : 300;
|
||||
_minimumDrawBgCycle = _flags.BackgroundEnabled ? ((_flags.BackgroundMask || _settings->CheckFlag(EmulationFlags::ForceBackgroundFirstColumn)) ? 0 : 8) : 300;
|
||||
_minimumDrawSpriteCycle = _flags.SpritesEnabled ? ((_flags.SpriteMask || _settings->CheckFlag(EmulationFlags::ForceSpritesFirstColumn)) ? 0 : 8) : 300;
|
||||
_minimumDrawSpriteStandardCycle = _flags.SpritesEnabled ? (_flags.SpriteMask ? 0 : 8) : 300;
|
||||
}
|
||||
|
||||
|
@ -667,10 +668,10 @@ void PPU::LoadSprite(uint8_t spriteY, uint8_t tileIndex, uint8_t attributes, uin
|
|||
|
||||
void PPU::LoadExtraSprites()
|
||||
{
|
||||
if(_spriteCount == 8 && EmulationSettings::CheckFlag(EmulationFlags::RemoveSpriteLimit)) {
|
||||
if(_spriteCount == 8 && _settings->CheckFlag(EmulationFlags::RemoveSpriteLimit)) {
|
||||
bool loadExtraSprites = true;
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::AdaptiveSpriteLimit)) {
|
||||
if(_settings->CheckFlag(EmulationFlags::AdaptiveSpriteLimit)) {
|
||||
uint16_t lastPosition = 0xFFFF;
|
||||
uint8_t identicalSpriteCount = 0;
|
||||
uint8_t maxIdenticalSpriteCount = 0;
|
||||
|
@ -729,7 +730,7 @@ uint8_t PPU::GetPixelColor()
|
|||
if(_cycle > _minimumDrawBgCycle) {
|
||||
//BackgroundMask = false: Hide background in leftmost 8 pixels of screen
|
||||
spriteBgColor = (((_state.LowBitShift << offset) & 0x8000) >> 15) | (((_state.HighBitShift << offset) & 0x8000) >> 14);
|
||||
if(EmulationSettings::GetBackgroundEnabled()) {
|
||||
if(_settings->GetBackgroundEnabled()) {
|
||||
backgroundColor = spriteBgColor;
|
||||
}
|
||||
}
|
||||
|
@ -759,7 +760,7 @@ uint8_t PPU::GetPixelColor()
|
|||
_console->DebugProcessEvent(EventType::SpriteZeroHit);
|
||||
}
|
||||
|
||||
if(EmulationSettings::GetSpritesEnabled() && (backgroundColor == 0 || !_spriteTiles[i].BackgroundPriority)) {
|
||||
if(_settings->GetSpritesEnabled() && (backgroundColor == 0 || !_spriteTiles[i].BackgroundPriority)) {
|
||||
//Check sprite priority
|
||||
return _lastSprite->PaletteOffset + spriteColor;
|
||||
}
|
||||
|
@ -840,7 +841,7 @@ void PPU::ProcessScanline()
|
|||
if(_cycle == 1) {
|
||||
_statusFlags.VerticalBlank = false;
|
||||
}
|
||||
if(_state.SpriteRamAddr >= 0x08 && IsRenderingEnabled() && !EmulationSettings::CheckFlag(EmulationFlags::DisableOamAddrBug)) {
|
||||
if(_state.SpriteRamAddr >= 0x08 && IsRenderingEnabled() && !_settings->CheckFlag(EmulationFlags::DisableOamAddrBug)) {
|
||||
//This should only be done if rendering is enabled (otherwise oam_stress test fails immediately)
|
||||
//"If OAMADDR is not less than eight when rendering starts, the eight bytes starting at OAMADDR & 0xF8 are copied to the first eight bytes of OAM"
|
||||
WriteSpriteRam(_cycle - 1, ReadSpriteRam((_state.SpriteRamAddr & 0xF8) + _cycle - 1));
|
||||
|
@ -893,7 +894,7 @@ void PPU::ProcessScanline()
|
|||
if(IsRenderingEnabled()) {
|
||||
ReadVram(GetNameTableAddr());
|
||||
|
||||
if(_scanline == -1 && _cycle == 339 && (_frameCount & 0x01) && _nesModel == NesModel::NTSC && EmulationSettings::GetPpuModel() == PpuModel::Ppu2C02) {
|
||||
if(_scanline == -1 && _cycle == 339 && (_frameCount & 0x01) && _nesModel == NesModel::NTSC && _settings->GetPpuModel() == PpuModel::Ppu2C02) {
|
||||
//This behavior is NTSC-specific - PAL frames are always the same number of cycles
|
||||
//"With rendering enabled, each odd PPU frame is one PPU clock shorter than normal" (skip from 339 to 0, going over 340)
|
||||
_cycle = 340;
|
||||
|
@ -1070,7 +1071,7 @@ void PPU::SendFrame()
|
|||
_console->GetVideoDecoder()->UpdateFrame(_currentOutputBuffer);
|
||||
}
|
||||
|
||||
_enableOamDecay = EmulationSettings::CheckFlag(EmulationFlags::EnableOamDecay);
|
||||
_enableOamDecay = _settings->CheckFlag(EmulationFlags::EnableOamDecay);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1129,7 @@ void PPU::Exec()
|
|||
|
||||
UpdateApuStatus();
|
||||
|
||||
if(_scanline == EmulationSettings::GetInputPollScanline()) {
|
||||
if(_scanline == _settings->GetInputPollScanline()) {
|
||||
_console->GetControlManager()->UpdateInputState();
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1209,7 @@ void PPU::UpdateState()
|
|||
|
||||
void PPU::ProcessCpuClock()
|
||||
{
|
||||
if(!EmulationSettings::HasOverclock()) {
|
||||
if(!_settings->HasOverclock()) {
|
||||
Exec();
|
||||
Exec();
|
||||
Exec();
|
||||
|
@ -1219,9 +1220,9 @@ void PPU::ProcessCpuClock()
|
|||
} else {
|
||||
if(_nesModel == NesModel::PAL) {
|
||||
//PAL PPU runs 3.2 clocks for every CPU clock, so we need to run an extra clock every 5 CPU clocks
|
||||
_cyclesNeeded += 3.2 / (EmulationSettings::GetOverclockRate() / 100.0);
|
||||
_cyclesNeeded += 3.2 / (_settings->GetOverclockRate() / 100.0);
|
||||
} else {
|
||||
_cyclesNeeded += 3.0 / (EmulationSettings::GetOverclockRate() / 100.0);
|
||||
_cyclesNeeded += 3.0 / (_settings->GetOverclockRate() / 100.0);
|
||||
}
|
||||
|
||||
while(_cyclesNeeded >= 1.0) {
|
||||
|
@ -1246,6 +1247,14 @@ uint8_t* PPU::GetSpriteRam()
|
|||
return _spriteRAM;
|
||||
}
|
||||
|
||||
uint32_t PPU::GetPixelBrightness(uint8_t x, uint8_t y)
|
||||
{
|
||||
//Used by Zapper, gives a rough approximation of the brightness level of the specific pixel
|
||||
uint16_t pixelData = _currentOutputBuffer[y << 8 | x];
|
||||
uint32_t argbColor = _settings->GetRgbPalette()[pixelData & 0x3F];
|
||||
return (argbColor & 0xFF) + ((argbColor >> 8) & 0xFF) + ((argbColor >> 16) & 0xFF);
|
||||
}
|
||||
|
||||
void PPU::StreamState(bool saving)
|
||||
{
|
||||
ArrayInfo<uint8_t> paletteRam = { _paletteRAM, 0x20 };
|
||||
|
@ -1258,9 +1267,9 @@ void PPU::StreamState(bool saving)
|
|||
bool disableOamAddrBug = false;
|
||||
|
||||
if(saving) {
|
||||
disablePpu2004Reads = EmulationSettings::CheckFlag(EmulationFlags::DisablePpu2004Reads);
|
||||
disablePaletteRead = EmulationSettings::CheckFlag(EmulationFlags::DisablePaletteRead);
|
||||
disableOamAddrBug = EmulationSettings::CheckFlag(EmulationFlags::DisableOamAddrBug);
|
||||
disablePpu2004Reads = _settings->CheckFlag(EmulationFlags::DisablePpu2004Reads);
|
||||
disablePaletteRead = _settings->CheckFlag(EmulationFlags::DisablePaletteRead);
|
||||
disableOamAddrBug = _settings->CheckFlag(EmulationFlags::DisableOamAddrBug);
|
||||
}
|
||||
|
||||
uint16_t unusedSpriteDmaAddr = 0;
|
||||
|
@ -1283,9 +1292,9 @@ void PPU::StreamState(bool saving)
|
|||
}
|
||||
|
||||
if(!saving) {
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisablePpu2004Reads, disablePpu2004Reads);
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisablePaletteRead, disablePaletteRead);
|
||||
EmulationSettings::SetFlagState(EmulationFlags::DisableOamAddrBug, disableOamAddrBug);
|
||||
_settings->SetFlagState(EmulationFlags::DisablePpu2004Reads, disablePpu2004Reads);
|
||||
_settings->SetFlagState(EmulationFlags::DisablePaletteRead, disablePaletteRead);
|
||||
_settings->SetFlagState(EmulationFlags::DisableOamAddrBug, disableOamAddrBug);
|
||||
|
||||
SetNesModel(_nesModel);
|
||||
UpdateMinimumDrawCycles();
|
||||
|
|
|
@ -30,6 +30,7 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
{
|
||||
protected:
|
||||
shared_ptr<Console> _console;
|
||||
EmulationSettings* _settings;
|
||||
|
||||
PPUState _state;
|
||||
int32_t _scanline;
|
||||
|
@ -227,13 +228,7 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
return _secondarySpriteRAM;
|
||||
}
|
||||
|
||||
uint32_t GetPixelBrightness(uint8_t x, uint8_t y)
|
||||
{
|
||||
//Used by Zapper, gives a rough approximation of the brightness level of the specific pixel
|
||||
uint16_t pixelData = _currentOutputBuffer[y << 8 | x];
|
||||
uint32_t argbColor = EmulationSettings::GetRgbPalette()[pixelData & 0x3F];
|
||||
return (argbColor & 0xFF) + ((argbColor >> 8) & 0xFF) + ((argbColor >> 16) & 0xFF);
|
||||
}
|
||||
uint32_t GetPixelBrightness(uint8_t x, uint8_t y);
|
||||
|
||||
uint16_t GetPixel(uint8_t x, uint8_t y)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
PartyTap(KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
PartyTap(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
PowerPad(uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(port, keyMappings)
|
||||
PowerPad(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(console, port, keyMappings)
|
||||
{
|
||||
_useSideA = keyMappings.PowerpadUseSideA;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "RawVideoFilter.h"
|
||||
#include "PPU.h"
|
||||
|
||||
RawVideoFilter::RawVideoFilter()
|
||||
RawVideoFilter::RawVideoFilter(shared_ptr<Console> console) : BaseVideoFilter(console)
|
||||
{
|
||||
//Use the same raw output as the Nestopia core
|
||||
for(int i = 0; i < 512; i++) {
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
#include "stdafx.h"
|
||||
#include "BaseVideoFilter.h"
|
||||
|
||||
class Console;
|
||||
|
||||
class RawVideoFilter : public BaseVideoFilter
|
||||
{
|
||||
private:
|
||||
uint32_t _rawPalette[512];
|
||||
|
||||
public:
|
||||
RawVideoFilter();
|
||||
RawVideoFilter(shared_ptr<Console> console);
|
||||
|
||||
void ApplyFilter(uint16_t *ppuOutputBuffer);
|
||||
FrameInfo GetFrameInfo();
|
||||
|
|
|
@ -182,17 +182,18 @@ void RecordedRomTest::RecordFromTest(string newTestFilename, string existingTest
|
|||
|
||||
int32_t RecordedRomTest::Run(string filename)
|
||||
{
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
string testName = FolderUtilities::GetFilename(filename, false);
|
||||
if(testName.compare("5.MMC3_rev_A") == 0 || testName.compare("6-MMC6") == 0 || testName.compare("6-MMC3_alt") == 0) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Mmc3IrqAltBehavior);
|
||||
settings->SetFlags(EmulationFlags::Mmc3IrqAltBehavior);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Mmc3IrqAltBehavior);
|
||||
settings->ClearFlags(EmulationFlags::Mmc3IrqAltBehavior);
|
||||
}
|
||||
|
||||
if(testName.compare("demo_pal") == 0 || testName.substr(0, 4).compare("pal_") == 0) {
|
||||
EmulationSettings::SetNesModel(NesModel::PAL);
|
||||
settings->SetNesModel(NesModel::PAL);
|
||||
} else {
|
||||
EmulationSettings::SetNesModel(NesModel::NTSC);
|
||||
settings->SetNesModel(NesModel::NTSC);
|
||||
}
|
||||
|
||||
VirtualFile testMovie(filename, "TestMovie.mmo");
|
||||
|
@ -212,7 +213,7 @@ int32_t RecordedRomTest::Run(string filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
EmulationSettings::SetMasterVolume(0);
|
||||
settings->SetMasterVolume(0);
|
||||
|
||||
_console->Pause();
|
||||
|
||||
|
@ -236,12 +237,12 @@ int32_t RecordedRomTest::Run(string filename)
|
|||
|
||||
//Start playing movie
|
||||
if(_console->Initialize(testRom)) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
settings->SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_runningTest = true;
|
||||
MovieManager::Play(testMovie, _console);
|
||||
|
||||
_console->Resume();
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
_console->GetSettings()->ClearFlags(EmulationFlags::Paused);
|
||||
_signal.Wait();
|
||||
_runningTest = false;
|
||||
_console->Stop();
|
||||
|
@ -250,8 +251,8 @@ int32_t RecordedRomTest::Run(string filename)
|
|||
return -2;
|
||||
}
|
||||
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(1.0);
|
||||
settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
settings->SetMasterVolume(1.0);
|
||||
|
||||
return _badFrameCount;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
RewindManager::RewindManager(shared_ptr<Console> console)
|
||||
{
|
||||
_console = console;
|
||||
_settings = console->GetSettings();
|
||||
_rewindState = RewindState::Stopped;
|
||||
_framesToFastForward = 0;
|
||||
AddHistoryBlock();
|
||||
|
@ -41,7 +42,7 @@ void RewindManager::ClearBuffer()
|
|||
void RewindManager::ProcessNotification(ConsoleNotificationType type, void * parameter)
|
||||
{
|
||||
if(type == ConsoleNotificationType::PpuFrameDone) {
|
||||
if(EmulationSettings::GetRewindBufferSize() > 0) {
|
||||
if(_settings->GetRewindBufferSize() > 0) {
|
||||
switch(_rewindState) {
|
||||
case RewindState::Starting:
|
||||
case RewindState::Started:
|
||||
|
@ -62,8 +63,8 @@ void RewindManager::ProcessNotification(ConsoleNotificationType type, void * par
|
|||
}
|
||||
_historyBackup.clear();
|
||||
_rewindState = RewindState::Stopped;
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Rewind);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::Rewind);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -79,7 +80,7 @@ void RewindManager::ProcessNotification(ConsoleNotificationType type, void * par
|
|||
|
||||
void RewindManager::AddHistoryBlock()
|
||||
{
|
||||
uint32_t maxHistorySize = EmulationSettings::GetRewindBufferSize() * 120;
|
||||
uint32_t maxHistorySize = _settings->GetRewindBufferSize() * 120;
|
||||
if(maxHistorySize > 0) {
|
||||
while(_history.size() > maxHistorySize) {
|
||||
_history.pop_front();
|
||||
|
@ -114,7 +115,7 @@ void RewindManager::PopHistory()
|
|||
|
||||
void RewindManager::Start(bool forDebugger)
|
||||
{
|
||||
if(_rewindState == RewindState::Stopped && EmulationSettings::GetRewindBufferSize() > 0) {
|
||||
if(_rewindState == RewindState::Stopped && _settings->GetRewindBufferSize() > 0) {
|
||||
_console->Pause();
|
||||
|
||||
_rewindState = forDebugger ? RewindState::Debugging : RewindState::Starting;
|
||||
|
@ -126,8 +127,8 @@ void RewindManager::Start(bool forDebugger)
|
|||
|
||||
PopHistory();
|
||||
_console->GetSoundMixer()->StopAudio(true);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetFlags(EmulationFlags::Rewind);
|
||||
_settings->SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->SetFlags(EmulationFlags::Rewind);
|
||||
|
||||
_console->Resume();
|
||||
}
|
||||
|
@ -143,8 +144,8 @@ void RewindManager::ForceStop()
|
|||
_currentHistory = _historyBackup.front();
|
||||
_historyBackup.clear();
|
||||
_rewindState = RewindState::Stopped;
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Rewind);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::Rewind);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,12 +181,12 @@ void RewindManager::Stop()
|
|||
if(_framesToFastForward > 0) {
|
||||
_rewindState = RewindState::Stopping;
|
||||
_currentHistory.FrameCount = 0;
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
} else {
|
||||
_rewindState = RewindState::Stopped;
|
||||
_historyBackup.clear();
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Rewind);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::Rewind);
|
||||
}
|
||||
|
||||
_videoHistoryBuilder.clear();
|
||||
|
@ -231,7 +232,7 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he
|
|||
|
||||
if(_rewindState == RewindState::Started || _videoHistory.size() >= RewindManager::BufferSize) {
|
||||
_rewindState = RewindState::Started;
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
_settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
if(!_videoHistory.empty()) {
|
||||
_console->GetVideoRenderer()->UpdateFrame(_videoHistory.back().data(), width, height);
|
||||
_videoHistory.pop_back();
|
||||
|
@ -270,7 +271,7 @@ bool RewindManager::ProcessAudio(int16_t * soundBuffer, uint32_t sampleCount, ui
|
|||
|
||||
void RewindManager::RecordInput(vector<shared_ptr<BaseControlDevice>> devices)
|
||||
{
|
||||
if(EmulationSettings::GetRewindBufferSize() > 0 && _rewindState == RewindState::Stopped) {
|
||||
if(_settings->GetRewindBufferSize() > 0 && _rewindState == RewindState::Stopped) {
|
||||
for(shared_ptr<BaseControlDevice> &device : devices) {
|
||||
_currentHistory.InputLogs[device->GetPort()].push_back(device->GetRawState());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ private:
|
|||
static constexpr int32_t BufferSize = 30; //Number of frames between each save state
|
||||
|
||||
shared_ptr<Console> _console;
|
||||
EmulationSettings* _settings;
|
||||
|
||||
std::deque<RewindData> _history;
|
||||
std::deque<RewindData> _historyBackup;
|
||||
|
|
|
@ -66,6 +66,7 @@ struct RomInfo
|
|||
RomFormat Format;
|
||||
|
||||
bool IsNes20Header = false;
|
||||
bool IsInDatabase = false;
|
||||
|
||||
uint16_t MapperID = 0;
|
||||
uint8_t SubMapperID = 0;
|
||||
|
|
|
@ -161,7 +161,7 @@ bool SaveStateManager::LoadState(istream &stream, bool hashCheckRequired)
|
|||
bool gameLoaded = !romInfo.Hash.Sha1.empty();
|
||||
if(romInfo.Hash.Sha1 != string(hash)) {
|
||||
//CRC doesn't match
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::AllowMismatchingSaveState) || !gameLoaded ||
|
||||
if(!_console->GetSettings()->CheckFlag(EmulationFlags::AllowMismatchingSaveState) || !gameLoaded ||
|
||||
romInfo.MapperID != mapperId || romInfo.SubMapperID != subMapperId)
|
||||
{
|
||||
//If mismatching states aren't allowed, or a game isn't loaded, or the mapper types don't match, try to find and load the matching ROM
|
||||
|
@ -222,7 +222,7 @@ bool SaveStateManager::LoadState(int stateIndex)
|
|||
|
||||
void SaveStateManager::SaveRecentGame(string romName, string romPath, string patchPath)
|
||||
{
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::ConsoleMode) && !EmulationSettings::CheckFlag(EmulationFlags::DisableGameSelectionScreen) && _console->GetRomInfo().Format != RomFormat::Nsf) {
|
||||
if(!_console->GetSettings()->CheckFlag(EmulationFlags::ConsoleMode) && !_console->GetSettings()->CheckFlag(EmulationFlags::DisableGameSelectionScreen) && _console->GetRomInfo().Format != RomFormat::Nsf) {
|
||||
string filename = FolderUtilities::GetFilename(_console->GetRomInfo().RomName, false) + ".rgd";
|
||||
ZipWriter writer;
|
||||
writer.Initialize(FolderUtilities::CombinePath(FolderUtilities::GetRecentGamesFolder(), filename));
|
||||
|
|
|
@ -62,7 +62,7 @@ void ScaleFilter::UpdateOutputBuffer(uint32_t width, uint32_t height)
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t* ScaleFilter::ApplyFilter(uint32_t *inputArgbBuffer, uint32_t width, uint32_t height)
|
||||
uint32_t* ScaleFilter::ApplyFilter(uint32_t *inputArgbBuffer, uint32_t width, uint32_t height, double scanlineIntensity)
|
||||
{
|
||||
UpdateOutputBuffer(width, height);
|
||||
|
||||
|
@ -82,7 +82,8 @@ uint32_t* ScaleFilter::ApplyFilter(uint32_t *inputArgbBuffer, uint32_t width, ui
|
|||
ApplyPrescaleFilter(inputArgbBuffer);
|
||||
}
|
||||
|
||||
double scanlineIntensity = 1.0 - EmulationSettings::GetPictureSettings().ScanlineIntensity;
|
||||
scanlineIntensity = 1.0 - scanlineIntensity;
|
||||
|
||||
if(scanlineIntensity < 1.0) {
|
||||
for(int y = 1, yMax = height * _filterScale; y < yMax; y += 2) {
|
||||
for(int x = 0, xMax = width * _filterScale; x < xMax; x++) {
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
~ScaleFilter();
|
||||
|
||||
uint32_t GetScale();
|
||||
uint32_t* ApplyFilter(uint32_t *inputArgbBuffer, uint32_t width, uint32_t height);
|
||||
uint32_t* ApplyFilter(uint32_t *inputArgbBuffer, uint32_t width, uint32_t height, double scanlineIntensity);
|
||||
FrameInfo GetFrameInfo(FrameInfo baseFrameInfo);
|
||||
|
||||
static shared_ptr<ScaleFilter> GetScaleFilter(VideoFilterType filter);
|
||||
|
|
|
@ -38,8 +38,8 @@ ShortcutKeyHandler::~ShortcutKeyHandler()
|
|||
|
||||
bool ShortcutKeyHandler::IsKeyPressed(EmulatorShortcut shortcut)
|
||||
{
|
||||
KeyCombination keyComb = EmulationSettings::GetShortcutKey(shortcut, _keySetIndex);
|
||||
vector<KeyCombination> supersets = EmulationSettings::GetShortcutSupersets(shortcut, _keySetIndex);
|
||||
KeyCombination keyComb = _console->GetSettings()->GetShortcutKey(shortcut, _keySetIndex);
|
||||
vector<KeyCombination> supersets = _console->GetSettings()->GetShortcutSupersets(shortcut, _keySetIndex);
|
||||
for(KeyCombination &superset : supersets) {
|
||||
if(IsKeyPressed(superset)) {
|
||||
//A superset is pressed, ignore this subset
|
||||
|
@ -98,21 +98,22 @@ bool ShortcutKeyHandler::DetectKeyRelease(EmulatorShortcut shortcut)
|
|||
|
||||
void ShortcutKeyHandler::CheckMappedKeys()
|
||||
{
|
||||
EmulationSettings* settings = _console->GetSettings();
|
||||
bool isNetplayClient = GameClient::Connected();
|
||||
bool isMovieActive = MovieManager::Playing() || MovieManager::Recording();
|
||||
|
||||
_keyboardMode = false;
|
||||
if(DetectKeyPress(EmulatorShortcut::ToggleKeyboardMode)) {
|
||||
if(EmulationSettings::IsKeyboardMode()) {
|
||||
EmulationSettings::DisableKeyboardMode();
|
||||
if(settings->IsKeyboardMode()) {
|
||||
settings->DisableKeyboardMode();
|
||||
} else {
|
||||
ControlManager* controlManager = _console->GetControlManager();
|
||||
if(controlManager && controlManager->HasKeyboard()) {
|
||||
EmulationSettings::EnableKeyboardMode();
|
||||
settings->EnableKeyboardMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
_keyboardMode = EmulationSettings::IsKeyboardMode();
|
||||
_keyboardMode = settings->IsKeyboardMode();
|
||||
|
||||
//Let the UI handle these shortcuts
|
||||
for(uint64_t i = (uint64_t)EmulatorShortcut::SwitchDiskSide; i < (uint64_t)EmulatorShortcut::ShortcutCount; i++) {
|
||||
|
@ -123,16 +124,16 @@ void ShortcutKeyHandler::CheckMappedKeys()
|
|||
}
|
||||
|
||||
if(DetectKeyPress(EmulatorShortcut::FastForward)) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Turbo);
|
||||
settings->SetFlags(EmulationFlags::Turbo);
|
||||
} else if(DetectKeyRelease(EmulatorShortcut::FastForward)) {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Turbo);
|
||||
settings->ClearFlags(EmulationFlags::Turbo);
|
||||
}
|
||||
|
||||
if(DetectKeyPress(EmulatorShortcut::ToggleFastForward)) {
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::Turbo)) {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Turbo);
|
||||
if(settings->CheckFlag(EmulationFlags::Turbo)) {
|
||||
settings->ClearFlags(EmulationFlags::Turbo);
|
||||
} else {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Turbo);
|
||||
settings->SetFlags(EmulationFlags::Turbo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,49 +185,51 @@ void ShortcutKeyHandler::CheckMappedKeys()
|
|||
}
|
||||
|
||||
if(DetectKeyPress(EmulatorShortcut::RunSingleFrame)) {
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
if(settings->CheckFlag(EmulationFlags::DebuggerWindowEnabled)) {
|
||||
shared_ptr<Debugger> debugger = _console->GetDebugger(false);
|
||||
if(debugger) {
|
||||
debugger->BreakOnScanline(241);
|
||||
}
|
||||
} else {
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::Paused)) {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::Paused);
|
||||
if(settings->CheckFlag(EmulationFlags::Paused)) {
|
||||
settings->ClearFlags(EmulationFlags::Paused);
|
||||
_console->Pause();
|
||||
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(50));
|
||||
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
||||
settings->SetFlags(EmulationFlags::Paused);
|
||||
_console->Resume();
|
||||
} else {
|
||||
EmulationSettings::SetFlags(EmulationFlags::Paused);
|
||||
settings->SetFlags(EmulationFlags::Paused);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isNetplayClient && !MovieManager::Recording() && !EmulationSettings::CheckFlag(NsfPlayerEnabled)) {
|
||||
if(!isNetplayClient && !MovieManager::Recording() && !settings->CheckFlag(NsfPlayerEnabled)) {
|
||||
RewindManager* rewindManager = _console->GetRewindManager();
|
||||
if(DetectKeyPress(EmulatorShortcut::ToggleRewind)) {
|
||||
if(rewindManager->IsRewinding()) {
|
||||
rewindManager->StopRewinding();
|
||||
} else {
|
||||
rewindManager->StartRewinding();
|
||||
if(rewindManager) {
|
||||
if(DetectKeyPress(EmulatorShortcut::ToggleRewind)) {
|
||||
if(rewindManager->IsRewinding()) {
|
||||
rewindManager->StopRewinding();
|
||||
} else {
|
||||
rewindManager->StartRewinding();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(DetectKeyPress(EmulatorShortcut::Rewind)) {
|
||||
rewindManager->StartRewinding();
|
||||
} else if(DetectKeyRelease(EmulatorShortcut::Rewind)) {
|
||||
rewindManager->StopRewinding();
|
||||
} else if(DetectKeyPress(EmulatorShortcut::RewindTenSecs)) {
|
||||
rewindManager->RewindSeconds(10);
|
||||
} else if(DetectKeyPress(EmulatorShortcut::RewindOneMin)) {
|
||||
rewindManager->RewindSeconds(60);
|
||||
if(DetectKeyPress(EmulatorShortcut::Rewind)) {
|
||||
rewindManager->StartRewinding();
|
||||
} else if(DetectKeyRelease(EmulatorShortcut::Rewind)) {
|
||||
rewindManager->StopRewinding();
|
||||
} else if(DetectKeyPress(EmulatorShortcut::RewindTenSecs)) {
|
||||
rewindManager->RewindSeconds(10);
|
||||
} else if(DetectKeyPress(EmulatorShortcut::RewindOneMin)) {
|
||||
rewindManager->RewindSeconds(60);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutKeyHandler::ProcessKeys()
|
||||
{
|
||||
if(!EmulationSettings::InputEnabled()) {
|
||||
if(!_console->GetSettings()->InputEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
SnesController(uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(port, keyMappings)
|
||||
SnesController(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(console, port, keyMappings)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "BaseControlDevice.h"
|
||||
#include "IKeyManager.h"
|
||||
#include "KeyManager.h"
|
||||
#include "Console.h"
|
||||
#include "EmulationSettings.h"
|
||||
|
||||
class SnesMouse : public BaseControlDevice
|
||||
{
|
||||
|
@ -30,11 +32,11 @@ protected:
|
|||
{
|
||||
SetPressedState(Buttons::Left, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
|
||||
SetPressedState(Buttons::Right, KeyManager::IsMouseButtonPressed(MouseButton::RightButton));
|
||||
SetMovement(KeyManager::GetMouseMovement(EmulationSettings::GetMouseSensitivity(MouseDevice::SnesMouse)));
|
||||
SetMovement(KeyManager::GetMouseMovement(_console->GetSettings()->GetMouseSensitivity(MouseDevice::SnesMouse)));
|
||||
}
|
||||
|
||||
public:
|
||||
SnesMouse(uint8_t port) : BaseControlDevice(port)
|
||||
SnesMouse(shared_ptr<Console> console, uint8_t port) : BaseControlDevice(console, port)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,13 @@ SoundMixer::SoundMixer(shared_ptr<Console> console)
|
|||
{
|
||||
_audioDevice = nullptr;
|
||||
_console = console;
|
||||
_settings = _console->GetSettings();
|
||||
_eqFrequencyGrid.reset(new orfanidis_eq::freq_grid());
|
||||
_oggMixer.reset();
|
||||
_outputBuffer = new int16_t[SoundMixer::MaxSamplesPerFrame];
|
||||
_blipBufLeft = blip_new(SoundMixer::MaxSamplesPerFrame);
|
||||
_blipBufRight = blip_new(SoundMixer::MaxSamplesPerFrame);
|
||||
_sampleRate = EmulationSettings::GetSampleRate();
|
||||
_sampleRate = _settings->GetSampleRate();
|
||||
_model = NesModel::NTSC;
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ void SoundMixer::StopAudio(bool clearBuffer)
|
|||
void SoundMixer::Reset()
|
||||
{
|
||||
if(_oggMixer) {
|
||||
_oggMixer->Reset();
|
||||
_oggMixer->Reset(_settings->GetSampleRate());
|
||||
}
|
||||
_fadeRatio = 1.0;
|
||||
_muteFrameCount = 0;
|
||||
|
@ -113,48 +114,48 @@ void SoundMixer::PlayAudioBuffer(uint32_t time)
|
|||
}
|
||||
|
||||
if(_oggMixer) {
|
||||
_oggMixer->ApplySamples(_outputBuffer, sampleCount);
|
||||
_oggMixer->ApplySamples(_outputBuffer, sampleCount, _settings->GetMasterVolume());
|
||||
}
|
||||
|
||||
if(_console->IsDualSystem()) {
|
||||
if(_console->IsMaster() && EmulationSettings::CheckFlag(EmulationFlags::VsDualMuteMaster)) {
|
||||
if(_console->IsMaster() && _settings->CheckFlag(EmulationFlags::VsDualMuteMaster)) {
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 0);
|
||||
} else if(!_console->IsMaster() && EmulationSettings::CheckFlag(EmulationFlags::VsDualMuteSlave)) {
|
||||
} else if(!_console->IsMaster() && _settings->CheckFlag(EmulationFlags::VsDualMuteSlave)) {
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
RewindManager* rewindManager = _console->GetRewindManager();
|
||||
|
||||
if(!_console->GetVideoRenderer()->IsRecording() && !_waveRecorder && !EmulationSettings::CheckFlag(EmulationFlags::NsfPlayerEnabled)) {
|
||||
if((EmulationSettings::CheckFlag(EmulationFlags::Turbo) || (rewindManager && rewindManager->IsRewinding())) && EmulationSettings::CheckFlag(EmulationFlags::ReduceSoundInFastForward)) {
|
||||
if(!_console->GetVideoRenderer()->IsRecording() && !_waveRecorder && !_settings->CheckFlag(EmulationFlags::NsfPlayerEnabled)) {
|
||||
if((_settings->CheckFlag(EmulationFlags::Turbo) || (rewindManager && rewindManager->IsRewinding())) && _settings->CheckFlag(EmulationFlags::ReduceSoundInFastForward)) {
|
||||
//Reduce volume when fast forwarding or rewinding
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 1.0 - EmulationSettings::GetVolumeReduction());
|
||||
} else if(EmulationSettings::CheckFlag(EmulationFlags::InBackground)) {
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::MuteSoundInBackground)) {
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 1.0 - _settings->GetVolumeReduction());
|
||||
} else if(_settings->CheckFlag(EmulationFlags::InBackground)) {
|
||||
if(_settings->CheckFlag(EmulationFlags::MuteSoundInBackground)) {
|
||||
//Mute sound when in background
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 0);
|
||||
} else if(EmulationSettings::CheckFlag(EmulationFlags::ReduceSoundInBackground)) {
|
||||
} else if(_settings->CheckFlag(EmulationFlags::ReduceSoundInBackground)) {
|
||||
//Apply low pass filter/volume reduction when in background (based on options)
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 1.0 - EmulationSettings::GetVolumeReduction());
|
||||
_lowPassFilter.ApplyFilter(_outputBuffer, sampleCount, 0, 1.0 - _settings->GetVolumeReduction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(EmulationSettings::GetReverbStrength() > 0) {
|
||||
_reverbFilter.ApplyFilter(_outputBuffer, sampleCount, _sampleRate, EmulationSettings::GetReverbStrength(), EmulationSettings::GetReverbDelay());
|
||||
if(_settings->GetReverbStrength() > 0) {
|
||||
_reverbFilter.ApplyFilter(_outputBuffer, sampleCount, _sampleRate, _settings->GetReverbStrength(), _settings->GetReverbDelay());
|
||||
} else {
|
||||
_reverbFilter.ResetFilter();
|
||||
}
|
||||
|
||||
switch(EmulationSettings::GetStereoFilter()) {
|
||||
switch(_settings->GetStereoFilter()) {
|
||||
case StereoFilter::None: break;
|
||||
case StereoFilter::Delay: _stereoDelay.ApplyFilter(_outputBuffer, sampleCount, _sampleRate); break;
|
||||
case StereoFilter::Panning: _stereoPanning.ApplyFilter(_outputBuffer, sampleCount); break;
|
||||
case StereoFilter::Delay: _stereoDelay.ApplyFilter(_outputBuffer, sampleCount, _sampleRate, _settings->GetStereoDelay()); break;
|
||||
case StereoFilter::Panning: _stereoPanning.ApplyFilter(_outputBuffer, sampleCount, _settings->GetStereoPanningAngle()); break;
|
||||
}
|
||||
|
||||
if(EmulationSettings::GetCrossFeedRatio() > 0) {
|
||||
_crossFeedFilter.ApplyFilter(_outputBuffer, sampleCount, EmulationSettings::GetCrossFeedRatio());
|
||||
if(_settings->GetCrossFeedRatio() > 0) {
|
||||
_crossFeedFilter.ApplyFilter(_outputBuffer, sampleCount, _settings->GetCrossFeedRatio());
|
||||
}
|
||||
|
||||
if(rewindManager && rewindManager->SendAudio(_outputBuffer, (uint32_t)sampleCount, _sampleRate)) {
|
||||
|
@ -169,15 +170,15 @@ void SoundMixer::PlayAudioBuffer(uint32_t time)
|
|||
|
||||
_console->GetVideoRenderer()->AddRecordingSound(_outputBuffer, (uint32_t)sampleCount, _sampleRate);
|
||||
|
||||
if(_audioDevice && !EmulationSettings::IsPaused()) {
|
||||
if(_audioDevice && !_console->IsPaused()) {
|
||||
_audioDevice->PlayBuffer(_outputBuffer, (uint32_t)sampleCount, _sampleRate, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(EmulationSettings::NeedAudioSettingsUpdate()) {
|
||||
if(EmulationSettings::GetSampleRate() != _sampleRate) {
|
||||
if(_settings->NeedAudioSettingsUpdate()) {
|
||||
if(_settings->GetSampleRate() != _sampleRate) {
|
||||
//Update sample rate for next frame if setting changed
|
||||
_sampleRate = EmulationSettings::GetSampleRate();
|
||||
_sampleRate = _settings->GetSampleRate();
|
||||
UpdateRates(true);
|
||||
UpdateEqualizers(true);
|
||||
} else {
|
||||
|
@ -198,11 +199,11 @@ void SoundMixer::SetNesModel(NesModel model)
|
|||
void SoundMixer::UpdateRates(bool forceUpdate)
|
||||
{
|
||||
uint32_t newRate = _console->GetCpu()->GetClockRate(_model);
|
||||
if(!EmulationSettings::GetOverclockAdjustApu()) {
|
||||
newRate = (uint32_t)(newRate * (double)EmulationSettings::GetOverclockRate() / 100);
|
||||
if(!_settings->GetOverclockAdjustApu()) {
|
||||
newRate = (uint32_t)(newRate * (double)_settings->GetOverclockRate() / 100);
|
||||
}
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode)) {
|
||||
if(_settings->CheckFlag(EmulationFlags::IntegerFpsMode)) {
|
||||
//Adjust sample rate when running at 60.0 fps instead of 60.1
|
||||
if(_model == NesModel::NTSC) {
|
||||
newRate = (uint32_t)(newRate * 60.0 / 60.0988118623484);
|
||||
|
@ -212,9 +213,9 @@ void SoundMixer::UpdateRates(bool forceUpdate)
|
|||
}
|
||||
|
||||
AudioStatistics stats = GetStatistics();
|
||||
int32_t requestedLatency = (int32_t)EmulationSettings::GetAudioLatency();
|
||||
int32_t requestedLatency = (int32_t)_settings->GetAudioLatency();
|
||||
double targetRate = _sampleRate;
|
||||
if(stats.AverageLatency > 0 && EmulationSettings::GetEmulationSpeed() == 100) {
|
||||
if(stats.AverageLatency > 0 && _settings->GetEmulationSpeed() == 100) {
|
||||
if(stats.AverageLatency > requestedLatency + 2) {
|
||||
targetRate *= 1.005;
|
||||
} else if(stats.AverageLatency < requestedLatency - 2) {
|
||||
|
@ -233,8 +234,8 @@ void SoundMixer::UpdateRates(bool forceUpdate)
|
|||
|
||||
bool hasPanning = false;
|
||||
for(uint32_t i = 0; i < MaxChannelCount; i++) {
|
||||
_volumes[i] = EmulationSettings::GetChannelVolume((AudioChannel)i);
|
||||
_panning[i] = EmulationSettings::GetChannelPanning((AudioChannel)i);
|
||||
_volumes[i] = _settings->GetChannelVolume((AudioChannel)i);
|
||||
_panning[i] = _settings->GetChannelPanning((AudioChannel)i);
|
||||
if(_panning[i] != 1.0) {
|
||||
if(!_hasPanning) {
|
||||
blip_clear(_blipBufLeft);
|
||||
|
@ -282,7 +283,7 @@ void SoundMixer::AddDelta(AudioChannel channel, uint32_t time, int16_t delta)
|
|||
|
||||
void SoundMixer::EndFrame(uint32_t time)
|
||||
{
|
||||
double masterVolume = EmulationSettings::GetMasterVolume() * _fadeRatio;
|
||||
double masterVolume = _settings->GetMasterVolume() * _fadeRatio;
|
||||
sort(_timestamps.begin(), _timestamps.end());
|
||||
_timestamps.erase(std::unique(_timestamps.begin(), _timestamps.end()), _timestamps.end());
|
||||
|
||||
|
@ -340,10 +341,10 @@ void SoundMixer::ApplyEqualizer(orfanidis_eq::eq1* equalizer, size_t sampleCount
|
|||
|
||||
void SoundMixer::UpdateEqualizers(bool forceUpdate)
|
||||
{
|
||||
EqualizerFilterType type = EmulationSettings::GetEqualizerFilterType();
|
||||
EqualizerFilterType type = _settings->GetEqualizerFilterType();
|
||||
if(type != EqualizerFilterType::None) {
|
||||
vector<double> bands = EmulationSettings::GetEqualizerBands();
|
||||
vector<double> bandGains = EmulationSettings::GetBandGains();
|
||||
vector<double> bands = _settings->GetEqualizerBands();
|
||||
vector<double> bandGains = _settings->GetBandGains();
|
||||
|
||||
if(bands.size() != _eqFrequencyGrid->get_number_of_bands()) {
|
||||
_equalizerLeft.reset();
|
||||
|
@ -358,8 +359,8 @@ void SoundMixer::UpdateEqualizers(bool forceUpdate)
|
|||
_eqFrequencyGrid->add_band((bands[i] + bands[i - 1]) / 2, bands[i], (bands[i + 1] + bands[i]) / 2);
|
||||
}
|
||||
|
||||
_equalizerLeft.reset(new orfanidis_eq::eq1(_eqFrequencyGrid.get(), (orfanidis_eq::filter_type)EmulationSettings::GetEqualizerFilterType()));
|
||||
_equalizerRight.reset(new orfanidis_eq::eq1(_eqFrequencyGrid.get(), (orfanidis_eq::filter_type)EmulationSettings::GetEqualizerFilterType()));
|
||||
_equalizerLeft.reset(new orfanidis_eq::eq1(_eqFrequencyGrid.get(), (orfanidis_eq::filter_type)_settings->GetEqualizerFilterType()));
|
||||
_equalizerRight.reset(new orfanidis_eq::eq1(_eqFrequencyGrid.get(), (orfanidis_eq::filter_type)_settings->GetEqualizerFilterType()));
|
||||
_equalizerLeft->set_sample_rate(_sampleRate);
|
||||
_equalizerRight->set_sample_rate(_sampleRate);
|
||||
}
|
||||
|
@ -377,7 +378,7 @@ void SoundMixer::UpdateEqualizers(bool forceUpdate)
|
|||
void SoundMixer::StartRecording(string filepath)
|
||||
{
|
||||
auto lock = _waveRecorderLock.AcquireSafe();
|
||||
_waveRecorder.reset(new WaveRecorder(filepath, EmulationSettings::GetSampleRate(), true));
|
||||
_waveRecorder.reset(new WaveRecorder(filepath, _settings->GetSampleRate(), true));
|
||||
}
|
||||
|
||||
void SoundMixer::StopRecording()
|
||||
|
@ -410,6 +411,7 @@ OggMixer* SoundMixer::GetOggMixer()
|
|||
{
|
||||
if(!_oggMixer) {
|
||||
_oggMixer.reset(new OggMixer());
|
||||
_oggMixer->Reset(_settings->GetSampleRate());
|
||||
}
|
||||
return _oggMixer.get();
|
||||
}
|
||||
|
@ -433,8 +435,8 @@ void SoundMixer::ProcessEndOfFrame()
|
|||
void SoundMixer::UpdateTargetSampleRate()
|
||||
{
|
||||
AudioStatistics stats = GetStatistics();
|
||||
if(stats.AverageLatency > 0 && EmulationSettings::GetEmulationSpeed() == 100) {
|
||||
int32_t requestedLatency = (int32_t)EmulationSettings::GetAudioLatency();
|
||||
if(stats.AverageLatency > 0 && _settings->GetEmulationSpeed() == 100) {
|
||||
int32_t requestedLatency = (int32_t)_settings->GetAudioLatency();
|
||||
double targetRate = _sampleRate;
|
||||
|
||||
//Try to stay within +/- 2ms of requested latency
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
static constexpr uint32_t MaxChannelCount = 11;
|
||||
|
||||
IAudioDevice* _audioDevice;
|
||||
EmulationSettings* _settings;
|
||||
unique_ptr<WaveRecorder> _waveRecorder;
|
||||
SimpleLock _waveRecorderLock;
|
||||
double _fadeRatio;
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
InitializeEnvelope(value);
|
||||
|
||||
_duty = (value & 0xC0) >> 6;
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::SwapDutyCycles)) {
|
||||
if(_console->GetSettings()->CheckFlag(EmulationFlags::SwapDutyCycles)) {
|
||||
_duty = ((_duty & 0x02) >> 1) | ((_duty & 0x01) << 1);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
class StandardController : public BaseControlDevice
|
||||
{
|
||||
private:
|
||||
shared_ptr<Console> _console;
|
||||
bool _microphoneEnabled = false;
|
||||
uint32_t _turboSpeed = 0;
|
||||
|
||||
|
@ -51,7 +50,7 @@ protected:
|
|||
SetPressedState(Buttons::Microphone, keyMapping.Microphone);
|
||||
}
|
||||
|
||||
if(!EmulationSettings::CheckFlag(EmulationFlags::AllowInvalidInput)) {
|
||||
if(!_console->GetSettings()->CheckFlag(EmulationFlags::AllowInvalidInput)) {
|
||||
if(IsPressed(Buttons::Up) && IsPressed(Buttons::Down)) {
|
||||
ClearBit(Buttons::Down);
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ protected:
|
|||
|
||||
void RefreshStateBuffer() override
|
||||
{
|
||||
if(EmulationSettings::GetConsoleType() == ConsoleType::Nes && EmulationSettings::CheckFlag(EmulationFlags::HasFourScore)) {
|
||||
if(_console->GetSettings()->GetConsoleType() == ConsoleType::Nes && _console->GetSettings()->CheckFlag(EmulationFlags::HasFourScore)) {
|
||||
if(_port >= 2) {
|
||||
_stateBuffer = ToByte() << 8;
|
||||
} else {
|
||||
|
@ -79,11 +78,10 @@ protected:
|
|||
public:
|
||||
enum Buttons { Up = 0, Down, Left, Right, Start, Select, B, A, Microphone };
|
||||
|
||||
StandardController(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(port, keyMappings)
|
||||
StandardController(shared_ptr<Console> console, uint8_t port, KeyMappingSet keyMappings) : BaseControlDevice(console, port, keyMappings)
|
||||
{
|
||||
_console = console;
|
||||
_turboSpeed = keyMappings.TurboSpeed;
|
||||
_microphoneEnabled = port == 1 && EmulationSettings::GetConsoleType() == ConsoleType::Famicom;
|
||||
_microphoneEnabled = port == 1 && _console->GetSettings()->GetConsoleType() == ConsoleType::Famicom;
|
||||
}
|
||||
|
||||
uint8_t ToByte()
|
||||
|
@ -111,7 +109,7 @@ public:
|
|||
|
||||
if((addr == 0x4016 && (_port & 0x01) == 0) || (addr == 0x4017 && (_port & 0x01) == 1)) {
|
||||
output = _stateBuffer & 0x01;
|
||||
if(_port >= 2 && EmulationSettings::GetConsoleType() == ConsoleType::Famicom) {
|
||||
if(_port >= 2 && _console->GetSettings()->GetConsoleType() == ConsoleType::Famicom) {
|
||||
//Famicom outputs P3 & P4 on bit 1
|
||||
output <<= 1;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue