19 std::vector<DungeonMap> dungeon_maps;
20 std::vector<std::array<uint8_t, kNumRooms>> current_floor_rooms_d;
21 std::vector<std::array<uint8_t, kNumRooms>> current_floor_gfx_d;
24 uint8_t nbr_basement_d;
27 current_floor_rooms_d.clear();
28 current_floor_gfx_d.clear();
40 nbr_basement_d &= 0x0F;
44 nbr_floor_d = nbr_floor_d >> 4;
46 total_floors_d = nbr_basement_d + nbr_floor_d;
49 for (
int i = 0; i < total_floors_d; i++) {
50 dungeon_map_labels[d].emplace_back();
52 std::array<uint8_t, kNumRooms> rdata;
53 std::array<uint8_t, kNumRooms> gdata;
60 gdata[j] = rdata[j] == 0x0F ? 0xFF : rom.
data()[pc_ptr_gfx++];
63 dungeon_map_labels[d][i][j] = label;
66 current_floor_gfx_d.push_back(gdata);
67 current_floor_rooms_d.push_back(rdata);
70 dungeon_maps.emplace_back(boss_room_d, nbr_floor_d, nbr_basement_d,
71 current_floor_rooms_d, current_floor_gfx_d);
84 const int nbr_floors = dungeon_maps[d].nbr_of_floor;
85 const int nbr_basements = dungeon_maps[d].nbr_of_basement;
86 for (
int i = 0; i < nbr_floors + nbr_basements; i++) {
89 dungeon_maps[d].floor_rooms[i][j]));
91 dungeon_maps[d].floor_gfx[i][j]));
97 return absl::OkStatus();
101 const std::vector<uint8_t> &gfx_data,
104 tile16_blockset.
map_size = {186, 186};
106 std::vector<uint8_t>(256 * 192, 0x00));
126 int sheet_offset = 212;
130 ComposeTile16(tile16_blockset, gfx_data, t1, t2, t3, t4, sheet_offset);
136 return absl::OkStatus();
163 return absl::OkStatus();
168 std::array<gfx::Bitmap, 4> &sheets,
169 std::vector<uint8_t> &gfx_bin_data) {
171 if (bin_file.empty()) {
172 return absl::InternalError(
"No file selected");
175 std::ifstream file(bin_file, std::ios::binary);
176 if (!file.is_open()) {
177 return absl::InternalError(
"Failed to open file");
181 std::vector<uint8_t> bin_data((std::istreambuf_iterator<char>(file)),
182 std::istreambuf_iterator<char>());
184 gfx_bin_data = converted_bin;
186 std::vector<std::vector<uint8_t>> gfx_sheets;
187 for (
int i = 0; i < 4; i++) {
188 gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
189 converted_bin.begin() + ((i + 1) * 0x1000));
190 sheets[i] =
gfx::Bitmap(128, 32, 8, gfx_sheets[i]);
198 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)
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)