SaveLargeMaps, SaveMap32Tiles, SaveItems updates
This commit is contained in:
@@ -160,9 +160,6 @@ absl::Status Tile16Editor::DrawToCurrentTile16(ImVec2 click_position) {
|
||||
// Draw the Tile8 to the correct position within the Tile16
|
||||
for (int y = 0; y < tile8_size; ++y) {
|
||||
for (int x = 0; x < tile8_size; ++x) {
|
||||
// int write_x = (x + tile_index_x % 4 * tile8_size);
|
||||
// int write_y = (y + tile_index_y % 4 * tile8_size);
|
||||
// int pixel_index = write_y * tile16_size + write_x;
|
||||
int pixel_index =
|
||||
(start_position.y + y) * tile16_size + ((start_position.x) + x);
|
||||
int gfx_pixel_index = y * tile8_size + x;
|
||||
@@ -278,7 +275,7 @@ absl::Status Tile16Editor::UpdateTransferTileCanvas() {
|
||||
|
||||
// Load the Link to the Past overworld.
|
||||
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))
|
||||
transfer_overworld_.SetCurrentMap(0);
|
||||
transfer_overworld_.set_current_map(0);
|
||||
palette_ = transfer_overworld_.AreaPalette();
|
||||
|
||||
// Create the tile16 blockset image
|
||||
|
||||
@@ -669,7 +669,7 @@ void OverworldEditor::CheckForCurrentMap() {
|
||||
auto current_map_y = current_highlighted_map / 8;
|
||||
|
||||
if (overworld_.overworld_map(current_map_)->IsLargeMap() ||
|
||||
overworld_.overworld_map(current_map_)->ParentIndex() != 0) {
|
||||
overworld_.overworld_map(current_map_)->large_index() != 0) {
|
||||
auto highlight_parent =
|
||||
overworld_.overworld_map(current_highlighted_map)->Parent();
|
||||
auto parent_map_x = highlight_parent % 8;
|
||||
|
||||
@@ -116,7 +116,7 @@ void Overworld::FetchLargeMaps() {
|
||||
overworld_maps_[138].SetAsLargeMap(129, 3);
|
||||
|
||||
map_parent_[136] = 136;
|
||||
overworld_maps_[136].SetAsSmallMap(0);
|
||||
overworld_maps_[136].SetAsSmallMap();
|
||||
|
||||
std::vector<bool> mapChecked;
|
||||
mapChecked.reserve(0x40);
|
||||
@@ -155,8 +155,8 @@ void Overworld::FetchLargeMaps() {
|
||||
} else {
|
||||
map_parent_[i] = (uchar)i;
|
||||
map_parent_[i + 64] = (uchar)(i + 64);
|
||||
overworld_maps_[i].SetAsSmallMap(0);
|
||||
overworld_maps_[i + 64].SetAsSmallMap(0);
|
||||
overworld_maps_[i].SetAsSmallMap();
|
||||
overworld_maps_[i + 64].SetAsSmallMap();
|
||||
mapChecked[i] = true;
|
||||
}
|
||||
}
|
||||
@@ -848,7 +848,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area to the left is a large area.
|
||||
if (overworld_maps_[i - 1].IsLargeMap()) {
|
||||
// If the area to the left is the bottom right of a large area.
|
||||
if (overworld_maps_[i - 1].ParentIndex() == 1) {
|
||||
if (overworld_maps_[i - 1].large_index() == 1) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen1 + (i * 2) + 16,
|
||||
0x0060));
|
||||
@@ -875,7 +875,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area to the right is a large area.
|
||||
if (overworld_maps_[i + 2].IsLargeMap()) {
|
||||
// If the area to the right is the top left of a large area.
|
||||
if (overworld_maps_[i + 2].ParentIndex() == 0) {
|
||||
if (overworld_maps_[i + 2].large_index() == 0) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 18, 0x0080));
|
||||
}
|
||||
@@ -900,7 +900,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area just above us is a large area.
|
||||
if (overworld_maps_[i - 8].IsLargeMap()) {
|
||||
// If the area just above us is the bottom left of a large area.
|
||||
if (overworld_maps_[i - 8].ParentIndex() == 2) {
|
||||
if (overworld_maps_[i - 8].large_index() == 2) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 02, 0x1800));
|
||||
}
|
||||
@@ -925,7 +925,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area just below us is a large area.
|
||||
if (overworld_maps_[i + 16].IsLargeMap()) {
|
||||
// If the area just below us is the top left of a large area.
|
||||
if (overworld_maps_[i + 16].ParentIndex() == 0) {
|
||||
if (overworld_maps_[i + 16].large_index() == 0) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 18, 0x2000));
|
||||
}
|
||||
@@ -959,7 +959,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// Just to make sure where don't try to read outside of the array.
|
||||
if (i - 1 >= 0 && parentxPos != 0) {
|
||||
if (overworld_maps_[i - 1].IsLargeMap()) {
|
||||
if (overworld_maps_[i - 1].ParentIndex() == 3) {
|
||||
if (overworld_maps_[i - 1].large_index() == 3) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen1 + (i * 2), 0xF060));
|
||||
}
|
||||
@@ -967,10 +967,10 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen2 + (i * 2) + 128, 0x0040));
|
||||
OverworldScreenTileMapChangeByScreen2 + (i * 2), 0x0040));
|
||||
if (i + 1 < 64 && parentxPos != 7) {
|
||||
if (overworld_maps_[i + 1].IsLargeMap()) {
|
||||
if (overworld_maps_[i + 1].ParentIndex() == 1) {
|
||||
if (overworld_maps_[i + 1].large_index() == 1) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen2 + (i * 2), 0xF040));
|
||||
}
|
||||
@@ -978,7 +978,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen3 + (i * 2) + 256, 0x1800));
|
||||
OverworldScreenTileMapChangeByScreen3 + (i * 2), 0x1800));
|
||||
|
||||
// If the area above is a large map, we don't need to add an offset to it.
|
||||
// otherwise leave it the same.
|
||||
@@ -987,7 +987,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area just above us is a large area.
|
||||
if (overworld_maps_[i - 8].IsLargeMap()) {
|
||||
// If we are under the bottom right of the large area.
|
||||
if (overworld_maps_[i - 8].ParentIndex() == 3) {
|
||||
if (overworld_maps_[i - 8].large_index() == 3) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen3 + (i * 2), 0x17C0));
|
||||
}
|
||||
@@ -995,7 +995,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen4 + (i * 2) + 384, 0x1000));
|
||||
OverworldScreenTileMapChangeByScreen4 + (i * 2), 0x1000));
|
||||
|
||||
// If the area below is a large map, we don't need to add an offset to it.
|
||||
// otherwise leave it the same.
|
||||
@@ -1004,7 +1004,7 @@ absl::Status Overworld::SaveLargeMaps() {
|
||||
// If the area just below us is a large area.
|
||||
if (overworld_maps_[i + 8].IsLargeMap()) {
|
||||
// If we are on top of the top right of the large area.
|
||||
if (overworld_maps_[i + 8].ParentIndex() == 1) {
|
||||
if (overworld_maps_[i + 8].large_index() == 1) {
|
||||
RETURN_IF_ERROR(rom()->WriteShort(
|
||||
OverworldScreenTileMapChangeByScreen4 + (i * 2), 0x0FC0));
|
||||
}
|
||||
@@ -1119,7 +1119,7 @@ absl::Status Overworld::CreateTile32Tilemap() {
|
||||
}
|
||||
|
||||
while (tiles32_unique_.size() % 4 != 0) {
|
||||
gfx::Tile32 padding_tile(420, 420, 420, 420);
|
||||
gfx::Tile32 padding_tile(0, 0, 0, 0);
|
||||
tiles32_unique_.emplace_back(padding_tile.GetPackedValue());
|
||||
}
|
||||
|
||||
@@ -1162,108 +1162,110 @@ absl::Status Overworld::SaveMap32Tiles() {
|
||||
}
|
||||
|
||||
// Top Left.
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile0_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile0_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile0_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile0_ & 0xFF));
|
||||
const auto top_left = rom()->version_constants().kMap32TileTL;
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile0_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile0_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile0_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile0_ & 0xFF)));
|
||||
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + (i + 4),
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + (i + 4),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index].tile0_ >> 4) & 0xF0) +
|
||||
((tiles32_unique_[unique_tile_index + 1].tile0_ >> 8) &
|
||||
0x0F)));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTL + (i + 5),
|
||||
0x0F))));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_left + (i + 5),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index + 2].tile0_ >> 4) &
|
||||
0xF0) +
|
||||
((tiles32_unique_[unique_tile_index + 3].tile0_ >> 8) &
|
||||
0x0F)));
|
||||
0x0F))));
|
||||
|
||||
// Top Right.
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile1_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile1_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile1_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile1_ & 0xFF));
|
||||
const auto top_right = rom()->version_constants().kMap32TileTR;
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile1_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile1_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile1_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile1_ & 0xFF)));
|
||||
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + (i + 4),
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + (i + 4),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index].tile1_ >> 4) & 0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 1].tile1_ >> 8) &
|
||||
0x0F)));
|
||||
rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileTR + (i + 5),
|
||||
0x0F))));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
top_right + (i + 5),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index + 2].tile1_ >> 4) &
|
||||
0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 3].tile1_ >> 8) &
|
||||
0x0F)));
|
||||
0x0F))));
|
||||
|
||||
// Bottom Left.
|
||||
rom()->WriteByte(
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile2_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile2_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile2_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile2_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile2_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile2_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile2_ & 0xFF));
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile2_ & 0xFF)));
|
||||
|
||||
rom()->WriteByte(
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + (i + 4),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index].tile2_ >> 4) & 0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 1].tile2_ >> 8) &
|
||||
0x0F)));
|
||||
rom()->WriteByte(
|
||||
0x0F))));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBL + (i + 5),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index + 2].tile2_ >> 4) &
|
||||
0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 3].tile2_ >> 8) &
|
||||
0x0F)));
|
||||
0x0F))));
|
||||
|
||||
// Bottom Right.
|
||||
rom()->WriteByte(
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + i,
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile3_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index].tile3_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + (i + 1),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile3_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 1].tile3_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + (i + 2),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile3_ & 0xFF));
|
||||
rom()->WriteByte(
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 2].tile3_ & 0xFF)));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + (i + 3),
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile3_ & 0xFF));
|
||||
(uint8_t)(tiles32_unique_[unique_tile_index + 3].tile3_ & 0xFF)));
|
||||
|
||||
rom()->WriteByte(
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + (i + 4),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index].tile3_ >> 4) & 0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 1].tile3_ >> 8) &
|
||||
0x0F)));
|
||||
rom()->WriteByte(
|
||||
0x0F))));
|
||||
RETURN_IF_ERROR(rom()->WriteByte(
|
||||
rom()->version_constants().kMap32TileBR + (i + 5),
|
||||
(uint8_t)(((tiles32_unique_[unique_tile_index + 2].tile3_ >> 4) &
|
||||
0xF0) |
|
||||
((tiles32_unique_[unique_tile_index + 3].tile3_ >> 8) &
|
||||
0x0F)));
|
||||
0x0F))));
|
||||
|
||||
unique_tile_index += 4;
|
||||
num_unique_tiles += 2;
|
||||
@@ -1381,86 +1383,81 @@ bool compareItemsArrays(std::vector<OverworldItem> itemArray1,
|
||||
} // namespace
|
||||
|
||||
absl::Status Overworld::SaveItems() {
|
||||
std::vector<std::vector<OverworldItem>> roomItems(128);
|
||||
std::vector<std::vector<OverworldItem>> room_items(128);
|
||||
|
||||
for (int i = 0; i < 128; i++) {
|
||||
roomItems[i] = std::vector<OverworldItem>();
|
||||
room_items[i] = std::vector<OverworldItem>();
|
||||
for (const OverworldItem &item : all_items_) {
|
||||
if (item.room_map_id == i) {
|
||||
roomItems[i].emplace_back(item);
|
||||
room_items[i].emplace_back(item);
|
||||
if (item.id == 0x86) {
|
||||
RETURN_IF_ERROR(rom()->WriteWord(
|
||||
0x16DC5 + (i * 2), (item.game_x_ + (item.game_y_ * 64)) * 2));
|
||||
0x16DC5 + (i * 2), (item.game_x + (item.game_y * 64)) * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dataPos = overworldItemsPointers + 0x100;
|
||||
int data_pos = overworldItemsPointers + 0x100;
|
||||
|
||||
std::vector<int> itemPointers(128);
|
||||
std::vector<int> itemPointersReuse(128);
|
||||
int emptyPointer = 0;
|
||||
int item_pointers[128];
|
||||
int item_pointers_reuse[128];
|
||||
int empty_pointer = 0;
|
||||
|
||||
for (int i = 0; i < 128; i++) {
|
||||
itemPointersReuse[i] = -1;
|
||||
item_pointers_reuse[i] = -1;
|
||||
for (int ci = 0; ci < i; ci++) {
|
||||
if (roomItems[i].empty()) {
|
||||
itemPointersReuse[i] = -2;
|
||||
if (room_items[i].empty()) {
|
||||
item_pointers_reuse[i] = -2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Unclear:
|
||||
compareItemsArrays(
|
||||
std::vector<OverworldItem>(roomItems[i].begin(), roomItems[i].end()),
|
||||
std::vector<OverworldItem>(roomItems[ci].begin(),
|
||||
roomItems[ci].end()));
|
||||
if (compareItemsArrays(std::vector<OverworldItem>(roomItems[i].begin(),
|
||||
roomItems[i].end()),
|
||||
std::vector<OverworldItem>(roomItems[ci].begin(),
|
||||
roomItems[ci].end()))) {
|
||||
itemPointersReuse[i] = ci;
|
||||
// Copy into separator vectors from i to ci, then ci to end
|
||||
if (compareItemsArrays(
|
||||
std::vector<OverworldItem>(room_items[i].begin(),
|
||||
room_items[i].end()),
|
||||
std::vector<OverworldItem>(room_items[ci].begin(),
|
||||
room_items[ci].end()))) {
|
||||
item_pointers_reuse[i] = ci;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (itemPointersReuse[i] == -1) {
|
||||
itemPointers[i] = dataPos;
|
||||
for (const OverworldItem &item : roomItems[i]) {
|
||||
short mapPos =
|
||||
static_cast<short>(((item.game_y_ << 6) + item.game_x_) << 1);
|
||||
if (item_pointers_reuse[i] == -1) {
|
||||
item_pointers[i] = data_pos;
|
||||
for (const OverworldItem &item : room_items[i]) {
|
||||
short map_pos =
|
||||
static_cast<short>(((item.game_y << 6) + item.game_x) << 1);
|
||||
|
||||
uint32_t data = static_cast<uint8_t>(mapPos & 0xFF) |
|
||||
static_cast<uint8_t>(mapPos >> 8) |
|
||||
uint32_t data = static_cast<uint8_t>(map_pos & 0xFF) |
|
||||
static_cast<uint8_t>(map_pos >> 8) |
|
||||
static_cast<uint8_t>(item.id);
|
||||
RETURN_IF_ERROR(rom()->WriteLong(dataPos, data));
|
||||
// WriteType::PotItemData);
|
||||
|
||||
dataPos += 3;
|
||||
RETURN_IF_ERROR(rom()->WriteLong(data_pos, data));
|
||||
data_pos += 3;
|
||||
}
|
||||
|
||||
emptyPointer = dataPos;
|
||||
RETURN_IF_ERROR(rom()->WriteWord(dataPos, 0xFFFF));
|
||||
dataPos += 2;
|
||||
} else if (itemPointersReuse[i] == -2) {
|
||||
itemPointers[i] = emptyPointer;
|
||||
empty_pointer = data_pos;
|
||||
RETURN_IF_ERROR(rom()->WriteWord(data_pos, 0xFFFF));
|
||||
data_pos += 2;
|
||||
} else if (item_pointers_reuse[i] == -2) {
|
||||
item_pointers[i] = empty_pointer;
|
||||
} else {
|
||||
itemPointers[i] = itemPointers[itemPointersReuse[i]];
|
||||
item_pointers[i] = item_pointers[item_pointers_reuse[i]];
|
||||
}
|
||||
|
||||
int snesaddr = core::PcToSnes(itemPointers[i]);
|
||||
int snesaddr = core::PcToSnes(item_pointers[i]);
|
||||
RETURN_IF_ERROR(
|
||||
rom()->WriteWord(overworldItemsPointers + (i * 2), snesaddr));
|
||||
}
|
||||
|
||||
if (dataPos > overworldItemsEndData) {
|
||||
if (data_pos > overworldItemsEndData) {
|
||||
return absl::AbortedError("Too many items");
|
||||
}
|
||||
|
||||
if (flags()->kLogToConsole) {
|
||||
std::cout << "End of Items : " << dataPos << std::endl;
|
||||
std::cout << "End of Items : " << data_pos << std::endl;
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
|
||||
@@ -110,11 +110,6 @@ class OverworldItem : public OverworldEntity {
|
||||
<< " X: " << static_cast<int>(this->game_x)
|
||||
<< " Y: " << static_cast<int>(this->game_y) << std::endl;
|
||||
}
|
||||
|
||||
OverworldItem Copy() {
|
||||
return OverworldItem(this->id, this->room_map_id, this->x_, this->y_,
|
||||
this->bg2);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr int OWExitRoomId = 0x15D8A; // 0x15E07 Credits sequences
|
||||
@@ -381,16 +376,18 @@ constexpr int overworldMapPaletteGroup = 0x75504;
|
||||
constexpr int overworldSpritePaletteGroup = 0x75580;
|
||||
constexpr int overworldSpriteset = 0x7A41;
|
||||
constexpr int overworldSpecialGFXGroup = 0x16821;
|
||||
constexpr int OverworldMapDataOverflow = 0x130000;
|
||||
constexpr int overworldSpecialPALGroup = 0x16831;
|
||||
constexpr int overworldSpritesBegining = 0x4C881;
|
||||
constexpr int overworldSpritesAgahnim = 0x4CA21;
|
||||
constexpr int overworldSpritesZelda = 0x4C901;
|
||||
|
||||
constexpr int mapGfx = 0x7C9C;
|
||||
constexpr int overlayPointers = 0x77664;
|
||||
constexpr int overlayPointersBank = 0x0E;
|
||||
|
||||
constexpr int overworldTilesType = 0x71459;
|
||||
constexpr int overworldMessages = 0x3F51D;
|
||||
|
||||
constexpr int overworldMusicBegining = 0x14303;
|
||||
constexpr int overworldMusicZelda = 0x14303 + 0x40;
|
||||
constexpr int overworldMusicMasterSword = 0x14303 + 0x80;
|
||||
@@ -423,11 +420,41 @@ constexpr int OverworldScreenTileMapChangeByScreen2 = 0x126B4;
|
||||
constexpr int OverworldScreenTileMapChangeByScreen3 = 0x12734;
|
||||
constexpr int OverworldScreenTileMapChangeByScreen4 = 0x127B4;
|
||||
|
||||
constexpr int OverworldMapDataOverflow = 0x130000;
|
||||
|
||||
constexpr int transition_target_north = 0x13ee2;
|
||||
constexpr int transition_target_west = 0x13f62;
|
||||
constexpr int overworldCustomMosaicASM = 0x1301D0;
|
||||
constexpr int overworldCustomMosaicArray = 0x1301F0;
|
||||
|
||||
constexpr int OverworldCustomASMHasBeenApplied =
|
||||
0x140145; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int OverworldCustomAreaSpecificBGPalette =
|
||||
0x140000; // 2 bytes for each overworld area (0x140)
|
||||
constexpr int OverworldCustomAreaSpecificBGEnabled =
|
||||
0x140140; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int OverworldCustomMainPaletteArray =
|
||||
0x140160; // 1 byte for each overworld area (0xA0)
|
||||
constexpr int OverworldCustomMainPaletteEnabled =
|
||||
0x140141; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int OverworldCustomMosaicArray =
|
||||
0x140200; // 1 byte for each overworld area (0xA0)
|
||||
constexpr int OverworldCustomMosaicEnabled =
|
||||
0x140142; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int OverworldCustomAnimatedGFXArray =
|
||||
0x1402A0; // 1 byte for each overworld area (0xA0)
|
||||
constexpr int OverworldCustomAnimatedGFXEnabled =
|
||||
0x140143; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int OverworldCustomSubscreenOverlayArray =
|
||||
0x140340; // 2 bytes for each overworld area (0x140)
|
||||
constexpr int OverworldCustomSubscreenOverlayEnabled =
|
||||
0x140144; // 1 byte, not 0 if enabled
|
||||
|
||||
constexpr int kMap16Tiles = 0x78000;
|
||||
constexpr int kNumOverworldMaps = 160;
|
||||
constexpr int Map32PerScreen = 256;
|
||||
|
||||
@@ -59,7 +59,7 @@ absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
||||
|
||||
void OverworldMap::LoadAreaInfo() {
|
||||
if (index_ != 0x80) {
|
||||
if (index_ <= 150)
|
||||
if (index_ <= 128)
|
||||
large_map_ = (rom_[overworldMapSize + (index_ & 0x3F)] != 0);
|
||||
else {
|
||||
large_map_ =
|
||||
@@ -67,7 +67,7 @@ void OverworldMap::LoadAreaInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
if (index_ < 64) {
|
||||
if (index_ < 0x40) {
|
||||
area_graphics_ = rom_[mapGfx + parent_];
|
||||
area_palette_ = rom_[overworldMapPalette + parent_];
|
||||
|
||||
|
||||
@@ -76,17 +76,20 @@ class OverworldMap : public GfxContext {
|
||||
auto set_sprite_palette(int i, uint8_t value) { sprite_palette_[i] = value; }
|
||||
auto set_message_id(uint16_t value) { message_id_ = value; }
|
||||
|
||||
auto ParentIndex() const { return parent_index_; }
|
||||
auto large_index() const { return large_index_; }
|
||||
|
||||
void SetAsLargeMap(int parent_index, int quadrant) {
|
||||
parent_ = parent_index;
|
||||
parent_index_ = quadrant;
|
||||
large_index_ = quadrant;
|
||||
large_map_ = true;
|
||||
}
|
||||
|
||||
void SetAsSmallMap(int quadrant) {
|
||||
parent_ = index_;
|
||||
parent_index_ = quadrant;
|
||||
void SetAsSmallMap(int index = -1) {
|
||||
if (index != -1)
|
||||
parent_ = index;
|
||||
else
|
||||
parent_ = index_;
|
||||
large_index_ = 0;
|
||||
large_map_ = false;
|
||||
}
|
||||
|
||||
@@ -107,12 +110,12 @@ class OverworldMap : public GfxContext {
|
||||
bool large_map_ = false;
|
||||
bool initialized_ = false;
|
||||
|
||||
int index_ = 0; // Map index
|
||||
int parent_ = 0; // Parent map index
|
||||
int parent_index_ = 0; // Quadrant ID [0-3]
|
||||
int world_ = 0; // World ID [0-2]
|
||||
int game_state_ = 0; // Game state [0-2]
|
||||
int world_index_ = 0; // Spr Pal Modifier
|
||||
int index_ = 0; // Map index
|
||||
int parent_ = 0; // Parent map index
|
||||
int large_index_ = 0; // Quadrant ID [0-3]
|
||||
int world_ = 0; // World ID [0-2]
|
||||
int game_state_ = 0; // Game state [0-2]
|
||||
int world_index_ = 0; // Spr Pal Modifier
|
||||
|
||||
uint16_t message_id_ = 0;
|
||||
uint8_t area_graphics_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user