diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 5b8dc36c..864010c2 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -1,9 +1,9 @@ #include "overworld_editor.h" #include +#include #include #include -#include #include "absl/status/status.h" #include "absl/strings/str_format.h" diff --git a/src/app/gfx/snes_tile.cc b/src/app/gfx/snes_tile.cc index b38ed6f2..33ef51bc 100644 --- a/src/app/gfx/snes_tile.cc +++ b/src/app/gfx/snes_tile.cc @@ -386,6 +386,19 @@ TileInfo GetTilesInfo(uint16_t tile) { return TileInfo(tid, p, v, h, o); } +void CopyTile8bpp16(int x, int y, int tile, std::vector& bitmap, + std::vector& blockset) { + int src_pos = + ((tile - ((tile / 0x08) * 0x08)) * 0x10) + ((tile / 0x08) * 2048); + int dest_pos = (x + (y * 0x200)); + for (int yy = 0; yy < 0x10; yy++) { + for (int xx = 0; xx < 0x10; xx++) { + bitmap[dest_pos + xx + (yy * 0x200)] = + blockset[src_pos + xx + (yy * 0x80)]; + } + } +} + } // namespace gfx } // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/gfx/snes_tile.h b/src/app/gfx/snes_tile.h index cf62af5c..fca3bf32 100644 --- a/src/app/gfx/snes_tile.h +++ b/src/app/gfx/snes_tile.h @@ -18,8 +18,8 @@ constexpr int kTilesheetDepth = 8; constexpr uint8_t kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; -std::vector SnesTo8bppSheet(const std::vector& sheet, - int bpp, int num_sheets = 1); +std::vector SnesTo8bppSheet(const std::vector& sheet, int bpp, + int num_sheets = 1); std::vector Bpp8SnesToIndexed(std::vector data, uint64_t bpp = 0); @@ -41,6 +41,9 @@ std::vector ConvertBpp(const std::vector& tiles, std::vector Convert3bppTo4bpp(const std::vector& tiles); std::vector Convert4bppTo3bpp(const std::vector& tiles); +void CopyTile8bpp16(int x, int y, int tile, std::vector& bitmap, + std::vector& blockset); + /** * @brief SNES 16-bit tile metadata container * diff --git a/src/app/zelda3/overworld/overworld_map.cc b/src/app/zelda3/overworld/overworld_map.cc index c6763602..71928c16 100644 --- a/src/app/zelda3/overworld/overworld_map.cc +++ b/src/app/zelda3/overworld/overworld_map.cc @@ -571,7 +571,8 @@ absl::StatusOr OverworldMap::GetPalette( } absl::Status OverworldMap::LoadPalette() { - int previousPalId = index_ > 0 ? rom_[kOverworldMapPaletteIds + parent_ - 1] : 0; + int previousPalId = + index_ > 0 ? rom_[kOverworldMapPaletteIds + parent_ - 1] : 0; int previousSprPalId = index_ > 0 ? rom_[kOverworldSpritePaletteIds + parent_ - 1] : 0; @@ -723,23 +724,6 @@ absl::Status OverworldMap::BuildTiles16Gfx(std::vector& tiles16, return absl::OkStatus(); } -namespace { - -void CopyTile8bpp16(int x, int y, int tile, std::vector& bitmap, - std::vector& blockset) { - int src_pos = - ((tile - ((tile / 0x08) * 0x08)) * 0x10) + ((tile / 0x08) * 2048); - int dest_pos = (x + (y * 0x200)); - for (int yy = 0; yy < 0x10; yy++) { - for (int xx = 0; xx < 0x10; xx++) { - bitmap[dest_pos + xx + (yy * 0x200)] = - blockset[src_pos + xx + (yy * 0x80)]; - } - } -} - -} // namespace - absl::Status OverworldMap::BuildBitmap(OWBlockset& world_blockset) { if (bitmap_data_.size() != 0) { bitmap_data_.clear(); @@ -756,8 +740,8 @@ absl::Status OverworldMap::BuildBitmap(OWBlockset& world_blockset) { for (int x = 0; x < 0x20; x++) { auto xt = x + (superX * 0x20); auto yt = y + (superY * 0x20); - CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt], - bitmap_data_, current_blockset_); + gfx::CopyTile8bpp16((x * 0x10), (y * 0x10), world_blockset[xt][yt], + bitmap_data_, current_blockset_); } } return absl::OkStatus();