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 },
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()
+