26 return absl::FailedPreconditionError(
27 "Overworld graphics session is missing or mismatched");
29 if (quadrant < 0 || quadrant >= 4 || tile16_id < 0 ||
31 return absl::InvalidArgumentError(
"Invalid Tile16 quadrant");
34 if (tile.id_ >= 8 * 64) {
35 return absl::UnimplementedError(
36 "This Tile16 quadrant does not address an overworld background sheet");
38 const int slot = tile.id_ / 64;
39 const int tile_index = tile.id_ % 64;
40 if (slot == 7 && tile_index < 32) {
41 return absl::UnimplementedError(
42 "Animated slot 7 tiles need an explicit frame source");
49 return absl::UnimplementedError(
50 "This quadrant has no loaded editable 3bpp sheet");
56 const bool right = slot == 0 || slot == 3 || slot == 4 || slot == 5;
57 const size_t base =
static_cast<size_t>(tile.palette_) * 16 + (right ? 8 : 0);
59 if (tile.palette_ >= 8 || colors.size() < base + 8) {
60 return absl::FailedPreconditionError(
61 "Selected map palette is not resolved");
63 std::vector<gfx::SnesColor> display_colors;
64 display_colors.reserve(8);
65 for (
int i = 0; i < 8; ++i) {
66 display_colors.push_back(colors[base + i]);
70 .tile_index =
static_cast<uint16_t
>(tile_index),
71 .label = absl::StrFormat(
72 "Tile16 %03X / quadrant %d / tile %03X / slot %d / sheet %02X / "
74 tile16_id, quadrant + 1, tile.id_, slot, sheet, tile.palette_,
75 right ?
"right" :
"left"),
77 .source_orientation_mask =
78 static_cast<uint8_t
>(1 << ((tile.horizontal_mirror_ ? 1 : 0) |
79 (tile.vertical_mirror_ ? 2 : 0))),
83 tile.palette_, right ? 8 : 0);
94 return target.status();
97 context.
owner = owner;
98 context.
label = absl::StrFormat(
99 "Map %02X (area %02X) / Tile16 %03X / quadrant %d / palette %02X",
100 map.
index(), map.
parent(), tile16_id, quadrant + 1,
103 "Map assignments are captured on entry; reopen from the overworld "
104 "after changing assignments.";
106 context.
targets.push_back(std::move(*target));
110 for (
int other = 0; other < 4; ++other) {
111 if (other == quadrant) {
116 if (!neighbor.ok()) {
117 if (neighbor.status().code() != absl::StatusCode::kUnimplemented) {
118 return neighbor.status();
121 absl::StrFormat(
" Quadrant %d is omitted: %s.", other + 1,
122 neighbor.status().message());
125 context.
targets.push_back(std::move(*neighbor));
zelda3::ResolvedGraphicsContext resolved
std::vector< GraphicsEditTarget > targets
const zelda3::GameData * owner