yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
gfx_sheet_png.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_GFX_SHEET_PNG_H
2#define YAZE_ZELDA3_GFX_SHEET_PNG_H
3
4#include <array>
5#include <cstdint>
6#include <utility>
7#include <vector>
8
9#include "absl/status/statusor.h"
10#include "rom/rom.h"
11#include "util/indexed_png.h"
13
14namespace yaze::zelda3 {
15
16struct GameData;
17
28using SheetColor = std::array<uint8_t, 3>;
30using SheetPalette = std::array<SheetColor, 8>;
31
33
37absl::StatusOr<SheetPalette> RoomBackgroundSheetPalette(Rom& rom,
38 GameData& data,
39 int room, int row);
40
45bool IsHighHalfSpriteSheet(int sheet);
46
49absl::StatusOr<SheetPalette> RoomSpriteSheetPalette(Rom& rom, GameData& data,
50 int room, int row,
51 bool high_half = false);
52
56absl::StatusOr<std::vector<uint8_t>> ExportSheetDiffPng(
57 const std::vector<uint8_t>& before_3bpp,
58 const std::vector<uint8_t>& after_3bpp, const SheetPalette& palette);
59
62absl::StatusOr<std::vector<uint8_t>> ExportSheetBlocksPng(
63 const std::vector<uint8_t>& snes_3bpp, const SheetPalette& palette,
64 int first_block = 0, int block_count = 16);
65
67 std::vector<uint8_t> snes_3bpp; // the edited sheet (0x600 bytes)
68 std::vector<int> changed_blocks; // 16x16 blocks 0-15
69 std::vector<int> changed_tiles; // 8x8 tiles 0-63
70 std::vector<std::pair<int, int>> changed_ranges; // [begin, end) in sheet
71};
72
82absl::StatusOr<SheetImportResult> ImportSheetBlocksPng(
83 const std::vector<uint8_t>& snes_3bpp, const util::PngImage& png,
84 int first_block, const SheetPalette& palette);
85
86// ---------------------------------------------------------------------------
87// Dungeon room background sets
88// ---------------------------------------------------------------------------
89
95 int room = 0;
96 uint8_t header_blockset = 0; // room blockset ($0AA2)
97 uint8_t main_blockset = 0; // main blockset ($0AA1)
98 std::array<uint8_t, 8> sheets{};
99 std::array<bool, 8> from_room_blockset{};
100};
101
102RoomBackgroundSet ResolveRoomBackgroundSet(const GameData& data, int room,
103 uint8_t header_blockset);
104
105// Read-only palette context for one 3bpp background sheet as loaded through
106// the room's default entrance. Inferred defaults are recorded, not treated
107// as proof of the entrance used during gameplay. Slot 7's animation overlay
108// is not baked into the exported source sheet.
119
120absl::StatusOr<RoomSheetPaletteContext> ResolveRoomSheetPalette(
121 Rom& rom, GameData& data, int room, int slot, int row);
122
124std::vector<RoomBackgroundSet> ResolveAllRoomBackgroundSets(
125 const Rom& rom, const GameData& data);
126
130absl::StatusOr<std::vector<uint8_t>> ExportRoomBackgroundPng(
131 const Rom& rom, const RoomBackgroundSet& set, const SheetPalette& palette);
132
134 uint16_t sheet = 0;
135 std::vector<int> slots; // slots showing this sheet
137};
138
142absl::StatusOr<std::vector<RoomSheetImport>> ImportRoomBackgroundPng(
143 const Rom& rom, const RoomBackgroundSet& set, const util::PngImage& png,
144 const SheetPalette& palette);
145
146} // namespace yaze::zelda3
147
148#endif // YAZE_ZELDA3_GFX_SHEET_PNG_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:52
Zelda 3 specific classes and functions.
std::vector< RoomBackgroundSet > ResolveAllRoomBackgroundSets(const Rom &rom, const GameData &data)
All 296 rooms' background sets (header bytes read from the ROM).
absl::StatusOr< SheetPalette > RoomSpriteSheetPalette(Rom &rom, GameData &data, int room, int row, bool high_half)
absl::StatusOr< RoomSheetPaletteContext > ResolveRoomSheetPalette(Rom &rom, GameData &data, int room, int slot, int row)
absl::StatusOr< std::vector< uint8_t > > ExportRoomBackgroundPng(const Rom &rom, const RoomBackgroundSet &set, const SheetPalette &palette)
absl::StatusOr< SheetImportResult > ImportSheetBlocksPng(const std::vector< uint8_t > &snes_3bpp, const util::PngImage &png, int first_block, const SheetPalette &palette)
Places a PNG's 16x16 blocks over a sheet from first_block.
RoomBackgroundSet ResolveRoomBackgroundSet(const GameData &data, int room, uint8_t header_blockset)
bool IsHighHalfSpriteSheet(int sheet)
std::array< uint8_t, 3 > SheetColor
std::array< SheetColor, 8 > SheetPalette
Colors for 3bpp indices 0-7. Index 0 is exported as transparent.
absl::StatusOr< std::vector< uint8_t > > ExportSheetBlocksPng(const std::vector< uint8_t > &snes_3bpp, const SheetPalette &palette, int first_block, int block_count)
SheetPalette GrayscaleSheetPalette()
absl::StatusOr< SheetPalette > RoomBackgroundSheetPalette(Rom &rom, GameData &data, int room, int row)
absl::StatusOr< std::vector< uint8_t > > ExportSheetDiffPng(const std::vector< uint8_t > &before_3bpp, const std::vector< uint8_t > &after_3bpp, const SheetPalette &palette)
absl::StatusOr< std::vector< RoomSheetImport > > ImportRoomBackgroundPng(const Rom &rom, const RoomBackgroundSet &set, const util::PngImage &png, const SheetPalette &palette)
A decoded PNG: palette indices for indexed files, RGBA otherwise.
Definition indexed_png.h:21
std::array< uint8_t, 8 > sheets
std::array< bool, 8 > from_room_blockset
std::array< uint8_t, 8 > cgram_indices
RoomMainBlocksetResolution main
std::vector< std::pair< int, int > > changed_ranges
std::vector< uint8_t > snes_3bpp
std::vector< int > changed_tiles
std::vector< int > changed_blocks