add entrances to ow draw
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
@@ -218,6 +220,14 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
xx = 0;
|
||||
}
|
||||
}
|
||||
for (const auto &each : overworld_.Entrances()) {
|
||||
if (each.mapId_ < 64 + (current_world_ * 0x40) &&
|
||||
each.mapId_ >= (current_world_ * 0x40)) {
|
||||
overworld_map_canvas_.DrawOutline(each.x_, each.y_, 16, 16);
|
||||
std::string str = absl::StrFormat("%#x", each.entranceId_);
|
||||
overworld_map_canvas_.DrawText(str, each.x_ - 2, each.y_ - 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
overworld_map_canvas_.DrawGrid(64.f);
|
||||
overworld_map_canvas_.DrawOverlay();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,8 +39,10 @@ void Canvas::DrawContextMenu() {
|
||||
// Add first and second point
|
||||
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
ImVec2 draw_tile_outline_pos;
|
||||
draw_tile_outline_pos.x = std::round((double)mouse_pos_in_canvas.x / 32) * 32;
|
||||
draw_tile_outline_pos.y = std::round((double)mouse_pos_in_canvas.y / 32) * 32;
|
||||
draw_tile_outline_pos.x =
|
||||
std::round((double)mouse_pos_in_canvas.x / 32) * 32;
|
||||
draw_tile_outline_pos.y =
|
||||
std::round((double)mouse_pos_in_canvas.y / 32) * 32;
|
||||
|
||||
points_.push_back(draw_tile_outline_pos);
|
||||
points_.push_back(
|
||||
@@ -86,11 +88,19 @@ void Canvas::DrawBitmap(const Bitmap &bitmap, int x_offset, int y_offset) {
|
||||
}
|
||||
|
||||
void Canvas::DrawOutline(int x, int y, int w, int h) {
|
||||
ImVec2 origin(x, y);
|
||||
ImVec2 size(x + w, y + h);
|
||||
ImVec2 origin(canvas_p0_.x + scrolling_.x + x,
|
||||
canvas_p0_.y + scrolling_.y + y);
|
||||
ImVec2 size(canvas_p0_.x + scrolling_.x + x + w,
|
||||
canvas_p0_.y + scrolling_.y + y + h);
|
||||
draw_list_->AddRect(origin, size, IM_COL32(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
void Canvas::DrawText(std::string text, int x, int y) {
|
||||
draw_list_->AddText(
|
||||
ImVec2(canvas_p0_.x + scrolling_.x + x, canvas_p0_.y + scrolling_.y + y),
|
||||
IM_COL32(255, 255, 255, 255), text.data());
|
||||
}
|
||||
|
||||
void Canvas::DrawGrid(float grid_step) {
|
||||
// Draw grid + all lines in the canvas
|
||||
draw_list_->PushClipRect(canvas_p0_, canvas_p1_, true);
|
||||
|
||||
@@ -24,6 +24,7 @@ class Canvas {
|
||||
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0);
|
||||
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
||||
void DrawOutline(int x, int y, int w, int h);
|
||||
void DrawText(std::string text, int x, int y);
|
||||
void DrawGrid(float grid_step = 64.0f);
|
||||
void DrawOverlay(); // last
|
||||
|
||||
|
||||
Reference in New Issue
Block a user