2024-04-28 20:19:37 -03:00
|
|
|
#include "reader.hpp"
|
|
|
|
#include "manager.hpp"
|
2024-05-01 19:09:43 -03:00
|
|
|
#include "lzx/decoderstream.hpp"
|
2024-05-02 10:52:08 -03:00
|
|
|
#include "typereadermanager.hpp"
|
2024-04-28 20:19:37 -03:00
|
|
|
|
|
|
|
namespace xna {
|
2024-05-01 19:09:43 -03:00
|
|
|
sptr<ContentReader> ContentReader::Create(ContentManager* contentManager, Stream* input, String const& assetName)
|
2024-04-28 20:19:37 -03:00
|
|
|
{
|
|
|
|
return sptr<ContentReader>();
|
|
|
|
}
|
2024-05-01 19:09:43 -03:00
|
|
|
|
|
|
|
sptr<Stream> ContentReader::PrepareStream(sptr<Stream>& input, String const* assetName, Int& graphicsProfile)
|
|
|
|
{
|
|
|
|
BinaryReader binaryReader = BinaryReader(input);
|
|
|
|
|
|
|
|
if (binaryReader.ReadByte() != 'X' || binaryReader.ReadByte() != 'N' || binaryReader.ReadByte() != 'B')
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
Int num1 = 0;
|
|
|
|
if (binaryReader.ReadByte() == 'w')
|
|
|
|
num1 = binaryReader.ReadUInt16();
|
|
|
|
else
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
graphicsProfile = (num1 & 32512) >> 8;
|
|
|
|
bool flag = false;
|
|
|
|
|
|
|
|
switch (num1 & -32513)
|
|
|
|
{
|
|
|
|
case 5:
|
|
|
|
flag = false;
|
|
|
|
break;
|
|
|
|
case 32773:
|
|
|
|
flag = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto num2 = binaryReader.ReadInt32();
|
|
|
|
|
|
|
|
if ((num2 - 10) > input->Length() - input->Position())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
if (!flag)
|
|
|
|
return input;
|
|
|
|
|
|
|
|
const Int compressedTodo = num2 - 14;
|
|
|
|
const auto decompressedTodo = binaryReader.ReadInt32();
|
|
|
|
|
|
|
|
auto lzxStream = New<LzxDecoderStream>(input, compressedTodo, decompressedTodo);
|
|
|
|
|
|
|
|
return reinterpret_pointer_cast<Stream>(lzxStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
Int ContentReader::ReadHeader() {
|
2024-05-02 10:52:08 -03:00
|
|
|
//typeReaders = ContentTypeReaderManager::ReadTypeManifest(this->Read7BitEncodedInt(), this);
|
2024-05-01 19:09:43 -03:00
|
|
|
}
|
2024-04-28 20:19:37 -03:00
|
|
|
}
|