Update AssembleMap32Tiles and AssembleMap16Tiles for expanded tile handling
This commit is contained in:
@@ -98,12 +98,8 @@ void Overworld::FetchLargeMaps() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::StatusOr<uint16_t> Overworld::GetTile16ForTile32(int index, int quadrant,
|
absl::StatusOr<uint16_t> Overworld::GetTile16ForTile32(
|
||||||
int dimension) {
|
int index, int quadrant, int dimension, const uint32_t *map32address) {
|
||||||
const uint32_t map32address[4] = {rom_.version_constants().kMap32TileTL,
|
|
||||||
rom_.version_constants().kMap32TileTR,
|
|
||||||
rom_.version_constants().kMap32TileBL,
|
|
||||||
rom_.version_constants().kMap32TileBR};
|
|
||||||
ASSIGN_OR_RETURN(auto arg1,
|
ASSIGN_OR_RETURN(auto arg1,
|
||||||
rom_.ReadByte(map32address[dimension] + quadrant + (index)));
|
rom_.ReadByte(map32address[dimension] + quadrant + (index)));
|
||||||
ASSIGN_OR_RETURN(auto arg2, rom_.ReadWord(map32address[dimension] + (index) +
|
ASSIGN_OR_RETURN(auto arg2, rom_.ReadWord(map32address[dimension] + (index) +
|
||||||
@@ -115,6 +111,11 @@ absl::StatusOr<uint16_t> Overworld::GetTile16ForTile32(int index, int quadrant,
|
|||||||
constexpr int kMap32TilesLength = 0x33F0;
|
constexpr int kMap32TilesLength = 0x33F0;
|
||||||
|
|
||||||
absl::Status Overworld::AssembleMap32Tiles() {
|
absl::Status Overworld::AssembleMap32Tiles() {
|
||||||
|
if (rom()->data()[0x01772E] == 0x04) {
|
||||||
|
const uint32_t map32address[4] = {rom_.version_constants().kMap32TileTL,
|
||||||
|
rom_.version_constants().kMap32TileTR,
|
||||||
|
rom_.version_constants().kMap32TileBL,
|
||||||
|
rom_.version_constants().kMap32TileBR};
|
||||||
// Loop through each 32x32 pixel tile in the rom
|
// Loop through each 32x32 pixel tile in the rom
|
||||||
for (int i = 0; i < kMap32TilesLength; i += 6) {
|
for (int i = 0; i < kMap32TilesLength; i += 6) {
|
||||||
// Loop through each quadrant of the 32x32 pixel tile.
|
// Loop through each quadrant of the 32x32 pixel tile.
|
||||||
@@ -122,19 +123,45 @@ absl::Status Overworld::AssembleMap32Tiles() {
|
|||||||
// Generate the 16-bit tile for the current quadrant of the current
|
// Generate the 16-bit tile for the current quadrant of the current
|
||||||
// 32x32 pixel tile.
|
// 32x32 pixel tile.
|
||||||
ASSIGN_OR_RETURN(uint16_t tl,
|
ASSIGN_OR_RETURN(uint16_t tl,
|
||||||
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTL));
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTL,
|
||||||
|
map32address));
|
||||||
ASSIGN_OR_RETURN(uint16_t tr,
|
ASSIGN_OR_RETURN(uint16_t tr,
|
||||||
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTR));
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTR,
|
||||||
|
map32address));
|
||||||
ASSIGN_OR_RETURN(uint16_t bl,
|
ASSIGN_OR_RETURN(uint16_t bl,
|
||||||
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBL));
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBL,
|
||||||
|
map32address));
|
||||||
ASSIGN_OR_RETURN(uint16_t br,
|
ASSIGN_OR_RETURN(uint16_t br,
|
||||||
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBR));
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBR,
|
||||||
|
map32address));
|
||||||
|
|
||||||
// Add the generated 16-bit tiles to the tiles32 vector.
|
// Add the generated 16-bit tiles to the tiles32 vector.
|
||||||
tiles32_unique_.emplace_back(gfx::Tile32(tl, tr, bl, br));
|
tiles32_unique_.emplace_back(gfx::Tile32(tl, tr, bl, br));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const uint32_t map32address[4] = {
|
||||||
|
rom_.version_constants().kMap32TileTL, kMap32TileTRExpanded,
|
||||||
|
kMap32TileBLExpanded, kMap32TileBRExpanded};
|
||||||
|
for (int i = 0; i < kMap32TileCountExpanded; i += 6) {
|
||||||
|
for (int k = 0; k < 4; k++) {
|
||||||
|
ASSIGN_OR_RETURN(uint16_t tl,
|
||||||
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTL,
|
||||||
|
map32address));
|
||||||
|
ASSIGN_OR_RETURN(uint16_t tr,
|
||||||
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesTR,
|
||||||
|
map32address));
|
||||||
|
ASSIGN_OR_RETURN(uint16_t bl,
|
||||||
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBL,
|
||||||
|
map32address));
|
||||||
|
ASSIGN_OR_RETURN(uint16_t br,
|
||||||
|
GetTile16ForTile32(i, k, (int)Dimension::map32TilesBR,
|
||||||
|
map32address));
|
||||||
|
|
||||||
|
tiles32_unique_.emplace_back(gfx::Tile32(tl, tr, bl, br));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
map_tiles_.light_world.resize(0x200);
|
map_tiles_.light_world.resize(0x200);
|
||||||
map_tiles_.dark_world.resize(0x200);
|
map_tiles_.dark_world.resize(0x200);
|
||||||
map_tiles_.special_world.resize(0x200);
|
map_tiles_.special_world.resize(0x200);
|
||||||
@@ -149,6 +176,7 @@ absl::Status Overworld::AssembleMap32Tiles() {
|
|||||||
|
|
||||||
void Overworld::AssembleMap16Tiles() {
|
void Overworld::AssembleMap16Tiles() {
|
||||||
int tpos = kMap16Tiles;
|
int tpos = kMap16Tiles;
|
||||||
|
if (rom()->data()[0x02FD28] == 0x0F) {
|
||||||
for (int i = 0; i < kNumTile16Individual; i += 1) {
|
for (int i = 0; i < kNumTile16Individual; i += 1) {
|
||||||
gfx::TileInfo t0 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
gfx::TileInfo t0 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
||||||
tpos += 2;
|
tpos += 2;
|
||||||
@@ -160,6 +188,20 @@ void Overworld::AssembleMap16Tiles() {
|
|||||||
tpos += 2;
|
tpos += 2;
|
||||||
tiles16_.emplace_back(t0, t1, t2, t3);
|
tiles16_.emplace_back(t0, t1, t2, t3);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tpos = kMap16TilesExpanded;
|
||||||
|
for (int i = 0; i < NumberOfMap16Ex; ++i) {
|
||||||
|
gfx::TileInfo t0 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
||||||
|
tpos += 2;
|
||||||
|
gfx::TileInfo t1 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
||||||
|
tpos += 2;
|
||||||
|
gfx::TileInfo t2 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
||||||
|
tpos += 2;
|
||||||
|
gfx::TileInfo t3 = gfx::GetTilesInfo(rom()->toint16(tpos));
|
||||||
|
tpos += 2;
|
||||||
|
tiles16_.emplace_back(t0, t1, t2, t3);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overworld::AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
void Overworld::AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
||||||
|
|||||||
@@ -432,13 +432,14 @@ constexpr int kMap16TilesExpanded = 0x1E8000;
|
|||||||
constexpr int kMap32TileTRExpanded = 0x020000;
|
constexpr int kMap32TileTRExpanded = 0x020000;
|
||||||
constexpr int kMap32TileBLExpanded = 0x1F0000;
|
constexpr int kMap32TileBLExpanded = 0x1F0000;
|
||||||
constexpr int kMap32TileBRExpanded = 0x1F8000;
|
constexpr int kMap32TileBRExpanded = 0x1F8000;
|
||||||
constexpr int kMap32TileCount = 0x0067E0;
|
constexpr int kMap32TileCountExpanded = 0x0067E0;
|
||||||
|
|
||||||
constexpr int kMap16Tiles = 0x78000;
|
constexpr int kMap16Tiles = 0x78000;
|
||||||
constexpr int kNumOverworldMaps = 160;
|
constexpr int kNumOverworldMaps = 160;
|
||||||
constexpr int kNumTile16Individual = 4096;
|
constexpr int kNumTile16Individual = 4096;
|
||||||
constexpr int Map32PerScreen = 256;
|
constexpr int Map32PerScreen = 256;
|
||||||
constexpr int NumberOfMap16 = 3752; // 4096
|
constexpr int NumberOfMap16 = 3752; // 4096
|
||||||
|
constexpr int NumberOfMap16Ex = 4096; // 4096
|
||||||
constexpr int LimitOfMap32 = 8864;
|
constexpr int LimitOfMap32 = 8864;
|
||||||
constexpr int NumberOfOWSprites = 352;
|
constexpr int NumberOfOWSprites = 352;
|
||||||
constexpr int NumberOfMap32 = Map32PerScreen * kNumOverworldMaps;
|
constexpr int NumberOfMap32 = Map32PerScreen * kNumOverworldMaps;
|
||||||
@@ -558,7 +559,8 @@ class Overworld : public SharedRom, public core::ExperimentFlags {
|
|||||||
|
|
||||||
void FetchLargeMaps();
|
void FetchLargeMaps();
|
||||||
absl::StatusOr<uint16_t> GetTile16ForTile32(int index, int quadrant,
|
absl::StatusOr<uint16_t> GetTile16ForTile32(int index, int quadrant,
|
||||||
int dimension);
|
int dimension,
|
||||||
|
const uint32_t *map32address);
|
||||||
absl::Status AssembleMap32Tiles();
|
absl::Status AssembleMap32Tiles();
|
||||||
void AssembleMap16Tiles();
|
void AssembleMap16Tiles();
|
||||||
void AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
void AssignWorldTiles(int x, int y, int sx, int sy, int tpos,
|
||||||
|
|||||||
Reference in New Issue
Block a user