From 0f8895bcc3801657d967897002e8533f795e34ab Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 18 Apr 2016 15:22:41 +0100 Subject: [PATCH] (3DS) the parallax layer register can be written to from userland with GSPGPU_WriteHWRegs. --- Makefile.ctr | 2 +- ctr/ctr_svchax.c | 46 -------------------------------------------- gfx/drivers/ctr_gu.h | 8 +++++++- 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/Makefile.ctr b/Makefile.ctr index 8aa1e34742..be92bf934e 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -21,7 +21,7 @@ APP_RSF = ctr/tools/template.rsf APP_SYSTEM_MODE = 64MB APP_SYSTEM_MODE_EXT = 124MB APP_BIG_TEXT_SECTION = 0 -APP_USE_SVCHAX = 1 +APP_USE_SVCHAX = 0 include ctr/Makefile.cores diff --git a/ctr/ctr_svchax.c b/ctr/ctr_svchax.c index 1baae59619..cadea4ecc5 100644 --- a/ctr/ctr_svchax.c +++ b/ctr/ctr_svchax.c @@ -45,27 +45,6 @@ static u32 svc_7b(backdoor_fn entry_fn, ...) // can pass up to two arguments to return 0; } -static __attribute__((naked)) -u32 k_get_PA(u32* addr) -{ - __asm__ volatile( - "mov r1, r0 \n\t" - "mcr p15, 0, r0, c7, c8, 1 \n\t" - "mrc p15, 0, r0, c7, c4, 0 \n\t" - "mov r0, r0, LSR#12 \n\t" - "mov r0, r0, LSL#12 \n\t" - "mov r1, r1, LSL#20 \n\t" - "orr r0, r1, LSR#20 \n\t" - "bx lr \n\t" - ); - return 0; -} - -u32 get_PA(u32 addr) -{ - return svc_7b((backdoor_fn)k_get_PA, addr); -} - static void k_enable_all_svcs(u32 isNew3DS) { u32* thread_ACL = *(*(u32***)CURRENT_KTHREAD + 0x22) - 0x6; @@ -526,28 +505,3 @@ Result svchax_init(bool patch_srv) return 0; } - -Result ctr_set_parallax_layer(bool state) -{ - static u32 parallax_layer_kaddr = 0; - - if(!__ctr_svchax) - return -1; - - if(!parallax_layer_kaddr) - { - for (parallax_layer_kaddr = 0xfffc0000; parallax_layer_kaddr < 0xfffe0000; parallax_layer_kaddr += 0x2000) - { - if (get_PA(parallax_layer_kaddr) == 0x10202000) - break; - else - svcSleepThread(10000); - } - } - - write_kaddr(parallax_layer_kaddr, state? 0x00010001: 0x0); -#if 0 - printf("set layer : %s\n", state?"ON" : "OFF"); -#endif - return 0; -} diff --git a/gfx/drivers/ctr_gu.h b/gfx/drivers/ctr_gu.h index cb4683af45..eee562c4a9 100644 --- a/gfx/drivers/ctr_gu.h +++ b/gfx/drivers/ctr_gu.h @@ -67,7 +67,13 @@ extern u32 gpuCmdBufOffset; extern u32 __linear_heap_size; extern u32 __linear_heap; -Result ctr_set_parallax_layer(bool state); +__attribute__((always_inline)) +static INLINE Result ctr_set_parallax_layer(bool state) +{ + u32 reg_state = state? 0x00010001: 0x0; + return GSPGPU_WriteHWRegs(0x202000, ®_state, 4); +} + __attribute__((always_inline)) static INLINE void ctrGuSetTexture(GPU_TEXUNIT unit, u32* data,