diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 8b4cd82f..0fa415b5 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -173,6 +173,9 @@ nw4r/ut/ut_list.cpp: nw4r/ut/ut_LinkList.cpp: .text start:0x8042A850 end:0x8042A9E0 +nw4r/ut/ut_binaryFileFormat.cpp: + .text start:0x8042A9E0 end:0x8042AA54 + nw4r/db/db_directPrint.cpp: .text start:0x804342A0 end:0x80434E9C .rodata start:0x804F5D28 end:0x804F5FDC diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 39171bc6..78caaed3 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -23939,7 +23939,7 @@ Erase__Q44nw4r2ut6detail12LinkListImplFQ54nw4r2ut6detail12LinkListImpl8Iterator Clear__Q44nw4r2ut6detail12LinkListImplFv = .text:0x8042A930; // type:function size:0x44 Insert__Q44nw4r2ut6detail12LinkListImplFQ54nw4r2ut6detail12LinkListImpl8IteratorPQ34nw4r2ut12LinkListNode = .text:0x8042A980; // type:function size:0x2C Erase__Q44nw4r2ut6detail12LinkListImplFPQ34nw4r2ut12LinkListNode = .text:0x8042A9B0; // type:function size:0x30 -fn_8042A9E0 = .text:0x8042A9E0; // type:function size:0x74 +IsValidBinaryFile__Q24nw4r2utFPCQ34nw4r2ut16BinaryFileHeaderUlUsUs = .text:0x8042A9E0; // type:function size:0x74 fn_8042AA60 = .text:0x8042AA60; // type:function size:0x78 fn_8042AAE0 = .text:0x8042AAE0; // type:function size:0x1C fn_8042AB00 = .text:0x8042AB00; // type:function size:0x1C diff --git a/configure.py b/configure.py index 075220c3..3563baa5 100644 --- a/configure.py +++ b/configure.py @@ -319,6 +319,7 @@ config.libs = [ [ Object(Matching, "nw4r/ut/ut_list.cpp"), Object(Matching, "nw4r/ut/ut_LinkList.cpp"), + Object(Matching, "nw4r/ut/ut_binaryFileFormat.cpp"), ], ), # EGG diff --git a/include/nw4r/ut/ut_binaryFileFormat.h b/include/nw4r/ut/ut_binaryFileFormat.h index eeb5faca..8185fc24 100644 --- a/include/nw4r/ut/ut_binaryFileFormat.h +++ b/include/nw4r/ut/ut_binaryFileFormat.h @@ -19,8 +19,7 @@ struct BinaryFileHeader { u16 numBlocks; // at 0xE }; -bool IsValidBinaryFile(const BinaryFileHeader* header, u32 magic, u16 version, - u16 numBlocks); +bool IsValidBinaryFile(const BinaryFileHeader *header, unsigned long magic, u16 version, u16 numBlocks); } // namespace ut } // namespace nw4r diff --git a/src/nw4r/ut/ut_binaryFileFormat.cpp b/src/nw4r/ut/ut_binaryFileFormat.cpp new file mode 100644 index 00000000..1b62b51c --- /dev/null +++ b/src/nw4r/ut/ut_binaryFileFormat.cpp @@ -0,0 +1,28 @@ +#include + +namespace nw4r { +namespace ut { + +/* 8042a9e0 */ +bool IsValidBinaryFile(const BinaryFileHeader *header, unsigned long magic, u16 version, u16 numBlocks) { + if (header->magic != magic) { + return false; + } + if (header->byteOrder != 0xFEFF) { + return false; + } + if (header->version != version) { + return false; + } + if (header->fileSize < (numBlocks * sizeof(BinaryBlockHeader) + sizeof(BinaryFileHeader))) { + return false; + } + + if (header->numBlocks < numBlocks) { + return false; + } + return true; +} + +} // namespace ut +} // namespace nw4r