Debugger: Added pause icon (and option to hide it)

This commit is contained in:
Sour 2018-03-03 13:11:45 -05:00
parent 13d4a0fc72
commit 51ce8a4781
10 changed files with 127 additions and 75 deletions

View File

@ -19,6 +19,8 @@ enum class DebuggerFlags
ShowUnidentifiedData = 0x200,
IgnoreRedundantWrites = 0x400,
HidePauseIcon = 0x800
};
enum class BreakSource

View File

@ -134,6 +134,7 @@ namespace Mesen.GUI.Config
public bool PpuAutoRefresh = true;
public bool PpuPartialDraw = false;
public bool PpuShowPreviousFrame = false;
public bool HidePauseIcon = false;
public bool ShowPpuScrollOverlay = true;
public bool ShowTileGrid = false;
public bool ShowAttributeGrid = false;

View File

@ -179,6 +179,7 @@ namespace Mesen.GUI.Debugger
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
this.mnuHidePauseIcon = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
@ -224,7 +225,7 @@ namespace Mesen.GUI.Debugger
this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10);
this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(1172, 573);
this.splitContainer.SplitterDistance = 413;
this.splitContainer.SplitterDistance = 410;
this.splitContainer.SplitterWidth = 7;
this.splitContainer.TabIndex = 1;
this.splitContainer.TabStop = false;
@ -247,7 +248,7 @@ namespace Mesen.GUI.Debugger
//
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
this.ctrlSplitContainerTop.Panel2MinSize = 150;
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 413);
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 410);
this.ctrlSplitContainerTop.SplitterDistance = 750;
this.ctrlSplitContainerTop.SplitterWidth = 7;
this.ctrlSplitContainerTop.TabIndex = 3;
@ -269,7 +270,7 @@ namespace Mesen.GUI.Debugger
this.tlpTop.Name = "tlpTop";
this.tlpTop.RowCount = 1;
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpTop.Size = new System.Drawing.Size(750, 413);
this.tlpTop.Size = new System.Drawing.Size(750, 410);
this.tlpTop.TabIndex = 2;
//
// ctrlDebuggerCode
@ -281,7 +282,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.ShowMemoryValues = false;
this.ctrlDebuggerCode.ShowScrollbars = true;
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 407);
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 404);
this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.TextZoom = 100;
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
@ -295,7 +296,7 @@ namespace Mesen.GUI.Debugger
this.ctrlConsoleStatus.Location = new System.Drawing.Point(292, 0);
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 413);
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 410);
this.ctrlConsoleStatus.TabIndex = 3;
this.ctrlConsoleStatus.OnGotoLocation += new System.EventHandler(this.ctrlConsoleStatus_OnGotoLocation);
//
@ -308,7 +309,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.ShowMemoryValues = false;
this.ctrlDebuggerCodeSplit.ShowScrollbars = true;
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 407);
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 404);
this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.TextZoom = 100;
this.ctrlDebuggerCodeSplit.Visible = false;
@ -330,16 +331,16 @@ namespace Mesen.GUI.Debugger
this.tlpFunctionLabelLists.RowCount = 2;
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 413);
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 410);
this.tlpFunctionLabelLists.TabIndex = 5;
//
// grpLabels
//
this.grpLabels.Controls.Add(this.ctrlLabelList);
this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLabels.Location = new System.Drawing.Point(3, 209);
this.grpLabels.Location = new System.Drawing.Point(3, 208);
this.grpLabels.Name = "grpLabels";
this.grpLabels.Size = new System.Drawing.Size(409, 201);
this.grpLabels.Size = new System.Drawing.Size(409, 199);
this.grpLabels.TabIndex = 6;
this.grpLabels.TabStop = false;
this.grpLabels.Text = "Labels";
@ -349,7 +350,7 @@ namespace Mesen.GUI.Debugger
this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlLabelList.Location = new System.Drawing.Point(3, 16);
this.ctrlLabelList.Name = "ctrlLabelList";
this.ctrlLabelList.Size = new System.Drawing.Size(403, 182);
this.ctrlLabelList.Size = new System.Drawing.Size(403, 180);
this.ctrlLabelList.TabIndex = 0;
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
@ -360,7 +361,7 @@ namespace Mesen.GUI.Debugger
this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpFunctions.Location = new System.Drawing.Point(3, 3);
this.grpFunctions.Name = "grpFunctions";
this.grpFunctions.Size = new System.Drawing.Size(409, 200);
this.grpFunctions.Size = new System.Drawing.Size(409, 199);
this.grpFunctions.TabIndex = 5;
this.grpFunctions.TabStop = false;
this.grpFunctions.Text = "Functions";
@ -370,7 +371,7 @@ namespace Mesen.GUI.Debugger
this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16);
this.ctrlFunctionList.Name = "ctrlFunctionList";
this.ctrlFunctionList.Size = new System.Drawing.Size(403, 181);
this.ctrlFunctionList.Size = new System.Drawing.Size(403, 180);
this.ctrlFunctionList.TabIndex = 0;
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
@ -401,7 +402,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 153);
this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 156);
this.tableLayoutPanel10.TabIndex = 0;
//
// grpWatch
@ -410,7 +411,7 @@ namespace Mesen.GUI.Debugger
this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpWatch.Location = new System.Drawing.Point(3, 3);
this.grpWatch.Name = "grpWatch";
this.grpWatch.Size = new System.Drawing.Size(384, 147);
this.grpWatch.Size = new System.Drawing.Size(384, 150);
this.grpWatch.TabIndex = 2;
this.grpWatch.TabStop = false;
this.grpWatch.Text = "Watch";
@ -420,7 +421,7 @@ namespace Mesen.GUI.Debugger
this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlWatch.Location = new System.Drawing.Point(3, 16);
this.ctrlWatch.Name = "ctrlWatch";
this.ctrlWatch.Size = new System.Drawing.Size(378, 128);
this.ctrlWatch.Size = new System.Drawing.Size(378, 131);
this.ctrlWatch.TabIndex = 0;
//
// grpBreakpoints
@ -429,7 +430,7 @@ namespace Mesen.GUI.Debugger
this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpBreakpoints.Location = new System.Drawing.Point(393, 3);
this.grpBreakpoints.Name = "grpBreakpoints";
this.grpBreakpoints.Size = new System.Drawing.Size(384, 147);
this.grpBreakpoints.Size = new System.Drawing.Size(384, 150);
this.grpBreakpoints.TabIndex = 3;
this.grpBreakpoints.TabStop = false;
this.grpBreakpoints.Text = "Breakpoints";
@ -439,7 +440,7 @@ namespace Mesen.GUI.Debugger
this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16);
this.ctrlBreakpoints.Name = "ctrlBreakpoints";
this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 128);
this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 131);
this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
//
@ -449,7 +450,7 @@ namespace Mesen.GUI.Debugger
this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpCallstack.Location = new System.Drawing.Point(783, 3);
this.grpCallstack.Name = "grpCallstack";
this.grpCallstack.Size = new System.Drawing.Size(386, 147);
this.grpCallstack.Size = new System.Drawing.Size(386, 150);
this.grpCallstack.TabIndex = 4;
this.grpCallstack.TabStop = false;
this.grpCallstack.Text = "Call Stack";
@ -459,7 +460,7 @@ namespace Mesen.GUI.Debugger
this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlCallstack.Location = new System.Drawing.Point(3, 16);
this.ctrlCallstack.Name = "ctrlCallstack";
this.ctrlCallstack.Size = new System.Drawing.Size(380, 128);
this.ctrlCallstack.Size = new System.Drawing.Size(380, 131);
this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
//
@ -906,6 +907,7 @@ namespace Mesen.GUI.Debugger
this.mnuShowCodePreview,
this.mnuShowOpCodeTooltips,
this.toolStripMenuItem6,
this.mnuHidePauseIcon,
this.mnuPpuPartialDraw,
this.mnuPpuShowPreviousFrame,
this.toolStripMenuItem19,
@ -1566,6 +1568,14 @@ namespace Mesen.GUI.Debugger
this.tsToolbar.Text = "toolStrip1";
this.tsToolbar.Visible = false;
//
// mnuHidePauseIcon
//
this.mnuHidePauseIcon.CheckOnClick = true;
this.mnuHidePauseIcon.Name = "mnuHidePauseIcon";
this.mnuHidePauseIcon.Size = new System.Drawing.Size(266, 22);
this.mnuHidePauseIcon.Text = "Hide Pause Icon";
this.mnuHidePauseIcon.Click += new System.EventHandler(this.mnuHidePauseIcon_Click);
//
// frmDebugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1758,5 +1768,6 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem22;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem23;
private System.Windows.Forms.ToolStripMenuItem mnuGoToProgramCount;
private System.Windows.Forms.ToolStripMenuItem mnuHidePauseIcon;
}
}

