From e7374447f3e571698bd99bf23dfc50e46be1161e Mon Sep 17 00:00:00 2001 From: warmCabin <35278529+warmCabin@users.noreply.github.com> Date: Tue, 10 Dec 2019 22:59:35 -0500 Subject: [PATCH 1/4] make onmemoryexecute address default to null --- BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index 3ef04e8708..2520830dc1 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -183,9 +183,9 @@ namespace BizHawk.Client.Common return nlf.Guid.ToString(); } - [LuaMethodExample("local steveonm = event.onmemoryexecute(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires after the given address is executed by the core\" );\r\n\tend\r\n\t, 0x200, \"Frame name\", \"System Bus\" );")] - [LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core")] - public string OnMemoryExecute(LuaFunction luaf, uint address, string name = null, string domain = null) + [LuaMethodExample("local steveonm = event.onmemoryexecute(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires after the given address is executed by the core. If no address is given, it will attach to every memory read\" );\r\n\tend\r\n\t, 0x200, \"Frame name\", \"System Bus\" );")] + [LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core. If no address is given, it will attach to every memory read")] + public string OnMemoryExecute(LuaFunction luaf, uint address = null, string name = null, string domain = null) { try { From baca4e2af8395e0019285b7f53eb267a24a1fa27 Mon Sep 17 00:00:00 2001 From: warmCabin <35278529+warmCabin@users.noreply.github.com> Date: Tue, 10 Dec 2019 23:02:18 -0500 Subject: [PATCH 2/4] allow onmemoryexecute to have null address --- .../Base Implementations/MemoryCallbackSystem.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs index 7a929cf8be..458cec1173 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs @@ -295,11 +295,6 @@ namespace BizHawk.Emulation.Common { public MemoryCallback(string scope, MemoryCallbackType type, string name, MemoryCallbackDelegate callback, uint? address, uint? mask) { - if (type == MemoryCallbackType.Execute && !address.HasValue) - { - throw new InvalidOperationException("When assigning an execute callback, an address must be specified"); - } - Type = type; Name = name; Callback = callback; From 715761f563e7319f16f9fae14479f82a3b756fb2 Mon Sep 17 00:00:00 2001 From: warmCabin <35278529+warmCabin@users.noreply.github.com> Date: Tue, 10 Dec 2019 23:23:40 -0500 Subject: [PATCH 3/4] unit? --- BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index 2520830dc1..073724d987 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -185,7 +185,7 @@ namespace BizHawk.Client.Common [LuaMethodExample("local steveonm = event.onmemoryexecute(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires after the given address is executed by the core. If no address is given, it will attach to every memory read\" );\r\n\tend\r\n\t, 0x200, \"Frame name\", \"System Bus\" );")] [LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core. If no address is given, it will attach to every memory read")] - public string OnMemoryExecute(LuaFunction luaf, uint address = null, string name = null, string domain = null) + public string OnMemoryExecute(LuaFunction luaf, uint? address = null, string name = null, string domain = null) { try { From 201a4b85a4b202f0c2f7f650343aaac63db872ea Mon Sep 17 00:00:00 2001 From: warmCabin <35278529+warmCabin@users.noreply.github.com> Date: Wed, 11 Dec 2019 12:44:54 -0500 Subject: [PATCH 4/4] remove default value for address The reason we throw an error originally is my concern is that it would be easy to leave out an address in a script, and that it would have huge concequences. I think address should not have a default value here and make the user explicitly add nil if they want this functionality. --- BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index 073724d987..4bbc58f34f 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -183,9 +183,9 @@ namespace BizHawk.Client.Common return nlf.Guid.ToString(); } - [LuaMethodExample("local steveonm = event.onmemoryexecute(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires after the given address is executed by the core. If no address is given, it will attach to every memory read\" );\r\n\tend\r\n\t, 0x200, \"Frame name\", \"System Bus\" );")] - [LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core. If no address is given, it will attach to every memory read")] - public string OnMemoryExecute(LuaFunction luaf, uint? address = null, string name = null, string domain = null) + [LuaMethodExample("local steveonm = event.onmemoryexecute(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires after the given address is executed by the core. If is explicitly nil, it will attach to every memory read\" );\r\n\tend\r\n\t, 0x200, \"Frame name\", \"System Bus\" );")] + [LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core. If the address is explicitly nil, it will attach to every memory read")] + public string OnMemoryExecute(LuaFunction luaf, uint? address, string name = null, string domain = null) { try {