Skip to content

Commit 6665835

Browse files
committed
erreula: Rework implementation and fix bugs
- ErrEula doesn't disappear on its own anymore. The expected behavior is for the game to call Disappear once a button has been selected. This fixes issues where the dialog would softlock in some games - Modernized code a bit - Added a subtle fade in/out effect
1 parent a5717e1 commit 6665835

File tree

5 files changed

+307
-176
lines changed

5 files changed

+307
-176
lines changed

src/Cafe/CafeSystem.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -637,40 +637,40 @@ namespace CafeSystem
637637
fsc_unmount("/cemuBossStorage/", FSC_PRIORITY_BASE);
638638
}
639639

640-
STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId)
640+
PREPARE_STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId)
641641
{
642642
cemuLog_log(LogType::Force, "Mounting title {:016x}", (uint64)titleId);
643643
sGameInfo_ForegroundTitle = CafeTitleList::GetGameInfo(titleId);
644644
if (!sGameInfo_ForegroundTitle.IsValid())
645645
{
646646
cemuLog_log(LogType::Force, "Mounting failed: Game meta information is either missing, inaccessible or not valid (missing or invalid .xml files in code and meta folder)");
647-
return STATUS_CODE::UNABLE_TO_MOUNT;
647+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
648648
}
649649
// check base
650650
TitleInfo& titleBase = sGameInfo_ForegroundTitle.GetBase();
651651
if (!titleBase.IsValid())
652-
return STATUS_CODE::UNABLE_TO_MOUNT;
652+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
653653
if(!titleBase.ParseXmlInfo())
654-
return STATUS_CODE::UNABLE_TO_MOUNT;
654+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
655655
cemuLog_log(LogType::Force, "Base: {}", titleBase.GetPrintPath());
656656
// mount base
657657
if (!titleBase.Mount("/vol/content", "content", FSC_PRIORITY_BASE) || !titleBase.Mount(GetInternalVirtualCodeFolder(), "code", FSC_PRIORITY_BASE))
658658
{
659659
cemuLog_log(LogType::Force, "Mounting failed");
660-
return STATUS_CODE::UNABLE_TO_MOUNT;
660+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
661661
}
662662
// check update
663663
TitleInfo& titleUpdate = sGameInfo_ForegroundTitle.GetUpdate();
664664
if (titleUpdate.IsValid())
665665
{
666666
if (!titleUpdate.ParseXmlInfo())
667-
return STATUS_CODE::UNABLE_TO_MOUNT;
667+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
668668
cemuLog_log(LogType::Force, "Update: {}", titleUpdate.GetPrintPath());
669669
// mount update
670670
if (!titleUpdate.Mount("/vol/content", "content", FSC_PRIORITY_PATCH) || !titleUpdate.Mount(GetInternalVirtualCodeFolder(), "code", FSC_PRIORITY_PATCH))
671671
{
672672
cemuLog_log(LogType::Force, "Mounting failed");
673-
return STATUS_CODE::UNABLE_TO_MOUNT;
673+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
674674
}
675675
}
676676
else
@@ -682,20 +682,20 @@ namespace CafeSystem
682682
// todo - support for multi-title AOC
683683
TitleInfo& titleAOC = aocList[0];
684684
if (!titleAOC.ParseXmlInfo())
685-
return STATUS_CODE::UNABLE_TO_MOUNT;
685+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
686686
cemu_assert_debug(titleAOC.IsValid());
687687
cemuLog_log(LogType::Force, "DLC: {}", titleAOC.GetPrintPath());
688688
// mount AOC
689689
if (!titleAOC.Mount(fmt::format("/vol/aoc{:016x}", titleAOC.GetAppTitleId()), "content", FSC_PRIORITY_PATCH))
690690
{
691691
cemuLog_log(LogType::Force, "Mounting failed");
692-
return STATUS_CODE::UNABLE_TO_MOUNT;
692+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
693693
}
694694
}
695695
else
696696
cemuLog_log(LogType::Force, "DLC: Not present");
697697
sForegroundTitleId = titleId;
698-
return STATUS_CODE::SUCCESS;
698+
return PREPARE_STATUS_CODE::SUCCESS;
699699
}
700700

701701
void UnmountForegroundTitle()
@@ -723,7 +723,7 @@ namespace CafeSystem
723723
}
724724
}
725725

726-
STATUS_CODE SetupExecutable()
726+
PREPARE_STATUS_CODE SetupExecutable()
727727
{
728728
// set rpx path from cos.xml if available
729729
_pathToBaseExecutable = _pathToExecutable;
@@ -755,7 +755,7 @@ namespace CafeSystem
755755
}
756756
}
757757
LoadMainExecutable();
758-
return STATUS_CODE::SUCCESS;
758+
return PREPARE_STATUS_CODE::SUCCESS;
759759
}
760760

