| 47 | } |
| 48 | |
| 49 | void MapEngine::stampDs1(const uint32_t ds1Index, const int originX, const int originY) { |
| 50 | const auto &ds1 = _ds1s[ds1Index]; |
| 51 | const auto ds1Width = ds1.width; |
| 52 | const auto ds1Height = ds1.height; |
| 53 | |
| 54 | // Block copy all layers of the specific DS1 to the specified location on the map |
| 55 | for (auto y = 0; y < ds1Height; ++y) { |
| 56 | for (auto x = 0; x < ds1Width; ++x) { |
| 57 | // Floors |
| 58 | for (auto layerIdx = 0; layerIdx < ds1.layers.floor.size(); ++layerIdx) { |
| 59 | const auto &tile = ds1.layers.floor[layerIdx][y * ds1Width + x]; |
| 60 | const auto mapX = originX + x; |
| 61 | const auto mapY = originY + y; |
| 62 | if (mapX < 0 || mapX >= _width || mapY < 0 || mapY >= _height) |
| 63 | continue; |
| 64 | _layers.floor[layerIdx][mapY * _width + mapX] = tile; |
| 65 | } |
| 66 | |
| 67 | // Walls |
| 68 | for (auto layerIdx = 0; layerIdx < ds1.layers.wall.size(); ++layerIdx) { |
| 69 | const auto &tile = ds1.layers.wall[layerIdx][y * ds1Width + x]; |
| 70 | const auto mapX = originX + x; |
| 71 | const auto mapY = originY + y; |
| 72 | if (mapX < 0 || mapX >= _width || mapY < 0 || mapY >= _height) |
| 73 | continue; |
| 74 | _layers.wall[layerIdx][mapY * _width + mapX] = tile; |
| 75 | } |
| 76 | |
| 77 | // Shadows |
| 78 | for (auto layerIdx = 0; layerIdx < ds1.layers.shadow.size(); ++layerIdx) { |
| 79 | const auto &tile = ds1.layers.shadow[layerIdx][y * ds1Width + x]; |
| 80 | const auto mapX = originX + x; |
| 81 | const auto mapY = originY + y; |
| 82 | if (mapX < 0 || mapX >= _width || mapY < 0 || mapY >= _height) |
| 83 | continue; |
| 84 | _layers.shadow[layerIdx][mapY * _width + mapX] = tile; |
| 85 | } |
| 86 | |
| 87 | // Substitutions |
| 88 | for (auto layerIdx = 0; layerIdx < ds1.layers.substitution.size(); ++layerIdx) { |
| 89 | const auto &tile = ds1.layers.substitution[layerIdx][y * ds1Width + x]; |
| 90 | const auto mapX = originX + x; |
| 91 | const auto mapY = originY + y; |
| 92 | if (mapX < 0 || mapX >= _width || mapY < 0 || mapY >= _height) |
| 93 | continue; |
| 94 | _layers.substitution[layerIdx][mapY * _width + mapX] = tile; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |
| 101 | void MapEngine::render() const { |
| 102 | const auto &renderer = AbyssEngine::getInstance().getRenderer(); |