Refactor FourCC magic uses

- Use new fourcc_t type
- Improves compiler compatibility by removing multi chars
This commit is contained in:
Joel Linn
2021-05-06 18:46:43 +02:00
committed by Rick Gibbed
parent 4daa3f5a52
commit a86d7173e1
25 changed files with 65 additions and 42 deletions

View File

@@ -13,9 +13,9 @@ namespace xe {
namespace kernel {
namespace util {
constexpr uint32_t kGameInfoExecMagic = 'EXEC';
constexpr uint32_t kGameInfoCommMagic = 'COMM';
constexpr uint32_t kGameInfoTitlMagic = 'TITL';
constexpr fourcc_t kGameInfoExecSignature = make_fourcc("EXEC");
constexpr fourcc_t kGameInfoCommSignature = make_fourcc("COMM");
constexpr fourcc_t kGameInfoTitlSignature = make_fourcc("TITL");
GameInfoWrapper::GameInfoWrapper(const uint8_t* data, size_t data_size)
: data_(data), data_size_(data_size) {
@@ -31,7 +31,7 @@ GameInfoWrapper::GameInfoWrapper(const uint8_t* data, size_t data_size)
data_offset += sizeof(GameInfoBlockHeader);
switch (block_header->magic) {
case kGameInfoExecMagic:
case kGameInfoExecSignature:
exec_.virtual_titleid =
reinterpret_cast<const char*>(data_ + data_offset);
data_offset += exec_.VirtualTitleIdLength + 1;
@@ -41,12 +41,12 @@ GameInfoWrapper::GameInfoWrapper(const uint8_t* data, size_t data_size)
reinterpret_cast<const char*>(data_ + data_offset);
data_offset += exec_.BuildDescriptionLength + 1;
break;
case kGameInfoCommMagic:
case kGameInfoCommSignature:
assert_true(block_header->block_size == sizeof(GameInfoBlockComm));
comm_ = reinterpret_cast<const GameInfoBlockComm*>(data_ + data_offset);
data_offset += block_header->block_size;
break;
case kGameInfoTitlMagic:
case kGameInfoTitlSignature:
assert_true(block_header->block_size == sizeof(GameInfoBlockTitl));
titl_ = reinterpret_cast<const GameInfoBlockTitl*>(data_ + data_offset);
data_offset += block_header->block_size;

View File

@@ -13,9 +13,9 @@ namespace xe {
namespace kernel {
namespace util {
constexpr uint32_t kXdbfMagicXdbf = 'XDBF';
constexpr uint32_t kXdbfMagicXstc = 'XSTC';
constexpr uint32_t kXdbfMagicXstr = 'XSTR';
constexpr fourcc_t kXdbfSignatureXdbf = make_fourcc("XDBF");
constexpr fourcc_t kXdbfSignatureXstc = make_fourcc("XSTC");
constexpr fourcc_t kXdbfSignatureXstr = make_fourcc("XSTR");
XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size)
: data_(data), data_size_(data_size) {
@@ -28,7 +28,7 @@ XdbfWrapper::XdbfWrapper(const uint8_t* data, size_t data_size)
header_ = reinterpret_cast<const XbdfHeader*>(ptr);
ptr += sizeof(XbdfHeader);
if (header_->magic != kXdbfMagicXdbf) {
if (header_->magic != kXdbfSignatureXdbf) {
data_ = nullptr;
return;
}
@@ -65,7 +65,7 @@ std::string XdbfWrapper::GetStringTableEntry(XLanguage language,
auto xstr_head =
reinterpret_cast<const XdbfXstrHeader*>(language_block.buffer);
assert_true(xstr_head->magic == kXdbfMagicXstr);
assert_true(xstr_head->magic == kXdbfSignatureXstr);
assert_true(xstr_head->version == 1);
const uint8_t* ptr = language_block.buffer + sizeof(XdbfXstrHeader);
@@ -94,7 +94,7 @@ XLanguage XdbfGameData::default_language() const {
return XLanguage::kEnglish;
}
auto xstc = reinterpret_cast<const XdbfXstc*>(block.buffer);
assert_true(xstc->magic == kXdbfMagicXstc);
assert_true(xstc->magic == kXdbfSignatureXstc);
return static_cast<XLanguage>(static_cast<uint32_t>(xstc->default_language));
}