Skip to content

Commit

Permalink
Rest of the generalization thing that wasn't in the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaymar committed Mar 1, 2024
1 parent 60c8b25 commit 9f9b7cb
Show file tree
Hide file tree
Showing 9 changed files with 355 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/converter_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <string_view>
#include "converter.hpp"
#include "endian.h"
#include "hd2_texture.hpp"
#include "stingray_texture.hpp"

static constexpr uint64_t type = 0x329ec6a0c63842cdull; // texture
static constexpr std::string_view section_default = "texture";
Expand Down
40 changes: 40 additions & 0 deletions source/stingray_bik.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "stingray_bik.hpp"

stingray::bik::~bik() {}

stingray::bik::bik(stingray::data_110000F0::meta_t meta) : _meta(meta)
{
_header = reinterpret_cast<decltype(_header)>(_meta.main);
_data_header = reinterpret_cast<decltype(_data_header)>(reinterpret_cast<uint8_t const*>(_header) + sizeof(header_t));
_data_header_sz = _meta.main_size - sizeof(header_t);
_data = reinterpret_cast<decltype(_data)>(_meta.stream ? _meta.stream : _meta.gpu);
_data_sz = _meta.stream_size ? _meta.stream_size : _meta.gpu_size;
}

size_t stingray::bik::size()
{
return _data_header_sz + _data_sz;
}

std::string stingray::bik::extension()
{
return "bik";
}

std::list<std::pair<void const*, size_t>> stingray::bik::sections()
{
return {
{_data_header, _data_header_sz},
{_data, _data_sz},
};
}
45 changes: 45 additions & 0 deletions source/stingray_bik.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once
#include <cinttypes>
#include <cstddef>
#include <list>
#include "stingray_data.hpp"

namespace stingray {
class bik {
public:
struct header_t {
uint32_t __unk0;
uint32_t __unk1;
uint32_t __unk2;
uint32_t __unk3;
};

private:
stingray::data_110000F0::meta_t _meta;
header_t const* _header;
uint8_t const* _data_header;
size_t _data_header_sz;
uint8_t const* _data;
size_t _data_sz;

public:
~bik();
bik(stingray::data_110000F0::meta_t meta);

size_t size();

std::string extension();

std::list<std::pair<void const*, size_t>> sections();
};
} // namespace stingray
59 changes: 59 additions & 0 deletions source/stingray_texture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "stingray_texture.hpp"

// Known information
// - gpu_resources only has mip level 2 and up again, which we won't need.
// - File appear to be DDS, and there is a reference to TGA as well.

stingray::texture::~texture() {}

stingray::texture::texture(stingray::data_110000F0::meta_t meta) : _meta(meta)
{
_header = reinterpret_cast<decltype(_header)>(_meta.main);
_data_header = reinterpret_cast<decltype(_data_header)>(reinterpret_cast<uint8_t const*>(_header) + sizeof(header_t));
_data_header_sz = _meta.main_size - sizeof(header_t);
_data = reinterpret_cast<decltype(_data)>(_meta.stream ? _meta.stream : _meta.gpu);
_data_sz = _meta.stream_size ? _meta.stream_size : _meta.gpu_size;
}

size_t stingray::texture::size()
{
return _data_header_sz + _data_sz;
}

std::string stingray::texture::extension()
{
#define TWOCC(a, b) ((a) | (b << 8))
#define FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))

// Take a reasonable guess at what the actual file type is.
if (_meta.main_size - sizeof(header_t) >= 4) {
uint16_t magic16 = *reinterpret_cast<uint16_t const*>(_data_header);
uint32_t magic32 = *reinterpret_cast<uint32_t const*>(_data_header);
if (magic32 == FOURCC('D', 'D', 'S', ' ')) {
return "dds";
} else if (magic32 == FOURCC('.', 'P', 'N', 'G')) {
return "png";
}
}

// If we still don't know, return the default.
return "texture";
}

