From 69146b04b245c89a017471d8ec96ef40aed14ed4 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 26 Jun 2020 14:37:36 +1000 Subject: [PATCH] Add and use DEBUG-conditional WriteLine methods --- .../GraphicsImplementations/IGL_TK.cs | 3 ++- src/BizHawk.Client.EmuHawk/MainForm.cs | 6 +++--- src/BizHawk.Client.EmuHawk/Throttle.cs | 2 +- src/BizHawk.Common/Util.cs | 17 +++++++++++++++++ .../Database/Database.cs | 2 +- .../Consoles/Nintendo/NES/BootGodDB.cs | 2 +- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs index dd5d4b2d57..10397183a5 100644 --- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs +++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/IGL_TK.cs @@ -11,6 +11,7 @@ using System.IO; using System.Collections.Generic; using BizHawk.Bizware.BizwareGL; +using BizHawk.Common; using OpenTK; using OpenTK.Graphics; @@ -221,7 +222,7 @@ namespace BizHawk.Client.EmuHawk throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}"); else success = false; resultLog = GL.GetProgramInfoLog(pid); - Console.WriteLine(resultLog); + Util.DebugWriteLine(resultLog); } //need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index d35a1ccc7d..aa5a73189c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -1138,9 +1138,9 @@ namespace BizHawk.Client.EmuHawk } - Console.WriteLine($"For emulator framebuffer {new Size(_currentVideoProvider.BufferWidth, _currentVideoProvider.BufferHeight)}:"); - Console.WriteLine($" For virtual size {new Size(_currentVideoProvider.VirtualWidth, _currentVideoProvider.VirtualHeight)}:"); - Console.WriteLine($" Selecting display size {lastComputedSize}"); + Util.DebugWriteLine($"For emulator framebuffer {new Size(_currentVideoProvider.BufferWidth, _currentVideoProvider.BufferHeight)}:"); + Util.DebugWriteLine($" For virtual size {new Size(_currentVideoProvider.VirtualWidth, _currentVideoProvider.VirtualHeight)}:"); + Util.DebugWriteLine($" Selecting display size {lastComputedSize}"); // Change size Size = new Size(lastComputedSize.Width + borderWidth, lastComputedSize.Height + borderHeight); diff --git a/src/BizHawk.Client.EmuHawk/Throttle.cs b/src/BizHawk.Client.EmuHawk/Throttle.cs index eb8a90b0e2..6a32202c31 100644 --- a/src/BizHawk.Client.EmuHawk/Throttle.cs +++ b/src/BizHawk.Client.EmuHawk/Throttle.cs @@ -156,7 +156,7 @@ namespace BizHawk.Client.EmuHawk afsfreq = 1000; tmethod = 0; } - Console.WriteLine("throttle method: {0}; resolution: {1}", tmethod, afsfreq); + Util.DebugWriteLine("throttle method: {0}; resolution: {1}", tmethod, afsfreq); tfreq = afsfreq * 65536; } diff --git a/src/BizHawk.Common/Util.cs b/src/BizHawk.Common/Util.cs index 10074202a3..d4c3fa3967 100644 --- a/src/BizHawk.Common/Util.cs +++ b/src/BizHawk.Common/Util.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; @@ -21,6 +22,22 @@ namespace BizHawk.Common } } + /// equivalent to Console.WriteLine but is #ifdef DEBUG + [Conditional("DEBUG")] + public static void DebugWriteLine() => Console.WriteLine(); + + /// equivalent to Console.WriteLine but is #ifdef DEBUG + [Conditional("DEBUG")] + public static void DebugWriteLine(string value) => Console.WriteLine(value); + + /// equivalent to Console.WriteLine but is #ifdef DEBUG + [Conditional("DEBUG")] + public static void DebugWriteLine(object value) => Console.WriteLine(value); + + /// equivalent to Console.WriteLine but is #ifdef DEBUG + [Conditional("DEBUG")] + public static void DebugWriteLine(string format, params object[] arg) => Console.WriteLine(format, arg); + /// issues with parsing /// TODO use and instead of using and keeping a reference to the array? --yoshi public static byte[] DecompressGzipFile(Stream src) diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index f776051523..244065410a 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Common var stopwatch = Stopwatch.StartNew(); ThreadPool.QueueUserWorkItem(_=> { initializeWork(path); - Console.WriteLine("GameDB load: " + stopwatch.Elapsed + " sec"); + Util.DebugWriteLine("GameDB load: " + stopwatch.Elapsed + " sec"); }); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs index 065242c1c8..44eb7921e1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs @@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ThreadPool.QueueUserWorkItem(_ => { instance = new BootGodDb(basePath); - Console.WriteLine("Bootgod DB load: " + stopwatch.Elapsed + " sec"); + Util.DebugWriteLine("Bootgod DB load: " + stopwatch.Elapsed + " sec"); acquire.Set(); }); }