diff --git a/source/converter_texture.cpp b/source/converter_texture.cpp index dcfacd9..61de144 100644 --- a/source/converter_texture.cpp +++ b/source/converter_texture.cpp @@ -13,7 +13,7 @@ #include #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"; diff --git a/source/stingray_bik.cpp b/source/stingray_bik.cpp new file mode 100644 index 0000000..03b1bca --- /dev/null +++ b/source/stingray_bik.cpp @@ -0,0 +1,40 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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(_meta.main); + _data_header = reinterpret_cast(reinterpret_cast(_header) + sizeof(header_t)); + _data_header_sz = _meta.main_size - sizeof(header_t); + _data = reinterpret_cast(_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> stingray::bik::sections() +{ + return { + {_data_header, _data_header_sz}, + {_data, _data_sz}, + }; +} diff --git a/source/stingray_bik.hpp b/source/stingray_bik.hpp new file mode 100644 index 0000000..6c85c67 --- /dev/null +++ b/source/stingray_bik.hpp @@ -0,0 +1,45 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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 +#include +#include +#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> sections(); + }; +} // namespace stingray diff --git a/source/stingray_texture.cpp b/source/stingray_texture.cpp new file mode 100644 index 0000000..b40c64a --- /dev/null +++ b/source/stingray_texture.cpp @@ -0,0 +1,59 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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(_meta.main); + _data_header = reinterpret_cast(reinterpret_cast(_header) + sizeof(header_t)); + _data_header_sz = _meta.main_size - sizeof(header_t); + _data = reinterpret_cast(_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(_data_header); + uint32_t magic32 = *reinterpret_cast(_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> stingray::texture::sections() +{ + return { + {_data_header, _data_header_sz}, + {_data, _data_sz}, + }; +} diff --git a/source/stingray_texture.hpp b/source/stingray_texture.hpp new file mode 100644 index 0000000..2847d3a --- /dev/null +++ b/source/stingray_texture.hpp @@ -0,0 +1,52 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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 +#include +#include +#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> sections(); + }; +} // namespace stingray diff --git a/source/stingray_wwise_bank.cpp b/source/stingray_wwise_bank.cpp new file mode 100644 index 0000000..5cbe0ca --- /dev/null +++ b/source/stingray_wwise_bank.cpp @@ -0,0 +1,37 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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(_meta.main); + _data = reinterpret_cast(_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> stingray::wwise_bank::sections() +{ + return { + {_data, _data_sz}, + }; +} diff --git a/source/stingray_wwise_bank.hpp b/source/stingray_wwise_bank.hpp new file mode 100644 index 0000000..fa8b6af --- /dev/null +++ b/source/stingray_wwise_bank.hpp @@ -0,0 +1,42 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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 +#include +#include +#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> sections(); + }; +} // namespace stingray diff --git a/source/stingray_wwise_stream.cpp b/source/stingray_wwise_stream.cpp new file mode 100644 index 0000000..5a2c3cc --- /dev/null +++ b/source/stingray_wwise_stream.cpp @@ -0,0 +1,37 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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(_meta.main); + _data = reinterpret_cast(_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> stingray::wwise_stream::sections() +{ + return { + {_data, _data_sz}, + }; +} diff --git a/source/stingray_wwise_stream.hpp b/source/stingray_wwise_stream.hpp new file mode 100644 index 0000000..2ca526b --- /dev/null +++ b/source/stingray_wwise_stream.hpp @@ -0,0 +1,42 @@ +// Copyright 2024 Michael Fabian 'Xaymar' Dirks +// +// 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 +#include +#include +#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> sections(); + }; +} // namespace stingray