Linux: Fixed Linux compilation errors/warnings (due to refactoring)

This commit is contained in:
Sour 2018-07-02 19:01:10 -04:00
parent 97270f2b2e
commit 1489868a3f
13 changed files with 39 additions and 24 deletions

View file

@ -17,7 +17,7 @@ private:
public: public:
AutomaticRomTest(); AutomaticRomTest();
~AutomaticRomTest(); virtual ~AutomaticRomTest();
void ProcessNotification(ConsoleNotificationType type, void* parameter) override; void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
int32_t Run(string filename); int32_t Run(string filename);

View file

@ -150,7 +150,7 @@ bool Console::LoadMatchingRom(string romName, HashInfo hashInfo)
if(!match.empty()) { if(!match.empty()) {
return Initialize(match); return Initialize(match);
} }
return nullptr; return false;
} }
string Console::FindMatchingRom(string romName, HashInfo hashInfo) string Console::FindMatchingRom(string romName, HashInfo hashInfo)

View file

@ -1,6 +1,4 @@
#include "stdafx.h" #include "stdafx.h"
#include <algorithm>
#include "MessageManager.h" #include "MessageManager.h"
#include "EmulationSettings.h" #include "EmulationSettings.h"

View file

@ -3,7 +3,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "IMessageManager.h" #include "IMessageManager.h"
#include "INotificationListener.h"
#include <unordered_map> #include <unordered_map>
#include "../Utilities/SimpleLock.h" #include "../Utilities/SimpleLock.h"

View file

@ -1,4 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <algorithm>
#include "NotificationManager.h" #include "NotificationManager.h"
void NotificationManager::RegisterNotificationListener(shared_ptr<INotificationListener> notificationListener) void NotificationManager::RegisterNotificationListener(shared_ptr<INotificationListener> notificationListener)

View file

