diff --git a/Source/Project64/UserInterface/API.js b/Source/Project64/UserInterface/API.js index 27f3fcf4a..bec3727ca 100644 --- a/Source/Project64/UserInterface/API.js +++ b/Source/Project64/UserInterface/API.js @@ -299,10 +299,10 @@ const events = (function() return events.on('exec', callback, param, param2) }, - onexecopcode: function(addr, value, arg3, arg4) + onopcode: function (addr, value, arg3, arg4) { - // onexecopcode(addr, value, callback) - // onexecopcode(addr, value, mask, callback) + // onopcode(addr, value, callback) + // onopcode(addr, value, mask, callback) var start = 0; var end = 0; @@ -331,7 +331,7 @@ const events = (function() } this._stashCallback(callback); - return _native.addCallback('execopcode', callback, start, end, value, mask) + return _native.addCallback('onopcode', callback, start, end, value, mask) }, onread: function(addr, callback) { diff --git a/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp b/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp index b9bb43732..2ab70a2b6 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp @@ -33,8 +33,8 @@ CScriptSystem::CScriptSystem(CDebuggerUI* debugger) RegisterHook("exec", m_HookCPUExec); RegisterHook("read", m_HookCPURead); RegisterHook("write", m_HookCPUWrite); + RegisterHook("onopcode", m_HookCPUExecOpcode); RegisterHook("draw", m_HookFrameDrawn); - RegisterHook("execopcode", m_HookCPUExecOpcode); HMODULE hInst = GetModuleHandle(NULL); HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(IDR_JSAPI_TEXT), "TEXT"); diff --git a/apidoc.htm b/apidoc.htm index 18cd9863b..0220bf90e 100644 --- a/apidoc.htm +++ b/apidoc.htm @@ -75,7 +75,7 @@ span.tag { color: #885; font-weight: bold; padding: 0px 2px; - font-size: 12px; + font-size: 11px; } span.tag2 { float: right; @@ -86,7 +86,7 @@ span.tag2 { color: #588; font-weight: bold; padding: 0px 2px; - font-size: 12px; + font-size: 11px; } @@ -213,7 +213,7 @@ Player.prototype.move = function(x, y, z) Player.prototype.heal = function() { - this.health = 100; + this.health = 100 } var player = new Player(0x8033B1AC) @@ -266,10 +266,10 @@ console.log('Internal ROM name: ' + romName) -->
@@ -279,60 +279,106 @@ events.onexec(0x802CB1C0, function() })
-events.onexec(ADDR_ANY, function(addr)) +events.onexec(ADDR_ANY, function(pc)) { // Log every step! - console.log('CPU is executing ' + addr.hex()) + console.log('CPU is executing 0x' + pc.hex()) })
events.onread(0x8033B1B0, function() { - console.log('CPU is reading 8033B1B0') + console.log('CPU is reading 0x8033B1B0') })
-const addr_range_rom = {start: 0xB0000000, end: 0xB6000000} - -events.onread(addr_range_rom, function(addr) +events.onread(ADDR_ANY_CART_ROM_UNC, function(addr) { - console.log('CPU is reading ROM ' + addr) + console.log('CPU is reading ROM 0x' + addr.hex()) })
events.onwrite(0x8033B1B0, function() { - console.log('CPU is modifying 8033B1B0') + console.log('CPU is modifying 0x8033B1B0') })
-events.onwrite({0xB0000000, 0x90000000}, function(addr) +events.onwrite(ADDR_ANY_CART_ROM_UNC, function(addr) { - console.log(gpr.pc.hex() + ': wrote to cartridge ' + addr.hex()); + console.log(gpr.pc.hex() + ': wrote to cartridge ' + addr.hex()) })
+const JR_RA = 0x03E00008 // 'jr ra' command + +events.onopcode(ADDR_ANY, JR_RA, function(pc) +{ + console.log(pc.hex()) // log pc at every 'jr ra' +}) ++
+const ADDIU_SP_SP = 0x27BD0000 // 'addiu sp, sp, 0x0000' +const NO_IMM16 = 0xFFFF0000 // mask off immediate field + +events.onopcode(ADDR_ANY, ADDIU_SP_SP, NO_IMM16, function(pc) +{ + // log pc at every 'addiu sp, sp, x' regardless of the immediate value + console.log(pc.hex()) +}) ++
+const JAL = 0x0C000000 // 'jal 0x00000000' +const NO_TARGET = 0xFC000000 // mask off target field + +events.onopcode(ADDR_ANY, JAL, NO_TARGET, function(pc) +{ + // log pc at every 'jal' regardless of the target address + console.log(pc.hex()) +}) ++