From c714584faccd0fd532977af1d6c69c836b0a125e Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Thu, 24 Jan 2019 19:48:26 +0100 Subject: [PATCH 1/2] Cause register access for scripts --- Source/Project64/UserInterface/API.js | 14 ++++++++++++++ .../UserInterface/Debugger/ScriptInstance.cpp | 17 +++++++++++++++++ .../UserInterface/Debugger/ScriptInstance.h | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/Source/Project64/UserInterface/API.js b/Source/Project64/UserInterface/API.js index 9fea578db..29d00cc1c 100644 --- a/Source/Project64/UserInterface/API.js +++ b/Source/Project64/UserInterface/API.js @@ -593,6 +593,20 @@ const dfpr = new Proxy({}, } }) +const cop0 = new Proxy({}, +{ + get: function (obj, prop) { + if (prop == "cause") { + return _native.getCauseVal(); + } + }, + set: function (obj, prop, val) { + if (prop == "cause") { + _native.setCauseVal(val); + } + } +}) + const rom = { u8: new Proxy({}, { diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp index 967f07073..7a353e324 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp @@ -974,6 +974,23 @@ duk_ret_t CScriptInstance::js_SetFPRVal(duk_context* ctx) return 1; } +duk_ret_t CScriptInstance::js_GetCauseVal(duk_context* ctx) +{ + duk_push_uint(ctx, g_Reg->FAKE_CAUSE_REGISTER); + return 1; +} + +duk_ret_t CScriptInstance::js_SetCauseVal(duk_context* ctx) +{ + uint32_t val = duk_to_uint32(ctx, 0); + + g_Reg->FAKE_CAUSE_REGISTER = val; + g_Reg->CheckInterrupts(); + + duk_pop_n(ctx, 1); + return 1; +} + duk_ret_t CScriptInstance::js_GetROMInt(duk_context* ctx) { uint32_t address = duk_to_uint32(ctx, 0) & 0x0FFFFFFF; diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.h b/Source/Project64/UserInterface/Debugger/ScriptInstance.h index 6c2294e3e..9b4836b30 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.h +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.h @@ -156,6 +156,8 @@ private: static duk_ret_t js_SetGPRVal(duk_context*); // (regNum, bUpper, value) static duk_ret_t js_GetFPRVal(duk_context*); // (regNum, bDouble) static duk_ret_t js_SetFPRVal(duk_context*); // (regNum, bDouble, value) + static duk_ret_t js_GetCauseVal(duk_context*); // () + static duk_ret_t js_SetCauseVal(duk_context*); // (value) static duk_ret_t js_GetROMInt(duk_context*); // (address, bitwidth, signed) static duk_ret_t js_GetROMFloat(duk_context*); // (address, bDouble) static duk_ret_t js_GetROMBlock(duk_context*); // (address, nBytes) ; returns Buffer @@ -202,6 +204,8 @@ private: { "getGPRVal", js_GetGPRVal, DUK_VARARGS }, { "setFPRVal", js_SetFPRVal, DUK_VARARGS }, { "getFPRVal", js_GetFPRVal, DUK_VARARGS }, + { "setCauseVal", js_SetCauseVal, DUK_VARARGS }, + { "getCauseVal", js_GetCauseVal, DUK_VARARGS }, { "getROMInt", js_GetROMInt, DUK_VARARGS }, { "getROMFloat", js_GetROMFloat, DUK_VARARGS }, From e438e535066c92a10bcdd9040fcfe2d4f251aa47 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Thu, 24 Jan 2019 19:51:49 +0100 Subject: [PATCH 2/2] ApiDoc update to include cop0 class and cause register. --- apidoc.htm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apidoc.htm b/apidoc.htm index 1a3fc4709..fe51e4481 100644 --- a/apidoc.htm +++ b/apidoc.htm @@ -108,6 +108,7 @@ span.tag2 { ugpr
fpr
dfpr
+ cop0
Server
Socket
AddressRange
@@ -773,6 +774,16 @@ events.onexec(0x802CB1C0, function() +
+
cop0
+
+
cop0.cause
+
+ Variable representing the Cause register. Updates interrupts when written. +
+
+
+
Server