From 69e0edffb4d7c18bce2189cc677b4439e78d91c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20B=2E?= Date: Sat, 25 Oct 2025 22:07:54 +0200 Subject: [PATCH] fix build on new libctru and add lang fetch (#358) removes ACT functions now in libctru implement a single function to load a CFG_Language --- include/ui_strings.h | 4 +++ source/badges.c | 58 +++++--------------------------------------- source/main.c | 3 +-- source/ui_strings.c | 9 +++++++ 4 files changed, 20 insertions(+), 54 deletions(-) diff --git a/include/ui_strings.h b/include/ui_strings.h index 5f90505..aef8b25 100644 --- a/include/ui_strings.h +++ b/include/ui_strings.h @@ -193,4 +193,8 @@ typedef enum { Language_s init_strings(CFG_Language lang); extern Language_s language; +// fetches the system language through CFGU_GetSystemLanguage +// and returns the appropriate CFG_Language enum value +CFG_Language get_system_language(void); + #endif diff --git a/source/badges.c b/source/badges.c index 0e7cc93..66f434b 100644 --- a/source/badges.c +++ b/source/badges.c @@ -32,7 +32,6 @@ #include "draw.h" #include "ui_strings.h" -static Handle actHandle; Handle badgeDataHandle; char *badgeMngBuffer; u16 *rgb_buf_64x64; @@ -42,51 +41,6 @@ u8 *alpha_buf_32x32; u64 progress_finish; u64 progress_status; -Result actInit(void) -{ - return srvGetServiceHandle(&actHandle, "act:u"); -} - -Result actExit(void) -{ - return svcCloseHandle(actHandle); -} - -Result ACTU_Initialize(u32 sdkVersion, u32 memSize, Handle handle) -{ - Result ret = 0; - u32 *cmdbuf = getThreadCommandBuffer(); - - cmdbuf[0] = 0x00010084; - cmdbuf[1] = sdkVersion; - cmdbuf[2] = memSize; - cmdbuf[3] = 0x20; - cmdbuf[4] = 0x0; - cmdbuf[5] = 0x0; - cmdbuf[6] = handle; - - if ((ret = svcSendSyncRequest(actHandle)) != 0) return ret; - - return (Result) cmdbuf[1]; -} - -Result ACTU_GetAccountDataBlock(u32 slot, u32 size, u32 blockId, u32 *output) -{ - Result ret = 0; - u32 *cmdbuf = getThreadCommandBuffer(); - cmdbuf[0] = 0x000600C2; - cmdbuf[1] = slot; - cmdbuf[2] = size; - cmdbuf[3] = blockId; - cmdbuf[4] = (size << 4) | 12; - cmdbuf[5] = (u32) output; - - if ((ret = svcSendSyncRequest(actHandle)) != 0) return ret; - - return (Result) cmdbuf[1]; -} - - void remove_exten(u16 *filename) { for (int i = 0; i < strulen(filename, 0x8A); ++i) @@ -575,27 +529,27 @@ Result install_badges(void) if (handle) FSFILE_Close(handle); DEBUG("Initializing ACT\n"); - res = actInit(); + res = actInit(true); if (R_FAILED(res)) { DEBUG("actInit() failed!\n"); return res; } - DEBUG("Initializing ACTU\n"); - res = ACTU_Initialize(0xB0502C8, 0, 0); + DEBUG("Initializing ACT\n"); + res = ACT_Initialize(0xB0502C8, 0, 0); if (R_FAILED(res)) { - DEBUG("ACTU_Initialize failed! %08lx\n", res); + DEBUG("ACT_Initialize failed! %08lx\n", res); return res; } DEBUG("Getting NNID\n"); u32 nnidNum = 0xFFFFFFFF; - res = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum); + res = ACT_GetAccountInfo(&nnidNum, sizeof(nnidNum), ACT_DEFAULT_ACCOUNT, INFO_TYPE_PRINCIPAL_ID); if (R_FAILED(res)) { - DEBUG("ACTU_GetAccountDataBlock failed! %08lx\n", res); + DEBUG("ACT_GetAccountInfo failed! %08lx\n", res); return res; } DEBUG("NNID found: 0x%08lx\n", nnidNum); diff --git a/source/main.c b/source/main.c index fe1a024..1bdb02a 100644 --- a/source/main.c +++ b/source/main.c @@ -381,8 +381,7 @@ int main(void) { srand(time(NULL)); init_services(); - CFG_Language lang; - CFGU_GetSystemLanguage(&lang); + const CFG_Language lang = get_system_language(); language = init_strings(lang); init_screens(); diff --git a/source/ui_strings.c b/source/ui_strings.c index 7baba56..5411e41 100644 --- a/source/ui_strings.c +++ b/source/ui_strings.c @@ -2086,3 +2086,12 @@ Language_s init_strings(CFG_Language lang) return language_english; } } + +CFG_Language get_system_language(void) +{ + u8 lang = CFG_LANGUAGE_EN; + // can never fail, cfguInit is one of the very first thing that happens on start + // and if it does anyway, default to english + CFGU_GetSystemLanguage(&lang); + return (CFG_Language)lang; +}