From e3973c6949814717f22e3db91129829a62941232 Mon Sep 17 00:00:00 2001
From: notaz <notasas@gmail.com>
Date: Sat, 8 Jul 2023 17:53:56 +0300
Subject: [PATCH] drc: fix some table math

libretro/pcsx_rearmed#713
---
 libpcsxcore/new_dynarec/pcsxmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c
index 69a4c99d..a32b4183 100644
--- a/libpcsxcore/new_dynarec/pcsxmem.c
+++ b/libpcsxcore/new_dynarec/pcsxmem.c
@@ -47,7 +47,8 @@ void map_item(uintptr_t *out, const void *h, uintptr_t flag)
 
 // size must be power of 2, at least 4k
 #define map_l1_mem(tab, i, addr, size, base) \
-	map_item(&tab[((addr)>>12) + i], (u8 *)(base) - (u32)(addr) - ((i << 12) & ~(size - 1)), 0)
+	map_item(&tab[((addr)>>12) + i], \
+		 (u8 *)(base) - (u32)((addr) + ((i << 12) & ~(size - 1))), 0)
 
 #define IOMEM32(a) (((a) & 0xfff) / 4)
 #define IOMEM16(a) (0x1000/4 + (((a) & 0xfff) / 2))
-- 
2.39.5