20 std::vector<DungeonMap> dungeon_maps;
21 std::vector<std::array<uint8_t, kNumRooms>> current_floor_rooms_d;
22 std::vector<std::array<uint8_t, kNumRooms>> current_floor_gfx_d;
25 uint8_t nbr_basement_d;
28 current_floor_rooms_d.clear();
29 current_floor_gfx_d.clear();
41 nbr_basement_d &= 0x0F;
45 nbr_floor_d = nbr_floor_d >> 4;
47 total_floors_d = nbr_basement_d + nbr_floor_d;
50 for (
int i = 0; i < total_floors_d; i++) {
51 dungeon_map_labels[d].emplace_back();
53 std::array<uint8_t, kNumRooms> rdata;
54 std::array<uint8_t, kNumRooms> gdata;
61 gdata[j] = rdata[j] == 0x0F ? 0xFF : rom.
data()[pc_ptr_gfx++];
64 dungeon_map_labels[d][i][j] = label;
67 current_floor_gfx_d.push_back(gdata);
68 current_floor_rooms_d.push_back(rdata);
71 dungeon_maps.emplace_back(boss_room_d, nbr_floor_d, nbr_basement_d,
72 current_floor_rooms_d, current_floor_gfx_d);
85 const int nbr_floors = dungeon_maps[d].nbr_of_floor;
86 const int nbr_basements = dungeon_maps[d].nbr_of_basement;
87 for (
int i = 0; i < nbr_floors + nbr_basements; i++) {
90 dungeon_maps[d].floor_rooms[i][j]));
92 dungeon_maps[d].floor_gfx[i][j]));
98 return absl::OkStatus();
102 const std::vector<uint8_t> &gfx_data,
105 tile16_blockset.
map_size = {186, 186};
107 std::vector<uint8_t>(256 * 192, 0x00));
127 int sheet_offset = 212;
131 ComposeTile16(tile16_blockset, gfx_data, t1, t2, t3, t4, sheet_offset);
138 &tile16_blockset.
atlas);
140 return absl::OkStatus();
167 return absl::OkStatus();
172 std::array<gfx::Bitmap, 4> &sheets,
173 std::vector<uint8_t> &gfx_bin_data) {
175 if (bin_file.empty()) {
176 return absl::InternalError(
"No file selected");
179 std::ifstream file(bin_file, std::ios::binary);
180 if (!file.is_open()) {
181 return absl::InternalError(
"Failed to open file");
185 std::vector<uint8_t> bin_data((std::istreambuf_iterator<char>(file)),
186 std::istreambuf_iterator<char>());
188 gfx_bin_data = converted_bin;
190 std::vector<std::vector<uint8_t>> gfx_sheets;
191 for (
int i = 0; i < 4; i++) {
192 gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
193 converted_bin.begin() + ((i + 1) * 0x1000));
194 sheets[i] =
gfx::Bitmap(128, 32, 8, gfx_sheets[i]);
204 return absl::OkStatus();
The Rom class is used to load, save, and modify Rom data.
absl::Status WriteByte(int addr, uint8_t value)
auto mutable_dungeon_palette(int i)
absl::StatusOr< uint16_t > ReadWord(int offset)
absl::StatusOr< uint8_t > ReadByte(int offset)
absl::Status WriteWord(int addr, uint16_t value)
void QueueTextureCommand(TextureCommandType type, Bitmap *bitmap)
Represents a bitmap image optimized for SNES ROM hacking.
void Create(int width, int height, int depth, std::span< uint8_t > data)
Create a bitmap with the given dimensions and data.
void SetPalette(const SnesPalette &palette)
Set the palette for the bitmap.
SNES 16-bit tile metadata container.
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
#define RETURN_IF_ERROR(expression)
#define ASSIGN_OR_RETURN(type_variable_name, expression)
uint16_t TileInfoToWord(TileInfo tile_info)
std::vector< uint8_t > SnesTo8bppSheet(std::span< uint8_t > sheet, int bpp, int num_sheets)
TileInfo WordToTileInfo(uint16_t word)
std::string HexByte(uint8_t byte, HexStringParams params)
Zelda 3 specific classes and functions.
absl::Status LoadDungeonMapGfxFromBinary(Rom &rom, gfx::Tilemap &tile16_blockset, std::array< gfx::Bitmap, 4 > &sheets, std::vector< uint8_t > &gfx_bin_data)
Load the dungeon map gfx from binary.
constexpr int kDungeonMapExpCheck
absl::Status LoadDungeonMapTile16(gfx::Tilemap &tile16_blockset, Rom &rom, const std::vector< uint8_t > &gfx_data, bool bin_mode)
Load the dungeon map tile16 from the ROM.
constexpr int kDungeonMapFloors
constexpr int kDungeonMapTile16
constexpr int kDungeonMapTile16Expanded
absl::Status SaveDungeonMapTile16(gfx::Tilemap &tile16_blockset, Rom &rom)
Save the dungeon map tile16 to the ROM.
constexpr int kDungeonMapBossRooms
constexpr int kDungeonMapRoomsPtr
constexpr int kNumDungeonMapTile16
constexpr int kNumDungeons
absl::StatusOr< std::vector< DungeonMap > > LoadDungeonMaps(Rom &rom, DungeonMapLabels &dungeon_map_labels)
Load the dungeon maps from the ROM.
std::array< std::vector< std::array< std::string, kNumRooms > >, kNumDungeons > DungeonMapLabels
constexpr int kDungeonMapGfxPtr
absl::Status SaveDungeonMaps(Rom &rom, std::vector< DungeonMap > &dungeon_maps)
Save the dungeon maps to the ROM.
uint32_t SnesToPc(uint32_t addr) noexcept
Tilemap structure for SNES tile-based graphics management.
Pair tile_size
Size of individual tiles (8x8 or 16x16)
Pair map_size
Size of tilemap in tiles.
Bitmap atlas
Master bitmap containing all tiles.
std::vector< std::array< gfx::TileInfo, 4 > > tile_info
Tile metadata (4 tiles per 16x16)