| ... | ... |
@@ -18,7 +18,7 @@ SYMBRecord::SYMBRecord() : entries() |
| 18 | 18 |
|
| 19 | 19 |
void SYMBRecord::Read(PseudoFile &file, std::uint32_t startOffset) |
| 20 | 20 |
{
|
| 21 |
- std::uint32_t count = file.ReadLE<uint32_t>(); |
|
| 21 |
+ std::uint32_t count = file.ReadLE<std::uint32_t>(); |
|
| 22 | 22 |
auto entryOffsets = std::vector<std::uint32_t>(count); |
| 23 | 23 |
file.ReadLE(entryOffsets); |
| 24 | 24 |
for (std::uint32_t i = 0; i < count; ++i) |
* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().
| ... | ... |
@@ -8,18 +8,20 @@ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 | 10 |
#include <vector> |
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "SYMBSection.h" |
| 13 |
+#include "common.h" |
|
| 12 | 14 |
|
| 13 | 15 |
SYMBRecord::SYMBRecord() : entries() |
| 14 | 16 |
{
|
| 15 | 17 |
} |
| 16 | 18 |
|
| 17 |
-void SYMBRecord::Read(PseudoFile &file, uint32_t startOffset) |
|
| 19 |
+void SYMBRecord::Read(PseudoFile &file, std::uint32_t startOffset) |
|
| 18 | 20 |
{
|
| 19 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 20 |
- auto entryOffsets = std::vector<uint32_t>(count); |
|
| 21 |
+ std::uint32_t count = file.ReadLE<uint32_t>(); |
|
| 22 |
+ auto entryOffsets = std::vector<std::uint32_t>(count); |
|
| 21 | 23 |
file.ReadLE(entryOffsets); |
| 22 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 24 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 23 | 25 |
if (entryOffsets[i]) |
| 24 | 26 |
{
|
| 25 | 27 |
file.pos = startOffset + entryOffsets[i]; |
| ... | ... |
@@ -33,13 +35,13 @@ SYMBSection::SYMBSection() : SEQrecord(), BANKrecord(), WAVEARCrecord(), PLAYERr |
| 33 | 35 |
|
| 34 | 36 |
void SYMBSection::Read(PseudoFile &file) |
| 35 | 37 |
{
|
| 36 |
- uint32_t startOfSYMB = file.pos; |
|
| 37 |
- int8_t type[4]; |
|
| 38 |
+ std::uint32_t startOfSYMB = file.pos; |
|
| 39 |
+ std::int8_t type[4]; |
|
| 38 | 40 |
file.ReadLE(type); |
| 39 | 41 |
if (!VerifyHeader(type, "SYMB")) |
| 40 | 42 |
throw std::runtime_error("SDAT SYMB Section invalid");
|
| 41 |
- file.ReadLE<uint32_t>(); // size |
|
| 42 |
- uint32_t recordOffsets[8]; |
|
| 43 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 44 |
+ std::uint32_t recordOffsets[8]; |
|
| 43 | 45 |
file.ReadLE(recordOffsets); |
| 44 | 46 |
if (recordOffsets[REC_SEQ]) |
| 45 | 47 |
{
|
(I never remember to update these and besides, GitHub history can show when they were last modified.)
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - SDAT SYMB (Symbol/Filename) Section structures |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2014-10-25 |
|
| 5 | 4 |
* |
| 6 | 5 |
* Nintendo DS Nitro Composer (SDAT) Specification document found at |
| 7 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
(It probably never triggered any errors in the past because of it being implicitly included by some other header file.)
Backwards compatibility is kept by treating the lack of PLAYER info as
if all channels are able to be allocated.
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* SSEQ Player - SDAT SYMB (Symbol/Filename) Section structures |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 |
- * Last modification on 2013-03-25 |
|
| 4 |
+ * Last modification on 2014-10-25 |
|
| 5 | 5 |
* |
| 6 | 6 |
* Nintendo DS Nitro Composer (SDAT) Specification document found at |
| 7 | 7 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| ... | ... |
@@ -27,7 +27,7 @@ void SYMBRecord::Read(PseudoFile &file, uint32_t startOffset) |
| 27 | 27 |
} |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-SYMBSection::SYMBSection() : SEQrecord(), BANKrecord(), WAVEARCrecord() |
|
| 30 |
+SYMBSection::SYMBSection() : SEQrecord(), BANKrecord(), WAVEARCrecord(), PLAYERrecord() |
|
| 31 | 31 |
{
|
| 32 | 32 |
} |
| 33 | 33 |
|
| ... | ... |
@@ -56,4 +56,9 @@ void SYMBSection::Read(PseudoFile &file) |
| 56 | 56 |
file.pos = startOfSYMB + recordOffsets[REC_WAVEARC]; |
| 57 | 57 |
this->WAVEARCrecord.Read(file, startOfSYMB); |
| 58 | 58 |
} |
| 59 |
+ if (recordOffsets[REC_PLAYER]) |
|
| 60 |
+ {
|
|
| 61 |
+ file.pos = startOfSYMB + recordOffsets[REC_PLAYER]; |
|
| 62 |
+ this->PLAYERrecord.Read(file, startOfSYMB); |
|
| 63 |
+ } |
|
| 59 | 64 |
} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,59 @@ |
| 1 |
+/* |
|
| 2 |
+ * SSEQ Player - SDAT SYMB (Symbol/Filename) Section structures |
|
| 3 |
+ * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
|
| 4 |
+ * Last modification on 2013-03-25 |
|
| 5 |
+ * |
|
| 6 |
+ * Nintendo DS Nitro Composer (SDAT) Specification document found at |
|
| 7 |
+ * http://www.feshrine.net/hacking/doc/nds-sdat.html |
|
| 8 |
+ */ |
|
| 9 |
+ |
|
| 10 |
+#include <vector> |
|
| 11 |
+#include "SYMBSection.h" |
|
| 12 |
+ |
|
| 13 |
+SYMBRecord::SYMBRecord() : entries() |
|
| 14 |
+{
|
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+void SYMBRecord::Read(PseudoFile &file, uint32_t startOffset) |
|
| 18 |
+{
|
|
| 19 |
+ uint32_t count = file.ReadLE<uint32_t>(); |
|
| 20 |
+ auto entryOffsets = std::vector<uint32_t>(count); |
|
| 21 |
+ file.ReadLE(entryOffsets); |
|
| 22 |
+ for (uint32_t i = 0; i < count; ++i) |
|
| 23 |
+ if (entryOffsets[i]) |
|
| 24 |
+ {
|
|
| 25 |
+ file.pos = startOffset + entryOffsets[i]; |
|
| 26 |
+ this->entries[i] = file.ReadNullTerminatedString(); |
|
| 27 |
+ } |
|
| 28 |
+} |
|
| 29 |
+ |
|
| 30 |
+SYMBSection::SYMBSection() : SEQrecord(), BANKrecord(), WAVEARCrecord() |
|
| 31 |
+{
|
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+void SYMBSection::Read(PseudoFile &file) |
|
| 35 |
+{
|
|
| 36 |
+ uint32_t startOfSYMB = file.pos; |
|
| 37 |
+ int8_t type[4]; |
|
| 38 |
+ file.ReadLE(type); |
|
| 39 |
+ if (!VerifyHeader(type, "SYMB")) |
|
| 40 |
+ throw std::runtime_error("SDAT SYMB Section invalid");
|
|
| 41 |
+ file.ReadLE<uint32_t>(); // size |
|
| 42 |
+ uint32_t recordOffsets[8]; |
|
| 43 |
+ file.ReadLE(recordOffsets); |
|
| 44 |
+ if (recordOffsets[REC_SEQ]) |
|
| 45 |
+ {
|
|
| 46 |
+ file.pos = startOfSYMB + recordOffsets[REC_SEQ]; |
|
| 47 |
+ this->SEQrecord.Read(file, startOfSYMB); |
|
| 48 |
+ } |
|
| 49 |
+ if (recordOffsets[REC_BANK]) |
|
| 50 |
+ {
|
|
| 51 |
+ file.pos = startOfSYMB + recordOffsets[REC_BANK]; |
|
| 52 |
+ this->BANKrecord.Read(file, startOfSYMB); |
|
| 53 |
+ } |
|
| 54 |
+ if (recordOffsets[REC_WAVEARC]) |
|
| 55 |
+ {
|
|
| 56 |
+ file.pos = startOfSYMB + recordOffsets[REC_WAVEARC]; |
|
| 57 |
+ this->WAVEARCrecord.Read(file, startOfSYMB); |
|
| 58 |
+ } |
|
| 59 |
+} |