mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-22 15:48:09 -05:00
Implement/match MxDeviceEnumerate::ParseDeviceName and ProcessDeviceBytes (#398)
* WIP * WIP * WIP * WIP * WIP * WIP
This commit is contained in:
parent
5ee268a36c
commit
778b0f2108
3 changed files with 70 additions and 6 deletions
|
@ -266,7 +266,7 @@ void MxDevice::Init(
|
||||||
// FUNCTION: LEGO1 0x1009bec0
|
// FUNCTION: LEGO1 0x1009bec0
|
||||||
MxDeviceEnumerate::MxDeviceEnumerate()
|
MxDeviceEnumerate::MxDeviceEnumerate()
|
||||||
{
|
{
|
||||||
m_unk0x10 = FALSE;
|
m_initialized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1009c070
|
// FUNCTION: LEGO1 0x1009c070
|
||||||
|
@ -388,7 +388,7 @@ HRESULT MxDeviceEnumerate::EnumDevicesCallback(
|
||||||
// FUNCTION: LEGO1 0x1009c6c0
|
// FUNCTION: LEGO1 0x1009c6c0
|
||||||
MxResult MxDeviceEnumerate::DoEnumerate()
|
MxResult MxDeviceEnumerate::DoEnumerate()
|
||||||
{
|
{
|
||||||
if (m_unk0x10)
|
if (m_initialized)
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|
||||||
HRESULT ret = DirectDrawEnumerate(DirectDrawEnumerateCallback, this);
|
HRESULT ret = DirectDrawEnumerate(DirectDrawEnumerateCallback, this);
|
||||||
|
@ -397,7 +397,7 @@ MxResult MxDeviceEnumerate::DoEnumerate()
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unk0x10 = TRUE;
|
m_initialized = TRUE;
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,9 +418,71 @@ const char* MxDeviceEnumerate::EnumerateErrorToString(HRESULT p_error)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x1009ce60
|
// FUNCTION: LEGO1 0x1009ce60
|
||||||
MxS32 MxDeviceEnumerate::ParseDeviceName(const char* p_deviceId)
|
MxS32 MxDeviceEnumerate::ParseDeviceName(const char* p_deviceId)
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
MxS32 num = -1;
|
||||||
|
MxS32 hex[4];
|
||||||
|
|
||||||
|
if (sscanf(p_deviceId, "%d 0x%x 0x%x 0x%x 0x%x", &num, &hex[0], &hex[1], &hex[2], &hex[3]) != 5)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (num < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
GUID guid;
|
||||||
|
memcpy(&guid, hex, sizeof(guid));
|
||||||
|
|
||||||
|
MxS32 result = ProcessDeviceBytes(num, guid);
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
return ProcessDeviceBytes(-1, guid);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x1009cf20
|
||||||
|
MxS32 MxDeviceEnumerate::ProcessDeviceBytes(MxS32 p_num, GUID& p_guid)
|
||||||
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
MxS32 i = 0;
|
||||||
|
MxS32 j = 0;
|
||||||
|
|
||||||
|
struct GUID4 {
|
||||||
|
MxS32 m_data1;
|
||||||
|
MxS32 m_data2;
|
||||||
|
MxS32 m_data3;
|
||||||
|
MxS32 m_data4;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(GUID4) == sizeof(GUID), "Equal size");
|
||||||
|
|
||||||
|
GUID4 deviceGuid;
|
||||||
|
memcpy(&deviceGuid, &p_guid, sizeof(GUID4));
|
||||||
|
|
||||||
|
for (list<MxDeviceEnumerateElement>::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||||
|
if (p_num >= 0 && p_num < i)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
GUID4 compareGuid;
|
||||||
|
MxDeviceEnumerateElement& elem = *it;
|
||||||
|
for (list<MxDevice>::iterator it2 = elem.m_devices.begin(); it2 != elem.m_devices.end(); it2++) {
|
||||||
|
memcpy(&compareGuid, (*it2).m_guid, sizeof(GUID4));
|
||||||
|
|
||||||
|
if (compareGuid.m_data1 == deviceGuid.m_data1 && compareGuid.m_data2 == deviceGuid.m_data2 &&
|
||||||
|
compareGuid.m_data3 == deviceGuid.m_data3 && compareGuid.m_data4 == deviceGuid.m_data4 && i == p_num)
|
||||||
|
return j;
|
||||||
|
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ class MxDeviceEnumerate {
|
||||||
);
|
);
|
||||||
const char* EnumerateErrorToString(HRESULT p_error);
|
const char* EnumerateErrorToString(HRESULT p_error);
|
||||||
MxS32 ParseDeviceName(const char* p_deviceId);
|
MxS32 ParseDeviceName(const char* p_deviceId);
|
||||||
|
MxS32 ProcessDeviceBytes(MxS32 p_num, GUID& p_guid);
|
||||||
MxResult FUN_1009d030(MxS32 p_und1, undefined** p_und2, undefined** p_und3);
|
MxResult FUN_1009d030(MxS32 p_und1, undefined** p_und2, undefined** p_und3);
|
||||||
MxResult FUN_1009d0d0();
|
MxResult FUN_1009d0d0();
|
||||||
MxResult FUN_1009d210();
|
MxResult FUN_1009d210();
|
||||||
|
@ -186,7 +187,7 @@ class MxDeviceEnumerate {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
list<MxDeviceEnumerateElement> m_list; // 0x04
|
list<MxDeviceEnumerateElement> m_list; // 0x04
|
||||||
MxBool m_unk0x10; // 0x10
|
MxBool m_initialized; // 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d9cc8
|
// VTABLE: LEGO1 0x100d9cc8
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
// We use `override` so newer compilers can tell us our vtables are valid,
|
// We use `override` so newer compilers can tell us our vtables are valid,
|
||||||
// however this keyword was added in C++11, so we define it as empty for
|
// however this keyword was added in C++11, so we define it as empty for
|
||||||
// compatibility with older compilers.
|
// compatibility with older compilers.
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1200 // 1200 corresponds to VC6.0 but "override" was probably added even later
|
#if __cplusplus < 201103L
|
||||||
#define override
|
#define override
|
||||||
|
#define static_assert(expr, msg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // COMPAT_H
|
#endif // COMPAT_H
|
||||||
|
|
Loading…
Reference in a new issue