Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 1489868

Browse files
committed
Linux: Fixed Linux compilation errors/warnings (due to refactoring)
1 parent 97270f2 commit 1489868

13 files changed

+39
-24
lines changed

Core/AutomaticRomTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AutomaticRomTest : public INotificationListener, public IInputProvider, pu
1717

1818
public:
1919
AutomaticRomTest();
20-
~AutomaticRomTest();
20+
virtual ~AutomaticRomTest();
2121

2222
void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
2323
int32_t Run(string filename);

Core/Console.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ bool Console::LoadMatchingRom(string romName, HashInfo hashInfo)
150150
if(!match.empty()) {
151151
return Initialize(match);
152152
}
153-
return nullptr;
153+
return false;
154154
}
155155

156156
string Console::FindMatchingRom(string romName, HashInfo hashInfo)

Core/MessageManager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "stdafx.h"
2-
3-
#include <algorithm>
42
#include "MessageManager.h"
53
#include "EmulationSettings.h"
64

Core/MessageManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "stdafx.h"
44

55
#include "IMessageManager.h"
6-
#include "INotificationListener.h"
76
#include <unordered_map>
87
#include "../Utilities/SimpleLock.h"
98

Core/NotificationManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "stdafx.h"
2+
#include <algorithm>
23
#include "NotificationManager.h"
34

45
void NotificationManager::RegisterNotificationListener(shared_ptr<INotificationListener> notificationListener)

