1 // Copyright (c) 2014- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
20 #include "Core/Host.h"
22 #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
23 #include "Core/Debugger/SymbolMap.h"
24 #include "Qt/mainwindow.h"
27 // TODO: Get rid of this junk
28 class NativeHost
: public Host
{
33 void UpdateUI() override
{}
35 void UpdateMemView() override
{}
36 void UpdateDisassembly() override
{}
38 void SetDebugMode(bool mode
) override
{ }
40 bool InitGraphics(std::string
*error_message
) override
{ return true; }
41 void ShutdownGraphics() override
{}
43 void InitSound() override
;
44 void UpdateSound() override
{}
45 void ShutdownSound() override
;
47 // this is sent from EMU thread! Make sure that Host handles it properly!
48 void BootDone() override
{}
50 bool IsDebuggingEnabled() override
{return false;}
51 bool AttemptLoadSymbolMap() override
{return false;}
52 void SetWindowTitle(const char *message
) override
{}
55 #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
56 static const char* SymbolMapFilename(std::string currentFilename
)
58 std::string result
= currentFilename
;
59 size_t dot
= result
.rfind('.');
60 if (dot
== result
.npos
)
61 return (result
+ ".map").c_str();
63 result
.replace(dot
, result
.npos
, ".map");
64 return result
.c_str();
67 class QtHost
: public Host
{
69 QtHost(MainWindow
*mainWindow_
)
71 mainWindow
= mainWindow_
;
76 virtual void UpdateUI() override
{
77 mainWindow
->updateMenus();
80 virtual void UpdateMemView() override
{
81 if(mainWindow
->GetDialogMemory())
82 mainWindow
->GetDialogMemory()->Update();
84 virtual void UpdateDisassembly() override
{
85 if(mainWindow
->GetDialogDisasm())
86 mainWindow
->GetDialogDisasm()->Update();
87 if(mainWindow
->GetDialogDisplaylist())
88 mainWindow
->GetDialogDisplaylist()->Update();
91 virtual void SetDebugMode(bool mode
) override
{
92 if(mainWindow
->GetDialogDisasm())
93 mainWindow
->GetDialogDisasm()->SetDebugMode(mode
);
96 virtual bool InitGraphics(std::string
*error_message
) override
{ return true; }
97 virtual void ShutdownGraphics() override
{}
99 virtual void InitSound() override
;
100 virtual void UpdateSound() override
{}
101 virtual void ShutdownSound();
103 // this is sent from EMU thread! Make sure that Host handles it properly!
104 virtual void BootDone() {
105 symbolMap
.SortSymbols();
109 virtual bool IsDebuggingEnabled() {
116 virtual bool AttemptLoadSymbolMap() {
117 return symbolMap
.LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart
));
119 virtual void PrepareShutdown() {
120 symbolMap
.SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart
));
122 virtual void ResetSymbolMap() {}
123 virtual void AddSymbol(std::string name
, u32 addr
, u32 size
, int type
=0) {}
124 virtual void SetWindowTitle(const char *message
) {
125 QString title
= "PPSSPP " + QString(PPSSPP_GIT_VERSION
) + " - " + QString::fromUtf8(message
);
127 mainWindow
->setWindowTitle(title
);
129 bool GPUDebuggingActive()
131 auto dialogDisplayList
= mainWindow
->GetDialogDisplaylist();
132 if (dialogDisplayList
&& dialogDisplayList
->isVisible())
134 if (m_GPUStep
&& m_GPUFlag
== -1)
141 void SetGPUStep(bool value
, int flag
= 0, u32 data
= 0)
148 MainWindow
* mainWindow
;