761761
void SetupMemorySpace()
@@ -769,7 +769,7 @@ namespace CafeSystem
769769
memory_unmapForCurrentTitle();
770770
}
771771

772-
STATUS_CODE PrepareForegroundTitle(TitleId titleId)
772+
PREPARE_STATUS_CODE PrepareForegroundTitle(TitleId titleId)
773773
{
774774
CafeTitleList::WaitForMandatoryScan();
775775
sLaunchModeIsStandalone = false;
@@ -780,21 +780,21 @@ namespace CafeSystem
780780
// mount mlc storage
781781
MountBaseDirectories();
782782
// mount title folders
783-
STATUS_CODE r = LoadAndMountForegroundTitle(titleId);
784-
if (r != STATUS_CODE::SUCCESS)
783+
PREPARE_STATUS_CODE r = LoadAndMountForegroundTitle(titleId);
784+
if (r != PREPARE_STATUS_CODE::SUCCESS)
785785
return r;
786786
gameProfile_load();
787787
// setup memory space and PPC recompiler
788788
SetupMemorySpace();
789789
PPCRecompiler_init();
790790
r = SetupExecutable(); // load RPX
791-
if (r != STATUS_CODE::SUCCESS)
791+
if (r != PREPARE_STATUS_CODE::SUCCESS)
792792
return r;
793793
InitVirtualMlcStorage();
794-
return STATUS_CODE::SUCCESS;
794+
return PREPARE_STATUS_CODE::SUCCESS;
795795
}
796796

797-
STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path)
797+
PREPARE_STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path)
798798
{
799799
sLaunchModeIsStandalone = true;
800800
cemuLog_log(LogType::Force, "Launching executable in standalone mode due to incorrect layout or missing meta files");
@@ -812,7 +812,7 @@ namespace CafeSystem
812812
if (!r)
813813
{
814814
cemuLog_log(LogType::Force, "Failed to mount {}", _pathToUtf8(contentPath));
815-
return STATUS_CODE::UNABLE_TO_MOUNT;
815+
return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT;
816816
}
817817
}
818818
}
@@ -824,7 +824,7 @@ namespace CafeSystem
824824
// since a lot of systems (including save folder location) rely on a TitleId, we derive a placeholder id from the executable hash
825825
auto execData = fsc_extractFile(_pathToExecutable.c_str());
826826
if (!execData)
827-
return STATUS_CODE::INVALID_RPX;
827+
return PREPARE_STATUS_CODE::INVALID_RPX;
828828
uint32 h = generateHashFromRawRPXData(execData->data(), execData->size());
829829
sForegroundTitleId = 0xFFFFFFFF00000000ULL | (uint64)h;
830830
cemuLog_log(LogType::Force, "Generated placeholder TitleId: {:016x}", sForegroundTitleId);
@@ -834,7 +834,7 @@ namespace CafeSystem
834834
// load executable
835835
SetupExecutable();
836836
InitVirtualMlcStorage();
837-
return STATUS_CODE::SUCCESS;
837+
return PREPARE_STATUS_CODE::SUCCESS;
838838
}
839839

840840
void _LaunchTitleThread()

src/Cafe/CafeSystem.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ namespace CafeSystem
1515
virtual void CafeRecreateCanvas() = 0;
1616
};
1717

18-
enum class STATUS_CODE
18+
enum class PREPARE_STATUS_CODE
1919
{
2020
SUCCESS,
2121
INVALID_RPX,
2222
UNABLE_TO_MOUNT, // failed to mount through TitleInfo (most likely caused by an invalid or outdated path)
23-
//BAD_META_DATA, - the title list only stores titles with valid meta, so this error code is impossible
2423
};
2524

2625
void Initialize();
2726
void SetImplementation(SystemImplementation* impl);
2827
void Shutdown();
2928

30-
STATUS_CODE PrepareForegroundTitle(TitleId titleId);
31-
STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path);
29+
PREPARE_STATUS_CODE PrepareForegroundTitle(TitleId titleId);
30+
PREPARE_STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path);
3231
void LaunchForegroundTitle();
3332
bool IsTitleRunning();
3433

src/Cafe/OS/libs/coreinit/coreinit_Time.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ namespace coreinit
4040

4141
inline TimerTicks ConvertNsToTimerTicks(uint64 ns)
4242
{
43-
return ((GetTimerClock() / 31250LL) * ((ns)) / 32000LL);
43+
return ((GetTimerClock() / 31250LL) * ((TimerTicks)ns) / 32000LL);
44+
}
45+
46+
inline TimerTicks ConvertMsToTimerTicks(uint64 ms)
47+
{
48+
return (TimerTicks)ms * GetTimerClock() / 1000LL;
4449
}
4550
};
4651

0 commit comments

Comments
 (0)