Add methods to get the TOC checksum as per the specs.

This commit is contained in:
King_DuckZ 2020-03-20 18:58:06 +01:00
parent c89a27f427
commit e40d092b7d
2 changed files with 17 additions and 0 deletions

View file

@ -61,6 +61,9 @@ public:
std::string product_code() const;
bool has_pocket_station_content() const;
std::string_view identifier() const;
uint8_t toc_checksum() const;
uint8_t calculate_toc_checksum() const;
private:
BasicFrame<Const> m_toc_entry;

View file

@ -215,6 +215,20 @@ std::string_view BasicBlock<Const>::identifier() const {
return {reinterpret_cast<const char*>(m_toc_entry.data() + 0x16), 8};
}
template <bool Const>
uint8_t BasicBlock<Const>::toc_checksum() const {
return m_toc_entry.data()[0xFF - 0x80];
}
template <bool Const>
uint8_t BasicBlock<Const>::calculate_toc_checksum() const {
uint8_t retval = 0;
for (std::size_t z = 0; z < m_toc_entry.size() - 1; ++z) {
retval ^= m_toc_entry[z];
}
return retval;
}
template class BasicBlock<true>;
template class BasicBlock<false>;
} //namespace mc::psx