18 std::vector<DungeonMap> dungeon_maps;
19 std::vector<std::array<uint8_t, kNumRooms>> current_floor_rooms_d;
20 std::vector<std::array<uint8_t, kNumRooms>> current_floor_gfx_d;
23 uint8_t nbr_basement_d;
26 current_floor_rooms_d.clear();
27 current_floor_gfx_d.clear();
39 nbr_basement_d &= 0x0F;
43 nbr_floor_d = nbr_floor_d >> 4;
45 total_floors_d = nbr_basement_d + nbr_floor_d;
48 for (
int i = 0; i < total_floors_d; i++) {
49 dungeon_map_labels[d].emplace_back();
51 std::array<uint8_t, kNumRooms> rdata;
52 std::array<uint8_t, kNumRooms> gdata;
59 gdata[j] = rdata[j] == 0x0F ? 0xFF : rom.
data()[pc_ptr_gfx++];
62 dungeon_map_labels[d][i][j] = label;
65 current_floor_gfx_d.push_back(gdata);
66 current_floor_rooms_d.push_back(rdata);
69 dungeon_maps.emplace_back(boss_room_d, nbr_floor_d, nbr_basement_d,
70 current_floor_rooms_d, current_floor_gfx_d);
83 const int nbr_floors = dungeon_maps[d].nbr_of_floor;
84 const int nbr_basements = dungeon_maps[d].nbr_of_basement;
85 for (
int i = 0; i < nbr_floors + nbr_basements; i++) {
88 dungeon_maps[d].floor_rooms[i][j]));
90 dungeon_maps[d].floor_gfx[i][j]));
96 return absl::OkStatus();
100 const std::vector<uint8_t> &gfx_data,
103 tile16_blockset.
map_size = {186, 186};
105 std::vector<uint8_t>(256 * 192, 0x00));
125 int sheet_offset = 212;
129 ComposeTile16(tile16_blockset, gfx_data, t1, t2, t3, t4, sheet_offset);
134 return absl::OkStatus();
161 return absl::OkStatus();
166 std::array<gfx::Bitmap, 4> &sheets,
167 std::vector<uint8_t> &gfx_bin_data) {
169 if (bin_file.empty()) {
170 return absl::InternalError(
"No file selected");
173 std::ifstream file(bin_file, std::ios::binary);
174 if (!file.is_open()) {
175 return absl::InternalError(
"Failed to open file");
179 std::vector<uint8_t> bin_data((std::istreambuf_iterator<char>(file)),
180 std::istreambuf_iterator<char>());
182 gfx_bin_data = converted_bin;
184 std::vector<std::vector<uint8_t>> gfx_sheets;
185 for (
int i = 0; i < 4; i++) {
186 gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
187 converted_bin.begin() + ((i + 1) * 0x1000));
188 sheets[i] =
gfx::Bitmap(128, 32, 8, gfx_sheets[i]);
195 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)
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
void RenderBitmap(gfx::Bitmap *bitmap)
Represents a bitmap image.
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.
#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
std::array< std::vector< std::array< std::string, kNumRooms > >, kNumDungeons > DungeonMapLabels
absl::StatusOr< std::vector< DungeonMap > > LoadDungeonMaps(Rom &rom, DungeonMapLabels &dungeon_map_labels)
Load the dungeon maps from the ROM.
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
std::vector< std::array< gfx::TileInfo, 4 > > tile_info