From 113472302904ac84d4ddf70df32ca245ad156bf2 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Fri, 1 Sep 2023 00:51:51 -0600 Subject: Migrated disassemble audio into audio manager class --- lib/binarytools/BinaryReader.cpp | 23 +++++++++++++++++++++++ lib/binarytools/BinaryReader.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'lib/binarytools') diff --git a/lib/binarytools/BinaryReader.cpp b/lib/binarytools/BinaryReader.cpp index 3aff001..75044b0 100644 --- a/lib/binarytools/BinaryReader.cpp +++ b/lib/binarytools/BinaryReader.cpp @@ -2,6 +2,7 @@ #include "MemoryStream.h" #include #include +#include LUS::BinaryReader::BinaryReader(char* nBuffer, size_t nBufferSize) { mStream = std::make_shared(nBuffer, nBufferSize); @@ -113,6 +114,28 @@ uint64_t LUS::BinaryReader::ReadUInt64() { return result; } +unsigned short LUS::BinaryReader::ReadUShort() { + unsigned short result = 0; + mStream->Read((char*)&result, sizeof(unsigned short)); + + if (mEndianness != Endianness::Native) { + result = BSWAP16(result); + } + + return result; +} + +short LUS::BinaryReader::ReadShort() { + short result = 0; + mStream->Read((char*)&result, sizeof(short)); + + if (mEndianness != Endianness::Native) { + result = BSWAP16(result); + } + + return result; +} + float LUS::BinaryReader::ReadFloat() { float result = NAN; diff --git a/lib/binarytools/BinaryReader.h b/lib/binarytools/BinaryReader.h index 59eeb52..91e2a40 100644 --- a/lib/binarytools/BinaryReader.h +++ b/lib/binarytools/BinaryReader.h @@ -34,6 +34,8 @@ class BinaryReader { uint16_t ReadUInt16(); uint32_t ReadUInt32(); uint64_t ReadUInt64(); + unsigned short ReadUShort(); + short ReadShort(); float ReadFloat(); double ReadDouble(); std::string ReadString(); -- cgit v1.2.3 From 063224c69d564d6e10dd4febf25caa9f59fccfda Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 3 Sep 2023 20:11:35 -0600 Subject: Fixed AIFC Extraction --- lib/binarytools/BinaryWriter.cpp | 13 +++++++++---- lib/binarytools/BinaryWriter.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/binarytools') diff --git a/lib/binarytools/BinaryWriter.cpp b/lib/binarytools/BinaryWriter.cpp index 362824f..6e0140f 100644 --- a/lib/binarytools/BinaryWriter.cpp +++ b/lib/binarytools/BinaryWriter.cpp @@ -132,10 +132,11 @@ void LUS::BinaryWriter::Write(double value) { mStream->Write((char*)&value, sizeof(double)); } -void LUS::BinaryWriter::Write(const std::string& str) { - int strLen = str.size(); - Write(strLen); - +void LUS::BinaryWriter::Write(const std::string& str, bool writeLength) { + if(writeLength){ + int strLen = str.size(); + Write(strLen); + } for (char c : str) { mStream->WriteByte(c); } @@ -145,6 +146,10 @@ void LUS::BinaryWriter::Write(char* srcBuffer, size_t length) { mStream->Write(srcBuffer, length); } +void LUS::BinaryWriter::WriteByte(char value) { + mStream->WriteByte(value); +} + std::vector LUS::BinaryWriter::ToVector() { return mStream->ToVector(); } diff --git a/lib/binarytools/BinaryWriter.h b/lib/binarytools/BinaryWriter.h index fbd4f65..dca683f 100644 --- a/lib/binarytools/BinaryWriter.h +++ b/lib/binarytools/BinaryWriter.h @@ -33,8 +33,9 @@ class BinaryWriter { void Write(uint64_t value); void Write(float value); void Write(double value); - void Write(const std::string& str); + void Write(const std::string& str, bool writeLength = true); void Write(char* srcBuffer, size_t length); + void WriteByte(char value); std::vector ToVector(); -- cgit v1.2.3 From 50b6c6f65bc0da4a2c07e24c75dcd19baba60083 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 3 Sep 2023 23:29:11 -0600 Subject: Added full SM64 -> AIFF Decoding --- lib/binarytools/BinaryReader.cpp | 8 ++++++-- lib/binarytools/BinaryReader.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/binarytools') diff --git a/lib/binarytools/BinaryReader.cpp b/lib/binarytools/BinaryReader.cpp index 75044b0..f802885 100644 --- a/lib/binarytools/BinaryReader.cpp +++ b/lib/binarytools/BinaryReader.cpp @@ -58,7 +58,6 @@ int16_t LUS::BinaryReader::ReadInt16() { if (mEndianness != Endianness::Native) { result = BSWAP16(result); } - return result; } @@ -192,6 +191,7 @@ std::string LUS::BinaryReader::ReadString() { for (int i = 0; i < numChars; i++) { res += ReadChar(); } + return res; } @@ -211,6 +211,10 @@ std::string LUS::BinaryReader::ReadCString() { return res; } +size_t LUS::BinaryReader::GetLength() { + return mStream->GetLength(); +} + std::vector LUS::BinaryReader::ToVector() { return mStream->ToVector(); -} +} \ No newline at end of file diff --git a/lib/binarytools/BinaryReader.h b/lib/binarytools/BinaryReader.h index 91e2a40..02e65cc 100644 --- a/lib/binarytools/BinaryReader.h +++ b/lib/binarytools/BinaryReader.h @@ -23,6 +23,7 @@ class BinaryReader { void Seek(int32_t offset, SeekOffsetType seekType); uint32_t GetBaseAddress(); + size_t GetLength(); void Read(int32_t length); void Read(char* buffer, int32_t length); -- cgit v1.2.3