[nostalgia/core] Revert some auto formatting done by CLion...
All checks were successful
Build / build (push) Successful in 2m28s
All checks were successful
Build / build (push) Successful in 2m28s
This commit is contained in:
parent
37e65ab0a6
commit
7fb0549c25
@ -10,16 +10,16 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
std::size_t idx(TileSheet::SubSheet const &ss, ox::Point const &pt) noexcept {
|
std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
|
||||||
return ptToIdx(pt, ss.columns);
|
return ptToIdx(pt, ss.columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static TileSheet::SubSheet const *getSubsheet(TileSheet::SubSheet const &ss, SubSheetId const id) noexcept {
|
static TileSheet::SubSheet const *getSubsheet(TileSheet::SubSheet const&ss, SubSheetId const id) noexcept {
|
||||||
if (ss.id == id) {
|
if (ss.id == id) {
|
||||||
return &ss;
|
return &ss;
|
||||||
}
|
}
|
||||||
for (auto const &child: ss.subsheets) {
|
for (auto const&child: ss.subsheets) {
|
||||||
if (auto out = getSubsheet(child, id)) {
|
if (auto out = getSubsheet(child, id)) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -28,33 +28,33 @@ static TileSheet::SubSheet const *getSubsheet(TileSheet::SubSheet const &ss, Sub
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static size_t getTileCnt(TileSheet::SubSheet const &ss, int const bpp) noexcept {
|
static size_t getTileCnt(TileSheet::SubSheet const&ss, int const bpp) noexcept {
|
||||||
if (ss.subsheets.empty()) {
|
if (ss.subsheets.empty()) {
|
||||||
auto const bytesPerTile = bpp == 4 ? 32u : 64u;
|
auto const bytesPerTile = bpp == 4 ? 32u : 64u;
|
||||||
return ss.pixels.size() / bytesPerTile;
|
return ss.pixels.size() / bytesPerTile;
|
||||||
} else {
|
} else {
|
||||||
size_t out{};
|
size_t out{};
|
||||||
for (auto const &child: ss.subsheets) {
|
for (auto const&child: ss.subsheets) {
|
||||||
out += getTileCnt(child, bpp);
|
out += getTileCnt(child, bpp);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getTileCnt(TileSheet const &ts) noexcept {
|
size_t getTileCnt(TileSheet const&ts) noexcept {
|
||||||
return getTileCnt(ts.subsheet, ts.bpp);
|
return getTileCnt(ts.subsheet, ts.bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheet::SubSheet const *getSubsheet(TileSheet const &ts, SubSheetId const id) noexcept {
|
TileSheet::SubSheet const *getSubsheet(TileSheet const&ts, SubSheetId const id) noexcept {
|
||||||
return getSubsheet(ts.subsheet, id);
|
return getSubsheet(ts.subsheet, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Optional<size_t> getPixelIdx(
|
static ox::Optional<size_t> getPixelIdx(
|
||||||
TileSheet::SubSheet const &ss,
|
TileSheet::SubSheet const&ss,
|
||||||
SubSheetId const id,
|
SubSheetId const id,
|
||||||
size_t idx,
|
size_t idx,
|
||||||
int8_t const bpp) noexcept {
|
int8_t const bpp) noexcept {
|
||||||
for (auto const &child: ss.subsheets) {
|
for (auto const&child: ss.subsheets) {
|
||||||
if (child.id == id) {
|
if (child.id == id) {
|
||||||
return ox::Optional<size_t>(ox::in_place, idx);
|
return ox::Optional<size_t>(ox::in_place, idx);
|
||||||
}
|
}
|
||||||
@ -66,12 +66,12 @@ static ox::Optional<size_t> getPixelIdx(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getTileIdx(TileSheet const &ts, SubSheetId const id) noexcept {
|
size_t getTileIdx(TileSheet const&ts, SubSheetId const id) noexcept {
|
||||||
auto const out = getPixelIdx(ts.subsheet, id, 0, ts.bpp);
|
auto const out = getPixelIdx(ts.subsheet, id, 0, ts.bpp);
|
||||||
return out.or_value(0) / PixelsPerTile;
|
return out.or_value(0) / PixelsPerTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel4Bpp(TileSheet::SubSheet const &ss, std::size_t idx) noexcept {
|
uint8_t getPixel4Bpp(TileSheet::SubSheet const&ss, std::size_t idx) noexcept {
|
||||||
if (idx & 1) {
|
if (idx & 1) {
|
||||||
return ss.pixels[idx / 2] >> 4;
|
return ss.pixels[idx / 2] >> 4;
|
||||||
} else {
|
} else {
|
||||||
@ -79,11 +79,11 @@ uint8_t getPixel4Bpp(TileSheet::SubSheet const &ss, std::size_t idx) noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel8Bpp(TileSheet::SubSheet const &ss, std::size_t idx) noexcept {
|
uint8_t getPixel8Bpp(TileSheet::SubSheet const&ss, std::size_t idx) noexcept {
|
||||||
return ss.pixels[idx];
|
return ss.pixels[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel(TileSheet::SubSheet const &ss, int8_t pBpp, std::size_t idx) noexcept {
|
uint8_t getPixel(TileSheet::SubSheet const&ss, int8_t pBpp, std::size_t idx) noexcept {
|
||||||
if (pBpp == 4) {
|
if (pBpp == 4) {
|
||||||
return getPixel4Bpp(ss, idx);
|
return getPixel4Bpp(ss, idx);
|
||||||
} else {
|
} else {
|
||||||
@ -91,17 +91,17 @@ uint8_t getPixel(TileSheet::SubSheet const &ss, int8_t pBpp, std::size_t idx) no
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel4Bpp(TileSheet::SubSheet const &ss, ox::Point const &pt) noexcept {
|
uint8_t getPixel4Bpp(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
|
||||||
const auto idx = ptToIdx(pt, ss.columns);
|
const auto idx = ptToIdx(pt, ss.columns);
|
||||||
return getPixel4Bpp(ss, idx);
|
return getPixel4Bpp(ss, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel8Bpp(TileSheet::SubSheet const &ss, ox::Point const &pt) noexcept {
|
uint8_t getPixel8Bpp(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept {
|
||||||
const auto idx = ptToIdx(pt, ss.columns);
|
const auto idx = ptToIdx(pt, ss.columns);
|
||||||
return getPixel8Bpp(ss, idx);
|
return getPixel8Bpp(ss, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPixel(TileSheet::SubSheet const &ss, int8_t pBpp, ox::Point const &pt) noexcept {
|
uint8_t getPixel(TileSheet::SubSheet const&ss, int8_t pBpp, ox::Point const&pt) noexcept {
|
||||||
const auto idx = ptToIdx(pt, ss.columns);
|
const auto idx = ptToIdx(pt, ss.columns);
|
||||||
return getPixel(ss, pBpp, idx);
|
return getPixel(ss, pBpp, idx);
|
||||||
}
|
}
|
||||||
@ -123,12 +123,12 @@ void setPixel(TileSheet::SubSheet &ss, int8_t pBpp, uint64_t idx, uint8_t palIdx
|
|||||||
setPixel(ss.pixels, pBpp, idx, palIdx);
|
setPixel(ss.pixels, pBpp, idx, palIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPixel(ox::Vector<uint8_t> &pixels, int columns, int8_t pBpp, ox::Point const &pt, uint8_t palIdx) noexcept {
|
static void setPixel(ox::Vector<uint8_t> &pixels, int columns, int8_t pBpp, ox::Point const&pt, uint8_t palIdx) noexcept {
|
||||||
const auto idx = ptToIdx(pt, columns);
|
const auto idx = ptToIdx(pt, columns);
|
||||||
setPixel(pixels, pBpp, idx, palIdx);
|
setPixel(pixels, pBpp, idx, palIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPixel(TileSheet::SubSheet &ss, int8_t pBpp, ox::Point const &pt, uint8_t palIdx) noexcept {
|
void setPixel(TileSheet::SubSheet &ss, int8_t pBpp, ox::Point const&pt, uint8_t palIdx) noexcept {
|
||||||
const auto idx = ptToIdx(pt, ss.columns);
|
const auto idx = ptToIdx(pt, ss.columns);
|
||||||
setPixel(ss, pBpp, idx, palIdx);
|
setPixel(ss, pBpp, idx, palIdx);
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ unsigned pixelCnt(TileSheet::SubSheet const&ss, int8_t pBpp) noexcept {
|
|||||||
return pBpp == 4 ? pixelsSize * 2 : pixelsSize;
|
return pBpp == 4 ? pixelsSize * 2 : pixelsSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const &sz) noexcept {
|
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept {
|
||||||
ox::Vector<uint8_t> out;
|
ox::Vector<uint8_t> out;
|
||||||
oxReturnError(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile));
|
oxReturnError(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile));
|
||||||
auto const w = sz.width * TileWidth;
|
auto const w = sz.width * TileWidth;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user