61 static absl::Status
LoadAndVerifyROM(
const std::string& path, std::unique_ptr<Rom>& rom) {
62 rom = std::make_unique<Rom>();
66 EXPECT_EQ(rom->size(), 0x200000) <<
"ROM size should be 2MB";
67 EXPECT_NE(rom->data(),
nullptr) <<
"ROM data should not be null";
70 auto header_byte = rom->ReadByte(0x7FC0);
72 EXPECT_EQ(*header_byte, 0x21) <<
"ROM should be LoROM format";
74 return absl::OkStatus();
79 const std::vector<uint32_t>& exclude_ranges = {}) {
80 std::ifstream file1(path1, std::ios::binary);
81 std::ifstream file2(path2, std::ios::binary);
83 if (!file1.is_open() || !file2.is_open()) {
87 file1.seekg(0, std::ios::end);
88 file2.seekg(0, std::ios::end);
90 size_t size1 = file1.tellg();
91 size_t size2 = file2.tellg();
100 std::vector<char> buffer1(size1);
101 std::vector<char> buffer2(size2);
103 file1.read(buffer1.data(), size1);
104 file2.read(buffer2.data(), size2);
107 for (
size_t i = 0; i < size1; i++) {
108 bool in_exclude_range =
false;
109 for (
const auto& range : exclude_ranges) {
110 if (i >= (range & 0xFFFFFF) && i < ((range >> 24) & 0xFF)) {
111 in_exclude_range =
true;
116 if (!in_exclude_range && buffer1[i] != buffer2[i]) {