diff --git a/src/BS2/BS2Mach.c b/src/BS2/BS2Mach.c index 51377c2e..3b0621e6 100644 --- a/src/BS2/BS2Mach.c +++ b/src/BS2/BS2Mach.c @@ -9,6 +9,8 @@ #include +#include + typedef struct AppLoaderHeader { char date[16]; // 0x00 u32 entryPoint; // 0x10 @@ -18,6 +20,7 @@ typedef struct AppLoaderHeader { } AppLoaderHeader; u8 TicketViewsBuf[OSRoundUp32B(sizeof(ESTicketView) * 64)] ALIGN32; +ESTicketView* lbl_81696578 = (ESTicketView*)TicketViewsBuf; DVDDiskID lbl_810ADF60 ALIGN32; OSBootInfo2 bi2 ALIGN32; AppLoaderHeader AppLoaderHdr ALIGN32; @@ -233,6 +236,79 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8*)OSPhysicalToCached(OS_ADDR_BOOT_INFO) - 0x30U) <= 1; } +BOOL BS2GetLockedTitles(ESTitleId* pTitleIds, u32* count) { + u32 i; + u32 titleMask; + u32 titleCount; + + if (State != BS2_STT_DATA_DISK && State != BS2_STT_RVL_GAME) { + return FALSE; + } + + if (pTitleIds) { + goto getLockedTitles; + } + + *count = 0; + lbl_81698A98 = (u32)PartitionInfoBuf; + for (i = 0; i < **(u32**)&lbl_81698AA0; i++) { + BS2Report("gamePartition ... 0x%08X\n", *(u32*)lbl_81698A98); + BS2Report("type ... 0x%08X\n", *(u32*)(lbl_81698A98 + 4)); + if (*(u32*)(lbl_81698A98 + 4) & 0xFF000000) { + BS2Report(" count++\n"); + (*count)++; + } + lbl_81698A98 += 8; + } + + lbl_81698A98 = (u32)PartitionInfoBuf + 0x20; + for (i = 0; i < **(u32**)&lbl_81698A9C; i++) { + BS2Report("gamePartition ... 0x%08X\n", *(u32*)lbl_81698A98); + BS2Report("type ... 0x%08X\n", *(u32*)(lbl_81698A98 + 4)); + if (*(u32*)(lbl_81698A98 + 4) & 0xFF000000) { + BS2Report(" count++\n"); + (*count)++; + } + lbl_81698A98 += 8; + } + + return TRUE; + +getLockedTitles: + titleCount = *count; + if (titleCount != 0) { + lbl_81698A98 = (u32)PartitionInfoBuf; + titleMask = (u32)-1; + for (i = 0; i < **(u32**)&lbl_81698AA0; i++) { + if (titleCount == 0) { + return TRUE; + } + if (*(u32*)(lbl_81698A98 + 4) & 0xFF000000) { + *pTitleIds = ((ESTitleId)0x00010000 << 32) | (*(u32*)(lbl_81698A98 + 4) & titleMask); + titleCount--; + pTitleIds++; + } + lbl_81698A98 += 8; + } + + lbl_81698A98 = (u32)PartitionInfoBuf + 0x20; + titleMask = (u32)-1; + for (i = 0; i < **(u32**)&lbl_81698A9C; i++) { + if (titleCount == 0) { + return TRUE; + } + if (*(u32*)(lbl_81698A98 + 4) & 0xFF000000) { + *pTitleIds = ((ESTitleId)0x00010000 << 32) | (*(u32*)(lbl_81698A98 + 4) & titleMask); + titleCount--; + pTitleIds++; + } + lbl_81698A98 += 8; + } + } + + return TRUE; +} + BOOL BS2IsTitleAvailable(ESTitleId titleId) { u32* count; u32 i; @@ -262,6 +338,91 @@ BOOL BS2IsTitleAvailable(ESTitleId titleId) { return FALSE; } +s32 BS2GetTicketFromNand(ESTitleId titleId, ESTicketView* pTicketView) { + s32 ret; + u32 ticketCount; + s32 index; + + ret = ES_GetTicketViews(titleId, NULL, &ticketCount); + if (ret != 0) { + OSReport("ES_GetTicketViews%d failed: %d\n", 1, ret); + return ret; + } + if (ticketCount == 0) { + OSReport("No ticket for disc. Please import a ticket.\n"); + return -1; + } + if (ticketCount > 0x40) { + OSReport("Internal error: Too many tickets\n"); + return -1; + } + + ret = ES_GetTicketViews(titleId, lbl_81696578, &ticketCount); + if (ret != 0) { + OSReport("ES_GetTicketViews%d failed: %d\n", 2, ret); + return ret; + } + + BS2Report("Found %d tickets in NAND\n", ticketCount); + index = __OSGetValidTicketIndex(lbl_81696578, ticketCount); + if (index < 0 || (u32)index > ticketCount - 1) { + OSReport("Failed to get best ticket.\n"); + return -1; + } + + memcpy(pTicketView, &lbl_81696578[index], sizeof(ESTicketView)); + DCStoreRange(pTicketView, sizeof(ESTicketView)); + return ticketCount; +} + +BOOL BS2StartLoadingTitle(ESTitleId titleId, ESTicketView* pTicketView) { + u32* gamePartitionCount; + u32* dataPartitionCount; + u32 i; + + if (State != BS2_STT_DATA_DISK && State != BS2_STT_RVL_GAME) { + return FALSE; + } + + lbl_81698A30 = 1; + lbl_81698A7C = (u32)pTicketView; + lbl_81698A98 = (u32)PartitionInfoBuf; + gamePartitionCount = *(u32**)&lbl_81698AA0; + for (i = 0; i < *gamePartitionCount; i++) { + if (*(u32*)(lbl_81698A98 + 4) == (u32)titleId) { + lbl_81698A90 = lbl_81698A98; + if (BS2BootFromCache) { + State = BS2_STT_8; + } else { + State = BS2_STT_LOCKED_DISK; + } + BS2BootFromCache = FALSE; + BS2BootCaching = FALSE; + return TRUE; + } + lbl_81698A98 += 8; + } + + lbl_81698A98 = (u32)PartitionInfoBuf + 0x20; + dataPartitionCount = *(u32**)&lbl_81698A9C; + for (i = 0; i < *dataPartitionCount; i++) { + if (*(u32*)(lbl_81698A98 + 4) == (u32)titleId) { + lbl_81698A90 = lbl_81698A98; + if (BS2BootFromCache) { + State = BS2_STT_8; + } else { + State = BS2_STT_LOCKED_DISK; + } + BS2BootFromCache = FALSE; + BS2BootCaching = FALSE; + return TRUE; + } + lbl_81698A98 += 8; + } + + return FALSE; +} + void callback(s32 result) { lbl_81698A54 = result; } diff --git a/src/keyboard/tiInputForm.cpp b/src/keyboard/tiInputForm.cpp new file mode 100644 index 00000000..74507c14 --- /dev/null +++ b/src/keyboard/tiInputForm.cpp @@ -0,0 +1,152 @@ +#include "keyboard/tiInputForm.h" +#include "keyboard/tiManager.h" + +namespace textinput { +namespace inputform { + +#pragma push +#pragma section const_type ".data" +extern "C" const char lbl_8165C820[] = "P_txtScrll_UP"; +extern "C" const char lbl_8165C830[] = "P_txtScrll_DOWN"; +extern "C" const char lbl_8165C8C0[] = "N_JPNUSAEUR"; +extern "C" const char lbl_8165C8CC[] = "N_separateBarAll"; +extern "C" const char lbl_8165C8E0[] = "T_2l_TextBox"; +extern "C" const char lbl_8165C8F0[] = "T_title_textJPN"; +extern "C" const char lbl_8165C900[] = "N_separateBarKOR"; +extern "C" const char lbl_8165C918[] = "T_2l_TextBoxKOR"; +extern "C" const char lbl_8165C928[] = "T_title_textKOR"; +extern "C" const char lbl_8165C938[] = "N_separateBarCHN"; +extern "C" const char lbl_8165C950[] = "T_2l_TextBoxCHN"; +extern "C" const char lbl_8165C960[] = "T_title_textCHN"; +extern "C" const char lbl_8165CBE0[] = "T_2l_TextBox"; +extern "C" const char lbl_8165D258[] = "RevoIpl_RodinNTLGProM_32_I4.brfnt"; +extern "C" const char lbl_8165D27C[] = "P_txtScrll_UP"; +extern "C" const char lbl_8165D28C[] = "P_txtScrll_DOWN"; +extern "C" const char lbl_8165D2A0[] = "N_separateBarAll"; +extern "C" const char lbl_8165D2B0[] = "T_title_text"; +extern "C" const char lbl_8165D2C0[] = "OutOfLength\n"; +extern "C" const char lbl_8165D2D0[] = "Error#004\nAn error has occurred.\nThe system files are corrupted."; +#pragma pop + +enum Animation { + ANM_Normal +}; + +enum KeyType { + KT_NormalButton +}; + +class AnmPane : public nw4rmanager::AnmPane { +public: + virtual void init(); + virtual void changeAnimation(u32 id); + virtual KeyType getKeyType() const; + virtual Animation getState(); + +protected: + Animation meState; + KeyType meKeyType; +}; + +class NormalButtonAnmPane : public AnmPane { +public: + virtual ~NormalButtonAnmPane(); +}; + +class EventHandler : public nw4rmanager::TiEventHandler { +public: + virtual ~EventHandler(); +}; + +void Base::enableSpaceByRight(bool rightWithSpace) { + mbRightWithSpace = rightWithSpace; +} + +void Base::setDestination(Destination destination) { + meDestination = destination; +} + +void Base::setLineDrawInfo(bool lineDraw, u32 lineCount) { + mbLineDraw = lineDraw; + muSpecifyLineDrawCount = lineCount; +} + +void Base::doWordWrap(bool wordWrap) { + mbDoWordWrap = wordWrap; +} + +void Base::limitStringLength(u32 limitStringLength) { + muLimitStringLength = limitStringLength; +} + +void Base::doAfterDrawProcess(const wchar_t*, u32, const DrawInfo&) {} + +void Base::finishDraw(u32) {} + +void Base::onSE(sound::SE) {} + +void Base::setString(const wchar_t* string) { + mpString->set(string); +} + +void AnmPane::changeAnimation(u32 id) { + meState = static_cast(id); + nw4rmanager::AnmPane::changeAnimation(id); +} + +void AnmPane::init() { + meState = ANM_Normal; +} + +KeyType AnmPane::getKeyType() const { + return meKeyType; +} + +Animation AnmPane::getState() { + return meState; +} + +NormalButtonAnmPane::~NormalButtonAnmPane() {} + +EventHandler::~EventHandler() {} + +wchar_t Base::getCandidate() const { + return mpString->getCandidate(); +} + +void* Base::getAtokString() { + return mpUnfixString; +} + +wchar_t* Base::getWCString() const { + return mpString->getWCString(); +} + +bool Base::isInScroll() { + return mScrollAnm.isActive(); +} + +nw4r::math::VEC2 Base::getScale() const { + return nw4r::math::VEC2(1.0f, 1.0f); +} + +bool LayoutByNW4R::isAbleToUp() { + return unk_0x2C0[0x0C]; +} + +bool LayoutByNW4R::isAbleToDown() { + return unk_0x2C0[0x0D]; +} + +bool LayoutByNW4R::updateInput(textinput::input::HKBManager& hkbManager) { + return nw4rmanager::Layout::updateInput(hkbManager); +} + +void LayoutByNW4R::visibleSeparator(bool flag) { + unk_0x2C0[0x0E] = flag; +} + +} +} + +void textinput::Base::create(MEMAllocator*) {}