Skip to content

Commit

Permalink
Merge pull request #5036 from leoetlino/hack
Browse files Browse the repository at this point in the history
IOS/ES: Partially restore hack to fake IOS titles
  • Loading branch information
Helios747 committed Mar 8, 2017
2 parents cd826ce + dc224cb commit 5acf2c8
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions Source/Core/Core/IOS/ES/ES.cpp
Expand Up @@ -86,6 +86,12 @@ constexpr const u8* s_key_table[11] = {
s_key_empty, // Unknown
};

static bool IsDiscTitle(u64 title_id)
{
return IsTitleType(title_id, IOS::ES::TitleType::Game) ||
IsTitleType(title_id, IOS::ES::TitleType::GameWithChannel);
}

ES::ES(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
}
Expand Down Expand Up @@ -146,8 +152,7 @@ void TitleContext::Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketR

void TitleContext::UpdateRunningGame() const
{
if (IOS::ES::IsTitleType(tmd.GetTitleId(), IOS::ES::TitleType::Game) ||
IOS::ES::IsTitleType(tmd.GetTitleId(), IOS::ES::TitleType::GameWithChannel))
if (IsDiscTitle(tmd.GetTitleId()))
{
const u32 title_identifier = Common::swap32(static_cast<u32>(tmd.GetTitleId()));
const u16 group_id = Common::swap16(tmd.GetGroupId());
Expand Down Expand Up @@ -1027,6 +1032,18 @@ IPCCommandResult ES::GetTitles(const IOCtlVRequest& request)
return GetTitles(GetInstalledTitles(), request);
}

// HACK: Since we do not want to require users to install disc updates when launching
// Wii games from the game list (which is the inaccurate game boot path anyway),
// IOSes have to be faked for games which reload IOS to work properly.
// To minimize the effect of this hack, we should only do this for disc titles
// booted from the game list, though.
static bool ShouldReturnFakeViewsForIOSes(u64 title_id)
{
const bool ios = IsTitleType(title_id, IOS::ES::TitleType::System) && title_id != TITLEID_SYSMENU;
const bool disc_title = s_title_context.active && IsDiscTitle(s_title_context.tmd.GetTitleId());
return ios && SConfig::GetInstance().m_BootType == SConfig::BOOT_ISO && disc_title;
}

IPCCommandResult ES::GetViewCount(const IOCtlVRequest& request)
{
if (!request.HasNumberOfValidVectors(1, 1))
Expand All @@ -1041,6 +1058,11 @@ IPCCommandResult ES::GetViewCount(const IOCtlVRequest& request)
{
view_count = Loader.GetTicket().GetNumberOfTickets();
}
else if (ShouldReturnFakeViewsForIOSes(TitleID))
{
view_count = 1;
WARN_LOG(IOS_ES, "GetViewCount: Faking IOS title %016" PRIx64 " being present", TitleID);
}

INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWCNT for titleID: %08x/%08x (View Count = %zu)",
static_cast<u32>(TitleID >> 32), static_cast<u32>(TitleID), view_count);
Expand Down Expand Up @@ -1069,6 +1091,11 @@ IPCCommandResult ES::GetViews(const IOCtlVRequest& request)
ticket_view.data(), ticket_view.size());
}
}
else if (ShouldReturnFakeViewsForIOSes(TitleID))
{
Memory::Memset(request.io_vectors[0].address, 0, sizeof(IOS::ES::TicketView));
WARN_LOG(IOS_ES, "GetViews: Faking IOS title %016" PRIx64 " being present", TitleID);
}

INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWS for titleID: %08x/%08x (MaxViews = %i)", (u32)(TitleID >> 32),
(u32)TitleID, maxViews);
Expand Down

0 comments on commit 5acf2c8

Please sign in to comment.