Mesen-X/Core/EmulationSettings.h

193 lines
3 KiB
C
Raw Normal View History

2015-07-17 20:58:57 -04:00
#pragma once
#include "stdafx.h"
#include "MessageManager.h"
2015-07-17 20:58:57 -04:00
enum EmulationFlags
{
Paused = 0x01,
ShowFPS = 0x02,
VerticalSync = 0x04,
LowLatency = 0x08,
Mmc3IrqAltBehavior = 0x8000,
2015-07-17 20:58:57 -04:00
};
enum class AudioChannel
{
Square1 = 0,
Square2 = 1,
Triangle = 2,
Noise = 3,
DMC = 4
};
2015-07-21 23:05:27 -04:00
enum class NesModel
{
Auto = 0,
NTSC = 1,
PAL = 2,
};
enum class VideoFilterType
{
None = 0,
NTSC = 1,
HdPack = 999
};
2015-07-23 23:16:31 -04:00
struct OverscanDimensions
{
uint32_t Left = 0;
uint32_t Right = 0;
uint32_t Top = 0;
uint32_t Bottom = 0;
uint32_t GetPixelCount()
{
return GetScreenWidth() * GetScreenHeight();
}
uint32_t GetScreenWidth()
{
return 256 - Left - Right;
}
uint32_t GetScreenHeight()
{
return 240 - Top - Bottom;
}
};
2015-07-17 20:58:57 -04:00
class EmulationSettings
{
private:
static uint32_t _flags;
static uint32_t _audioLatency;
static double _channelVolume[5];
static double _masterVolume;
static uint32_t _sampleRate;
static NesModel _model;
static uint32_t _emulationSpeed;
static OverscanDimensions _overscan;
static VideoFilterType _videoFilterType;
static uint32_t _videoScale;
2015-07-17 20:58:57 -04:00
public:
static void SetFlags(EmulationFlags flags)
2015-07-17 20:58:57 -04:00
{
_flags |= flags;
2015-07-17 20:58:57 -04:00
}
static void ClearFlags(EmulationFlags flags)
2015-07-17 20:58:57 -04:00
{
_flags &= ~flags;
2015-07-17 20:58:57 -04:00
}
static bool CheckFlag(uint32_t flag)
{
return (_flags & flag) == flag;
2015-07-17 20:58:57 -04:00
}
2015-07-21 23:05:27 -04:00
static void SetNesModel(NesModel model)
{
_model = model;
2015-07-21 23:05:27 -04:00
}
static NesModel GetNesModel()
{
return _model;
2015-07-21 23:05:27 -04:00
}
2015-07-17 20:58:57 -04:00
//0: Muted, 0.5: Default, 1.0: Max volume
static void SetChannelVolume(AudioChannel channel, double volume)
{
_channelVolume[(int)channel] = volume;
2015-07-17 20:58:57 -04:00
}
static void SetMasterVolume(double volume)
{
_masterVolume = volume;
}
static void SetSampleRate(uint32_t sampleRate)
{
_sampleRate = sampleRate;
}
static uint32_t GetSampleRate()
{
return _sampleRate;
}
2015-07-17 20:58:57 -04:00
static void SetAudioLatency(uint32_t msLatency)
{
_audioLatency = msLatency;
2015-07-17 20:58:57 -04:00
}
//0: No limit, Number: % of default speed (50/60fps)
static void SetEmulationSpeed(uint32_t emulationSpeed)
{
_emulationSpeed = emulationSpeed;
}
static uint32_t GetEmulationSpeed()
{
return _emulationSpeed;
}
2015-07-23 23:16:31 -04:00
static void SetOverscanDimensions(uint8_t left, uint8_t right, uint8_t top, uint8_t bottom)
{
_overscan.Left = left;
_overscan.Right = right;
_overscan.Top = top;
_overscan.Bottom = bottom;
2015-07-23 23:16:31 -04:00
}
static OverscanDimensions GetOverscanDimensions()
{
return _overscan;
2015-07-23 23:16:31 -04:00
}
2015-07-17 20:58:57 -04:00
static double GetChannelVolume(AudioChannel channel)
{
return _channelVolume[(int)channel];
}
static double GetMasterVolume()
{
return _masterVolume;
2015-07-17 20:58:57 -04:00
}
static uint32_t GetAudioLatency()
{
return _audioLatency;
}
static void SetVideoFilterType(VideoFilterType videoFilterType)
{
_videoFilterType = videoFilterType;
}
static VideoFilterType GetVideoFilterType()
{
return _videoFilterType;
}
static void SetVideoScale(uint32_t scale)
{
_videoScale = scale;
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
}
static uint32_t GetVideoScale()
{
return _videoScale;
2015-07-17 20:58:57 -04:00
}
};