yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rom_diagnostics.cc
Go to the documentation of this file.
2
3#include <iomanip>
4#include <sstream>
5
6#include "absl/strings/str_cat.h"
7#include "util/log.h"
8
9namespace yaze {
10
13 header_misalignment = false;
14 all_sheets_0xFF = true; // Assume true, prove false
15
16 // Check for size zero regression
17 for (const auto& sheet : sheets) {
18 if (sheet.is_compressed && sheet.decomp_size_param == 0) {
20 }
21
22 // If any sheet succeeded and has non-0xFF data, clear the symptom flag
23 if (sheet.decompression_succeeded && sheet.actual_decomp_size > 0) {
24 all_sheets_0xFF = false;
25 }
26 }
27
28 if (sheets[0].pc_offset > rom_size) {
30 }
31
33 LOG_ERROR("Graphics", "CRITICAL: Graphics size zero regression detected!");
34 }
36 LOG_ERROR("Graphics", "CRITICAL: Graphics header misalignment detected! (Sheet 0 offset 0x%X > ROM size 0x%X)",
37 sheets[0].pc_offset, (uint32_t)rom_size);
38 }
39 if (all_sheets_0xFF) {
40 LOG_WARN("Graphics", "WARNING: All graphics sheets appear to be empty (0xFF).");
41 }
42
43 LOG_INFO("Graphics", "Diagnostics: %d sheets processed, size_zero_fault=%s, alignment_fault=%s, empty_fault=%s",
44 (int)sheets.size(), size_zero_regression ? "YES" : "NO",
45 header_misalignment ? "YES" : "NO", all_sheets_0xFF ? "YES" : "NO");
46}
47
49 std::ostringstream json;
50 json << std::boolalpha;
51 json << "{";
52 json << "\"rom_size\":" << rom_size << ",";
53 json << "\"header_stripped\":" << header_stripped << ",";
54 json << "\"checksum_valid\":" << checksum_valid << ",";
55
56 json << "\"analysis\":{";
57 json << "\"size_zero_regression\":" << size_zero_regression << ",";
58 json << "\"header_misalignment\":" << header_misalignment << ",";
59 json << "\"all_sheets_0xFF\":" << all_sheets_0xFF;
60 json << "},";
61
62 json << "\"sheets\":[";
63 for (size_t i = 0; i < sheets.size(); ++i) {
64 const auto& s = sheets[i];
65 if (i > 0) json << ",";
66 json << "{";
67 json << "\"idx\":" << s.index << ",";
68 json << "\"pc\":" << s.pc_offset << ",";
69 json << "\"snes\":" << s.snes_address << ",";
70 json << "\"comp\":" << s.is_compressed << ",";
71 json << "\"ok\":" << s.decompression_succeeded << ",";
72 json << "\"param\":" << s.decomp_size_param << ",";
73 json << "\"sz\":" << s.actual_decomp_size << ",";
74
75 json << "\"bytes\":\"";
76 for (size_t b = 0; b < s.first_bytes.size(); ++b) {
77 json << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << (int)s.first_bytes[b];
78 }
79 json << std::dec << "\"";
80
81 json << "}";
82 }
83 json << "]";
84 json << "}";
85 return json.str();
86}
87
88} // namespace yaze
#define LOG_ERROR(category, format,...)
Definition log.h:109
#define LOG_WARN(category, format,...)
Definition log.h:107
#define LOG_INFO(category, format,...)
Definition log.h:105
std::array< SheetDiagnostics, 223 > sheets