102 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
103 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
106 ASSERT_OK(ExtractGoldenData(vanilla_test_path_, golden_data_path_));
109 EXPECT_TRUE(std::filesystem::exists(golden_data_path_));
112 EXPECT_TRUE(ValidateROMAgainstGoldenData(*rom, golden_data_path_));
117 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
118 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
121 auto status = overworld.
Load(rom.get());
122 ASSERT_TRUE(status.ok());
128 EXPECT_EQ(maps.size(), 160);
131 auto asm_version = rom->ReadByte(0x140145);
132 ASSERT_TRUE(asm_version.ok());
133 EXPECT_EQ(*asm_version, 0xFF);
140 const auto& entrances = overworld.
entrances();
141 const auto& exits = overworld.
exits();
142 const auto& holes = overworld.
holes();
143 const auto& items = overworld.
all_items();
145 EXPECT_EQ(entrances.size(), 129);
146 EXPECT_EQ(exits->size(), 0x4F);
147 EXPECT_EQ(holes.size(), 0x13);
148 EXPECT_GE(items.size(), 0);
152 EXPECT_EQ(sprites.size(), 3);
157 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
158 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
162 ASSERT_OK(rom->WriteByte(0x140145, 0x03));
165 ASSERT_OK(rom->WriteByte(0x140146, 0x01));
166 ASSERT_OK(rom->WriteByte(0x140147, 0x01));
167 ASSERT_OK(rom->WriteByte(0x140148, 0x01));
168 ASSERT_OK(rom->WriteByte(0x140149, 0x01));
169 ASSERT_OK(rom->WriteByte(0x14014A, 0x01));
170 ASSERT_OK(rom->WriteByte(0x14014B, 0x01));
176 std::unique_ptr<Rom> reloaded_rom = std::make_unique<Rom>();
177 ASSERT_OK(reloaded_rom->LoadFromFile(edited_test_path_));
180 auto asm_version = reloaded_rom->ReadByte(0x140145);
181 ASSERT_TRUE(asm_version.ok());
182 EXPECT_EQ(*asm_version, 0x03);
185 auto main_palettes = reloaded_rom->ReadByte(0x140146);
186 auto area_bg = reloaded_rom->ReadByte(0x140147);
187 auto subscreen_overlay = reloaded_rom->ReadByte(0x140148);
188 auto animated_gfx = reloaded_rom->ReadByte(0x140149);
189 auto custom_tiles = reloaded_rom->ReadByte(0x14014A);
190 auto mosaic = reloaded_rom->ReadByte(0x14014B);
192 ASSERT_TRUE(main_palettes.ok());
193 ASSERT_TRUE(area_bg.ok());
194 ASSERT_TRUE(subscreen_overlay.ok());
195 ASSERT_TRUE(animated_gfx.ok());
196 ASSERT_TRUE(custom_tiles.ok());
197 ASSERT_TRUE(mosaic.ok());
199 EXPECT_EQ(*main_palettes, 0x01);
200 EXPECT_EQ(*area_bg, 0x01);
201 EXPECT_EQ(*subscreen_overlay, 0x01);
202 EXPECT_EQ(*animated_gfx, 0x01);
203 EXPECT_EQ(*custom_tiles, 0x01);
204 EXPECT_EQ(*mosaic, 0x01);
208 auto status = overworld.
Load(reloaded_rom.get());
209 ASSERT_TRUE(status.ok());
218 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
219 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
223 auto status = overworld.
Load(rom.get());
224 ASSERT_TRUE(status.ok());
228 uint8_t original_gfx = map0->area_graphics();
229 uint8_t original_palette = map0->main_palette();
232 map0->set_area_graphics(0x01);
233 map0->set_main_palette(0x02);
237 ASSERT_TRUE(save_maps_status.ok());
239 ASSERT_TRUE(save_props_status.ok());
245 std::unique_ptr<Rom> reloaded_rom = std::make_unique<Rom>();
246 ASSERT_OK(reloaded_rom->LoadFromFile(edited_test_path_));
251 const auto& reloaded_map0 = reloaded_overworld.
overworld_map(0);
252 EXPECT_EQ(reloaded_map0->area_graphics(), 0x01);
253 EXPECT_EQ(reloaded_map0->main_palette(), 0x02);
258 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
259 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
264 const auto& entrances = overworld.
entrances();
265 EXPECT_EQ(entrances.size(), 129);
268 for (
int i = 0; i < std::min(10, static_cast<int>(entrances.size())); i++) {
269 const auto& entrance = entrances[i];
272 uint16_t map_pos = entrance.map_pos_;
273 uint16_t map_id = entrance.map_id_;
275 int position = map_pos >> 1;
276 int x_coord = position % 64;
277 int y_coord = position >> 6;
278 int expected_x = (x_coord * 16) + (((map_id % 64) - (((map_id % 64) / 8) * 8)) * 512);
279 int expected_y = (y_coord * 16) + (((map_id % 64) / 8) * 512);
281 EXPECT_EQ(entrance.x_, expected_x) <<
"Entrance " << i <<
" X coordinate mismatch";
282 EXPECT_EQ(entrance.y_, expected_y) <<
"Entrance " << i <<
" Y coordinate mismatch";
286 const auto& holes = overworld.
holes();
287 EXPECT_EQ(holes.size(), 0x13);
289 for (
int i = 0; i < std::min(5, static_cast<int>(holes.size())); i++) {
290 const auto& hole = holes[i];
293 uint16_t map_pos = hole.map_pos_;
294 uint16_t map_id = hole.map_id_;
296 int position = map_pos >> 1;
297 int x_coord = position % 64;
298 int y_coord = position >> 6;
299 int expected_x = (x_coord * 16) + (((map_id % 64) - (((map_id % 64) / 8) * 8)) * 512);
300 int expected_y = (y_coord * 16) + (((map_id % 64) / 8) * 512);
302 EXPECT_EQ(hole.x_, expected_x) <<
"Hole " << i <<
" X coordinate mismatch";
303 EXPECT_EQ(hole.y_, expected_y) <<
"Hole " << i <<
" Y coordinate mismatch";
304 EXPECT_TRUE(hole.is_hole_) <<
"Hole " << i <<
" should be marked as hole";
311 ASSERT_OK(ExtractGoldenData(vanilla_test_path_, golden_data_path_));
314 std::unique_ptr<Rom> vanilla_rom = std::make_unique<Rom>();
315 ASSERT_OK(vanilla_rom->LoadFromFile(vanilla_test_path_));
318 auto original_asm_version = vanilla_rom->ReadByte(0x140145);
319 auto original_graphics_0 = vanilla_rom->ReadByte(0x7C9C);
320 auto original_palette_0 = vanilla_rom->ReadByte(0x7D1C);
322 ASSERT_TRUE(original_asm_version.ok());
323 ASSERT_TRUE(original_graphics_0.ok());
324 ASSERT_TRUE(original_palette_0.ok());
327 auto write1 = vanilla_rom->WriteByte(0x140145, 0x03);
328 ASSERT_TRUE(write1.ok());
329 auto write2 = vanilla_rom->WriteByte(0x7C9C, 0x01);
330 ASSERT_TRUE(write2.ok());
331 auto write3 = vanilla_rom->WriteByte(0x7D1C, 0x02);
332 ASSERT_TRUE(write3.ok());
338 std::unique_ptr<Rom> modified_rom = std::make_unique<Rom>();
339 ASSERT_OK(modified_rom->LoadFromFile(edited_test_path_));
341 auto modified_asm_version = modified_rom->ReadByte(0x140145);
342 auto modified_graphics_0 = modified_rom->ReadByte(0x7C9C);
343 auto modified_palette_0 = modified_rom->ReadByte(0x7D1C);
345 ASSERT_TRUE(modified_asm_version.ok());
346 ASSERT_TRUE(modified_graphics_0.ok());
347 ASSERT_TRUE(modified_palette_0.ok());
350 EXPECT_EQ(*modified_asm_version, 0x03);
351 EXPECT_EQ(*modified_graphics_0, 0x01);
352 EXPECT_EQ(*modified_palette_0, 0x02);
355 EXPECT_NE(*original_asm_version, *modified_asm_version);
356 EXPECT_NE(*original_graphics_0, *modified_graphics_0);
357 EXPECT_NE(*original_palette_0, *modified_palette_0);
362 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
363 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
367 auto status = overworld.
Load(rom.get());
368 ASSERT_TRUE(status.ok());
374 EXPECT_EQ(maps.size(), 160);
377 for (
int i = 0; i < std::min(10, static_cast<int>(maps.size())); i++) {
378 const auto& map = maps[i];
381 EXPECT_GE(map.area_graphics(), 0);
382 EXPECT_GE(map.main_palette(), 0);
389 EXPECT_EQ(sprites.size(), 3);
392 const auto& items = overworld.
all_items();
393 EXPECT_GE(items.size(), 0);
396 const auto& entrances = overworld.
entrances();
397 const auto& exits = overworld.
exits();
398 EXPECT_EQ(entrances.size(), 129);
399 EXPECT_EQ(exits->size(), 0x4F);
404 std::unique_ptr<Rom> rom = std::make_unique<Rom>();
405 ASSERT_OK(rom->LoadFromFile(vanilla_test_path_));
408 for (
int cycle = 0; cycle < 5; cycle++) {
410 auto status = overworld.
Load(rom.get());
411 ASSERT_TRUE(status.ok()) <<
"Load failed on cycle " << cycle;
415 EXPECT_EQ(maps.size(), 160) <<
"Map count mismatch on cycle " << cycle;
417 const auto& entrances = overworld.
entrances();
418 EXPECT_EQ(entrances.size(), 129) <<
"Entrance count mismatch on cycle " << cycle;
420 const auto& exits = overworld.
exits();
421 EXPECT_EQ(exits->size(), 0x4F) <<
"Exit count mismatch on cycle " << cycle;