View File

@ -64,6 +64,7 @@ namespace Mesen.GUI.Debugger
this.mnuSplitView.Checked = ConfigManager.Config.DebugInfo.SplitView;
this.mnuPpuPartialDraw.Checked = ConfigManager.Config.DebugInfo.PpuPartialDraw;
this.mnuPpuShowPreviousFrame.Checked = ConfigManager.Config.DebugInfo.PpuShowPreviousFrame;
this.mnuHidePauseIcon.Checked = ConfigManager.Config.DebugInfo.HidePauseIcon;
this.mnuShowEffectiveAddresses.Checked = ConfigManager.Config.DebugInfo.ShowEffectiveAddresses;
this.mnuShowCodePreview.Checked = ConfigManager.Config.DebugInfo.ShowCodePreview;
this.mnuShowToolbar.Checked = ConfigManager.Config.DebugInfo.ShowToolbar;
@ -312,6 +313,7 @@ namespace Mesen.GUI.Debugger
SetFlag(DebuggerFlags.ShowUnidentifiedData, mnuShowUnidentifiedData.Checked);
SetFlag(DebuggerFlags.BreakOnUnofficialOpCode, mnuBreakOnUnofficialOpcodes.Checked);
SetFlag(DebuggerFlags.BreakOnBrk, mnuBreakOnBrk.Checked);
SetFlag(DebuggerFlags.HidePauseIcon, mnuHidePauseIcon.Checked);
InteropEmu.SetFlag(EmulationFlags.DebuggerWindowEnabled, true);
}
@ -691,9 +693,9 @@ namespace Mesen.GUI.Debugger
}
InteropEmu.DebugRun();
ConfigManager.Config.DebugInfo.FontFamily = ctrlDebuggerCode.Font.FontFamily.Name;
ConfigManager.Config.DebugInfo.FontStyle = ctrlDebuggerCode.Font.Style;
ConfigManager.Config.DebugInfo.FontSize = ctrlDebuggerCode.Font.Size;
ConfigManager.Config.DebugInfo.FontFamily = ctrlDebuggerCode.BaseFont.FontFamily.Name;
ConfigManager.Config.DebugInfo.FontStyle = ctrlDebuggerCode.BaseFont.Style;
ConfigManager.Config.DebugInfo.FontSize = ctrlDebuggerCode.BaseFont.Size;
ConfigManager.Config.DebugInfo.WindowWidth = this.WindowState == FormWindowState.Maximized ? this.RestoreBounds.Width : this.Width;
ConfigManager.Config.DebugInfo.WindowHeight = this.WindowState == FormWindowState.Maximized ? this.RestoreBounds.Height : this.Height;
ConfigManager.Config.DebugInfo.TopPanelHeight = this.splitContainer.GetSplitterDistance();
@ -773,6 +775,12 @@ namespace Mesen.GUI.Debugger
DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger);
}
private void mnuHidePauseIcon_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.HidePauseIcon = mnuHidePauseIcon.Checked;
ConfigManager.ApplyChanges();
}
private void mnuPpuPartialDraw_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.PpuPartialDraw = mnuPpuPartialDraw.Checked;