@ -60,9 +60,10 @@ bool SaveStateManager::LoadState()
void SaveStateManager::SaveState(ostream &stream) void SaveStateManager::SaveState(ostream &stream)
{ {
uint32_t emuVersion = EmulationSettings::GetMesenVersion(); uint32_t emuVersion = EmulationSettings::GetMesenVersion();
uint32_t formatVersion = SaveStateManager::FileFormatVersion;
stream.write("MST", 3); stream.write("MST", 3);
stream.write((char*)&emuVersion, sizeof(emuVersion)); stream.write((char*)&emuVersion, sizeof(emuVersion));
stream.write((char*)&SaveStateManager::FileFormatVersion, sizeof(uint32_t)); stream.write((char*)&formatVersion, sizeof(uint32_t));
MapperInfo mapperInfo = _console->GetMapperInfo(); MapperInfo mapperInfo = _console->GetMapperInfo();
stream.write((char*)&mapperInfo.MapperId, sizeof(uint16_t)); stream.write((char*)&mapperInfo.MapperId, sizeof(uint16_t));

View file

@ -66,6 +66,10 @@ namespace InteropEmu {
{ {
_callback = callback; _callback = callback;
} }
virtual ~InteropNotificationListener()
{
}
void ProcessNotification(ConsoleNotificationType type, void* parameter) void ProcessNotification(ConsoleNotificationType type, void* parameter)
{ {
@ -107,7 +111,7 @@ namespace InteropEmu {
#ifdef _WIN32 #ifdef _WIN32
_renderer = new Renderer(_console, (HWND)_viewerHandle); _renderer = new Renderer(_console, (HWND)_viewerHandle);
#else #else
_renderer = new SdlRenderer(_viewerHandle); _renderer = new SdlRenderer(_console, _viewerHandle);
#endif #endif
} }
@ -115,7 +119,7 @@ namespace InteropEmu {
#ifdef _WIN32 #ifdef _WIN32
_soundManager = new SoundManager(_console, (HWND)_windowHandle); _soundManager = new SoundManager(_console, (HWND)_windowHandle);
#else #else
_soundManager = new SdlSoundManager(); _soundManager = new SdlSoundManager(_console);
#endif #endif
} }
@ -123,7 +127,7 @@ namespace InteropEmu {
#ifdef _WIN32 #ifdef _WIN32
_keyManager = new WindowsKeyManager(_console, (HWND)_windowHandle); _keyManager = new WindowsKeyManager(_console, (HWND)_windowHandle);
#else #else
_keyManager = new LinuxKeyManager(); _keyManager = new LinuxKeyManager(_console);
#endif #endif
KeyManager::RegisterKeyManager(_keyManager); KeyManager::RegisterKeyManager(_keyManager);

View file

@ -227,8 +227,10 @@ static vector<KeyDefinition> _keyDefinitions = {
{ "", 246, "XF86WLAN", "" }, { "", 246, "XF86WLAN", "" },
}; };
LinuxKeyManager::LinuxKeyManager() LinuxKeyManager::LinuxKeyManager(shared_ptr<Console> console)
{ {
_console = console;
ResetKeyState(); ResetKeyState();
vector<string> buttonNames = { vector<string> buttonNames = {
@ -378,14 +380,14 @@ void LinuxKeyManager::StartUpdateDeviceThread()
} }
if(!indexesToRemove.empty() || !controllersToAdd.empty()) { if(!indexesToRemove.empty() || !controllersToAdd.empty()) {
Console::Pause(); _console->Pause();
for(int index : indexesToRemove) { for(int index : indexesToRemove) {
_controllers.erase(_controllers.begin()+index); _controllers.erase(_controllers.begin()+index);
} }
for(std::shared_ptr<LinuxGameController> controller : controllersToAdd) { for(std::shared_ptr<LinuxGameController> controller : controllersToAdd) {
_controllers.push_back(controller); _controllers.push_back(controller);
} }
Console::Resume(); _console->Resume();
} }
_stopSignal.Wait(2000); _stopSignal.Wait(2000);

View file

@ -6,6 +6,7 @@
#include "../Utilities/AutoResetEvent.h" #include "../Utilities/AutoResetEvent.h"
class LinuxGameController; class LinuxGameController;
class Console;
struct KeyDefinition { struct KeyDefinition {
string name; string name;
@ -17,6 +18,7 @@ struct KeyDefinition {
class LinuxKeyManager : public IKeyManager class LinuxKeyManager : public IKeyManager
{ {
private: private:
shared_ptr<Console> _console;
std::vector<shared_ptr<LinuxGameController>> _controllers; std::vector<shared_ptr<LinuxGameController>> _controllers;
bool _keyState[0x200]; bool _keyState[0x200];
bool _mouseState[0x03]; bool _mouseState[0x03];
@ -31,7 +33,7 @@ private:
void StartUpdateDeviceThread(); void StartUpdateDeviceThread();
public: public:
LinuxKeyManager(); LinuxKeyManager(shared_ptr<Console> console);
virtual ~LinuxKeyManager(); virtual ~LinuxKeyManager();
void RefreshState(); void RefreshState();

View file

@ -5,7 +5,7 @@
#include "../Core/VideoDecoder.h" #include "../Core/VideoDecoder.h"
#include "../Core/EmulationSettings.h" #include "../Core/EmulationSettings.h"
SdlRenderer::SdlRenderer(void* windowHandle) : _windowHandle(windowHandle) SdlRenderer::SdlRenderer(shared_ptr<Console> console, void* windowHandle) : BaseRenderer(console), _windowHandle(windowHandle)
{ {
_frameBuffer = nullptr; _frameBuffer = nullptr;
SetScreenSize(256,240); SetScreenSize(256,240);
@ -14,7 +14,7 @@ SdlRenderer::SdlRenderer(void* windowHandle) : _windowHandle(windowHandle)
SdlRenderer::~SdlRenderer() SdlRenderer::~SdlRenderer()
{ {
VideoRenderer::GetInstance()->UnregisterRenderingDevice(this); _console->GetVideoRenderer()->UnregisterRenderingDevice(this);
Cleanup(); Cleanup();
} }
@ -99,7 +99,7 @@ void SdlRenderer::Reset()
{ {
Cleanup(); Cleanup();
if(Init()) { if(Init()) {
VideoRenderer::GetInstance()->RegisterRenderingDevice(this); _console->GetVideoRenderer()->RegisterRenderingDevice(this);
} else { } else {
Cleanup(); Cleanup();
} }
@ -108,7 +108,7 @@ void SdlRenderer::Reset()
void SdlRenderer::SetScreenSize(uint32_t width, uint32_t height) void SdlRenderer::SetScreenSize(uint32_t width, uint32_t height)
{ {
ScreenSize screenSize; ScreenSize screenSize;
VideoDecoder::GetInstance()->GetScreenSize(screenSize, false); _console->GetVideoDecoder()->GetScreenSize(screenSize, false);
if(_screenHeight != (uint32_t)screenSize.Height || _screenWidth != (uint32_t)screenSize.Width || _nesFrameHeight != height || _nesFrameWidth != width || _resizeFilter != EmulationSettings::GetVideoResizeFilter() || _vsyncEnabled != EmulationSettings::CheckFlag(EmulationFlags::VerticalSync)) { if(_screenHeight != (uint32_t)screenSize.Height || _screenWidth != (uint32_t)screenSize.Width || _nesFrameHeight != height || _nesFrameWidth != width || _resizeFilter != EmulationSettings::GetVideoResizeFilter() || _vsyncEnabled != EmulationSettings::CheckFlag(EmulationFlags::VerticalSync)) {
_reinitLock.Acquire(); _reinitLock.Acquire();
@ -147,9 +147,9 @@ void SdlRenderer::Render()
return; return;
} }
bool paused = EmulationSettings::IsPaused() && Console::IsRunning(); bool paused = EmulationSettings::IsPaused() && _console->IsRunning();
bool disableOverlay = EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay); bool disableOverlay = EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay);
shared_ptr<Debugger> debugger = Console::GetInstance()->GetDebugger(false); shared_ptr<Debugger> debugger = _console->GetDebugger(false);
if(debugger && debugger->IsExecutionStopped()) { if(debugger && debugger->IsExecutionStopped()) {
paused = debugger->IsPauseIconShown(); paused = debugger->IsPauseIconShown();
disableOverlay = true; disableOverlay = true;
@ -185,7 +185,7 @@ void SdlRenderer::Render()
if(paused && !EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay)) { if(paused && !EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay)) {
DrawPauseScreen(disableOverlay); DrawPauseScreen(disableOverlay);
} else if(VideoDecoder::GetInstance()->IsRunning()) { } else if(_console->GetVideoDecoder()->IsRunning()) {
DrawCounters(); DrawCounters();
} }

View file

@ -21,6 +21,8 @@ struct SDL_Window
}; };
typedef struct SDL_Window SDL_Window; typedef struct SDL_Window SDL_Window;
class Console;
class SdlRenderer : public IRenderingDevice, public BaseRenderer class SdlRenderer : public IRenderingDevice, public BaseRenderer
{ {
private: private:
@ -59,7 +61,7 @@ private:
bool ContainsCharacter(wchar_t character) override; bool ContainsCharacter(wchar_t character) override;
public: public:
SdlRenderer(void* windowHandle); SdlRenderer(shared_ptr<Console> console, void* windowHandle);
virtual ~SdlRenderer(); virtual ~SdlRenderer();
void UpdateFrame(void *frameBuffer, uint32_t width, uint32_t height) override; void UpdateFrame(void *frameBuffer, uint32_t width, uint32_t height) override;

View file

@ -2,11 +2,14 @@
#include "../Core/EmulationSettings.h" #include "../Core/EmulationSettings.h"
#include "../Core/MessageManager.h" #include "../Core/MessageManager.h"
#include "../Core/SoundMixer.h" #include "../Core/SoundMixer.h"
#include "../Core/Console.h"
SdlSoundManager::SdlSoundManager() SdlSoundManager::SdlSoundManager(shared_ptr<Console> console)
{ {
_console = console;
if(InitializeAudio(44100, false)) { if(InitializeAudio(44100, false)) {
SoundMixer::RegisterAudioDevice(this); _console->GetSoundMixer()->RegisterAudioDevice(this);
} }
} }

View file

@ -2,10 +2,12 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "../Core/BaseSoundManager.h" #include "../Core/BaseSoundManager.h"
class Console;
class SdlSoundManager : public BaseSoundManager class SdlSoundManager : public BaseSoundManager
{ {
public: public:
SdlSoundManager(); SdlSoundManager(shared_ptr<Console> console);
~SdlSoundManager(); ~SdlSoundManager();
void PlayBuffer(int16_t *soundBuffer, uint32_t bufferSize, uint32_t sampleRate, bool isStereo); void PlayBuffer(int16_t *soundBuffer, uint32_t bufferSize, uint32_t sampleRate, bool isStereo);
@ -28,6 +30,7 @@ private:
void WriteToBuffer(uint8_t* output, uint32_t len); void WriteToBuffer(uint8_t* output, uint32_t len);
private: private:
shared_ptr<Console> _console;
SDL_AudioDeviceID _audioDeviceID; SDL_AudioDeviceID _audioDeviceID;
string _deviceName; string _deviceName;
bool _needReset = false; bool _needReset = false;