homebrew/inc/n64_util.inc

39 lines
974 B
PHP
Raw Normal View History

2018-08-20 20:10:06 -07:00
macro EnableInt() {
// careful not to touch unrelated flags here
mfc0 t0, CP0_Status
addiu at, r0, CP0_STATUS_IE
or t0, at
mtc0 t0, CP0_Status
}
macro DisableInt() {
// careful not to touch unrelated flags here
mfc0 t0, CP0_Status
addiu at, r0, ~CP0_STATUS_IE
and t0, at
mtc0 t0, CP0_Status
}
macro SetIntMask() {
2018-08-23 20:13:08 -07:00
lli t0, MI_INTR_MASK_ALL_SET
2018-08-20 20:10:06 -07:00
lui a0, MI_BASE
sw t0, MI_INTR_MASK(a0)
2018-08-23 20:13:08 -07:00
// careful not to touch unrelated flags here
mfc0 t1, CP0_Status
lli t0, CP0_STATUS_IM_ALL
or t1, t0
2018-08-20 20:10:06 -07:00
mtc0 t1, CP0_Status
}
macro ClearIntMask() {
2018-08-23 20:13:08 -07:00
lli t0, MI_INTR_MASK_ALL_CLR
2018-08-20 20:10:06 -07:00
lui a0, MI_BASE
sw t0, MI_INTR_MASK(a0)
2018-08-23 20:13:08 -07:00
// careful not to touch unrelated flags here
mfc0 t1, CP0_Status
lli t0, CP0_STATUS_IM_ALL
nor t0, r0 // invert the mask (including upper halfword)
and t1, t0
2018-08-20 20:10:06 -07:00
mtc0 t1, CP0_Status
}