std::list<std::pair<void const*, size_t>> stingray::texture::sections()
{
return {
{_data_header, _data_header_sz},
{_data, _data_sz},
};
}
52 changes: 52 additions & 0 deletions source/stingray_texture.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once
#include <cinttypes>
#include <cstddef>
#include <list>
#include "stingray_data.hpp"

namespace stingray {
class texture {
public:
struct streamable_section_t {
uint32_t offset;
uint32_t size;
uint16_t width;
uint16_t height;
};

struct header_t {
uint32_t __unk0;
uint32_t __unk1;
uint32_t __unk2;
streamable_section_t sections[15];
};

private:
stingray::data_110000F0::meta_t _meta;
header_t const* _header;
uint8_t const* _data_header;
size_t _data_header_sz;
uint8_t const* _data;
size_t _data_sz;

public:
~texture();
texture(stingray::data_110000F0::meta_t meta);

size_t size();

std::string extension();

std::list<std::pair<void const*, size_t>> sections();
};
} // namespace stingray
37 changes: 37 additions & 0 deletions source/stingray_wwise_bank.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "stingray_wwise_bank.hpp"

stingray::wwise_bank::~wwise_bank() {}

stingray::wwise_bank::wwise_bank(stingray::data_110000F0::meta_t meta) : _meta(meta)
{
_header = reinterpret_cast<decltype(_header)>(_meta.main);
_data = reinterpret_cast<decltype(_data)>(_meta.main) + sizeof(header_t);
_data_sz = _header->size;
}

size_t stingray::wwise_bank::size()
{
return _data_sz;
}

std::string stingray::wwise_bank::extension()
{
return "bnk";
}

std::list<std::pair<void const*, size_t>> stingray::wwise_bank::sections()
{
return {
{_data, _data_sz},
};
}
42 changes: 42 additions & 0 deletions source/stingray_wwise_bank.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once
#include <cinttypes>
#include <cstddef>
#include <list>
#include "stingray_data.hpp"

namespace stingray {
class wwise_bank {
public:
struct header_t {
uint32_t __unk0;
uint32_t size;
uint64_t name_hash;
};

private:
stingray::data_110000F0::meta_t _meta;
header_t const* _header;
uint8_t const* _data;
size_t _data_sz;

public:
~wwise_bank();
wwise_bank(stingray::data_110000F0::meta_t meta);

size_t size();

std::string extension();

std::list<std::pair<void const*, size_t>> sections();
};
} // namespace stingray
37 changes: 37 additions & 0 deletions source/stingray_wwise_stream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "stingray_wwise_stream.hpp"

stingray::wwise_stream::~wwise_stream() {}

stingray::wwise_stream::wwise_stream(stingray::data_110000F0::meta_t meta) : _meta(meta)
{
_header = reinterpret_cast<decltype(_header)>(_meta.main);
_data = reinterpret_cast<decltype(_data)>(_meta.stream ? _meta.stream : _meta.gpu);
_data_sz = _header->size;
}

size_t stingray::wwise_stream::size()
{
return _data_sz;
}

std::string stingray::wwise_stream::extension()
{
return "wem";
}

std::list<std::pair<void const*, size_t>> stingray::wwise_stream::sections()
{
return {
{_data, _data_sz},
};
}
42 changes: 42 additions & 0 deletions source/stingray_wwise_stream.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Michael Fabian 'Xaymar' Dirks <[email protected]>
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once
#include <cinttypes>
#include <cstddef>
#include <list>
#include "stingray_data.hpp"

namespace stingray {
class wwise_stream {
public:
struct header_t {
uint32_t __unk0;
uint32_t __unk1;
uint32_t size;
};

private:
stingray::data_110000F0::meta_t _meta;
header_t const* _header;
uint8_t const* _data;
size_t _data_sz;

public:
~wwise_stream();
wwise_stream(stingray::data_110000F0::meta_t meta);

size_t size();

std::string extension();

std::list<std::pair<void const*, size_t>> sections();
};
} // namespace stingray

0 comments on commit 9f9b7cb

Please sign in to comment.