-
Notifications
You must be signed in to change notification settings - Fork 3
/
NDSStdHeader.cpp
31 lines (27 loc) · 898 Bytes
/
NDSStdHeader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* SSEQ Player - Nintendo DS Standard Header structure
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
* Last modification on 2013-03-21
*
* Nintendo DS Nitro Composer (SDAT) Specification document found at
* http://www.feshrine.net/hacking/doc/nds-sdat.html
*/
#include <stdexcept>
#include "NDSStdHeader.h"
NDSStdHeader::NDSStdHeader() : magic(0)
{
memset(this->type, 0, sizeof(this->type));
}
void NDSStdHeader::Read(PseudoFile &file)
{
file.ReadLE(this->type);
this->magic = file.ReadLE<uint32_t>();
file.ReadLE<uint32_t>(); // file size
file.ReadLE<uint16_t>(); // structure size
file.ReadLE<uint16_t>(); // # of blocks
}
void NDSStdHeader::Verify(const std::string &typeToCheck, uint32_t magicToCheck)
{
if (!VerifyHeader(this->type, typeToCheck) || this->magic != magicToCheck)
throw std::runtime_error("NDS Standard Header for " + typeToCheck + " invalid");
}