add entrances to ow draw
This commit is contained in:
@@ -38,6 +38,7 @@ absl::Status Overworld::Load(ROM &rom) {
|
||||
overworld_maps_.emplace_back(map_index, rom_, tiles16);
|
||||
|
||||
FetchLargeMaps();
|
||||
LoadEntrances();
|
||||
|
||||
auto size = tiles16.size();
|
||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
||||
@@ -194,10 +195,9 @@ void Overworld::FetchLargeMaps() {
|
||||
overworld_maps_[136].SetLargeMap(false);
|
||||
|
||||
bool mapChecked[64];
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
mapChecked[i] = false;
|
||||
}
|
||||
for (int i = 0; i < 64; i++) {
|
||||
mapChecked[i] = false;
|
||||
}
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
while (true) {
|
||||
@@ -238,6 +238,40 @@ void Overworld::FetchLargeMaps() {
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld::LoadEntrances() {
|
||||
for (int i = 0; i < 129; i++) {
|
||||
short mapId = rom_.toint16(core::OWEntranceMap + (i * 2));
|
||||
ushort mapPos = rom_.toint16(core::OWEntrancePos + (i * 2));
|
||||
uchar entranceId = (rom_[core::OWEntranceEntranceId + i]);
|
||||
int p = mapPos >> 1;
|
||||
int x = (p % 64);
|
||||
int y = (p >> 6);
|
||||
bool deleted = false;
|
||||
if (mapPos == 0xFFFF) {
|
||||
deleted = true;
|
||||
}
|
||||
all_entrances_.emplace_back(
|
||||
(x * 16) + (((mapId % 64) - (((mapId % 64) / 8) * 8)) * 512),
|
||||
(y * 16) + (((mapId % 64) / 8) * 512), entranceId, mapId, mapPos,
|
||||
deleted);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0x13; i++) {
|
||||
short mapId = (short)((rom_[core::OWHoleArea + (i * 2) + 1] << 8) +
|
||||
(rom_[core::OWHoleArea + (i * 2)]));
|
||||
short mapPos = (short)((rom_[core::OWHolePos + (i * 2) + 1] << 8) +
|
||||
(rom_[core::OWHolePos + (i * 2)]));
|
||||
uchar entranceId = (rom_[core::OWHoleEntrance + i]);
|
||||
int p = (mapPos + 0x400) >> 1;
|
||||
int x = (p % 64);
|
||||
int y = (p >> 6);
|
||||
all_holes_.emplace_back(EntranceOWEditor(
|
||||
(x * 16) + (((mapId % 64) - (((mapId % 64) / 8) * 8)) * 512),
|
||||
(y * 16) + (((mapId % 64) / 8) * 512), entranceId, mapId,
|
||||
(ushort)(mapPos + 0x400), true));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace zelda3
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
@@ -17,6 +17,60 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
class EntranceOWEditor {
|
||||
public:
|
||||
int x_;
|
||||
int y_;
|
||||
ushort mapPos;
|
||||
uchar entranceId_, AreaX, AreaY;
|
||||
short mapId_;
|
||||
bool isHole = false;
|
||||
bool deleted = false;
|
||||
|
||||
EntranceOWEditor(int x, int y, uchar entranceId, short mapId, ushort mapPos,
|
||||
bool hole) {
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
entranceId_ = entranceId;
|
||||
mapId_ = mapId;
|
||||
mapPos = mapPos;
|
||||
|
||||
int mapX = (mapId_ - ((mapId / 8) * 8));
|
||||
int mapY = (mapId_ / 8);
|
||||
|
||||
AreaX = (uchar)((std::abs(x - (mapX * 512)) / 16));
|
||||
AreaY = (uchar)((std::abs(y - (mapY * 512)) / 16));
|
||||
|
||||
isHole = hole;
|
||||
}
|
||||
|
||||
auto Copy() {
|
||||
return new EntranceOWEditor(x_, y_, entranceId_, mapId_, mapPos, isHole);
|
||||
}
|
||||
|
||||
void updateMapStuff(short mapId) {
|
||||
mapId_ = mapId;
|
||||
|
||||
if (mapId_ >= 64) {
|
||||
mapId_ -= 64;
|
||||
}
|
||||
|
||||
int mapX = (mapId_ - ((mapId_ / 8) * 8));
|
||||
int mapY = (mapId_ / 8);
|
||||
|
||||
AreaX = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
||||
AreaY = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
||||
|
||||
int mx = (mapId_ - ((mapId_ / 8) * 8));
|
||||
int my = (mapId_ / 8);
|
||||
|
||||
uchar xx = (uchar)((x_ - (mx * 512)) / 16);
|
||||
uchar yy = (uchar)((y_ - (my * 512)) / 16);
|
||||
|
||||
mapPos = (ushort)((((AreaY) << 6) | (AreaX & 0x3F)) << 1);
|
||||
}
|
||||
};
|
||||
|
||||
class Overworld {
|
||||
public:
|
||||
absl::Status Load(ROM &rom);
|
||||
@@ -27,6 +81,7 @@ class Overworld {
|
||||
auto AreaGraphics() const {
|
||||
return overworld_maps_[current_map_].AreaGraphics();
|
||||
}
|
||||
auto Entrances() const { return all_entrances_; }
|
||||
auto AreaPalette() const {
|
||||
return overworld_maps_[current_map_].AreaPalette();
|
||||
}
|
||||
@@ -57,6 +112,8 @@ class Overworld {
|
||||
int &ttpos);
|
||||
absl::Status DecompressAllMapTiles();
|
||||
void FetchLargeMaps();
|
||||
void LoadEntrances();
|
||||
|
||||
void LoadOverworldMap();
|
||||
|
||||
int game_state_ = 1;
|
||||
@@ -70,6 +127,8 @@ class Overworld {
|
||||
std::vector<gfx::Tile16> tiles16;
|
||||
std::vector<gfx::Tile32> tiles32;
|
||||
std::vector<OverworldMap> overworld_maps_;
|
||||
std::vector<EntranceOWEditor> all_entrances_;
|
||||
std::vector<EntranceOWEditor> all_holes_;
|
||||
};
|
||||
|
||||
} // namespace zelda3
|
||||
|
||||
Reference in New Issue
Block a user