diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c7aeb915..f86a96200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,7 +272,6 @@ add_library(PKWare STATIC set(devilutionx_SRCS Source/appfat.cpp Source/automap.cpp - Source/automap_render.cpp Source/capture.cpp Source/codec.cpp Source/control.cpp @@ -352,6 +351,7 @@ set(devilutionx_SRCS Source/controls/touch.cpp Source/controls/keymapper.cpp Source/engine/animationinfo.cpp + Source/engine/render/automap_render.cpp Source/qol/autopickup.cpp Source/qol/common.cpp Source/qol/monhealthbar.cpp diff --git a/Source/automap.cpp b/Source/automap.cpp index 001b0c5e8..edcc241f5 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -7,8 +7,8 @@ #include -#include "automap_render.hpp" #include "control.h" +#include "engine/render/automap_render.hpp" #include "inv.h" #include "miniwin/miniwin.h" #include "monster.h" @@ -284,14 +284,14 @@ void DrawAutomapPlr(const CelOutputBuffer &out, int playerId) case DIR_N: { const Point point { base.x, base.y - AmLine16 }; DrawVerticalLine(out, point, AmLine16, playerColor); - DrawMapLineNE2(out, { point.x - AmLine4, point.y + 2 * AmLine4 }, AmLine4, playerColor); - DrawMapLineNW2(out, { point.x + AmLine4, point.y + 2 * AmLine4 }, AmLine4, playerColor); + DrawMapLineSteepNE(out, { point.x - AmLine4, point.y + 2 * AmLine4 }, AmLine4, playerColor); + DrawMapLineSteepNW(out, { point.x + AmLine4, point.y + 2 * AmLine4 }, AmLine4, playerColor); } break; case DIR_NE: { const Point point { base.x + AmLine16, base.y - AmLine8 }; DrawHorizontalLine(out, {point.x - AmLine8, point.y}, AmLine8, playerColor); DrawMapLineNE(out, { point.x - 2 * AmLine8, point.y + AmLine8 }, AmLine8, playerColor); - DrawMapLineSW2(out, point, AmLine4, playerColor); + DrawMapLineSteepSW(out, point, AmLine4, playerColor); } break; case DIR_E: { const Point point { base.x + AmLine16, base.y }; @@ -303,18 +303,18 @@ void DrawAutomapPlr(const CelOutputBuffer &out, int playerId) const Point point { base.x + AmLine16, base.y + AmLine8 }; DrawMapLineSE(out, { point.x - 2 * AmLine8, point.y - AmLine8 }, AmLine8, playerColor); DrawHorizontalLine(out, { point.x - (AmLine8 + 1), point.y }, AmLine8 + 1, playerColor); - DrawMapLineNW2(out, point, AmLine4, playerColor); + DrawMapLineSteepNW(out, point, AmLine4, playerColor); } break; case DIR_S: case DIR_OMNI: { const Point point { base.x, base.y + AmLine16 }; DrawVerticalLine(out, { point.x, point.y - AmLine16 }, AmLine16, playerColor); - DrawMapLineSW2(out, { point.x + AmLine4, point.y - 2 * AmLine4}, AmLine4, playerColor); - DrawMapLineSE2(out, { point.x - AmLine4, point.y - 2 * AmLine4}, AmLine4, playerColor); + DrawMapLineSteepSW(out, { point.x + AmLine4, point.y - 2 * AmLine4}, AmLine4, playerColor); + DrawMapLineSteepSE(out, { point.x - AmLine4, point.y - 2 * AmLine4}, AmLine4, playerColor); } break; case DIR_SW: { const Point point { base.x - AmLine16, base.y + AmLine8 }; - DrawMapLineNE2(out, point, AmLine4, playerColor); + DrawMapLineSteepNE(out, point, AmLine4, playerColor); DrawMapLineSW(out, { point.x + 2 * AmLine8, point.y - AmLine8 }, AmLine8, playerColor); DrawHorizontalLine(out, point, AmLine8 + 1, playerColor); } break; @@ -328,7 +328,7 @@ void DrawAutomapPlr(const CelOutputBuffer &out, int playerId) const Point point { base.x - AmLine16, base.y - AmLine8 }; DrawMapLineNW(out, { point.x + 2 * AmLine8, point.y + AmLine8 }, AmLine8, playerColor); DrawHorizontalLine(out, point, AmLine8 + 1, playerColor); - DrawMapLineSE2(out, point, AmLine4, playerColor); + DrawMapLineSteepSE(out, point, AmLine4, playerColor); } break; } } diff --git a/Source/automap_render.cpp b/Source/engine/render/automap_render.cpp similarity index 62% rename from Source/automap_render.cpp rename to Source/engine/render/automap_render.cpp index 2d09b9ebc..3bea82e2b 100644 --- a/Source/automap_render.cpp +++ b/Source/engine/render/automap_render.cpp @@ -1,4 +1,4 @@ -#include "automap_render.hpp" +#include "engine/render/automap_render.hpp" namespace devilution { namespace { @@ -27,7 +27,7 @@ void DrawMapLine(const CelOutputBuffer &out, Point from, int height, std::uint8_ } template -void DrawMapLine2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) +void DrawMapLineSteep(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) { while (width-- > 0) { SetPixel(out, from, colorIndex); @@ -61,24 +61,24 @@ void DrawMapLineSW(const CelOutputBuffer &out, Point from, int height, std::uint DrawMapLine(out, from, height, colorIndex); } -void DrawMapLineNE2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) +void DrawMapLineSteepNE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) { - DrawMapLine2(out, from, width, colorIndex); + DrawMapLineSteep(out, from, width, colorIndex); } -void DrawMapLineSE2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) +void DrawMapLineSteepSE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) { - DrawMapLine2(out, from, width, colorIndex); + DrawMapLineSteep(out, from, width, colorIndex); } -void DrawMapLineNW2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) +void DrawMapLineSteepNW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) { - DrawMapLine2(out, from, width, colorIndex); + DrawMapLineSteep(out, from, width, colorIndex); } -void DrawMapLineSW2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) +void DrawMapLineSteepSW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex) { - DrawMapLine2(out, from, width, colorIndex); + DrawMapLineSteep(out, from, width, colorIndex); } } // namespace devilution diff --git a/Source/automap_render.hpp b/Source/engine/render/automap_render.hpp similarity index 72% rename from Source/automap_render.hpp rename to Source/engine/render/automap_render.hpp index 5a4c60320..47d8d1c19 100644 --- a/Source/automap_render.hpp +++ b/Source/engine/render/automap_render.hpp @@ -1,3 +1,14 @@ +/** @file automap_render.hpp + * Defines 2 sets of rendering primitives for drawing automap lines. + * + * 1. DrawMapLine* - used for rendering most map lines - 2 pixels horizontally for each pixel vertically. + * 2. DrawMapLineSteep* - currently only used for rendering the player arrow - 2 pixels vertically for each pixel horizontally. + * + * These functions draw a single extra pixel at the end of the line -- they always draw an odd number of pixels. + * These functions clip to the output buffer -- they are safe to call with out-of-bounds coordinates. + */ +#pragma once + #include "engine.h" namespace devilution { @@ -45,7 +56,7 @@ void DrawMapLineSW(const CelOutputBuffer &out, Point from, int height, std::uint * * The end point is at `{ from.x + width + 1, from.y - 2 * width }`. */ -void DrawMapLineNE2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); +void DrawMapLineSteepNE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); /** * @brief Draw a line in the target buffer from the given point towards south east at an `atan(2)` angle. @@ -54,7 +65,7 @@ void DrawMapLineNE2(const CelOutputBuffer &out, Point from, int width, std::uint * * The end point is at `{ from.x + width + 1, from.y + 2 * width }`. */ -void DrawMapLineSE2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); +void DrawMapLineSteepSE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); /** * @brief Draw a line in the target buffer from the given point towards north west at an `atan(1/2)` angle. @@ -63,7 +74,7 @@ void DrawMapLineSE2(const CelOutputBuffer &out, Point from, int width, std::uint * * The end point is at `{ from.x - (width + 1), from.y - 2 * width }`. */ -void DrawMapLineNW2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); +void DrawMapLineSteepNW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); /** * @brief Draw a line in the target buffer from the given point towards south west at an `atan(1/2)` angle. @@ -72,6 +83,6 @@ void DrawMapLineNW2(const CelOutputBuffer &out, Point from, int width, std::uint * * The end point is at `{ from.x - (width + 1), from.y + 2 * width }`. */ -void DrawMapLineSW2(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); +void DrawMapLineSteepSW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex); } // namespace devilution