mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-22 15:48:09 -05:00
Backports of isle-portable x64 fixes (#1044)
* Introduce LPD3DRM_APPDATA typedef for setting d3drm appdata * Fix warning about assigning const string literals to variable char pointers * Don't cast pointers to integers on non-32-bit architectures * memset 2nd argument is int * Assume cpuid is available on x86_64, needs testing on i386 and unavailable on anything else * Store HFILE in its own member variable
This commit is contained in:
parent
62307e1819
commit
8113a17167
13 changed files with 115 additions and 57 deletions
|
@ -430,6 +430,7 @@ if (ISLE_USE_SMARTHEAP)
|
||||||
endif()
|
endif()
|
||||||
foreach(tgt IN LISTS lego1_targets)
|
foreach(tgt IN LISTS lego1_targets)
|
||||||
target_link_libraries(${tgt} PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5>)
|
target_link_libraries(${tgt} PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5>)
|
||||||
|
target_compile_definitions(${tgt} PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DIRECTX5_SDK>)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Make sure filenames are ALL CAPS
|
# Make sure filenames are ALL CAPS
|
||||||
|
|
|
@ -96,7 +96,7 @@ class LegoAnimationManager : public MxCore {
|
||||||
public:
|
public:
|
||||||
// SIZE 0x18
|
// SIZE 0x18
|
||||||
struct Character {
|
struct Character {
|
||||||
char* m_name; // 0x00
|
const char* m_name; // 0x00
|
||||||
MxBool m_inExtras; // 0x04
|
MxBool m_inExtras; // 0x04
|
||||||
MxS8 m_vehicleId; // 0x05
|
MxS8 m_vehicleId; // 0x05
|
||||||
undefined m_unk0x06; // 0x06 (unused?)
|
undefined m_unk0x06; // 0x06 (unused?)
|
||||||
|
@ -112,7 +112,7 @@ class LegoAnimationManager : public MxCore {
|
||||||
|
|
||||||
// SIZE 0x08
|
// SIZE 0x08
|
||||||
struct Vehicle {
|
struct Vehicle {
|
||||||
char* m_name; // 0x00
|
const char* m_name; // 0x00
|
||||||
MxBool m_unk0x04; // 0x04
|
MxBool m_unk0x04; // 0x04
|
||||||
MxBool m_unk0x05; // 0x05
|
MxBool m_unk0x05; // 0x05
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,17 +7,23 @@
|
||||||
#include "mxstl/stlcompat.h"
|
#include "mxstl/stlcompat.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32
|
||||||
|
#else
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32*
|
||||||
|
#endif
|
||||||
|
|
||||||
struct LegoPathActorSetCompare {
|
struct LegoPathActorSetCompare {
|
||||||
MxU32 operator()(const LegoPathActor* p_lhs, const LegoPathActor* p_rhs) const
|
MxU32 operator()(const LegoPathActor* p_lhs, const LegoPathActor* p_rhs) const
|
||||||
{
|
{
|
||||||
return (MxS32) p_lhs < (MxS32) p_rhs;
|
return (COMPARE_POINTER_TYPE) p_lhs < (COMPARE_POINTER_TYPE) p_rhs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LegoAnimPresenterSetCompare {
|
struct LegoAnimPresenterSetCompare {
|
||||||
MxBool operator()(const LegoAnimPresenter* p_lhs, const LegoAnimPresenter* p_rhs) const
|
MxBool operator()(const LegoAnimPresenter* p_lhs, const LegoAnimPresenter* p_rhs) const
|
||||||
{
|
{
|
||||||
return (MxS32) p_lhs < (MxS32) p_rhs;
|
return (COMPARE_POINTER_TYPE) p_lhs < (COMPARE_POINTER_TYPE) p_rhs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,12 @@ class LegoWorld;
|
||||||
class MxAtomId;
|
class MxAtomId;
|
||||||
class Vector3;
|
class Vector3;
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32
|
||||||
|
#else
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32*
|
||||||
|
#endif
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d7da8
|
// VTABLE: LEGO1 0x100d7da8
|
||||||
// SIZE 0x40
|
// SIZE 0x40
|
||||||
struct LegoPathCtrlEdge : public LegoUnknown100db7f4 {};
|
struct LegoPathCtrlEdge : public LegoUnknown100db7f4 {};
|
||||||
|
@ -21,7 +27,7 @@ struct LegoPathCtrlEdge : public LegoUnknown100db7f4 {};
|
||||||
struct LegoPathCtrlEdgeCompare {
|
struct LegoPathCtrlEdgeCompare {
|
||||||
MxU32 operator()(const LegoPathCtrlEdge* p_lhs, const LegoPathCtrlEdge* p_rhs) const
|
MxU32 operator()(const LegoPathCtrlEdge* p_lhs, const LegoPathCtrlEdge* p_rhs) const
|
||||||
{
|
{
|
||||||
return (MxS32) p_lhs < (MxS32) p_rhs;
|
return (COMPARE_POINTER_TYPE) p_lhs < (COMPARE_POINTER_TYPE) p_rhs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,17 @@ class LegoEntityList;
|
||||||
class LegoPathBoundary;
|
class LegoPathBoundary;
|
||||||
class LegoHideAnimPresenter;
|
class LegoHideAnimPresenter;
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32
|
||||||
|
#else
|
||||||
|
#define COMPARE_POINTER_TYPE MxS32*
|
||||||
|
#endif
|
||||||
|
|
||||||
struct CoreSetCompare {
|
struct CoreSetCompare {
|
||||||
MxS32 operator()(MxCore* const& p_a, MxCore* const& p_b) const { return (MxS32) p_a < (MxS32) p_b; }
|
MxS32 operator()(MxCore* const& p_a, MxCore* const& p_b) const
|
||||||
|
{
|
||||||
|
return (COMPARE_POINTER_TYPE) p_a < (COMPARE_POINTER_TYPE) p_b;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef set<MxCore*, CoreSetCompare> MxCoreSet;
|
typedef set<MxCore*, CoreSetCompare> MxCoreSet;
|
||||||
|
|
|
@ -15,9 +15,9 @@ DECOMP_SIZE_ASSERT(HistoryBook, 0x3e4)
|
||||||
// FUNCTION: LEGO1 0x100822f0
|
// FUNCTION: LEGO1 0x100822f0
|
||||||
HistoryBook::HistoryBook()
|
HistoryBook::HistoryBook()
|
||||||
{
|
{
|
||||||
memset(m_alphabet, NULL, sizeof(m_alphabet));
|
memset(m_alphabet, 0, sizeof(m_alphabet));
|
||||||
memset(m_names, NULL, sizeof(m_names));
|
memset(m_names, 0, sizeof(m_names));
|
||||||
memset(m_scores, NULL, sizeof(m_scores));
|
memset(m_scores, 0, sizeof(m_scores));
|
||||||
NotificationManager()->Register(this);
|
NotificationManager()->Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1054,6 +1054,7 @@ int MxDeviceEnumerate::SupportsCPUID()
|
||||||
{
|
{
|
||||||
int has_cpuid;
|
int has_cpuid;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
#if defined(_M_IX86)
|
||||||
__asm {
|
__asm {
|
||||||
xor eax, eax ; Zero EAX register
|
xor eax, eax ; Zero EAX register
|
||||||
pushfd ; Push EFLAGS register value on the stack
|
pushfd ; Push EFLAGS register value on the stack
|
||||||
|
@ -1065,7 +1066,13 @@ int MxDeviceEnumerate::SupportsCPUID()
|
||||||
popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
|
popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
|
||||||
mov has_cpuid, eax ; Save eax into C variable
|
mov has_cpuid, eax ; Save eax into C variable
|
||||||
}
|
}
|
||||||
|
#elif defined(_M_X64)
|
||||||
|
has_cpuid = 1;
|
||||||
#else
|
#else
|
||||||
|
has_cpuid = 0;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if defined(__i386__)
|
||||||
__asm__("xorl %%eax, %%eax\n\t" // Zero EAX register
|
__asm__("xorl %%eax, %%eax\n\t" // Zero EAX register
|
||||||
"pushfl\n\t" // Push EFLAGS register value on the stack
|
"pushfl\n\t" // Push EFLAGS register value on the stack
|
||||||
"orl $0x200000, (%%esp)\n\t" // Set bit 0x200000: Able to use CPUID instruction (Pentium+)
|
"orl $0x200000, (%%esp)\n\t" // Set bit 0x200000: Able to use CPUID instruction (Pentium+)
|
||||||
|
@ -1076,6 +1083,11 @@ int MxDeviceEnumerate::SupportsCPUID()
|
||||||
"popfl" // Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
|
"popfl" // Push EFLAGS register value on the stack (again, and makes sure the stack remains the same)
|
||||||
: "=a"(has_cpuid) // has_cpuid == EAX
|
: "=a"(has_cpuid) // has_cpuid == EAX
|
||||||
);
|
);
|
||||||
|
#elif defined(__x86_64__) || defined(__amd64__)
|
||||||
|
has_cpuid = 1;
|
||||||
|
#else
|
||||||
|
has_cpuid = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return has_cpuid;
|
return has_cpuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
#define MXIO_MINFO_MFILE
|
||||||
|
#endif
|
||||||
|
|
||||||
// SIZE 0x48
|
// SIZE 0x48
|
||||||
class MXIOINFO {
|
class MXIOINFO {
|
||||||
public:
|
public:
|
||||||
|
@ -29,6 +33,9 @@ class MXIOINFO {
|
||||||
// NOTE: In MXIOINFO, the `hmmio` member of MMIOINFO is used like
|
// NOTE: In MXIOINFO, the `hmmio` member of MMIOINFO is used like
|
||||||
// an HFILE (int) instead of an HMMIO (WORD).
|
// an HFILE (int) instead of an HMMIO (WORD).
|
||||||
MMIOINFO m_info;
|
MMIOINFO m_info;
|
||||||
|
#ifndef MXIO_MINFO_MFILE
|
||||||
|
HFILE m_file;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MXIO_H
|
#endif // MXIO_H
|
||||||
|
|
|
@ -9,6 +9,16 @@
|
||||||
// but this assert will enforce the size if we decide to change that.
|
// but this assert will enforce the size if we decide to change that.
|
||||||
DECOMP_SIZE_ASSERT(MXIOINFO, sizeof(MMIOINFO));
|
DECOMP_SIZE_ASSERT(MXIOINFO, sizeof(MMIOINFO));
|
||||||
|
|
||||||
|
#ifdef MXIO_MINFO_MFILE
|
||||||
|
#define ASSIGN_M_FILE(X) m_info.hmmio = (HMMIO) (X)
|
||||||
|
#define M_FILE (HFILE)(m_info.hmmio)
|
||||||
|
#define RAW_M_FILE m_info.hmmio
|
||||||
|
#else
|
||||||
|
#define ASSIGN_M_FILE(X) m_file = (X)
|
||||||
|
#define M_FILE (m_file)
|
||||||
|
#define RAW_M_FILE m_file
|
||||||
|
#endif
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100cc800
|
// FUNCTION: LEGO1 0x100cc800
|
||||||
// FUNCTION: BETA10 0x1015e140
|
// FUNCTION: BETA10 0x1015e140
|
||||||
MXIOINFO::MXIOINFO()
|
MXIOINFO::MXIOINFO()
|
||||||
|
@ -33,9 +43,10 @@ MxU16 MXIOINFO::Open(const char* p_filename, MxULong p_flags)
|
||||||
m_info.lDiskOffset = m_info.lBufOffset = 0;
|
m_info.lDiskOffset = m_info.lBufOffset = 0;
|
||||||
|
|
||||||
// DECOMP: Cast of p_flags to u16 forces the `movzx` instruction
|
// DECOMP: Cast of p_flags to u16 forces the `movzx` instruction
|
||||||
m_info.hmmio = (HMMIO) OpenFile(p_filename, &unused, (MxU16) p_flags);
|
// original: m_info.hmmio = OpenFile(p_filename, &unused, (MxU16) p_flags);
|
||||||
|
ASSIGN_M_FILE(OpenFile(p_filename, &unused, (MxU16) p_flags));
|
||||||
|
|
||||||
if ((HFILE) m_info.hmmio != HFILE_ERROR) {
|
if (M_FILE != HFILE_ERROR) {
|
||||||
m_info.dwFlags = p_flags;
|
m_info.dwFlags = p_flags;
|
||||||
if (m_info.dwFlags & MMIO_ALLOCBUF) {
|
if (m_info.dwFlags & MMIO_ALLOCBUF) {
|
||||||
|
|
||||||
|
@ -75,10 +86,10 @@ MxU16 MXIOINFO::Close(MxLong p_unused)
|
||||||
{
|
{
|
||||||
MxU16 result = 0;
|
MxU16 result = 0;
|
||||||
|
|
||||||
if (m_info.hmmio) {
|
if (RAW_M_FILE) {
|
||||||
result = Flush(0);
|
result = Flush(0);
|
||||||
_lclose((HFILE) m_info.hmmio);
|
_lclose(M_FILE);
|
||||||
m_info.hmmio = 0;
|
ASSIGN_M_FILE(0);
|
||||||
|
|
||||||
if (m_info.dwFlags & MMIO_ALLOCBUF) {
|
if (m_info.dwFlags & MMIO_ALLOCBUF) {
|
||||||
delete[] m_info.pchBuffer;
|
delete[] m_info.pchBuffer;
|
||||||
|
@ -127,12 +138,12 @@ MxLong MXIOINFO::Read(void* p_buf, MxLong p_len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_info.hmmio && p_len > 0) {
|
else if (RAW_M_FILE && p_len > 0) {
|
||||||
bytesRead = _hread((HFILE) m_info.hmmio, p_buf, p_len);
|
bytesRead = _hread(M_FILE, p_buf, p_len);
|
||||||
|
|
||||||
if (bytesRead == -1) {
|
if (bytesRead == -1) {
|
||||||
bytesRead = 0;
|
bytesRead = 0;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesRead;
|
m_info.lDiskOffset += bytesRead;
|
||||||
|
@ -180,12 +191,12 @@ MxLong MXIOINFO::Write(void* p_buf, MxLong p_len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_info.hmmio && p_len > 0) {
|
else if (RAW_M_FILE && p_len > 0) {
|
||||||
bytesWritten = _hwrite((HFILE) m_info.hmmio, (const char*) p_buf, p_len);
|
bytesWritten = _hwrite(M_FILE, (const char*) p_buf, p_len);
|
||||||
|
|
||||||
if (bytesWritten == -1) {
|
if (bytesWritten == -1) {
|
||||||
bytesWritten = 0;
|
bytesWritten = 0;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesWritten;
|
m_info.lDiskOffset += bytesWritten;
|
||||||
|
@ -234,11 +245,11 @@ MxLong MXIOINFO::Seek(MxLong p_offset, MxLong p_origin)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// we have to read another chunk from disk.
|
// we have to read another chunk from disk.
|
||||||
if (m_info.hmmio && !Flush(0)) {
|
if (RAW_M_FILE && !Flush(0)) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, p_offset, p_origin);
|
m_info.lDiskOffset = _llseek(M_FILE, p_offset, p_origin);
|
||||||
|
|
||||||
if (m_info.lDiskOffset == -1) {
|
if (m_info.lDiskOffset == -1) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -248,10 +259,10 @@ MxLong MXIOINFO::Seek(MxLong p_offset, MxLong p_origin)
|
||||||
// do we need to seek again?
|
// do we need to seek again?
|
||||||
// (i.e. are we already aligned to buffer size?)
|
// (i.e. are we already aligned to buffer size?)
|
||||||
if (p_offset != m_info.lBufOffset) {
|
if (p_offset != m_info.lBufOffset) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, m_info.lBufOffset, SEEK_SET);
|
m_info.lDiskOffset = _llseek(M_FILE, m_info.lBufOffset, SEEK_SET);
|
||||||
|
|
||||||
if (m_info.lDiskOffset == -1) {
|
if (m_info.lDiskOffset == -1) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,10 +270,10 @@ MxLong MXIOINFO::Seek(MxLong p_offset, MxLong p_origin)
|
||||||
// is the file open for writing only?
|
// is the file open for writing only?
|
||||||
if ((m_info.dwFlags & MMIO_RWMODE) == 0 || (m_info.dwFlags & MMIO_RWMODE) == MMIO_READWRITE) {
|
if ((m_info.dwFlags & MMIO_RWMODE) == 0 || (m_info.dwFlags & MMIO_RWMODE) == MMIO_READWRITE) {
|
||||||
// We can read from the file. Fill the buffer.
|
// We can read from the file. Fill the buffer.
|
||||||
bytesRead = _hread((HFILE) m_info.hmmio, m_info.pchBuffer, m_info.cchBuffer);
|
bytesRead = _hread(M_FILE, m_info.pchBuffer, m_info.cchBuffer);
|
||||||
|
|
||||||
if (bytesRead == -1) {
|
if (bytesRead == -1) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesRead;
|
m_info.lDiskOffset += bytesRead;
|
||||||
|
@ -283,19 +294,19 @@ MxLong MXIOINFO::Seek(MxLong p_offset, MxLong p_origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_info.hmmio) {
|
else if (RAW_M_FILE) {
|
||||||
// No buffer so just seek the file directly (if we have a valid handle)
|
// No buffer so just seek the file directly (if we have a valid handle)
|
||||||
// i.e. if we just want to get the current file position
|
// i.e. if we just want to get the current file position
|
||||||
if (p_origin == SEEK_CUR && p_offset == 0) {
|
if (p_origin == SEEK_CUR && p_offset == 0) {
|
||||||
return m_info.lDiskOffset;
|
return m_info.lDiskOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, p_offset, p_origin);
|
m_info.lDiskOffset = _llseek(M_FILE, p_offset, p_origin);
|
||||||
|
|
||||||
result = m_info.lDiskOffset;
|
result = m_info.lDiskOffset;
|
||||||
|
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,25 +345,25 @@ MxU16 MXIOINFO::Flush(MxU16 p_unused)
|
||||||
// if we have allocated an IO buffer
|
// if we have allocated an IO buffer
|
||||||
if (m_info.pchBuffer) {
|
if (m_info.pchBuffer) {
|
||||||
// if we have a file open for writing
|
// if we have a file open for writing
|
||||||
if (m_info.hmmio && (m_info.dwFlags & MMIO_RWMODE)) {
|
if (RAW_M_FILE && (m_info.dwFlags & MMIO_RWMODE)) {
|
||||||
// DECOMP: pulling this value out into a variable forces it into EBX
|
// DECOMP: pulling this value out into a variable forces it into EBX
|
||||||
MxLong cchBuffer = m_info.cchBuffer;
|
MxLong cchBuffer = m_info.cchBuffer;
|
||||||
if (cchBuffer > 0) {
|
if (cchBuffer > 0) {
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, m_info.lBufOffset, SEEK_SET);
|
m_info.lDiskOffset = _llseek(M_FILE, m_info.lBufOffset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Was the previous seek (if required) successful?
|
// Was the previous seek (if required) successful?
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
result = MMIOERR_CANNOTSEEK;
|
result = MMIOERR_CANNOTSEEK;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bytesWritten = _hwrite((HFILE) m_info.hmmio, m_info.pchBuffer, cchBuffer);
|
bytesWritten = _hwrite(M_FILE, m_info.pchBuffer, cchBuffer);
|
||||||
|
|
||||||
if (bytesWritten == -1 || bytesWritten != cchBuffer) {
|
if (bytesWritten == -1 || bytesWritten != cchBuffer) {
|
||||||
result = MMIOERR_CANNOTWRITE;
|
result = MMIOERR_CANNOTWRITE;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesWritten;
|
m_info.lDiskOffset += bytesWritten;
|
||||||
|
@ -392,19 +403,19 @@ MxU16 MXIOINFO::Advance(MxU16 p_option)
|
||||||
((p_option & MMIO_WRITE) || (rwmode == MMIO_READWRITE)) && cch > 0) {
|
((p_option & MMIO_WRITE) || (rwmode == MMIO_READWRITE)) && cch > 0) {
|
||||||
|
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, m_info.lBufOffset, SEEK_SET);
|
m_info.lDiskOffset = _llseek(M_FILE, m_info.lBufOffset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
result = MMIOERR_CANNOTSEEK;
|
result = MMIOERR_CANNOTSEEK;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bytesCounter = _hwrite((HFILE) m_info.hmmio, m_info.pchBuffer, cch);
|
bytesCounter = _hwrite(M_FILE, m_info.pchBuffer, cch);
|
||||||
|
|
||||||
if (bytesCounter == -1 || bytesCounter != cch) {
|
if (bytesCounter == -1 || bytesCounter != cch) {
|
||||||
result = MMIOERR_CANNOTWRITE;
|
result = MMIOERR_CANNOTWRITE;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesCounter;
|
m_info.lDiskOffset += bytesCounter;
|
||||||
|
@ -418,20 +429,20 @@ MxU16 MXIOINFO::Advance(MxU16 p_option)
|
||||||
m_info.lBufOffset += cch;
|
m_info.lBufOffset += cch;
|
||||||
if ((!rwmode || rwmode == MMIO_READWRITE) && cch > 0) {
|
if ((!rwmode || rwmode == MMIO_READWRITE) && cch > 0) {
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, m_info.lBufOffset, SEEK_SET);
|
m_info.lDiskOffset = _llseek(M_FILE, m_info.lBufOffset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if previous seek failed
|
// if previous seek failed
|
||||||
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
if (m_info.lBufOffset != m_info.lDiskOffset) {
|
||||||
result = MMIOERR_CANNOTSEEK;
|
result = MMIOERR_CANNOTSEEK;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bytesCounter = _hread((HFILE) m_info.hmmio, m_info.pchBuffer, cch);
|
bytesCounter = _hread(M_FILE, m_info.pchBuffer, cch);
|
||||||
|
|
||||||
if (bytesCounter == -1) {
|
if (bytesCounter == -1) {
|
||||||
result = MMIOERR_CANNOTREAD;
|
result = MMIOERR_CANNOTREAD;
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset += bytesCounter;
|
m_info.lDiskOffset += bytesCounter;
|
||||||
|
@ -574,11 +585,11 @@ MxU16 MXIOINFO::Ascend(MMCKINFO* p_chunkInfo, MxU16 p_ascend)
|
||||||
m_info.dwFlags |= MMIO_DIRTY;
|
m_info.dwFlags |= MMIO_DIRTY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, ofs, SEEK_SET);
|
m_info.lDiskOffset = _llseek(M_FILE, ofs, SEEK_SET);
|
||||||
|
|
||||||
if (m_info.lDiskOffset == ofs) {
|
if (m_info.lDiskOffset == ofs) {
|
||||||
if (_lwrite((HFILE) m_info.hmmio, (char*) &size, 4) != 4) {
|
if (_lwrite(M_FILE, (char*) &size, 4) != 4) {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
result = MMIOERR_CANNOTWRITE;
|
result = MMIOERR_CANNOTWRITE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -586,7 +597,7 @@ MxU16 MXIOINFO::Ascend(MMCKINFO* p_chunkInfo, MxU16 p_ascend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_info.lDiskOffset = _llseek((HFILE) m_info.hmmio, 0, SEEK_CUR);
|
m_info.lDiskOffset = _llseek(M_FILE, 0, SEEK_CUR);
|
||||||
result = MMIOERR_CANNOTSEEK;
|
result = MMIOERR_CANNOTSEEK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
|
|
||||||
#include <d3drm.h>
|
#include <d3drm.h>
|
||||||
|
|
||||||
|
#ifdef DIRECTX5_SDK
|
||||||
|
typedef DWORD LPD3DRM_APPDATA;
|
||||||
|
#else
|
||||||
|
typedef LPVOID LPD3DRM_APPDATA;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declare D3D types
|
// Forward declare D3D types
|
||||||
struct IDirect3DRM2;
|
struct IDirect3DRM2;
|
||||||
struct IDirect3DRMDevice2;
|
struct IDirect3DRMDevice2;
|
||||||
|
|
|
@ -15,16 +15,16 @@ void TextureDestroyCallback(IDirect3DRMObject* pObject, void* pArg);
|
||||||
// FUNCTION: LEGO1 0x100a12a0
|
// FUNCTION: LEGO1 0x100a12a0
|
||||||
Result TextureImpl::SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage)
|
Result TextureImpl::SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage)
|
||||||
{
|
{
|
||||||
unsigned long appData;
|
void* appData;
|
||||||
Result result;
|
Result result;
|
||||||
|
|
||||||
appData = reinterpret_cast<unsigned long>(pImage);
|
appData = pImage;
|
||||||
|
|
||||||
// This is here because in the original code they asserted
|
// This is here because in the original code they asserted
|
||||||
// on the return value being NULL.
|
// on the return value being NULL.
|
||||||
TextureGetImage(pSelf);
|
TextureGetImage(pSelf);
|
||||||
|
|
||||||
result = ResultVal(pSelf->SetAppData(appData));
|
result = ResultVal(pSelf->SetAppData((LPD3DRM_APPDATA) appData));
|
||||||
if (Succeeded(result) && pImage) {
|
if (Succeeded(result) && pImage) {
|
||||||
result = ResultVal(pSelf->AddDestroyCallback(TextureDestroyCallback, NULL));
|
result = ResultVal(pSelf->AddDestroyCallback(TextureDestroyCallback, NULL));
|
||||||
if (!Succeeded(result)) {
|
if (!Succeeded(result)) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ Result ViewImpl::ViewportCreateAppData(IDirect3DRM2* pDevice, IDirect3DRMViewpor
|
||||||
{
|
{
|
||||||
ViewportAppData* data = new ViewportAppData(pDevice);
|
ViewportAppData* data = new ViewportAppData(pDevice);
|
||||||
data->m_pCamera = pCamera;
|
data->m_pCamera = pCamera;
|
||||||
Result result = ResultVal(pView->SetAppData(reinterpret_cast<unsigned long>(data)));
|
Result result = ResultVal(pView->SetAppData(reinterpret_cast<LPD3DRM_APPDATA>(data)));
|
||||||
if (Succeeded(result)) {
|
if (Succeeded(result)) {
|
||||||
result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data));
|
result = ResultVal(pView->AddDestroyCallback(ViewportDestroyCallback, data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ float g_unk0x1010105c = 0.000125F;
|
||||||
// GLOBAL: LEGO1 0x10101060
|
// GLOBAL: LEGO1 0x10101060
|
||||||
float g_elapsedSeconds = 0;
|
float g_elapsedSeconds = 0;
|
||||||
|
|
||||||
inline void SetAppData(ViewROI* p_roi, DWORD data);
|
inline void SetAppData(ViewROI* p_roi, LPD3DRM_APPDATA data);
|
||||||
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer);
|
inline undefined4 GetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer);
|
||||||
inline undefined4 GetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene);
|
inline undefined4 GetFrame(IDirect3DRMFrame2*& frame, Tgl::Group* scene);
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und)
|
||||||
|
|
||||||
if (lod->GetUnknown0x08() & ViewLOD::c_bit4) {
|
if (lod->GetUnknown0x08() & ViewLOD::c_bit4) {
|
||||||
scene->Add((Tgl::MeshBuilder*) group);
|
scene->Add((Tgl::MeshBuilder*) group);
|
||||||
SetAppData(p_roi, (DWORD) p_roi);
|
SetAppData(p_roi, reinterpret_cast<LPD3DRM_APPDATA>(p_roi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -187,7 +187,7 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und)
|
||||||
|
|
||||||
if (meshBuilder != NULL) {
|
if (meshBuilder != NULL) {
|
||||||
group->Add(meshBuilder);
|
group->Add(meshBuilder);
|
||||||
SetAppData(p_roi, (DWORD) p_roi);
|
SetAppData(p_roi, reinterpret_cast<LPD3DRM_APPDATA>(p_roi));
|
||||||
p_roi->SetUnknown0xe0(p_und);
|
p_roi->SetUnknown0xe0(p_und);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -533,7 +533,7 @@ ViewROI* ViewManager::Pick(Tgl::View* p_view, unsigned long x, unsigned long y)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SetAppData(ViewROI* p_roi, DWORD data)
|
inline void SetAppData(ViewROI* p_roi, LPD3DRM_APPDATA data)
|
||||||
{
|
{
|
||||||
IDirect3DRMFrame2* frame = NULL;
|
IDirect3DRMFrame2* frame = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue