From 55d744b5c240848066d70f84d9abbb993a4ae210 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Fri, 26 May 2023 11:01:34 +0200 Subject: [PATCH] nxdt_includes: properly handle old sysver fields. Turns out old system versions just use 16-bit long relstep values in their lower half. The major/minor/micro combination in the upper half remains the same. Thanks to @liamadvance for clarifying this. --- include/core/nxdt_includes.h | 19 ++++++++++++------- source/gamecard_tab.cpp | 13 ++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/core/nxdt_includes.h b/include/core/nxdt_includes.h index ba6b415..ab55ae6 100644 --- a/include/core/nxdt_includes.h +++ b/include/core/nxdt_includes.h @@ -78,16 +78,21 @@ #include "lz4.h" /// Used to store version numbers expressed in dot notation: "{major}.{minor}.{micro}-{major_relstep}.{minor_relstep}". -/// Used by system version fields. +/// Used by system version fields. 16-bit long relstep values were used by system version fields prior to HOS 3.0.0. typedef struct { union { u32 value; struct { - u32 minor_relstep : 8; - u32 major_relstep : 8; - u32 micro : 4; - u32 minor : 6; - u32 major : 6; + union { + u16 relstep; + struct { + u16 minor_relstep : 8; + u16 major_relstep : 8; + }; + }; + u16 micro : 4; + u16 minor : 6; + u16 major : 6; }; }; } SystemVersion; @@ -109,7 +114,7 @@ typedef struct { NXDT_ASSERT(ApplicationVersion, 0x4); /// Used to store version numbers expressed in dot notation: "{major}.{minor}.{micro}-{relstep}". -/// Used by SDK version fields. This format was also used for system version fields prior to HOS 3.0.0. +/// Used by SDK version fields. typedef struct { union { u32 value; diff --git a/source/gamecard_tab.cpp b/source/gamecard_tab.cpp index 3767808..ea6e1b5 100644 --- a/source/gamecard_tab.cpp +++ b/source/gamecard_tab.cpp @@ -162,14 +162,13 @@ namespace nxdt::views gamecardGetDecryptedCardInfoArea(&card_info); const SystemVersion upp_version = card_info.upp_version.system_version; - const SdkAddOnVersion upp_version_old = card_info.upp_version.sdk_addon_version; /* TODO: move somewhere else? */ - if (upp_version_old.major == 0 && upp_version_old.minor == 0) + if (upp_version.major == 0 && upp_version.minor == 0) { std::string upp_version_display = ""; - switch(upp_version_old.micro) + switch(upp_version.micro) { case 0: /* v450 / 0.0.0-450 */ upp_version_display = "1.0.0"; @@ -192,11 +191,11 @@ namespace nxdt::views if (upp_version_display != "") { - update_version->setValue(fmt::format("{} ({}.{}.{}-{}) (v{})", upp_version_display, upp_version_old.major, upp_version_old.minor, upp_version_old.micro, \ - upp_version_old.relstep, upp_version_old.value)); + update_version->setValue(fmt::format("{} ({}.{}.{}-{}) (v{})", upp_version_display, upp_version.major, upp_version.minor, upp_version.micro, \ + upp_version.relstep, upp_version.value)); } else { - update_version->setValue(fmt::format("{}.{}.{}-{} (v{})", upp_version_old.major, upp_version_old.minor, upp_version_old.micro, \ - upp_version_old.relstep, upp_version_old.value)); + update_version->setValue(fmt::format("{}.{}.{}-{} (v{})", upp_version.major, upp_version.minor, upp_version.micro, \ + upp_version.relstep, upp_version.value)); } } else { update_version->setValue(fmt::format("{}.{}.{}-{}.{} (v{})", upp_version.major, upp_version.minor, upp_version.micro, \