From 2793daa55fd6c52a401f829a78fb6eb2a7bcbedc Mon Sep 17 00:00:00 2001 From: d0k3 Date: Wed, 6 May 2020 17:22:47 +0200 Subject: [PATCH] Take over title version when building CIA from NCSD --- arm9/source/utils/gameutil.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arm9/source/utils/gameutil.c b/arm9/source/utils/gameutil.c index 38934ff..acbc1e9 100644 --- a/arm9/source/utils/gameutil.c +++ b/arm9/source/utils/gameutil.c @@ -1618,6 +1618,16 @@ u32 BuildCiaFromNcsdFile(const char* path_ncsd, const char* path_cia) { (InsertCiaMeta(path_cia, meta) == 0)) cia->header.size_meta = CIA_META_SIZE; if (meta) free(meta); + + // update title version from cart header (yeah, that's a bit hacky) + u16 title_version; + if (fvx_qread(path_ncsd, &title_version, 0x310, 2, NULL) == FR_OK) { + u8 title_version_le[2]; + title_version_le[0] = (title_version >> 8) & 0xFF; + title_version_le[1] = title_version & 0xFF; + memcpy((cia->tmd).title_version, title_version_le, 2); + memcpy((cia->ticket).ticket_version, title_version_le, 2); + } // write the CIA stub (take #2) FindTitleKey((Ticket*)&(cia->ticket), title_id);