2014-03-01 15:09:16 +00:00
|
|
|
// Copyright (c) 2014- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Core/Host.h"
|
2016-05-28 05:00:14 +00:00
|
|
|
#include "UI/OnScreenDisplay.h"
|
2014-03-01 15:09:16 +00:00
|
|
|
|
|
|
|
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
|
|
|
#include "Qt/mainwindow.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// TODO: Get rid of this junk
|
|
|
|
class NativeHost : public Host {
|
|
|
|
public:
|
|
|
|
NativeHost() {
|
|
|
|
}
|
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
void UpdateUI() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
void UpdateMemView() override {}
|
|
|
|
void UpdateDisassembly() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
void SetDebugMode(bool mode) override { }
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2015-12-31 15:59:40 +00:00
|
|
|
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
|
2014-09-20 19:55:58 +00:00
|
|
|
void ShutdownGraphics() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2015-01-11 11:02:49 +00:00
|
|
|
void InitSound() override;
|
2014-09-20 19:55:58 +00:00
|
|
|
void UpdateSound() override {}
|
|
|
|
void ShutdownSound() override;
|
2014-03-01 15:09:16 +00:00
|
|
|
|
|
|
|
// this is sent from EMU thread! Make sure that Host handles it properly!
|
2014-09-20 19:55:58 +00:00
|
|
|
void BootDone() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
bool IsDebuggingEnabled() override {return false;}
|
|
|
|
bool AttemptLoadSymbolMap() override {return false;}
|
|
|
|
void SetWindowTitle(const char *message) override {}
|
2016-05-28 05:00:14 +00:00
|
|
|
|
|
|
|
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
|
|
|
|
osm.Show(message, duration, color, -1, true, id);
|
|
|
|
}
|
2014-03-01 15:09:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
|
|
|
static const char* SymbolMapFilename(std::string currentFilename)
|
|
|
|
{
|
|
|
|
std::string result = currentFilename;
|
|
|
|
size_t dot = result.rfind('.');
|
|
|
|
if (dot == result.npos)
|
|
|
|
return (result + ".map").c_str();
|
|
|
|
|
|
|
|
result.replace(dot, result.npos, ".map");
|
|
|
|
return result.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
class QtHost : public Host {
|
|
|
|
public:
|
|
|
|
QtHost(MainWindow *mainWindow_)
|
|
|
|
{
|
|
|
|
mainWindow = mainWindow_;
|
|
|
|
m_GPUStep = false;
|
|
|
|
m_GPUFlag = 0;
|
|
|
|
}
|
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void UpdateUI() override {
|
2014-03-01 15:09:16 +00:00
|
|
|
mainWindow->updateMenus();
|
|
|
|
}
|
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void UpdateMemView() override {
|
2014-03-01 15:09:16 +00:00
|
|
|
if(mainWindow->GetDialogMemory())
|
|
|
|
mainWindow->GetDialogMemory()->Update();
|
|
|
|
}
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void UpdateDisassembly() override {
|
2014-03-01 15:09:16 +00:00
|
|
|
if(mainWindow->GetDialogDisasm())
|
|
|
|
mainWindow->GetDialogDisasm()->Update();
|
|
|
|
if(mainWindow->GetDialogDisplaylist())
|
|
|
|
mainWindow->GetDialogDisplaylist()->Update();
|
|
|
|
}
|
|
|
|
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void SetDebugMode(bool mode) override {
|
2014-03-01 15:09:16 +00:00
|
|
|
if(mainWindow->GetDialogDisasm())
|
|
|
|
mainWindow->GetDialogDisasm()->SetDebugMode(mode);
|
|
|
|
}
|
|
|
|
|
2016-01-03 14:03:08 +00:00
|
|
|
virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override { return true; }
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void ShutdownGraphics() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
|
2015-01-11 11:02:49 +00:00
|
|
|
virtual void InitSound() override;
|
2014-09-20 19:55:58 +00:00
|
|
|
virtual void UpdateSound() override {}
|
2014-03-01 15:09:16 +00:00
|
|
|
virtual void ShutdownSound();
|
|
|
|
|
|
|
|
// this is sent from EMU thread! Make sure that Host handles it properly!
|
|
|
|
virtual void BootDone() {
|
2015-10-31 22:53:20 +00:00
|
|
|
g_symbolMap->SortSymbols();
|
2014-03-01 15:09:16 +00:00
|
|
|
mainWindow->Boot();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsDebuggingEnabled() {
|
|
|
|
#ifdef _DEBUG
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
virtual bool AttemptLoadSymbolMap() {
|
2015-10-31 22:53:20 +00:00
|
|
|
return g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart));
|
2014-03-01 15:09:16 +00:00
|
|
|
}
|
|
|
|
virtual void PrepareShutdown() {
|
2015-10-31 22:53:20 +00:00
|
|
|
g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart));
|
2014-03-01 15:09:16 +00:00
|
|
|
}
|
|
|
|
virtual void ResetSymbolMap() {}
|
|
|
|
virtual void AddSymbol(std::string name, u32 addr, u32 size, int type=0) {}
|
|
|
|
virtual void SetWindowTitle(const char *message) {
|
|
|
|
QString title = "PPSSPP " + QString(PPSSPP_GIT_VERSION) + " - " + QString::fromUtf8(message);
|
|
|
|
|
|
|
|
mainWindow->setWindowTitle(title);
|
|
|
|
}
|
2016-05-28 05:00:14 +00:00
|
|
|
|
|
|
|
void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override {
|
|
|
|
osm.Show(message, duration, color, -1, true, id);
|
|
|
|
}
|
|
|
|
|
2014-03-01 15:09:16 +00:00
|
|
|
bool GPUDebuggingActive()
|
|
|
|
{
|
|
|
|
auto dialogDisplayList = mainWindow->GetDialogDisplaylist();
|
|
|
|
if (dialogDisplayList && dialogDisplayList->isVisible())
|
|
|
|
{
|
|
|
|
if (m_GPUStep && m_GPUFlag == -1)
|
|
|
|
m_GPUFlag = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void SetGPUStep(bool value, int flag = 0, u32 data = 0)
|
|
|
|
{
|
|
|
|
m_GPUStep = value;
|
|
|
|
m_GPUFlag = flag;
|
|
|
|
m_GPUData = data;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
MainWindow* mainWindow;
|
|
|
|
bool m_GPUStep;
|
|
|
|
int m_GPUFlag;
|
|
|
|
u32 m_GPUData;
|
|
|
|
};
|
|
|
|
#endif
|