From 8aab789a24be44e1fdb8a14f7b92862f4cef1068 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 24 Aug 2018 05:13:08 +0200 Subject: [PATCH] fix interrupt enable/disable macros --- inc/n64_util.inc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/inc/n64_util.inc b/inc/n64_util.inc index e444b81..a42a88a 100644 --- a/inc/n64_util.inc +++ b/inc/n64_util.inc @@ -1,15 +1,22 @@ macro EnableInt() { - lli t0, 0xAAA - lli t1, 0xFF01 + lli t0, MI_INTR_MASK_ALL_SET lui a0, MI_BASE sw t0, MI_INTR_MASK(a0) + // careful not to touch unrelated flags here + mfc0 t1, CP0_Status + lli t0, CP0_STATUS_IM_ALL + or t1, t0 mtc0 t1, CP0_Status } macro DisableInt() { - lli t0, 0x555 - lli t1, 0x0001 + lli t0, MI_INTR_MASK_ALL_CLR lui a0, MI_BASE sw t0, MI_INTR_MASK(a0) + // 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 mtc0 t1, CP0_Status }