Merge pull request #1574 from LuigiBlood/cause_reg_pull

COP0 Cause register access for Scripts
This commit is contained in:
zilmar 2019-01-25 06:16:51 +10:30 committed by GitHub
commit 1789dccda2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 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 = { const rom = {
u8: new Proxy({}, u8: new Proxy({},
{ {

View File

@ -974,6 +974,23 @@ duk_ret_t CScriptInstance::js_SetFPRVal(duk_context* ctx)
return 1; 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) duk_ret_t CScriptInstance::js_GetROMInt(duk_context* ctx)
{ {
uint32_t address = duk_to_uint32(ctx, 0) & 0x0FFFFFFF; 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_SetGPRVal(duk_context*); // (regNum, bUpper, value)
static duk_ret_t js_GetFPRVal(duk_context*); // (regNum, bDouble) 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_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_GetROMInt(duk_context*); // (address, bitwidth, signed)
static duk_ret_t js_GetROMFloat(duk_context*); // (address, bDouble) static duk_ret_t js_GetROMFloat(duk_context*); // (address, bDouble)
static duk_ret_t js_GetROMBlock(duk_context*); // (address, nBytes) ; returns Buffer static duk_ret_t js_GetROMBlock(duk_context*); // (address, nBytes) ; returns Buffer
@ -202,6 +204,8 @@ private:
{ "getGPRVal", js_GetGPRVal, DUK_VARARGS }, { "getGPRVal", js_GetGPRVal, DUK_VARARGS },
{ "setFPRVal", js_SetFPRVal, DUK_VARARGS }, { "setFPRVal", js_SetFPRVal, DUK_VARARGS },
{ "getFPRVal", js_GetFPRVal, DUK_VARARGS }, { "getFPRVal", js_GetFPRVal, DUK_VARARGS },
{ "setCauseVal", js_SetCauseVal, DUK_VARARGS },
{ "getCauseVal", js_GetCauseVal, DUK_VARARGS },
{ "getROMInt", js_GetROMInt, DUK_VARARGS }, { "getROMInt", js_GetROMInt, DUK_VARARGS },
{ "getROMFloat", js_GetROMFloat, DUK_VARARGS }, { "getROMFloat", js_GetROMFloat, DUK_VARARGS },

View File

@ -108,6 +108,7 @@ span.tag2 {
<a href="#ugpr">ugpr</a><br> <a href="#ugpr">ugpr</a><br>
<a href="#fpr">fpr</a><br> <a href="#fpr">fpr</a><br>
<a href="#dfpr">dfpr</a><br> <a href="#dfpr">dfpr</a><br>
<a href="#cop0">cop0</a><br>
<a href="#Server">Server</a><br> <a href="#Server">Server</a><br>
<a href="#Socket">Socket</a><br> <a href="#Socket">Socket</a><br>
<a href="#AddressRange">AddressRange</a><br> <a href="#AddressRange">AddressRange</a><br>
@ -773,6 +774,16 @@ events.onexec(0x802CB1C0, function()
</div> </div>
</div> </div>
<div class="panel" id="cop0">
<div class="classname">cop0</div>
<div class="property">
<div class="propertyname">cop0.cause</div>
<div class="propertydesc">
Variable representing the Cause register. Updates interrupts when written.
</div>
</div>
</div>
<div class="panel" id="Server"> <div class="panel" id="Server">
<div class="classname">Server</div> <div class="classname">Server</div>