chore: made ROM title offset a constant

This commit is contained in:
Justin Scofield
2022-08-08 15:16:20 -04:00
parent 4c2786be0e
commit 48ee666656
2 changed files with 7 additions and 1 deletions

View File

@@ -576,6 +576,7 @@ absl::Status ROM::LoadFromFile(const absl::string_view& filename) {
return absl::InternalError(
absl::StrCat("Could not open ROM file: ", filename));
}
size_ = std::filesystem::file_size(filename);
rom_data_.resize(size_);
for (auto i = 0; i < size_; ++i) {
@@ -583,9 +584,12 @@ absl::Status ROM::LoadFromFile(const absl::string_view& filename) {
file.read(&byte_to_read, sizeof(char));
rom_data_[i] = byte_to_read;
}
// copy ROM title
memcpy(title, rom_data_.data() + kTitleStringOffset, kTitleStringLength);
file.close();
is_loaded_ = true;
memcpy(title, rom_data_.data() + 32704, 20); // copy ROM title
return absl::OkStatus();
}

View File

@@ -36,6 +36,8 @@ constexpr int kMaxLengthCompression = 1024;
constexpr int kNintendoMode1 = 0;
constexpr int kNintendoMode2 = 1;
constexpr int kTile32Num = 4432;
constexpr int kTitleStringOffset = 0x7FC0;
constexpr int kTitleStringLength = 20;
constexpr uchar kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
0x08, 0x04, 0x02, 0x01};