diff --git a/sysmodules/rosalina/include/menu.h b/sysmodules/rosalina/include/menu.h index 0bba97b5..6a42a67e 100644 --- a/sysmodules/rosalina/include/menu.h +++ b/sysmodules/rosalina/include/menu.h @@ -70,6 +70,9 @@ extern bool isHidInitialized; extern u32 mcuFwVersion; extern u8 mcuInfoTable[9]; extern bool mcuInfoTableRead; +extern const char *topScreenType; +extern const char *bottomScreenType; +extern bool areScreenTypesInitialized; // From main.c extern bool isN3DS; diff --git a/sysmodules/rosalina/include/menus.h b/sysmodules/rosalina/include/menus.h index 3b7a662a..336f4ccb 100644 --- a/sysmodules/rosalina/include/menus.h +++ b/sysmodules/rosalina/include/menus.h @@ -41,5 +41,7 @@ void RosalinaMenu_PowerOff(void); void RosalinaMenu_Reboot(void); void RosalinaMenu_Cheats(void); +void RosalinaMenu_ShowSystemInfo(); + bool rosalinaMenuShouldShowDebugInfo(void); void RosalinaMenu_ShowDebugInfo(void); diff --git a/sysmodules/rosalina/source/menu.c b/sysmodules/rosalina/source/menu.c index b2b24aa4..5d3fefda 100644 --- a/sysmodules/rosalina/source/menu.c +++ b/sysmodules/rosalina/source/menu.c @@ -46,6 +46,10 @@ u32 mcuFwVersion = 0; u8 mcuInfoTable[9] = {0}; bool mcuInfoTableRead = false; +const char *topScreenType = NULL; +const char *bottomScreenType = NULL; +bool areScreenTypesInitialized = false; + // libctru redefinition: bool hidShouldUseIrrst(void) @@ -235,6 +239,50 @@ static Result menuUpdateMcuInfo(void) return res; } +static const char *menuGetScreenTypeStr(u8 vendorId) +{ + switch (vendorId) + { + case 1: return "IPS"; // SHARP + case 12: return "TN"; // JDN + default: return "unknown"; + } +} + +static void menuReadScreenTypes(void) +{ + if (areScreenTypesInitialized) + return; + + if (!isN3DS) + { + // Old3DS never have IPS screens and GetVendors is not implemented + topScreenType = "TN"; + bottomScreenType = "TN"; + areScreenTypesInitialized = true; + } + else + { + srvSetBlockingPolicy(true); + + Result res = gspLcdInit(); + if (R_SUCCEEDED(res)) + { + u8 vendors = 0; + if (R_SUCCEEDED(GSPLCD_GetVendors(&vendors))) + { + topScreenType = menuGetScreenTypeStr(vendors >> 4); + bottomScreenType = menuGetScreenTypeStr(vendors & 0xF); + areScreenTypesInitialized = true; + } + + gspLcdExit(); + } + + srvSetBlockingPolicy(false); + } +} + static inline u32 menuAdvanceCursor(u32 pos, u32 numItems, s32 displ) { return (pos + numItems + displ) % numItems; @@ -272,7 +320,7 @@ void menuThreadMain(void) if(isN3DS) N3DSMenu_UpdateStatus(); - while (!isServiceUsable("ac:u") || !isServiceUsable("hid:USER") || !isServiceUsable("gsp::Gpu") || !isServiceUsable("cdc:CHK")) + while (!isServiceUsable("ac:u") || !isServiceUsable("hid:USER") || !isServiceUsable("gsp::Gpu") || !isServiceUsable("gsp::Lcd") || !isServiceUsable("cdc:CHK")) svcSleepThread(250 * 1000 * 1000LL); handleShellOpened(); @@ -280,6 +328,8 @@ void menuThreadMain(void) hidInit(); // assume this doesn't fail isHidInitialized = true; + menuReadScreenTypes(); + while(!preTerminationRequested) { svcSleepThread(50 * 1000 * 1000LL); @@ -385,6 +435,14 @@ static void menuDraw(Menu *menu, u32 selected) int n = sprintf(ipBuffer, "%hhu.%hhu.%hhu.%hhu", addr[0], addr[1], addr[2], addr[3]); Draw_DrawString(SCREEN_BOT_WIDTH - 10 - SPACING_X * n, 10, COLOR_WHITE, ipBuffer); } +#if 0 + else if (areScreenTypesInitialized) + { + char screenTypesBuffer[32]; + int n = sprintf(screenTypesBuffer, "T: %s | B: %s", topScreenType, bottomScreenType); + Draw_DrawString(SCREEN_BOT_WIDTH - 10 - SPACING_X * n, 10, COLOR_WHITE, screenTypesBuffer); + } +#endif else Draw_DrawFormattedString(SCREEN_BOT_WIDTH - 10 - SPACING_X * 15, 10, COLOR_WHITE, "%15s", ""); diff --git a/sysmodules/rosalina/source/menus.c b/sysmodules/rosalina/source/menus.c index 766a0d8c..f4d43443 100644 --- a/sysmodules/rosalina/source/menus.c +++ b/sysmodules/rosalina/source/menus.c @@ -59,6 +59,7 @@ Menu rosalinaMenu = { { "Save settings", METHOD, .method = &RosalinaMenu_SaveSettings }, { "Power off", METHOD, .method = &RosalinaMenu_PowerOff }, { "Reboot", METHOD, .method = &RosalinaMenu_Reboot }, + { "System info", METHOD, .method = &RosalinaMenu_ShowSystemInfo }, { "Credits", METHOD, .method = &RosalinaMenu_ShowCredits }, { "Debug info", METHOD, .method = &RosalinaMenu_ShowDebugInfo, .visibility = &rosalinaMenuShouldShowDebugInfo }, {}, @@ -96,6 +97,37 @@ void RosalinaMenu_SaveSettings(void) while(!(waitInput() & KEY_B) && !menuShouldExit); } +void RosalinaMenu_ShowSystemInfo(void) +{ + u32 kver = osGetKernelVersion(); + + do + { + Draw_Lock(); + Draw_DrawString(10, 10, COLOR_TITLE, "Rosalina -- System info"); + + u32 posY = 30; + + if (areScreenTypesInitialized) + { + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "Top screen type: %s\n", topScreenType); + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "Bottom screen type: %s\n\n", bottomScreenType); + } + + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "Kernel version: %lu.%lu-%lu\n\n", GET_VERSION_MAJOR(kver), GET_VERSION_MINOR(kver), GET_VERSION_REVISION(kver)); + if (mcuFwVersion != 0 && mcuInfoTableRead) + { + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu\n", GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion)); + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "PMIC vendor: %hhu\n", mcuInfoTable[1]); + posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "Battery vendor: %hhu\n\n", mcuInfoTable[2]); + } + + Draw_FlushFramebuffer(); + Draw_Unlock(); + } + while(!(waitInput() & KEY_B) && !menuShouldExit); +} + void RosalinaMenu_ShowDebugInfo(void) { Draw_Lock(); @@ -111,7 +143,6 @@ void RosalinaMenu_ShowDebugInfo(void) u32 kextPa = (u32)((u64)kextAddrSize >> 32); u32 kextSize = (u32)kextAddrSize; - u32 kernelVer = osGetKernelVersion(); FS_SdMmcSpeedInfo speedInfo; do @@ -119,24 +150,10 @@ void RosalinaMenu_ShowDebugInfo(void) Draw_Lock(); Draw_DrawString(10, 10, COLOR_TITLE, "Rosalina -- Debug info"); - u32 posY = Draw_DrawString(10, 30, COLOR_WHITE, memoryMap); + u32 posY = 30; + + posY = Draw_DrawString(10, posY, COLOR_WHITE, memoryMap); posY = Draw_DrawFormattedString(10, posY, COLOR_WHITE, "Kernel ext PA: %08lx - %08lx\n\n", kextPa, kextPa + kextSize); - posY = Draw_DrawFormattedString( - 10, posY, COLOR_WHITE, "Kernel version: %lu.%lu-%lu\n", - GET_VERSION_MAJOR(kernelVer), GET_VERSION_MINOR(kernelVer), GET_VERSION_REVISION(kernelVer) - ); - if (mcuFwVersion != 0 && mcuInfoTableRead) - { - posY = Draw_DrawFormattedString( - 10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu (PMIC vendor: %hhu)\n", - GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion), - mcuInfoTable[1] - ); - posY = Draw_DrawFormattedString( - 10, posY, COLOR_WHITE, "Battery: vendor: %hhu gauge IC ver.: %hhu.%hhu RCOMP: %hhu\n", - mcuInfoTable[2], mcuInfoTable[3], mcuInfoTable[4], mcuInfoTable[4] - ); - } if (R_SUCCEEDED(FSUSER_GetSdmcSpeedInfo(&speedInfo))) { u32 clkDiv = 1 << (1 + (speedInfo.sdClkCtrl & 0xFF));