Skip to content

Commit

Permalink
Merge pull request #4632 from delroth/wfs
Browse files Browse the repository at this point in the history
Initial WFSI/WFSSRV implementation (+ some ES additions).
  • Loading branch information
delroth committed Jan 14, 2017
2 parents a0ee1be + 45a1232 commit be6e7d7
Show file tree
Hide file tree
Showing 17 changed files with 1,101 additions and 32 deletions.
1 change: 1 addition & 0 deletions Source/Core/Common/CommonPaths.h
Expand Up @@ -75,6 +75,7 @@
#define ANAGLYPH_DIR "Anaglyph"
#define PIPES_DIR "Pipes"
#define MEMORYWATCHER_DIR "MemoryWatcher"
#define WFSROOT_DIR "WFS"

// This one is only used to remove it if it was present
#define SHADERCACHE_LEGACY_DIR "ShaderCache"
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.cpp
Expand Up @@ -780,6 +780,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[D_MAILLOGS_IDX] = s_user_paths[D_LOGS_IDX] + MAIL_LOGS_DIR DIR_SEP;
s_user_paths[D_THEMES_IDX] = s_user_paths[D_USER_IDX] + THEMES_DIR DIR_SEP;
s_user_paths[D_PIPES_IDX] = s_user_paths[D_USER_IDX] + PIPES_DIR DIR_SEP;
s_user_paths[D_WFSROOT_IDX] = s_user_paths[D_USER_IDX] + WFSROOT_DIR DIR_SEP;
s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
s_user_paths[F_DEBUGGERCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DEBUGGER_CONFIG;
s_user_paths[F_LOGGERCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + LOGGER_CONFIG;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.h
Expand Up @@ -46,6 +46,7 @@ enum
D_THEMES_IDX,
D_PIPES_IDX,
D_MEMORYWATCHER_IDX,
D_WFSROOT_IDX,
F_DOLPHINCONFIG_IDX,
F_DEBUGGERCONFIG_IDX,
F_LOGGERCONFIG_IDX,
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/CMakeLists.txt
Expand Up @@ -135,6 +135,7 @@ set(SRCS ActionReplay.cpp
HW/WiimoteEmu/Speaker.cpp
HW/WiimoteReal/WiimoteReal.cpp
HW/WiiSaveCrypted.cpp
IPC_HLE/ESFormats.cpp
IPC_HLE/ICMPLin.cpp
IPC_HLE/NWC24Config.cpp
IPC_HLE/WII_IPC_HLE.cpp
Expand All @@ -154,6 +155,8 @@ set(SRCS ActionReplay.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.cpp
IPC_HLE/WII_IPC_HLE_Device_wfsi.cpp
IPC_HLE/WII_IPC_HLE_WiiMote.cpp
IPC_HLE/WiiMote_HID_Attr.cpp
IPC_HLE/WiiNetConfig.cpp
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -167,6 +167,7 @@
<ClCompile Include="HW\WiimoteReal\WiimoteReal.cpp" />
<ClCompile Include="HW\WII_IPC.cpp" />
<ClCompile Include="HW\WiiSaveCrypted.cpp" />
<ClCompile Include="IPC_HLE\ESFormats.cpp" />
<ClCompile Include="IPC_HLE\ICMPWin.cpp" />
<ClCompile Include="IPC_HLE\NWC24Config.cpp" />
<ClCompile Include="IPC_HLE\WiiMote_HID_Attr.cpp" />
Expand Down Expand Up @@ -196,6 +197,8 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_ven.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_wfssrv.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_wfsi.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_WiiMote.cpp" />
<ClCompile Include="IPC_HLE\WII_Socket.cpp" />
<ClCompile Include="IPC_HLE\WiiNetConfig.cpp" />
Expand Down Expand Up @@ -392,6 +395,7 @@
<ClInclude Include="HW\WiimoteReal\WiimoteRealBase.h" />
<ClInclude Include="HW\WiiSaveCrypted.h" />
<ClInclude Include="HW\WII_IPC.h" />
<ClInclude Include="IPC_HLE\ESFormats.h" />
<ClInclude Include="IPC_HLE\hci.h" />
<ClInclude Include="IPC_HLE\ICMP.h" />
<ClInclude Include="IPC_HLE\l2cap.h" />
Expand All @@ -415,6 +419,8 @@
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_ven.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_wfssrv.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_wfsi.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_WiiMote.h" />
<ClInclude Include="IPC_HLE\WII_Socket.h" />
<ClInclude Include="IPC_HLE\WiiNetConfig.h" />
Expand Down
21 changes: 21 additions & 0 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -133,6 +133,9 @@
<Filter Include="IPC HLE %28IOS/Starlet%29\USB">
<UniqueIdentifier>{4a090016-76d5-43dd-95a4-abedfc11ef31}</UniqueIdentifier>
</Filter>
<Filter Include="IPC HLE %28IOS/Starlet%29\WFS">
<UniqueIdentifier>{f11746cf-277a-4d58-bcf1-578a45348b07}</UniqueIdentifier>
</Filter>
<Filter Include="IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote">
<UniqueIdentifier>{8352be4d-d37d-4f55-adec-b940a9712802}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -565,6 +568,9 @@
<ClCompile Include="DSP\LabelMap.cpp">
<Filter>DSPCore</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\ESFormats.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\ES</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE.cpp">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClCompile>
Expand Down Expand Up @@ -628,6 +634,12 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_wfssrv.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\WFS</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_wfsi.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\WFS</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_WiiMote.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
Expand Down Expand Up @@ -1162,6 +1174,9 @@
<ClInclude Include="DSP\LabelMap.h">
<Filter>DSPCore</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\ESFormats.h">
<Filter>IPC HLE %28IOS/Starlet%29\ES</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE.h">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClInclude>
Expand Down Expand Up @@ -1237,6 +1252,12 @@
<ClInclude Include="IPC_HLE\WiiMote_HID_Attr.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_wfssrv.h">
<Filter>IPC HLE %28IOS/Starlet%29\WFS</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_wfsi.h">
<Filter>IPC HLE %28IOS/Starlet%29\WFS</Filter>
</ClInclude>
<ClInclude Include="HW\Wiimote.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote</Filter>
</ClInclude>
Expand Down
96 changes: 96 additions & 0 deletions Source/Core/Core/IPC_HLE/ESFormats.cpp
@@ -0,0 +1,96 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "Core/IPC_HLE/ESFormats.h"

#include <algorithm>
#include <utility>
#include <vector>

#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"

TMDReader::TMDReader(const std::vector<u8>& bytes) : m_bytes(bytes)
{
}

TMDReader::TMDReader(std::vector<u8>&& bytes) : m_bytes(std::move(bytes))
{
}

void TMDReader::SetBytes(const std::vector<u8>& bytes)
{
m_bytes = bytes;
}

void TMDReader::SetBytes(std::vector<u8>&& bytes)
{
m_bytes = std::move(bytes);
}

bool TMDReader::IsValid() const
{
if (m_bytes.size() < 0x1E4)
{
// TMD is too small to contain its base fields.
return false;
}

if (m_bytes.size() < 0x1E4 + GetNumContents() * 36u)
{
// TMD is too small to contain all its expected content entries.
return false;
}

return true;
}

u64 TMDReader::GetTitleId() const
{
return Common::swap64(m_bytes.data() + 0x18C);
}

u16 TMDReader::GetNumContents() const
{
return Common::swap16(m_bytes.data() + 0x1DE);
}

bool TMDReader::GetContent(u16 index, Content* content) const
{
if (index >= GetNumContents())
{
return false;
}

const u8* content_base = m_bytes.data() + 0x1E4 + index * 36;
content->id = Common::swap32(content_base);
content->index = Common::swap16(content_base + 4);
content->type = Common::swap16(content_base + 6);
content->size = Common::swap64(content_base + 8);
std::copy(content_base + 16, content_base + 36, content->sha1.begin());

return true;
}

bool TMDReader::FindContentById(u32 id, Content* content) const
{
for (u16 index = 0; index < GetNumContents(); ++index)
{
if (!GetContent(index, content))
{
return false;
}
if (content->id == id)
{
return true;
}
}
return false;
}

void TMDReader::DoState(PointerWrap& p)
{
p.Do(m_bytes);
}
46 changes: 46 additions & 0 deletions Source/Core/Core/IPC_HLE/ESFormats.h
@@ -0,0 +1,46 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

// Utilities to manipulate files and formats from the Wii's ES module: tickets,
// TMD, and other title informations.

#pragma once

#include <array>
#include <vector>

#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"

class TMDReader final
{
public:
TMDReader() = default;
explicit TMDReader(const std::vector<u8>& bytes);
explicit TMDReader(std::vector<u8>&& bytes);

void SetBytes(const std::vector<u8>& bytes);
void SetBytes(std::vector<u8>&& bytes);

bool IsValid() const;

u64 GetTitleId() const;

struct Content
{
u32 id;
u16 index;
u16 type;
u64 size;
std::array<u8, 20> sha1;
};
u16 GetNumContents() const;
bool GetContent(u16 index, Content* content) const;
bool FindContentById(u32 id, Content* content) const;

void DoState(PointerWrap& p);

private:
std::vector<u8> m_bytes;
};
4 changes: 4 additions & 0 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp
Expand Up @@ -48,6 +48,8 @@
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h"

namespace CoreTiming
{
Expand Down Expand Up @@ -157,6 +159,8 @@ void Reinit()
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/usb/hid");
#endif
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/usb/oh1");
AddDevice<CWII_IPC_HLE_Device_usb_wfssrv>("/dev/usb/wfssrv");
AddDevice<CWII_IPC_HLE_Device_wfsi>("/dev/wfsi");
}

void Init()
Expand Down

0 comments on commit be6e7d7

Please sign in to comment.