From 7a547a16c6e9a809785280fcfc4bf48236f32734 Mon Sep 17 00:00:00 2001 From: Sunguk Lee Date: Tue, 17 Oct 2017 13:50:24 +0900 Subject: [PATCH] Implement platform::initKey2Seed --- source/nds_platform.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/nds_platform.cpp b/source/nds_platform.cpp index 9710afb..b2064d3 100644 --- a/source/nds_platform.cpp +++ b/source/nds_platform.cpp @@ -97,6 +97,22 @@ void platform::initBlowfishPS(uint32_t (&ps)[ntrcard::BLOWFISH_PS_N], ntrcard::B memcpy(ps, ptr, sizeof(ps)); } +void platform::initKey2Seed(std::uint64_t x, std::uint64_t y) { + REG_ROMCTRL = 0; + + uint32_t xl = (uint32_t)(x & 0xFFFFFFFF); + uint32_t yl = (uint32_t)(y & 0xFFFFFFFF); + uint16_t xh = (uint16_t)((x >> 32) & 0x7F); + uint16_t yh = (uint16_t)((y >> 32) & 0x7F); + + REG_CARD_1B0 = xl; + REG_CARD_1B4 = yl; + REG_CARD_1B8 = xh; + REG_CARD_1BA = yh; + + REG_ROMCTRL = CARD_nRESET| CARD_SEC_SEED | CARD_SEC_EN | CARD_SEC_DAT; +} + #ifdef DEBUG_PRINT int platform::logMessage(log_priority priority, const char *fmt, ...) { va_list args;