Add hex utility functions and refactor usage in editors

This commit is contained in:
scawful
2025-01-22 13:28:21 -05:00
parent 62e6157864
commit 50c9223a53
17 changed files with 174 additions and 134 deletions

View File

@@ -21,6 +21,7 @@
#include "app/gfx/snes_color.h"
#include "app/gfx/snes_palette.h"
#include "app/gfx/snes_tile.h"
#include "util/hex.h"
#include "util/macro.h"
namespace yaze {
@@ -303,7 +304,7 @@ absl::Status Rom::WriteByte(int addr, uint8_t value) {
value, addr));
}
rom_data_[addr] = value;
core::logf("WriteByte: %#06X: %s", addr, core::HexByte(value).data());
core::logf("WriteByte: %#06X: %s", addr, util::HexByte(value).data());
return absl::OkStatus();
}
@@ -315,7 +316,7 @@ absl::Status Rom::WriteWord(int addr, uint16_t value) {
}
rom_data_[addr] = (uint8_t)(value & 0xFF);
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
core::logf("WriteWord: %#06X: %s", addr, core::HexWord(value).data());
core::logf("WriteWord: %#06X: %s", addr, util::HexWord(value).data());
return absl::OkStatus();
}
@@ -327,7 +328,7 @@ absl::Status Rom::WriteShort(int addr, uint16_t value) {
}
rom_data_[addr] = (uint8_t)(value & 0xFF);
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
core::logf("WriteShort: %#06X: %s", addr, core::HexWord(value).data());
core::logf("WriteShort: %#06X: %s", addr, util::HexWord(value).data());
return absl::OkStatus();
}
@@ -340,7 +341,7 @@ absl::Status Rom::WriteLong(uint32_t addr, uint32_t value) {
rom_data_[addr] = (uint8_t)(value & 0xFF);
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
rom_data_[addr + 2] = (uint8_t)((value >> 16) & 0xFF);
core::logf("WriteLong: %#06X: %s", addr, core::HexLong(value).data());
core::logf("WriteLong: %#06X: %s", addr, util::HexLong(value).data());
return absl::OkStatus();
}
@@ -353,7 +354,7 @@ absl::Status Rom::WriteVector(int addr, std::vector<uint8_t> data) {
for (int i = 0; i < static_cast<int>(data.size()); i++) {
rom_data_[addr + i] = data[i];
}
core::logf("WriteVector: %#06X: %s", addr, core::HexByte(data[0]).data());
core::logf("WriteVector: %#06X: %s", addr, util::HexByte(data[0]).data());
return absl::OkStatus();
}
@@ -362,7 +363,7 @@ absl::Status Rom::WriteColor(uint32_t address, const gfx::SnesColor &color) {
(color.snes() & 0x7C00);
// Write the 16-bit color value to the ROM at the specified address
core::logf("WriteColor: %#06X: %s", address, core::HexWord(bgr).data());
core::logf("WriteColor: %#06X: %s", address, util::HexWord(bgr).data());
return WriteShort(address, bgr);
}