2 #include "Core/Config.h"
4 #include "DSoundStream.h"
5 #include "WindowsHost.h"
6 #include "WndMainWindow.h"
7 #include "OpenGLBase.h"
9 #include "../Windows/Debugger/Debugger_Disasm.h"
10 #include "../Windows/Debugger/Debugger_MemoryDlg.h"
11 #include "../Core/Debugger/SymbolMap.h"
16 static PMixer
*curMixer
;
18 int MyMix(short *buffer
, int numSamples
, int bits
, int rate
, int channels
)
20 if (curMixer
&& !Core_IsStepping())
21 return curMixer
->Mix(buffer
, numSamples
);
24 memset(buffer
,0,numSamples
*sizeof(short)*2);
29 void WindowsHost::InitGL()
31 GL_Init(MainWindow::GetDisplayHWND());
34 void WindowsHost::ShutdownGL()
39 void WindowsHost::SetWindowTitle(const char *message
)
41 // Really need a better way to deal with versions.
42 std::string title
= PPSSPP_VERSION_STR
" - ";
45 int size
= MultiByteToWideChar(CP_UTF8
, 0, message
, (int) title
.size(), NULL
, 0);
48 wchar_t *utf16_title
= new wchar_t[size
+ 1];
50 size
= MultiByteToWideChar(CP_UTF8
, 0, message
, (int) title
.size(), utf16_title
, size
);
56 utf16_title
[size
] = 0;
57 // Don't use SetWindowTextW because it will internally use DefWindowProcA.
58 DefWindowProcW(mainWindow_
, WM_SETTEXT
, 0, (LPARAM
) utf16_title
);
63 // Something went wrong, fall back to using the local codepage.
65 SetWindowTextA(mainWindow_
, title
.c_str());
68 void WindowsHost::InitSound(PMixer
*mixer
)
71 DSound::DSound_StartSound(MainWindow::GetHWND(), MyMix
);
74 void WindowsHost::UpdateSound()
76 DSound::DSound_UpdateSound();
79 void WindowsHost::ShutdownSound()
81 DSound::DSound_StopSound();
86 void WindowsHost::UpdateUI()
89 MainWindow::UpdateMenus();
93 void WindowsHost::UpdateMemView()
95 for (int i
=0; i
<numCPUs
; i
++)
97 memoryWindow
[i
]->Update();
100 void WindowsHost::UpdateDisassembly()
102 for (int i
=0; i
<numCPUs
; i
++)
104 disasmWindow
[i
]->Update();
107 void WindowsHost::SetDebugMode(bool mode
)
109 for (int i
=0; i
<numCPUs
; i
++)
111 disasmWindow
[i
]->SetDebugMode(mode
);
115 void WindowsHost::BeginFrame()
117 for (auto iter
= this->input
.begin(); iter
!= this->input
.end(); iter
++)
118 if ((*iter
)->UpdateState() == 0)
119 break; // *iter is std::shared_ptr, **iter is InputDevice
122 void WindowsHost::EndFrame()
127 void WindowsHost::BootDone()
129 symbolMap
.SortSymbols();
130 SendMessage(MainWindow::GetHWND(), WM_USER
+1, 0,0);
133 static std::string
SymbolMapFilename(const char *currentFilename
)
135 std::string result
= currentFilename
;
136 size_t dot
= result
.rfind('.');
137 if (dot
== result
.npos
)
138 return result
+ ".map";
140 result
.replace(dot
, result
.npos
, ".map");
144 bool WindowsHost::AttemptLoadSymbolMap()
146 return symbolMap
.LoadSymbolMap(SymbolMapFilename(GetCurrentFilename()).c_str());
149 void WindowsHost::PrepareShutdown()
151 symbolMap
.SaveSymbolMap(SymbolMapFilename(GetCurrentFilename()).c_str());
154 void WindowsHost::AddSymbol(std::string name
, u32 addr
, u32 size
, int type
=0)
156 symbolMap
.AddSymbol(name
.c_str(), addr
, size
, (SymbolType
)type
);
159 bool WindowsHost::IsDebuggingEnabled()