View File

@ -82,9 +82,9 @@ namespace Mesen.GUI.Debugger
debugInfo.TraceIndentCode = chkIndentCode.Checked;
debugInfo.TraceLoggerSize = this.WindowState == FormWindowState.Maximized ? this.RestoreBounds.Size : this.Size;
debugInfo.TraceFontFamily = txtTraceLog.Font.FontFamily.Name;
debugInfo.TraceFontSize = txtTraceLog.Font.Size;
debugInfo.TraceFontStyle = txtTraceLog.Font.Style;
debugInfo.TraceFontFamily = txtTraceLog.BaseFont.FontFamily.Name;
debugInfo.TraceFontSize = txtTraceLog.BaseFont.Size;
debugInfo.TraceFontStyle = txtTraceLog.BaseFont.Style;
debugInfo.TraceTextZoom = txtTraceLog.TextZoom;
_entityBinder.Entity = debugInfo.TraceLoggerOptions;

View File

@ -1538,6 +1538,8 @@ namespace Mesen.GUI
ShowUnidentifiedData = 0x200,
IgnoreRedundantWrites = 0x400,
HidePauseIcon = 0x800,
}
public struct InteropRomInfo

View File

@ -1,4 +1,6 @@
#include "SdlRenderer.h"
#include "../Core/Console.h"
#include "../Core/Debugger.h"
#include "../Core/VideoRenderer.h"
#include "../Core/VideoDecoder.h"
#include "../Core/EmulationSettings.h"
@ -143,7 +145,14 @@ void SdlRenderer::Render()
return;
}
bool paused = EmulationSettings::IsPaused();
bool paused = EmulationSettings::IsPaused() && Console::IsRunning();
bool disableOverlay = EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay);
shared_ptr<Debugger> debugger = Console::GetInstance()->GetDebugger(false);
if(debugger && debugger->IsExecutionStopped()) {
paused = !debugger->CheckFlag(DebuggerFlags::HidePauseIcon);
disableOverlay = true;
}
if(_noUpdateCount > 10 || _frameChanged || paused || IsMessageShown()) {
auto lock = _frameLock.AcquireSafe();
@ -170,7 +179,7 @@ void SdlRenderer::Render()
SDL_RenderCopy(_sdlRenderer, _sdlTexture, &source, &dest);
if(paused && !EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay)) {
DrawPauseScreen();
DrawPauseScreen(disableOverlay);
} else if(VideoDecoder::GetInstance()->IsRunning()) {
DrawCounters();
}
@ -183,24 +192,29 @@ void SdlRenderer::Render()
}
}
void SdlRenderer::DrawPauseScreen()
void SdlRenderer::DrawPauseScreen(bool disableOverlay)
{
uint32_t textureData = 0x222222AA;
SDL_Surface* surf = SDL_CreateRGBSurfaceFrom((void*)&textureData, 1, 1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
if(surf) {
SDL_Texture* texture = SDL_CreateTextureFromSurface(_sdlRenderer, surf);
if(texture) {
SDL_Rect source = {0, 0, 1, 1 };
SDL_Rect dest = {0, 0, (int)_screenWidth, (int)_screenHeight };
SDL_RenderCopy(_sdlRenderer, texture, &source, &dest);
SDL_DestroyTexture(texture);
if(disableOverlay) {
DrawString("I", 15, 15, 106, 90, 205);
DrawString("I", 23, 15, 106, 90, 205);
} else {
uint32_t textureData = 0x222222AA;
SDL_Surface* surf = SDL_CreateRGBSurfaceFrom((void*)&textureData, 1, 1, 32, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
if(surf) {
SDL_Texture* texture = SDL_CreateTextureFromSurface(_sdlRenderer, surf);
if(texture) {
SDL_Rect source = { 0, 0, 1, 1 };
SDL_Rect dest = { 0, 0, (int)_screenWidth, (int)_screenHeight };
SDL_RenderCopy(_sdlRenderer, texture, &source, &dest);
SDL_DestroyTexture(texture);
}
SDL_FreeSurface(surf);
}
SDL_FreeSurface(surf);
}
XMVECTOR stringDimensions = _largeFont->MeasureString(L"PAUSE");
float* measureF = (float*)&stringDimensions;
_largeFont->DrawString(_sdlRenderer, L"PAUSE", (int)(_screenWidth / 2 - measureF[0] / 2), (int)(_screenHeight / 2 - measureF[1] / 2 - 8), 250, 235, 215);
XMVECTOR stringDimensions = _largeFont->MeasureString(L"PAUSE");
float* measureF = (float*)&stringDimensions;
_largeFont->DrawString(_sdlRenderer, L"PAUSE", (int)(_screenWidth / 2 - measureF[0] / 2), (int)(_screenHeight / 2 - measureF[1] / 2 - 8), 250, 235, 215);
}
}
void SdlRenderer::DrawString(std::wstring message, int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t opacity)

View File

@ -50,7 +50,7 @@ private:
void Cleanup();
void SetScreenSize(uint32_t width, uint32_t height);
void DrawPauseScreen();
void DrawPauseScreen(bool disableOverlay);
float MeasureString(std::wstring text) override;
bool ContainsCharacter(wchar_t character) override;

View File

@ -3,6 +3,7 @@
#include "DirectXTK/SpriteBatch.h"
#include "DirectXTK/SpriteFont.h"
#include "../Core/Console.h"
#include "../Core/Debugger.h"
#include "../Core/PPU.h"
#include "../Core/VideoRenderer.h"
#include "../Core/VideoDecoder.h"
@ -536,42 +537,54 @@ namespace NES
_spriteBatch->Draw(_pTextureSrv, destRect);
}
void Renderer::DrawPauseScreen()
void Renderer::DrawPauseScreen(bool disableOverlay)
{
RECT destRect;
destRect.left = 0;
destRect.top = 0;
destRect.right = _realScreenWidth;
destRect.bottom = _realScreenHeight;
if(disableOverlay) {
DrawString("I", 15, 15, Colors::SlateBlue, 2.0f, _font.get());
DrawString("I", 32, 15, Colors::SlateBlue, 2.0f, _font.get());
} else {
RECT destRect;
destRect.left = 0;
destRect.top = 0;
destRect.right = _realScreenWidth;
destRect.bottom = _realScreenHeight;
D3D11_MAPPED_SUBRESOURCE dd;
HRESULT hr = _pDeviceContext->Map(_overlayTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &dd);
if(FAILED(hr)) {
MessageManager::Log("(DrawPauseScreen) DeviceContext::Map() failed - Error:" + std::to_string(hr));
return;
}
uint8_t* surfacePointer = (uint8_t*)dd.pData;
for(uint32_t i = 0, len = 8; i < len; i++) {
//Gray transparent overlay
for(int j = 0; j < 8; j++) {
((uint32_t*)surfacePointer)[j] = 0xAA222222;
D3D11_MAPPED_SUBRESOURCE dd;
HRESULT hr = _pDeviceContext->Map(_overlayTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &dd);
if(FAILED(hr)) {
MessageManager::Log("(DrawPauseScreen) DeviceContext::Map() failed - Error:" + std::to_string(hr));
return;
}
surfacePointer += dd.RowPitch;
uint8_t* surfacePointer = (uint8_t*)dd.pData;
for(uint32_t i = 0, len = 8; i < len; i++) {
//Gray transparent overlay
for(int j = 0; j < 8; j++) {
((uint32_t*)surfacePointer)[j] = 0xAA222222;
}
surfacePointer += dd.RowPitch;
}
_pDeviceContext->Unmap(_overlayTexture, 0);
_spriteBatch->Draw(_pOverlaySrv, destRect);
XMVECTOR stringDimensions = _largeFont->MeasureString(L"PAUSE");
float x = (float)_screenWidth / 2 - stringDimensions.m128_f32[0] / 2;
float y = (float)_screenHeight / 2 - stringDimensions.m128_f32[1] / 2 - 8;
DrawString("PAUSE", x, y, Colors::AntiqueWhite, 1.0f, _largeFont.get());
}
_pDeviceContext->Unmap(_overlayTexture, 0);
_spriteBatch->Draw(_pOverlaySrv, destRect);
XMVECTOR stringDimensions = _largeFont->MeasureString(L"PAUSE");
float x = (float)_screenWidth / 2 - stringDimensions.m128_f32[0] / 2;
float y = (float)_screenHeight / 2 - stringDimensions.m128_f32[1] / 2 - 8;
DrawString("PAUSE", x, y, Colors::AntiqueWhite, 1.0f, _largeFont.get());
}
void Renderer::Render()
{
bool paused = EmulationSettings::IsPaused() && Console::IsRunning();
bool disableOverlay = EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay);
shared_ptr<Debugger> debugger = Console::GetInstance()->GetDebugger(false);
if(debugger && debugger->IsExecutionStopped()) {
paused = !debugger->CheckFlag(DebuggerFlags::HidePauseIcon);
disableOverlay = true;
}
if(_noUpdateCount > 10 || _frameChanged || paused || IsMessageShown()) {
_noUpdateCount = 0;
@ -597,9 +610,11 @@ namespace NES
//Draw nes screen
DrawNESScreen();
if(paused && !EmulationSettings::CheckFlag(EmulationFlags::HidePauseOverlay)) {
DrawPauseScreen();
} else if(VideoDecoder::GetInstance()->IsRunning()) {
if(paused) {
DrawPauseScreen(disableOverlay);
}
if(VideoDecoder::GetInstance()->IsRunning()) {
DrawCounters();
}

View File

@ -76,8 +76,7 @@ namespace NES {
ID3D11Texture2D* CreateTexture(uint32_t width, uint32_t height);
ID3D11ShaderResourceView* GetShaderResourceView(ID3D11Texture2D* texture);
void DrawNESScreen();
void DrawPauseScreen();
void DrawPauseScreen(bool disableOverlay);
void DrawString(string message, float x, float y, DirectX::FXMVECTOR color, float scale, SpriteFont* font = nullptr);
void DrawString(std::wstring message, float x, float y, DirectX::FXMVECTOR color, float scale, SpriteFont* font = nullptr);