Core/SaveStateManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ bool SaveStateManager::LoadState()
6060
void SaveStateManager::SaveState(ostream &stream)
6161
{
6262
uint32_t emuVersion = EmulationSettings::GetMesenVersion();
63+
uint32_t formatVersion = SaveStateManager::FileFormatVersion;
6364
stream.write("MST", 3);
6465
stream.write((char*)&emuVersion, sizeof(emuVersion));
65-
stream.write((char*)&SaveStateManager::FileFormatVersion, sizeof(uint32_t));
66+
stream.write((char*)&formatVersion, sizeof(uint32_t));
6667

6768
MapperInfo mapperInfo = _console->GetMapperInfo();
6869
stream.write((char*)&mapperInfo.MapperId, sizeof(uint16_t));

InteropDLL/ConsoleWrapper.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ namespace InteropEmu {
6666
{
6767
_callback = callback;
6868
}
69+
70+
virtual ~InteropNotificationListener()
71+
{
72+
}
6973

7074
void ProcessNotification(ConsoleNotificationType type, void* parameter)
7175
{
@@ -107,23 +111,23 @@ namespace InteropEmu {
107111
#ifdef _WIN32
108112
_renderer = new Renderer(_console, (HWND)_viewerHandle);
109113
#else
110-
_renderer = new SdlRenderer(_viewerHandle);
114+
_renderer = new SdlRenderer(_console, _viewerHandle);
111115
#endif
112116
}
113117

114118
if(!noAudio) {
115119
#ifdef _WIN32
116120
_soundManager = new SoundManager(_console, (HWND)_windowHandle);
117121
#else
118-
_soundManager = new SdlSoundManager();
122+
_soundManager = new SdlSoundManager(_console);
119123
#endif
120124
}
121125

122126
if(!noInput) {
123127
#ifdef _WIN32
124128
_keyManager = new WindowsKeyManager(_console, (HWND)_windowHandle);
125129
#else
126-
_keyManager = new LinuxKeyManager();
130+
_keyManager = new LinuxKeyManager(_console);
127131
#endif
128132

129133
KeyManager::RegisterKeyManager(_keyManager);

Linux/LinuxKeyManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,10 @@ static vector<KeyDefinition> _keyDefinitions = {
227227
{ "", 246, "XF86WLAN", "" },
228228
};
229229

230-
LinuxKeyManager::LinuxKeyManager()
230+
LinuxKeyManager::LinuxKeyManager(shared_ptr<Console> console)
231231
{
232+
_console = console;
233+
232234
ResetKeyState();
233235

234236
vector<string> buttonNames = {
@@ -378,14 +380,14 @@ void LinuxKeyManager::StartUpdateDeviceThread()
378380
}
379381

380382
if(!indexesToRemove.empty() || !controllersToAdd.empty()) {
381-
Console::Pause();
383+
_console->Pause();
382384
for(int index : indexesToRemove) {
383385
_controllers.erase(_controllers.begin()+index);
384386
}
385387
for(std::shared_ptr<LinuxGameController> controller : controllersToAdd) {
386388
_controllers.push_back(controller);
387389
}
388-
Console::Resume();
390+
_console->Resume();
389391
}
390392

391393
_stopSignal.Wait(2000);

Linux/LinuxKeyManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../Utilities/AutoResetEvent.h"
77

88
class LinuxGameController;
9+
class Console;
910

1011
struct KeyDefinition {
1112
string name;
@@ -17,6 +18,7 @@ struct KeyDefinition {
1718
class LinuxKeyManager : public IKeyManager
1819
{
1920
private:
21+
shared_ptr<Console> _console;
2022
std::vector<shared_ptr<LinuxGameController>> _controllers;
2123
bool _keyState[0x200];
2224
bool _mouseState[0x03];
@@ -31,7 +33,7 @@ class LinuxKeyManager : public IKeyManager
3133
void StartUpdateDeviceThread();
3234

3335
public:
34-
LinuxKeyManager();
36+
LinuxKeyManager(shared_ptr<Console> console);
3537
virtual ~LinuxKeyManager();
3638

3739
void RefreshState();

Linux/SdlRenderer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "../Core/VideoDecoder.h"
66
#include "../Core/EmulationSettings.h"
77

8-
SdlRenderer::SdlRenderer(void* windowHandle) : _windowHandle(windowHandle)
8+
SdlRenderer::SdlRenderer(shared_ptr<Console> console, void* windowHandle) : BaseRenderer(console), _windowHandle(windowHandle)
99
{
1010
_frameBuffer = nullptr;
1111
SetScreenSize(256,240);
@@ -14,7 +14,7 @@ SdlRenderer::SdlRenderer(void* windowHandle) : _windowHandle(windowHandle)
1414

1515
SdlRenderer::~SdlRenderer()
1616
{
17-
VideoRenderer::GetInstance()->UnregisterRenderingDevice(this);
17+
_console->GetVideoRenderer()->UnregisterRenderingDevice(this);
1818
Cleanup();
1919
}
2020

@@ -99,7 +99,7 @@ void SdlRenderer::Reset()
9999
{
100100
Cleanup();
101101
if(Init()) {
102-
VideoRenderer::GetInstance()->RegisterRenderingDevice(this);
102+
_console->GetVideoRenderer()->RegisterRenderingDevice(this);
103103
} else {
104104
Cleanup();
105105
}
@@ -108,7 +108,7 @@ void SdlRenderer::Reset()
108108
void SdlRenderer::SetScreenSize(uint32_t width, uint32_t height)
109109
{
110110
ScreenSize screenSize;
111-
VideoDecoder::GetInstance()->GetScreenSize(screenSize, false);
111+
_console->GetVideoDecoder()->GetScreenSize(screenSize, false);
112112

113113
if(_screenHeight != (uint32_t)screenSize.Height || _screenWidth != (uint32_t)screenSize.Width || _nesFrameHeight != height || _nesFrameWidth != width || _resizeFilter != EmulationSettings::GetVideoResizeFilter() || _vsyncEnabled != EmulationSettings::CheckFlag(EmulationFlags::VerticalSync)) {
114114
_reinitLock.Acquire();
@@ -147,9 +147,9 @@ void SdlRenderer::Render()
147147
return;
148148
}
149149

150-
bool paused = EmulationSettings::IsPaused() && Console::IsRunning();
150+
bool paused = EmulationSettings::IsPaused() && _console->IsRunning();
151151
bool disableOverlay = EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay);
152-
shared_ptr<Debugger> debugger = Console::GetInstance()->GetDebugger(false);
152+
shared_ptr<Debugger> debugger = _console->GetDebugger(false);
153153
if(debugger && debugger->IsExecutionStopped()) {
154154
paused = debugger->IsPauseIconShown();
155155
disableOverlay = true;
@@ -185,7 +185,7 @@ void SdlRenderer::Render()
185185

186186
if(paused && !EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay)) {
187187
DrawPauseScreen(disableOverlay);
188-
} else if(VideoDecoder::GetInstance()->IsRunning()) {
188+
} else if(_console->GetVideoDecoder()->IsRunning()) {
189189
DrawCounters();
190190
}
191191

0 commit comments

Comments
 (0)