Cause register access for scripts

This commit is contained in:
LuigiBlood 2019-01-24 19:48:26 +01:00
parent 2d8afa9217
commit c714584fac
3 changed files with 35 additions and 0 deletions

View File

@ -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({},
{

View File

@ -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;

View File

@ -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 },