diff --git a/Core/DebugHud.cpp b/Core/DebugHud.cpp index 8248e090..14d1d60b 100644 --- a/Core/DebugHud.cpp +++ b/Core/DebugHud.cpp @@ -36,29 +36,39 @@ void DebugHud::Draw(uint32_t* argbBuffer, OverscanDimensions overscan, uint32_t void DebugHud::DrawPixel(int x, int y, int color, int frameCount, int startFrame) { auto lock = _commandLock.AcquireSafe(); - _commands.push_back(unique_ptr(new DrawPixelCommand(x, y, color, frameCount, startFrame))); + if(_commands.size() < DebugHud::MaxCommandCount) { + _commands.push_back(unique_ptr(new DrawPixelCommand(x, y, color, frameCount, startFrame))); + } } void DebugHud::DrawLine(int x, int y, int x2, int y2, int color, int frameCount, int startFrame) { auto lock = _commandLock.AcquireSafe(); - _commands.push_back(unique_ptr(new DrawLineCommand(x, y, x2, y2, color, frameCount, startFrame))); + if(_commands.size() < DebugHud::MaxCommandCount) { + _commands.push_back(unique_ptr(new DrawLineCommand(x, y, x2, y2, color, frameCount, startFrame))); + } } void DebugHud::DrawRectangle(int x, int y, int width, int height, int color, bool fill, int frameCount, int startFrame) { auto lock = _commandLock.AcquireSafe(); - _commands.push_back(unique_ptr(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount, startFrame))); + if(_commands.size() < DebugHud::MaxCommandCount) { + _commands.push_back(unique_ptr(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount, startFrame))); + } } void DebugHud::DrawScreenBuffer(uint32_t* screenBuffer, int startFrame) { auto lock = _commandLock.AcquireSafe(); - _commands.push_back(unique_ptr(new DrawScreenBufferCommand(screenBuffer, startFrame))); + if(_commands.size() < DebugHud::MaxCommandCount) { + _commands.push_back(unique_ptr(new DrawScreenBufferCommand(screenBuffer, startFrame))); + } } void DebugHud::DrawString(int x, int y, string text, int color, int backColor, int frameCount, int startFrame) { auto lock = _commandLock.AcquireSafe(); - _commands.push_back(unique_ptr(new DrawStringCommand(x, y, text, color, backColor, frameCount, startFrame))); + if(_commands.size() < DebugHud::MaxCommandCount) { + _commands.push_back(unique_ptr(new DrawStringCommand(x, y, text, color, backColor, frameCount, startFrame))); + } } diff --git a/Core/DebugHud.h b/Core/DebugHud.h index c6d0d609..1a66815f 100644 --- a/Core/DebugHud.h +++ b/Core/DebugHud.h @@ -8,6 +8,7 @@ class DrawCommand; class DebugHud { private: + static constexpr size_t MaxCommandCount = 500000; vector> _commands; SimpleLock _commandLock; diff --git a/Core/LuaScriptingContext.cpp b/Core/LuaScriptingContext.cpp index 5afb7e0f..044d2e66 100644 --- a/Core/LuaScriptingContext.cpp +++ b/Core/LuaScriptingContext.cpp @@ -6,6 +6,9 @@ #include "DebuggerTypes.h" #include "Debugger.h" +LuaScriptingContext* LuaScriptingContext::_context = nullptr; +uint32_t LuaScriptingContext::_timeout = 1000; + LuaScriptingContext::LuaScriptingContext(Debugger* debugger) : ScriptingContext(debugger) { } @@ -38,18 +41,34 @@ LuaScriptingContext::~LuaScriptingContext() } } +void LuaScriptingContext::SetScriptTimeout(uint32_t timeout) +{ + _timeout = timeout; +} + +void LuaScriptingContext::ExecutionCountHook(lua_State *lua, lua_Debug *ar) +{ + if(_context->_timer.GetElapsedMS() > _timeout) { + luaL_error(lua, (std::string("Maximum execution time (") + std::to_string(_timeout) + " ms) exceeded.").c_str()); + } +} + bool LuaScriptingContext::LoadScript(string scriptName, string scriptContent, Debugger* debugger) { _scriptName = scriptName; int iErr = 0; _lua = luaL_newstate(); + + _context = this; LuaApi::SetContext(this); luaL_openlibs(_lua); luaL_requiref(_lua, "emu", LuaApi::GetLibrary, 1); Log("Loading script..."); if((iErr = luaL_loadbufferx(_lua, scriptContent.c_str(), scriptContent.size(), ("@" + scriptName).c_str(), nullptr)) == 0) { + _timer.Reset(); + lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000); if((iErr = lua_pcall(_lua, 0, LUA_MULTRET, 0)) == 0) { //Script loaded properly Log("Script loaded successfully."); @@ -77,12 +96,19 @@ void LuaScriptingContext::UnregisterEventCallback(EventType type, int reference) void LuaScriptingContext::InternalCallMemoryCallback(uint16_t addr, uint8_t &value, CallbackType type) { + if(_callbacks[(int)type][addr].empty()) { + return; + } + + _timer.Reset(); + _context = this; + lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000); LuaApi::SetContext(this); for(int &ref : _callbacks[(int)type][addr]) { int top = lua_gettop(_lua); lua_rawgeti(_lua, LUA_REGISTRYINDEX, ref); lua_pushinteger(_lua, addr); - lua_pushinteger(_lua, value); + lua_pushinteger(_lua, value); if(lua_pcall(_lua, 2, LUA_MULTRET, 0) != 0) { Log(lua_tostring(_lua, -1)); } else { @@ -98,6 +124,13 @@ void LuaScriptingContext::InternalCallMemoryCallback(uint16_t addr, uint8_t &val int LuaScriptingContext::InternalCallEventCallback(EventType type) { + if(_eventCallbacks[(int)type].empty()) { + return 0; + } + + _timer.Reset(); + _context = this; + lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000); LuaApi::SetContext(this); LuaCallHelper l(_lua); for(int &ref : _eventCallbacks[(int)type]) { diff --git a/Core/LuaScriptingContext.h b/Core/LuaScriptingContext.h index e3de0575..f590e12c 100644 --- a/Core/LuaScriptingContext.h +++ b/Core/LuaScriptingContext.h @@ -1,14 +1,21 @@ #pragma once #include "stdafx.h" #include "ScriptingContext.h" +#include "../Utilities/Timer.h" struct lua_State; +struct lua_Debug; class Debugger; class LuaScriptingContext : public ScriptingContext { private: + static LuaScriptingContext* _context; + static uint32_t _timeout; lua_State* _lua = nullptr; + Timer _timer; + + static void ExecutionCountHook(lua_State* lua, lua_Debug* ar); protected: void InternalCallMemoryCallback(uint16_t addr, uint8_t &value, CallbackType type) override; @@ -18,6 +25,8 @@ public: LuaScriptingContext(Debugger* debugger); virtual ~LuaScriptingContext(); + static void SetScriptTimeout(uint32_t timeout); + bool LoadScript(string scriptName, string scriptContent, Debugger* debugger) override; void UnregisterMemoryCallback(CallbackType type, int startAddr, int endAddr, int reference) override; diff --git a/GUI.NET/Config/DebugInfo.cs b/GUI.NET/Config/DebugInfo.cs index cdc3c953..0c8d4c22 100644 --- a/GUI.NET/Config/DebugInfo.cs +++ b/GUI.NET/Config/DebugInfo.cs @@ -321,6 +321,7 @@ namespace Mesen.GUI.Config public FontStyle ScriptFontStyle = FontStyle.Regular; public float ScriptFontSize = BaseControl.DefaultFontSize; public int ScriptZoom = 100; + public UInt32 ScriptTimeout = 1000; public bool AssemblerCodeHighlighting = true; public XmlColor AssemblerOpcodeColor = Color.FromArgb(22, 37, 37); @@ -369,6 +370,7 @@ namespace Mesen.GUI.Config static public void ApplyConfig() { InteropEmu.SetFlag(EmulationFlags.BreakOnCrash, ConfigManager.Config.DebugInfo.BreakOnCrash); + InteropEmu.DebugSetScriptTimeout(ConfigManager.Config.DebugInfo.ScriptTimeout); } public void AddRecentScript(string scriptFile) diff --git a/GUI.NET/Debugger/frmScript.Designer.cs b/GUI.NET/Debugger/frmScript.Designer.cs index 3c723c16..b8da980b 100644 --- a/GUI.NET/Debugger/frmScript.Designer.cs +++ b/GUI.NET/Debugger/frmScript.Designer.cs @@ -62,6 +62,8 @@ this.mnuBlankWindow = new System.Windows.Forms.ToolStripMenuItem(); this.mnuTutorialScript = new System.Windows.Forms.ToolStripMenuItem(); this.mnuAutoLoadLastScript = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuApiReference = new System.Windows.Forms.ToolStripMenuItem(); this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip(); this.txtScriptContent = new FastColoredTextBoxNS.FastColoredTextBox(); this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -76,8 +78,8 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.lblScriptActive = new System.Windows.Forms.ToolStripStatusLabel(); - this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuApiReference = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuSetScriptTimeout = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator(); this.mnuMain.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.txtScriptContent)).BeginInit(); this.contextMenu.SuspendLayout(); @@ -257,6 +259,8 @@ this.scriptToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mnuRun, this.mnuStop, + this.toolStripMenuItem7, + this.mnuSetScriptTimeout, this.toolStripMenuItem3, this.mnuSaveBeforeRun, this.mnuAutoReload, @@ -332,6 +336,22 @@ this.mnuAutoLoadLastScript.Text = "Load the last script loaded"; this.mnuAutoLoadLastScript.Click += new System.EventHandler(this.mnuAutoLoadLastScript_Click); // + // mnuHelp + // + this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuApiReference}); + this.mnuHelp.Name = "mnuHelp"; + this.mnuHelp.Size = new System.Drawing.Size(44, 20); + this.mnuHelp.Text = "Help"; + // + // mnuApiReference + // + this.mnuApiReference.Image = global::Mesen.GUI.Properties.Resources.Exclamation; + this.mnuApiReference.Name = "mnuApiReference"; + this.mnuApiReference.Size = new System.Drawing.Size(147, 22); + this.mnuApiReference.Text = "API Reference"; + this.mnuApiReference.Click += new System.EventHandler(this.mnuApiReference_Click); + // // tsToolbar // this.tsToolbar.Location = new System.Drawing.Point(0, 24); @@ -368,7 +388,6 @@ this.txtScriptContent.Cursor = System.Windows.Forms.Cursors.IBeam; this.txtScriptContent.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180))))); this.txtScriptContent.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtScriptContent.Font = new System.Drawing.Font("Courier New", 9.75F); this.txtScriptContent.IsReplaceMode = false; this.txtScriptContent.Language = FastColoredTextBoxNS.Language.Lua; this.txtScriptContent.LeftBracket = '('; @@ -496,21 +515,18 @@ this.lblScriptActive.Text = "Script is running"; this.lblScriptActive.Visible = false; // - // mnuHelp + // mnuSetScriptTimeout // - this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuApiReference}); - this.mnuHelp.Name = "mnuHelp"; - this.mnuHelp.Size = new System.Drawing.Size(44, 20); - this.mnuHelp.Text = "Help"; + this.mnuSetScriptTimeout.Image = global::Mesen.GUI.Properties.Resources.Speed; + this.mnuSetScriptTimeout.Name = "mnuSetScriptTimeout"; + this.mnuSetScriptTimeout.Size = new System.Drawing.Size(258, 22); + this.mnuSetScriptTimeout.Text = "Set Script Timeout..."; + this.mnuSetScriptTimeout.Click += new System.EventHandler(this.mnuSetScriptTimeout_Click); // - // mnuApiReference + // toolStripMenuItem7 // - this.mnuApiReference.Image = global::Mesen.GUI.Properties.Resources.Exclamation; - this.mnuApiReference.Name = "mnuApiReference"; - this.mnuApiReference.Size = new System.Drawing.Size(152, 22); - this.mnuApiReference.Text = "API Reference"; - this.mnuApiReference.Click += new System.EventHandler(this.mnuApiReference_Click); + this.toolStripMenuItem7.Name = "toolStripMenuItem7"; + this.toolStripMenuItem7.Size = new System.Drawing.Size(255, 6); // // frmScript // @@ -589,5 +605,7 @@ private System.Windows.Forms.ToolStripMenuItem mnuBuiltInScripts; private System.Windows.Forms.ToolStripMenuItem mnuHelp; private System.Windows.Forms.ToolStripMenuItem mnuApiReference; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7; + private System.Windows.Forms.ToolStripMenuItem mnuSetScriptTimeout; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmScript.cs b/GUI.NET/Debugger/frmScript.cs index 27691d56..29954004 100644 --- a/GUI.NET/Debugger/frmScript.cs +++ b/GUI.NET/Debugger/frmScript.cs @@ -31,6 +31,8 @@ namespace Mesen.GUI.Debugger { InitializeComponent(); + DebugInfo.ApplyConfig(); + List builtInScripts = new List { "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua" }; foreach(string script in builtInScripts) { ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script); @@ -470,6 +472,13 @@ namespace Mesen.GUI.Debugger Process.Start("https://www.mesen.ca/ApiReference.php"); } + private void mnuSetScriptTimeout_Click(object sender, EventArgs e) + { + using(frmSetScriptTimeout frm = new frmSetScriptTimeout()) { + frm.ShowDialog(); + } + } + static readonly List> _availableFunctions = new List>() { new List {"enum", "emu", "", "", "", "", "" }, new List {"func","emu.addEventCallback","emu.addEventCallback(function, type)","function - A Lua function.\ntype - *Enum* See eventCallbackType.","Returns an integer value that can be used to remove the callback by calling removeEventCallback.","Registers a callback function to be called whenever the specified event occurs.",}, diff --git a/GUI.NET/Debugger/frmSetScriptTimeout.Designer.cs b/GUI.NET/Debugger/frmSetScriptTimeout.Designer.cs new file mode 100644 index 00000000..3232e5b6 --- /dev/null +++ b/GUI.NET/Debugger/frmSetScriptTimeout.Designer.cs @@ -0,0 +1,142 @@ +using Mesen.GUI.Controls; + +namespace Mesen.GUI.Debugger +{ + partial class frmSetScriptTimeout + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nudTimeout = new Mesen.GUI.Controls.MesenNumericUpDown(); + this.lblTimeout = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.lblMs = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // baseConfigPanel + // + this.baseConfigPanel.Location = new System.Drawing.Point(0, 29); + this.baseConfigPanel.Size = new System.Drawing.Size(186, 29); + // + // nudTimeout + // + this.nudTimeout.DecimalPlaces = 0; + this.nudTimeout.Increment = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nudTimeout.Location = new System.Drawing.Point(84, 3); + this.nudTimeout.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.nudTimeout.MaximumSize = new System.Drawing.Size(10000, 20); + this.nudTimeout.Minimum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.nudTimeout.MinimumSize = new System.Drawing.Size(0, 21); + this.nudTimeout.Name = "nudTimeout"; + this.tableLayoutPanel1.SetRowSpan(this.nudTimeout, 2); + this.nudTimeout.Size = new System.Drawing.Size(57, 21); + this.nudTimeout.TabIndex = 3; + this.nudTimeout.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // lblTimeout + // + this.lblTimeout.AutoSize = true; + this.lblTimeout.Location = new System.Drawing.Point(3, 5); + this.lblTimeout.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); + this.lblTimeout.Name = "lblTimeout"; + this.tableLayoutPanel1.SetRowSpan(this.lblTimeout, 2); + this.lblTimeout.Size = new System.Drawing.Size(75, 13); + this.lblTimeout.TabIndex = 0; + this.lblTimeout.Text = "Script Timeout"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 4; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.lblMs, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.lblTimeout, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.nudTimeout, 1, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(186, 58); + this.tableLayoutPanel1.TabIndex = 0; + // + // lblMs + // + this.lblMs.AutoSize = true; + this.lblMs.Location = new System.Drawing.Point(147, 5); + this.lblMs.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); + this.lblMs.Name = "lblMs"; + this.tableLayoutPanel1.SetRowSpan(this.lblMs, 2); + this.lblMs.Size = new System.Drawing.Size(20, 13); + this.lblMs.TabIndex = 4; + this.lblMs.Text = "ms"; + // + // frmSetScriptTimeout + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(186, 58); + this.Controls.Add(this.tableLayoutPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "frmSetScriptTimeout"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Set Script Timeout"; + this.Controls.SetChildIndex(this.tableLayoutPanel1, 0); + this.Controls.SetChildIndex(this.baseConfigPanel, 0); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private MesenNumericUpDown nudTimeout; + private System.Windows.Forms.Label lblTimeout; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lblMs; + } +} \ No newline at end of file diff --git a/GUI.NET/Debugger/frmSetScriptTimeout.cs b/GUI.NET/Debugger/frmSetScriptTimeout.cs new file mode 100644 index 00000000..7005f966 --- /dev/null +++ b/GUI.NET/Debugger/frmSetScriptTimeout.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Mesen.GUI.Config; +using Mesen.GUI.Forms; + +namespace Mesen.GUI.Debugger +{ + public partial class frmSetScriptTimeout : BaseConfigForm + { + public frmSetScriptTimeout() + { + InitializeComponent(); + + nudTimeout.Value = ConfigManager.Config.DebugInfo.ScriptTimeout; + } + + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + nudTimeout.Focus(); + } + + protected override void OnFormClosed(FormClosedEventArgs e) + { + base.OnFormClosed(e); + if(this.DialogResult == DialogResult.OK) { + UInt32 count = (UInt32)nudTimeout.Value; + ConfigManager.Config.DebugInfo.ScriptTimeout = count; + ConfigManager.ApplyChanges(); + DebugInfo.ApplyConfig(); + } + } + } +} diff --git a/GUI.NET/Debugger/frmSetScriptTimeout.resx b/GUI.NET/Debugger/frmSetScriptTimeout.resx new file mode 100644 index 00000000..8766f298 --- /dev/null +++ b/GUI.NET/Debugger/frmSetScriptTimeout.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index cae3f742..01ee44b7 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -650,6 +650,12 @@ frmAssembler.cs + + Form + + + frmSetScriptTimeout.cs + Form @@ -1330,6 +1336,9 @@ ctrlSourceViewer.cs + + frmSetScriptTimeout.cs + frmTextHooker.cs diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 4a38ab42..34c3b5d3 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -248,6 +248,7 @@ namespace Mesen.GUI [DllImport(DLLPath)] public static extern void DebugSetMemoryValue(DebugMemoryType type, UInt32 address, byte value); [DllImport(DLLPath)] public static extern void DebugSetInputOverride(Int32 port, Int32 state); + [DllImport(DLLPath)] public static extern void DebugSetScriptTimeout(UInt32 timeout); [DllImport(DLLPath)] public static extern Int32 DebugLoadScript([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string content, Int32 scriptId = -1); [DllImport(DLLPath)] public static extern void DebugRemoveScript(Int32 scriptId); [DllImport(DLLPath, EntryPoint = "DebugGetScriptLog")] private static extern IntPtr DebugGetScriptLogWrapper(Int32 scriptId); diff --git a/InteropDLL/DebugWrapper.cpp b/InteropDLL/DebugWrapper.cpp index 4f08c4c1..87ad4f10 100644 --- a/InteropDLL/DebugWrapper.cpp +++ b/InteropDLL/DebugWrapper.cpp @@ -8,6 +8,7 @@ #include "../Core/Profiler.h" #include "../Core/Assembler.h" #include "../Core/TraceLogger.h" +#include "../Core/LuaScriptingContext.h" enum class ConsoleId; @@ -138,6 +139,7 @@ extern "C" DllExport int32_t __stdcall DebugLoadScript(char* name, char* content, int32_t scriptId) { return GetDebugger()->LoadScript(name, content, scriptId); } DllExport void __stdcall DebugRemoveScript(int32_t scriptId) { GetDebugger()->RemoveScript(scriptId); } DllExport const char* __stdcall DebugGetScriptLog(int32_t scriptId) { return GetDebugger()->GetScriptLog(scriptId); } + DllExport void __stdcall DebugSetScriptTimeout(uint32_t timeout) { LuaScriptingContext::SetScriptTimeout(timeout); } DllExport void __stdcall DebugGetDebugEvents(uint32_t* pictureBuffer, DebugEventInfo *infoArray, uint32_t &maxEventCount, bool returnPreviousFrameData) { GetDebugger()->GetDebugEvents(pictureBuffer, infoArray, maxEventCount, returnPreviousFrameData); } DllExport uint32_t __stdcall DebugGetDebugEventCount(bool returnPreviousFrameData) { return GetDebugger()->GetDebugEventCount(returnPreviousFrameData); }