Refactor OverworldMap constructor to remove unnecessary tiles16 parameter
This commit is contained in:
@@ -86,8 +86,7 @@ absl::Status Overworld::Load(Rom &rom) {
|
|||||||
|
|
||||||
const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld;
|
const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld;
|
||||||
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
||||||
overworld_maps_.emplace_back(map_index, rom_, tiles16_,
|
overworld_maps_.emplace_back(map_index, rom_, load_custom_overworld);
|
||||||
load_custom_overworld);
|
|
||||||
|
|
||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
LoadEntrances();
|
LoadEntrances();
|
||||||
@@ -314,7 +313,7 @@ absl::Status Overworld::LoadOverworldMaps() {
|
|||||||
}
|
}
|
||||||
auto task_function = [this, i, size, world_type]() {
|
auto task_function = [this, i, size, world_type]() {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, world_type,
|
return overworld_maps_[i].BuildMap(size, game_state_, world_type,
|
||||||
GetMapTiles(world_type));
|
tiles16_, GetMapTiles(world_type));
|
||||||
};
|
};
|
||||||
futures.emplace_back(std::async(std::launch::async, task_function));
|
futures.emplace_back(std::async(std::launch::async, task_function));
|
||||||
}
|
}
|
||||||
@@ -1517,28 +1516,27 @@ absl::Status Overworld::LoadPrototype(Rom &rom,
|
|||||||
|
|
||||||
const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld;
|
const bool load_custom_overworld = flags()->overworld.kLoadCustomOverworld;
|
||||||
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
||||||
overworld_maps_.emplace_back(map_index, rom_, tiles16_,
|
overworld_maps_.emplace_back(map_index, rom_, load_custom_overworld);
|
||||||
load_custom_overworld);
|
|
||||||
|
|
||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
LoadEntrances();
|
LoadEntrances();
|
||||||
|
|
||||||
auto size = tiles16_.size();
|
auto size = tiles16_.size();
|
||||||
std::vector<std::future<absl::Status>> futures;
|
std::vector<std::future<absl::Status>> futures;
|
||||||
for (int i = 0; i < kNumOverworldMaps; ++i) {
|
// for (int i = 0; i < kNumOverworldMaps; ++i) {
|
||||||
futures.emplace_back(std::async(std::launch::async, [this, i, size]() {
|
// futures.emplace_back(std::async(std::launch::async, [this, i, size]() {
|
||||||
if (i < 64) {
|
// if (i < 64) {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, 0,
|
// return overworld_maps_[i].BuildMap(size, game_state_, 0,
|
||||||
map_tiles_.light_world);
|
// map_tiles_.light_world);
|
||||||
} else if (i < 0x80 && i >= 0x40) {
|
// } else if (i < 0x80 && i >= 0x40) {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, 1,
|
// return overworld_maps_[i].BuildMap(size, game_state_, 1,
|
||||||
map_tiles_.dark_world);
|
// map_tiles_.dark_world);
|
||||||
} else {
|
// } else {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, 2,
|
// return overworld_maps_[i].BuildMap(size, game_state_, 2,
|
||||||
map_tiles_.special_world);
|
// map_tiles_.special_world);
|
||||||
}
|
// }
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Wait for all tasks to complete and check their results
|
// Wait for all tasks to complete and check their results
|
||||||
for (auto &future : futures) {
|
for (auto &future : futures) {
|
||||||
|
|||||||
@@ -514,6 +514,7 @@ class Overworld : public SharedRom, public core::ExperimentFlags {
|
|||||||
auto exits() const { return &all_exits_; }
|
auto exits() const { return &all_exits_; }
|
||||||
auto mutable_exits() { return &all_exits_; }
|
auto mutable_exits() { return &all_exits_; }
|
||||||
std::vector<gfx::Tile16> tiles16() const { return tiles16_; }
|
std::vector<gfx::Tile16> tiles16() const { return tiles16_; }
|
||||||
|
auto mutable_tiles16() { return &tiles16_; }
|
||||||
|
|
||||||
auto Sprites(int state) const { return all_sprites_[state]; }
|
auto Sprites(int state) const { return all_sprites_[state]; }
|
||||||
auto mutable_sprites(int state) { return &all_sprites_[state]; }
|
auto mutable_sprites(int state) { return &all_sprites_[state]; }
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ namespace app {
|
|||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
namespace overworld {
|
namespace overworld {
|
||||||
|
|
||||||
OverworldMap::OverworldMap(int index, Rom& rom,
|
OverworldMap::OverworldMap(int index, Rom& rom, bool load_custom_data)
|
||||||
std::vector<gfx::Tile16>& tiles16,
|
: index_(index), parent_(index), rom_(rom) {
|
||||||
bool load_custom_data)
|
|
||||||
: index_(index), parent_(index), rom_(rom), tiles16_(tiles16) {
|
|
||||||
LoadAreaInfo();
|
LoadAreaInfo();
|
||||||
|
|
||||||
if (load_custom_data) {
|
if (load_custom_data) {
|
||||||
@@ -37,6 +35,7 @@ OverworldMap::OverworldMap(int index, Rom& rom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
||||||
|
std::vector<gfx::Tile16>& tiles16,
|
||||||
OWBlockset& world_blockset) {
|
OWBlockset& world_blockset) {
|
||||||
game_state_ = game_state;
|
game_state_ = game_state;
|
||||||
world_ = world;
|
world_ = world;
|
||||||
@@ -59,7 +58,7 @@ absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
|||||||
|
|
||||||
LoadAreaGraphics();
|
LoadAreaGraphics();
|
||||||
RETURN_IF_ERROR(BuildTileset())
|
RETURN_IF_ERROR(BuildTileset())
|
||||||
RETURN_IF_ERROR(BuildTiles16Gfx(count))
|
RETURN_IF_ERROR(BuildTiles16Gfx(tiles16, count))
|
||||||
RETURN_IF_ERROR(LoadPalette());
|
RETURN_IF_ERROR(LoadPalette());
|
||||||
RETURN_IF_ERROR(BuildBitmap(world_blockset))
|
RETURN_IF_ERROR(BuildBitmap(world_blockset))
|
||||||
built_ = true;
|
built_ = true;
|
||||||
@@ -678,7 +677,8 @@ absl::Status OverworldMap::BuildTileset() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
absl::Status OverworldMap::BuildTiles16Gfx(std::vector<gfx::Tile16>& tiles16,
|
||||||
|
int count) {
|
||||||
if (current_blockset_.size() == 0) current_blockset_.resize(0x100000, 0x00);
|
if (current_blockset_.size() == 0) current_blockset_.resize(0x100000, 0x00);
|
||||||
|
|
||||||
const int offsets[] = {0x00, 0x08, 0x400, 0x408};
|
const int offsets[] = {0x00, 0x08, 0x400, 0x408};
|
||||||
@@ -687,7 +687,7 @@ absl::Status OverworldMap::BuildTiles16Gfx(int count) {
|
|||||||
|
|
||||||
for (auto i = 0; i < count; i++) {
|
for (auto i = 0; i < count; i++) {
|
||||||
for (auto tile = 0; tile < 0x04; tile++) {
|
for (auto tile = 0; tile < 0x04; tile++) {
|
||||||
gfx::TileInfo info = tiles16_[i].tiles_info[tile];
|
gfx::TileInfo info = tiles16[i].tiles_info[tile];
|
||||||
int offset = offsets[tile];
|
int offset = offsets[tile];
|
||||||
for (auto y = 0; y < 0x08; ++y) {
|
for (auto y = 0; y < 0x08; ++y) {
|
||||||
for (auto x = 0; x < 0x08; ++x) {
|
for (auto x = 0; x < 0x08; ++x) {
|
||||||
|
|||||||
@@ -67,16 +67,16 @@ constexpr int OverworldCustomTileGFXGroupEnabled = 0x140148;
|
|||||||
class OverworldMap : public editor::context::GfxContext {
|
class OverworldMap : public editor::context::GfxContext {
|
||||||
public:
|
public:
|
||||||
OverworldMap() = default;
|
OverworldMap() = default;
|
||||||
OverworldMap(int index, Rom& rom, std::vector<gfx::Tile16>& tiles16,
|
OverworldMap(int index, Rom& rom, bool load_custom_data = false);
|
||||||
bool load_custom_data = false);
|
|
||||||
|
|
||||||
absl::Status BuildMap(int count, int game_state, int world,
|
absl::Status BuildMap(int count, int game_state, int world,
|
||||||
|
std::vector<gfx::Tile16>& tiles16,
|
||||||
OWBlockset& world_blockset);
|
OWBlockset& world_blockset);
|
||||||
|
|
||||||
void LoadAreaGraphics();
|
void LoadAreaGraphics();
|
||||||
absl::Status LoadPalette();
|
absl::Status LoadPalette();
|
||||||
absl::Status BuildTileset();
|
absl::Status BuildTileset();
|
||||||
absl::Status BuildTiles16Gfx(int count);
|
absl::Status BuildTiles16Gfx(std::vector<gfx::Tile16>& tiles16, int count);
|
||||||
absl::Status BuildBitmap(OWBlockset& world_blockset);
|
absl::Status BuildBitmap(OWBlockset& world_blockset);
|
||||||
|
|
||||||
void DrawAnimatedTiles();
|
void DrawAnimatedTiles();
|
||||||
@@ -118,9 +118,7 @@ class OverworldMap : public editor::context::GfxContext {
|
|||||||
auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; }
|
auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; }
|
||||||
auto set_message_id(uint16_t value) { message_id_ = value; }
|
auto set_message_id(uint16_t value) { message_id_ = value; }
|
||||||
|
|
||||||
uint8_t* mutable_custom_tileset(int index) {
|
uint8_t* mutable_custom_tileset(int index) { return &custom_gfx_ids_[index]; }
|
||||||
return &custom_gfx_ids_[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAsLargeMap(int parent_index, int quadrant) {
|
void SetAsLargeMap(int parent_index, int quadrant) {
|
||||||
parent_ = parent_index;
|
parent_ = parent_index;
|
||||||
@@ -141,7 +139,6 @@ class OverworldMap : public editor::context::GfxContext {
|
|||||||
current_blockset_.clear();
|
current_blockset_.clear();
|
||||||
current_gfx_.clear();
|
current_gfx_.clear();
|
||||||
bitmap_data_.clear();
|
bitmap_data_.clear();
|
||||||
tiles16_.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -193,7 +190,6 @@ class OverworldMap : public editor::context::GfxContext {
|
|||||||
OWMapTiles map_tiles_;
|
OWMapTiles map_tiles_;
|
||||||
|
|
||||||
gfx::SnesPalette current_palette_;
|
gfx::SnesPalette current_palette_;
|
||||||
std::vector<gfx::Tile16> tiles16_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace overworld
|
} // namespace overworld
|
||||||
|
|||||||
Reference in New Issue
Block a user