7#include "absl/status/status.h"
8#include "absl/status/statusor.h"
9#include "absl/strings/str_format.h"
23 return absl::FailedPreconditionError(
24 "Dungeon Map / Tiles Gfx palette is unavailable");
27 if (palette.size() < 8) {
28 return absl::FailedPreconditionError(
29 "Dungeon Map / Tiles Gfx needs eight preview colors");
35 image.
pixels.resize(128 * 128);
36 for (
int slot = 0; slot < 4; ++slot) {
38 if (sheet.size() != 128 * 32) {
39 return absl::FailedPreconditionError(
40 absl::StrFormat(
"Dungeon Map sheet %d is not loaded", 212 + slot));
42 std::copy(sheet.begin(), sheet.end(),
43 image.
pixels.begin() + slot * 128 * 32);
45 for (
int color = 0; color < 8; ++color) {
46 const auto rgb = palette[color].rgb();
48 SDL_Color{
static_cast<uint8_t
>(rgb.x),
static_cast<uint8_t
>(rgb.y),
49 static_cast<uint8_t
>(rgb.z), 255};
56 if (binary_gfx_loaded) {
57 return absl::FailedPreconditionError(
58 "BIN graphics are not ROM sheets; reopen Screen assets to edit ROM "
61 if (selected_tile8 < 0 || selected_tile8 >= 256) {
62 return absl::InvalidArgumentError(
63 "Select a Dungeon Map Tiles Gfx tile from 0 to 255");
67 return preview.status();
69 const uint16_t sheet_id =
static_cast<uint16_t
>(212 + selected_tile8 / 64);
72 return absl::FailedPreconditionError(
73 "Selected Dungeon Map sheet is not 3bpp");
76 std::vector<gfx::SnesColor> colors;
78 for (
int index = 0; index < 8; ++index) {
79 colors.push_back(palette[index]);
83 context.
owner = owner;
84 context.
label =
"Dungeon Map / Tiles Gfx / raw palette row 0";
86 "This previews raw 3bpp tile indices with dungeon_main[3] colors 0-7; "
87 "Tile16 composition and map palette words are separate.";
90 .tile_index =
static_cast<uint16_t
>(selected_tile8 % 64),
91 .label = absl::StrFormat(
"Dungeon Map Tiles Gfx tile %d / sheet %d / "
92 "local tile %d / raw row 0",
93 selected_tile8, sheet_id, selected_tile8 % 64),
101 for (
int slot = 0; slot < 4; ++slot) {
104 .role =
"dungeon_map_tiles_gfx",
105 .palette_group =
"dungeon_main",
106 .sheet_id = 212 + slot,
107 .source =
"fixed_rom_sheet",
108 .loader_agrees =
true,
115 {
"raw_preview",
"dungeon_main", 3,
false});
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
uint64_t Revision(uint16_t sheet) const
absl::Span< const uint8_t > Sheet(uint16_t sheet) const
The sheet's 4096 pixels, or an empty span when it is not held.
Locates graphics sheets in the ROM and writes edited sheets back.
Editors are the view controllers for the application.
absl::StatusOr< usage_preview::PreviewImage > RenderDungeonMapTilesGfxPreview(const zelda3::GameData *owner)
absl::StatusOr< GraphicsEditContext > MakeDungeonMapTilesGfxEditContext(const zelda3::GameData *owner, int selected_tile8, bool binary_gfx_loaded)
GfxSheetStorageKind GetGfxSheetStorageKind(uint16_t sheet_id)
zelda3::ResolvedGraphicsContext resolved
std::vector< GraphicsEditTarget > targets
std::function< absl::StatusOr< usage_preview::PreviewImage >()> render_preview
const zelda3::GameData * owner
std::array< SDL_Color, 256 > colors
std::vector< uint8_t > pixels
PaletteGroup dungeon_main
gfx::PaletteGroupMap palette_groups
GraphicsSheetStore sheet_store
std::vector< ResolvedPaletteSource > palettes
bool palette_colors_resolved
std::vector< ResolvedGraphicsSlot > slots