chore: refactor overworld
This commit is contained in:
@@ -27,7 +27,7 @@ uint GetOwMapGfxLowPtr(const uchar *rom, int index) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
absl::Status Overworld::Load(ROM &rom, uchar *ow_blockset) {
|
absl::Status Overworld::Load(ROM &rom) {
|
||||||
rom_ = rom;
|
rom_ = rom;
|
||||||
|
|
||||||
AssembleMap32Tiles();
|
AssembleMap32Tiles();
|
||||||
@@ -67,16 +67,12 @@ ushort Overworld::GenerateTile32(int i, int k, int dimension) {
|
|||||||
|
|
||||||
void Overworld::AssembleMap32Tiles() {
|
void Overworld::AssembleMap32Tiles() {
|
||||||
for (int i = 0; i < 0x33F0; i += 6) {
|
for (int i = 0; i < 0x33F0; i += 6) {
|
||||||
ushort tl;
|
|
||||||
ushort tr;
|
|
||||||
ushort bl;
|
|
||||||
ushort br;
|
|
||||||
for (int k = 0; k < 4; k++) {
|
for (int k = 0; k < 4; k++) {
|
||||||
tl = GenerateTile32(i, k, (int)Dimension::map32TilesTL);
|
tiles32.push_back(gfx::Tile32(
|
||||||
tr = GenerateTile32(i, k, (int)Dimension::map32TilesTR);
|
/*top-left=*/GenerateTile32(i, k, (int)Dimension::map32TilesTL),
|
||||||
bl = GenerateTile32(i, k, (int)Dimension::map32TilesBL);
|
/*top-right=*/GenerateTile32(i, k, (int)Dimension::map32TilesTR),
|
||||||
br = GenerateTile32(i, k, (int)Dimension::map32TilesBR);
|
/*bottom-left=*/GenerateTile32(i, k, (int)Dimension::map32TilesBL),
|
||||||
tiles32.push_back(gfx::Tile32(tl, tr, bl, br));
|
/*bottom-right=*/GenerateTile32(i, k, (int)Dimension::map32TilesBR)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map_tiles_.light_world.resize(kTile32Num);
|
map_tiles_.light_world.resize(kTile32Num);
|
||||||
@@ -116,8 +112,8 @@ void Overworld::AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
|||||||
world[position_x2][position_y2] = tiles32[tpos].tile3_;
|
world[position_x2][position_y2] = tiles32[tpos].tile3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overworld::OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, OWBlockset &world,
|
void Overworld::OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, int i, int sx,
|
||||||
int i, int sx, int sy, int &ttpos) {
|
int sy, int &ttpos) {
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
auto tidD = (ushort)((bytes2[ttpos] << 8) + bytes[ttpos]);
|
auto tidD = (ushort)((bytes2[ttpos] << 8) + bytes[ttpos]);
|
||||||
@@ -163,7 +159,7 @@ absl::Status Overworld::DecompressAllMapTiles() {
|
|||||||
|
|
||||||
ASSIGN_OR_RETURN(auto bytes, rom_.DecompressOverworld(p2, 1000))
|
ASSIGN_OR_RETURN(auto bytes, rom_.DecompressOverworld(p2, 1000))
|
||||||
ASSIGN_OR_RETURN(auto bytes2, rom_.DecompressOverworld(p1, 1000))
|
ASSIGN_OR_RETURN(auto bytes2, rom_.DecompressOverworld(p1, 1000))
|
||||||
OrganizeMapTiles(bytes, bytes2, map_tiles_.light_world, i, sx, sy, ttpos);
|
OrganizeMapTiles(bytes, bytes2, i, sx, sy, ttpos);
|
||||||
|
|
||||||
sx++;
|
sx++;
|
||||||
if (sx >= 8) {
|
if (sx >= 8) {
|
||||||
|
|||||||
@@ -20,10 +20,16 @@ namespace zelda3 {
|
|||||||
|
|
||||||
class Overworld {
|
class Overworld {
|
||||||
public:
|
public:
|
||||||
absl::Status Load(ROM &rom, uchar *ow_blockset);
|
absl::Status Load(ROM &rom);
|
||||||
auto GetTiles16() const { return tiles16; }
|
auto GetTiles16() const { return tiles16; }
|
||||||
auto GetOverworldMap(uint index) { return overworld_maps_[index]; }
|
auto GetOverworldMap(uint index) { return overworld_maps_[index]; }
|
||||||
auto GetOverworldMaps() const { return overworld_maps_; }
|
auto GetOverworldMaps() const { return overworld_maps_; }
|
||||||
|
auto GetCurrentBlockset() const {
|
||||||
|
return overworld_maps_[current_map_].GetCurrentBlockset();
|
||||||
|
}
|
||||||
|
auto GetCurrentGraphics() const {
|
||||||
|
return overworld_maps_[current_map_].GetCurrentGraphics();
|
||||||
|
}
|
||||||
auto isLoaded() const { return is_loaded_; }
|
auto isLoaded() const { return is_loaded_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -39,14 +45,15 @@ class Overworld {
|
|||||||
ushort GenerateTile32(int i, int k, int dimension);
|
ushort GenerateTile32(int i, int k, int dimension);
|
||||||
void AssembleMap32Tiles();
|
void AssembleMap32Tiles();
|
||||||
void AssembleMap16Tiles();
|
void AssembleMap16Tiles();
|
||||||
void AssignWorldTiles(int x, int y, int sx, int sy,
|
void AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
||||||
int tpos, OWBlockset &world);
|
OWBlockset &world);
|
||||||
void OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, OWBlockset &world, int i,
|
void OrganizeMapTiles(Bytes &bytes, Bytes &bytes2, int i, int sx, int sy,
|
||||||
int sx, int sy, int &ttpos);
|
int &ttpos);
|
||||||
absl::Status DecompressAllMapTiles();
|
absl::Status DecompressAllMapTiles();
|
||||||
void FetchLargeMaps();
|
void FetchLargeMaps();
|
||||||
|
|
||||||
int game_state_ = 1;
|
int game_state_ = 1;
|
||||||
|
int current_map_ = 0;
|
||||||
uchar map_parent_[160];
|
uchar map_parent_[160];
|
||||||
bool is_loaded_ = false;
|
bool is_loaded_ = false;
|
||||||
|
|
||||||
@@ -55,7 +62,6 @@ class Overworld {
|
|||||||
|
|
||||||
std::vector<gfx::Tile16> tiles16;
|
std::vector<gfx::Tile16> tiles16;
|
||||||
std::vector<gfx::Tile32> tiles32;
|
std::vector<gfx::Tile32> tiles32;
|
||||||
std::vector<gfx::Tile32> map16tiles;
|
|
||||||
std::vector<OverworldMap> overworld_maps_;
|
std::vector<OverworldMap> overworld_maps_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user