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
42absl::StatusOr<SheetPalette> RoomSpriteSheetPalette(Rom& rom, GameData& data,
43 int room, int row);
44
47absl::StatusOr<std::vector<uint8_t>> ExportSheetBlocksPng(
48 const std::vector<uint8_t>& snes_3bpp, const SheetPalette& palette,
49 int first_block = 0, int block_count = 16);
50
52 std::vector<uint8_t> snes_3bpp; // the edited sheet (0x600 bytes)
53 std::vector<int> changed_blocks; // 16x16 blocks 0-15
54 std::vector<int> changed_tiles; // 8x8 tiles 0-63
55 std::vector<std::pair<int, int>> changed_ranges; // [begin, end) in sheet
56};
57
67absl::StatusOr<SheetImportResult> ImportSheetBlocksPng(
68 const std::vector<uint8_t>& snes_3bpp, const util::PngImage& png,
69 int first_block, const SheetPalette& palette);
70
71// ---------------------------------------------------------------------------
72// Dungeon room background sets
73// ---------------------------------------------------------------------------
74
80 int room = 0;
81 uint8_t header_blockset = 0; // room blockset ($0AA2)
82 uint8_t main_blockset = 0; // main blockset ($0AA1)
83 std::array<uint8_t, 8> sheets{};
84 std::array<bool, 8> from_room_blockset{};
85};
86
87RoomBackgroundSet ResolveRoomBackgroundSet(const GameData& data, int room,
88 uint8_t header_blockset);
89
90// Read-only palette context for one 3bpp background sheet as loaded through
91// the room's default entrance. Inferred defaults are recorded, not treated
92// as proof of the entrance used during gameplay. Slot 7's animation overlay
93// is not baked into the exported source sheet.
104
105absl::StatusOr<RoomSheetPaletteContext> ResolveRoomSheetPalette(
106 Rom& rom, GameData& data, int room, int slot, int row);
107
109std::vector<RoomBackgroundSet> ResolveAllRoomBackgroundSets(
110 const Rom& rom, const GameData& data);
111
115absl::StatusOr<std::vector<uint8_t>> ExportRoomBackgroundPng(
116 const Rom& rom, const RoomBackgroundSet& set, const SheetPalette& palette);
117
119 uint16_t sheet = 0;
120 std::vector<int> slots; // slots showing this sheet
122};
123
127absl::StatusOr<std::vector<RoomSheetImport>> ImportRoomBackgroundPng(
128 const Rom& rom, const RoomBackgroundSet& set, const util::PngImage& png,
129 const SheetPalette& palette);
130
131} // namespace yaze::zelda3
132
133#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:49
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< 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)
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< SheetPalette > RoomSpriteSheetPalette(Rom &rom, GameData &data, int room, int row)
Sprite palette row (OAM palette 0-7, CGRAM row 8 + row) of room room.
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< 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