chore: made ROM title offset a constant
This commit is contained in:
@@ -576,6 +576,7 @@ absl::Status ROM::LoadFromFile(const absl::string_view& filename) {
|
|||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrCat("Could not open ROM file: ", filename));
|
absl::StrCat("Could not open ROM file: ", filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_ = std::filesystem::file_size(filename);
|
size_ = std::filesystem::file_size(filename);
|
||||||
rom_data_.resize(size_);
|
rom_data_.resize(size_);
|
||||||
for (auto i = 0; i < size_; ++i) {
|
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));
|
file.read(&byte_to_read, sizeof(char));
|
||||||
rom_data_[i] = byte_to_read;
|
rom_data_[i] = byte_to_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy ROM title
|
||||||
|
memcpy(title, rom_data_.data() + kTitleStringOffset, kTitleStringLength);
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
is_loaded_ = true;
|
is_loaded_ = true;
|
||||||
memcpy(title, rom_data_.data() + 32704, 20); // copy ROM title
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ constexpr int kMaxLengthCompression = 1024;
|
|||||||
constexpr int kNintendoMode1 = 0;
|
constexpr int kNintendoMode1 = 0;
|
||||||
constexpr int kNintendoMode2 = 1;
|
constexpr int kNintendoMode2 = 1;
|
||||||
constexpr int kTile32Num = 4432;
|
constexpr int kTile32Num = 4432;
|
||||||
|
constexpr int kTitleStringOffset = 0x7FC0;
|
||||||
|
constexpr int kTitleStringLength = 20;
|
||||||
constexpr uchar kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
|
constexpr uchar kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10,
|
||||||
0x08, 0x04, 0x02, 0x01};
|
0x08, 0x04, 0x02, 0x01};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user