Fix large map saving bug
This commit is contained in:
@@ -111,12 +111,12 @@ void Overworld::FetchLargeMaps() {
|
|||||||
map_parent_[137] = 129;
|
map_parent_[137] = 129;
|
||||||
map_parent_[138] = 129;
|
map_parent_[138] = 129;
|
||||||
overworld_maps_[129].SetAsLargeMap(129, 0);
|
overworld_maps_[129].SetAsLargeMap(129, 0);
|
||||||
overworld_maps_[129].SetAsLargeMap(130, 1);
|
overworld_maps_[130].SetAsLargeMap(129, 1);
|
||||||
overworld_maps_[129].SetAsLargeMap(137, 2);
|
overworld_maps_[137].SetAsLargeMap(129, 2);
|
||||||
overworld_maps_[129].SetAsLargeMap(138, 3);
|
overworld_maps_[138].SetAsLargeMap(129, 3);
|
||||||
|
|
||||||
map_parent_[136] = 136;
|
map_parent_[136] = 136;
|
||||||
overworld_maps_[136].SetLargeMap(false);
|
overworld_maps_[136].SetAsSmallMap(0);
|
||||||
|
|
||||||
std::vector<bool> mapChecked;
|
std::vector<bool> mapChecked;
|
||||||
mapChecked.reserve(0x40);
|
mapChecked.reserve(0x40);
|
||||||
@@ -127,7 +127,7 @@ void Overworld::FetchLargeMaps() {
|
|||||||
int yy = 0;
|
int yy = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (int i = xx + (yy * 8); mapChecked[i] == false) {
|
if (int i = xx + (yy * 8); mapChecked[i] == false) {
|
||||||
if (overworld_maps_[i].IsLargeMap() == true) {
|
if (overworld_maps_[i].IsLargeMap()) {
|
||||||
mapChecked[i] = true;
|
mapChecked[i] = true;
|
||||||
map_parent_[i] = (uchar)i;
|
map_parent_[i] = (uchar)i;
|
||||||
map_parent_[i + 64] = (uchar)(i + 64);
|
map_parent_[i + 64] = (uchar)(i + 64);
|
||||||
@@ -777,6 +777,12 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check 5 and 6
|
// Check 5 and 6
|
||||||
|
RETURN_IF_ERROR(rom()->WriteShort(transition_target_north + (i * 2),
|
||||||
|
(ushort)((parentyPos * 0x200) - 0xE0)));
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
rom()->WriteShort(transition_target_west + (i * 2),
|
||||||
|
(ushort)((parentxPos * 0x200) - 0x100)));
|
||||||
|
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(transition_target_north + (i * 2) + 2,
|
RETURN_IF_ERROR(rom()->WriteShort(transition_target_north + (i * 2) + 2,
|
||||||
(ushort)((parentyPos * 0x200) - 0xE0)));
|
(ushort)((parentyPos * 0x200) - 0xE0)));
|
||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
@@ -795,12 +801,12 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
rom()->WriteShort(transition_target_west + (i * 2) + 18,
|
rom()->WriteShort(transition_target_west + (i * 2) + 18,
|
||||||
(ushort)((parentxPos * 0x200) - 0x100)));
|
(ushort)((parentxPos * 0x200) - 0x100)));
|
||||||
|
|
||||||
|
// Check 7 and 8
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(overworldTransitionPositionX + (i * 2),
|
RETURN_IF_ERROR(rom()->WriteShort(overworldTransitionPositionX + (i * 2),
|
||||||
(parentxPos * 0x200)));
|
(parentxPos * 0x200)));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(overworldTransitionPositionY + (i * 2),
|
RETURN_IF_ERROR(rom()->WriteShort(overworldTransitionPositionY + (i * 2),
|
||||||
(parentyPos * 0x200)));
|
(parentyPos * 0x200)));
|
||||||
|
|
||||||
// Check 7 and 8
|
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
overworldTransitionPositionX + (i * 2) + 2, (parentxPos * 0x200)));
|
overworldTransitionPositionX + (i * 2) + 2, (parentxPos * 0x200)));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
@@ -853,14 +859,14 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
|
|
||||||
// Always 0x0080
|
// Always 0x0080
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 128, 0x0080));
|
OverworldScreenTileMapChangeByScreen2 + (i * 2), 0x0080));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 2 + 128, 0x0080));
|
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 2, 0x0080));
|
||||||
// Lower always 0x1080
|
// Lower always 0x1080
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 16 + 128, 0x1080));
|
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 16, 0x1080));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 18 + 128, 0x1080));
|
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 18, 0x1080));
|
||||||
|
|
||||||
// If the area to the right is a large map, we don't need to add an offset
|
// If the area to the right is a large map, we don't need to add an offset
|
||||||
// to it. otherwise leave it the same. Just to make sure where don't try
|
// to it. otherwise leave it the same. Just to make sure where don't try
|
||||||
@@ -878,14 +884,14 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
|
|
||||||
// Always 0x1800
|
// Always 0x1800
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 256, 0x1800));
|
OverworldScreenTileMapChangeByScreen3 + (i * 2), 0x1800));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 16 + 256, 0x1800));
|
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 16, 0x1800));
|
||||||
// Right side is always 0x1840
|
// Right side is always 0x1840
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 2 + 256, 0x1840));
|
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 2, 0x1840));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 18 + 256, 0x1840));
|
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 18, 0x1840));
|
||||||
|
|
||||||
// If the area above is a large map, we don't need to add an offset to it.
|
// If the area above is a large map, we don't need to add an offset to it.
|
||||||
// otherwise leave it the same.
|
// otherwise leave it the same.
|
||||||
@@ -903,14 +909,14 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
|
|
||||||
// Always 0x2000
|
// Always 0x2000
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 384, 0x2000));
|
OverworldScreenTileMapChangeByScreen4 + (i * 2), 0x2000));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 16 + 384, 0x2000));
|
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 16, 0x2000));
|
||||||
// Right side always 0x2040
|
// Right side always 0x2040
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 2 + 384, 0x2040));
|
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 2, 0x2040));
|
||||||
RETURN_IF_ERROR(rom()->WriteShort(
|
RETURN_IF_ERROR(rom()->WriteShort(
|
||||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 18 + 384, 0x2040));
|
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 18, 0x2040));
|
||||||
|
|
||||||
// If the area below is a large map, we don't need to add an offset to it.
|
// If the area below is a large map, we don't need to add an offset to it.
|
||||||
// otherwise leave it the same.
|
// otherwise leave it the same.
|
||||||
@@ -1018,6 +1024,18 @@ absl::Status Overworld::SaveLargeMaps() {
|
|||||||
checked_map.emplace(i, 1);
|
checked_map.emplace(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr int OverworldScreenTileMapChangeMask = 0x1262C;
|
||||||
|
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
rom()->WriteShort(OverworldScreenTileMapChangeMask + 0, 0x1F80));
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
rom()->WriteShort(OverworldScreenTileMapChangeMask + 2, 0x1F80));
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
rom()->WriteShort(OverworldScreenTileMapChangeMask + 4, 0x007F));
|
||||||
|
RETURN_IF_ERROR(
|
||||||
|
rom()->WriteShort(OverworldScreenTileMapChangeMask + 6, 0x007F));
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -443,8 +443,8 @@ struct MapData {
|
|||||||
|
|
||||||
class Overworld : public SharedROM, public core::ExperimentFlags {
|
class Overworld : public SharedROM, public core::ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
absl::Status Load(ROM &rom);
|
|
||||||
OWBlockset &GetMapTiles(int world_type);
|
OWBlockset &GetMapTiles(int world_type);
|
||||||
|
absl::Status Load(ROM &rom);
|
||||||
absl::Status LoadOverworldMaps();
|
absl::Status LoadOverworldMaps();
|
||||||
void LoadTileTypes();
|
void LoadTileTypes();
|
||||||
void LoadEntrances();
|
void LoadEntrances();
|
||||||
@@ -470,7 +470,7 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
|
|||||||
absl::Status LoadPrototype(ROM &rom_, const std::string &tilemap_filename);
|
absl::Status LoadPrototype(ROM &rom_, const std::string &tilemap_filename);
|
||||||
|
|
||||||
int current_world_ = 0;
|
int current_world_ = 0;
|
||||||
int GetTile16Id(ImVec2 position) const {
|
int GetTileFromPosition(ImVec2 position) const {
|
||||||
if (current_world_ == 0) {
|
if (current_world_ == 0) {
|
||||||
return map_tiles_.light_world[position.x][position.y];
|
return map_tiles_.light_world[position.x][position.y];
|
||||||
} else if (current_world_ == 1) {
|
} else if (current_world_ == 1) {
|
||||||
@@ -507,7 +507,7 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
|
|||||||
return overworld_maps_[current_map_].Tile16Blockset();
|
return overworld_maps_[current_map_].Tile16Blockset();
|
||||||
}
|
}
|
||||||
auto is_loaded() const { return is_loaded_; }
|
auto is_loaded() const { return is_loaded_; }
|
||||||
void SetCurrentMap(int i) { current_map_ = i; }
|
void set_current_map(int i) { current_map_ = i; }
|
||||||
|
|
||||||
auto map_tiles() const { return map_tiles_; }
|
auto map_tiles() const { return map_tiles_; }
|
||||||
auto mutable_map_tiles() { return &map_tiles_; }
|
auto mutable_map_tiles() { return &map_tiles_; }
|
||||||
|
|||||||
Reference in New Issue
Block a user