30 auto rom_data = rom.
vector();
37 auto& cpu = snes.
cpu();
38 auto& ppu = snes.
ppu();
41 int max_cycles = 15000000;
43 while (cycles < max_cycles) {
46 if (cpu.PB == 0x00 && cpu.PC == 0x8034) {
51 if (cycles >= max_cycles) {
52 return absl::InternalError(
"Emulator timed out; did not reach main game loop.");
55 std::ofstream out_file(output_path);
56 if (!out_file.is_open()) {
57 return absl::InternalError(
"Failed to open output file: " + output_path);
61 out_file <<
"// =============================================================================" << std::endl;
62 out_file <<
"// YAZE Dungeon Test Harness State - Generated from: " <<
rom_path_ << std::endl;
63 out_file <<
"// Generated on: " << __DATE__ <<
" " << __TIME__ << std::endl;
64 out_file <<
"// =============================================================================" << std::endl;
65 out_file << std::endl;
66 out_file <<
"#pragma once" << std::endl;
67 out_file << std::endl;
68 out_file <<
"#include <cstdint>" << std::endl;
69 out_file <<
"#include <array>" << std::endl;
70 out_file << std::endl;
71 out_file <<
"namespace yaze {" << std::endl;
72 out_file <<
"namespace emu {" << std::endl;
73 out_file << std::endl;
76 out_file <<
"constexpr std::array<uint8_t, 0x20000> kInitialWRAMState = {{" << std::endl;
77 for (
int i = 0; i < 0x20000; ++i) {
78 if (i % 16 == 0) out_file <<
" ";
79 out_file <<
"0x" << std::hex << std::setw(2) << std::setfill(
'0')
80 <<
static_cast<int>(snes.
Read(0x7E0000 + i));
81 if (i < 0x1FFFF) out_file <<
", ";
82 if (i % 16 == 15) out_file << std::endl;
84 out_file <<
"}};" << std::endl << std::endl;
87 out_file <<
"// =============================================================================" << std::endl;
88 out_file <<
"// Initial Register States" << std::endl;
89 out_file <<
"// =============================================================================" << std::endl;
90 out_file << std::endl;
92 out_file <<
"struct InitialPpuState {" << std::endl;
93 out_file <<
" uint8_t inidisp = 0x" << std::hex << ppu.Read(0x2100,
false) <<
";" << std::endl;
94 out_file <<
" uint8_t objsel = 0x" << std::hex << ppu.Read(0x2101,
false) <<
";" << std::endl;
95 out_file <<
" uint8_t bgmode = 0x" << std::hex << ppu.Read(0x2105,
false) <<
";" << std::endl;
96 out_file <<
" uint8_t mosaic = 0x" << std::hex << ppu.Read(0x2106,
false) <<
";" << std::endl;
97 out_file <<
" uint8_t tm = 0x" << std::hex << ppu.Read(0x212C,
false) <<
";" << std::endl;
98 out_file <<
" uint8_t ts = 0x" << std::hex << ppu.Read(0x212D,
false) <<
";" << std::endl;
99 out_file <<
" uint8_t cgwsel = 0x" << std::hex << ppu.Read(0x2130,
false) <<
";" << std::endl;
100 out_file <<
" uint8_t cgadsub = 0x" << std::hex << ppu.Read(0x2131,
false) <<
";" << std::endl;
101 out_file <<
" uint8_t setini = 0x" << std::hex << ppu.Read(0x2133,
false) <<
";" << std::endl;
102 out_file <<
"};" << std::endl << std::endl;
104 out_file <<
"} // namespace emu" << std::endl;
105 out_file <<
"} // namespace yaze" << std::endl;
107 return absl::OkStatus();