From d7444e144ae3851641fc00ba83debd7a065795b5 Mon Sep 17 00:00:00 2001 From: Wolfvak Date: Thu, 23 Jul 2020 23:46:15 -0300 Subject: [PATCH] use a regular global pointer for sharedmem fetching the thread id requires coprocessor access which means doing funky switches between thumb and arm - it's faster to just allocate a single pointer and do an indirect load when necessary --- arm9/source/main.c | 1 + common/shmem.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arm9/source/main.c b/arm9/source/main.c index 4d6e8d7..36be0c0 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -7,6 +7,7 @@ #include "hid.h" +SystemSHMEM *shmemGlobalBase; void main(int argc, char** argv, int entrypoint) { diff --git a/common/shmem.h b/common/shmem.h index 39b5255..e377e2f 100755 --- a/common/shmem.h +++ b/common/shmem.h @@ -36,13 +36,15 @@ typedef struct { #ifdef ARM9 #include +extern SystemSHMEM *shmemGlobalBase; + static inline SystemSHMEM *ARM_GetSHMEM(void) { - return (SystemSHMEM*)ARM_GetTID(); + return shmemGlobalBase; } static inline void ARM_InitSHMEM(void) { - ARM_SetTID(PXI_DoCMD(PXI_GET_SHMEM, NULL, 0)); + shmemGlobalBase = (SystemSHMEM*)PXI_DoCMD(PXI_GET_SHMEM, NULL, 0); } #endif