[nostalgia/core] Fix clang-tidy warnings
This commit is contained in:
parent
ea55a33b60
commit
a049861f3a
@ -7,7 +7,7 @@
|
|||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
// map ASCII values to the nostalgia charset
|
// map ASCII values to the nostalgia charset
|
||||||
char charMap[128] = {
|
ox::Array<char, 128> charMap = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <ox/std/array.hpp>
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
#include <ox/model/def.hpp>
|
#include <ox/model/def.hpp>
|
||||||
|
|
||||||
#include <nostalgia/geo/point.hpp>
|
#include <nostalgia/geo/point.hpp>
|
||||||
#include <nostalgia/geo/size.hpp>
|
#include <nostalgia/geo/size.hpp>
|
||||||
|
|
||||||
@ -15,7 +17,7 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
extern char charMap[128];
|
extern ox::Array<char, 128> charMap;
|
||||||
|
|
||||||
class Drawer {
|
class Drawer {
|
||||||
public:
|
public:
|
||||||
@ -92,7 +94,8 @@ struct TileSheet {
|
|||||||
other.rows = 0;
|
other.rows = 0;
|
||||||
}
|
}
|
||||||
constexpr SubSheet(const char *pName, int pColumns, int pRows, int bpp) noexcept:
|
constexpr SubSheet(const char *pName, int pColumns, int pRows, int bpp) noexcept:
|
||||||
name(pName), columns(pColumns), rows(pRows), pixels(static_cast<std::size_t>(columns * rows * PixelsPerTile) / (bpp == 4 ? 2u : 1u)) {
|
name(pName), columns(pColumns), rows(pRows),
|
||||||
|
pixels(static_cast<std::size_t>(columns * rows * PixelsPerTile) / (bpp == 4 ? 2u : 1u)) {
|
||||||
}
|
}
|
||||||
constexpr SubSheet(const char *pName, int pColumns, int pRows, ox::Vector<uint8_t> pPixels) noexcept:
|
constexpr SubSheet(const char *pName, int pColumns, int pRows, ox::Vector<uint8_t> pPixels) noexcept:
|
||||||
name(pName), columns(pColumns), rows(pRows), pixels(std::move(pPixels)) {
|
name(pName), columns(pColumns), rows(pRows), pixels(std::move(pPixels)) {
|
||||||
@ -125,7 +128,7 @@ struct TileSheet {
|
|||||||
* Reads all pixels of this sheet or its children into the given pixel list
|
* Reads all pixels of this sheet or its children into the given pixel list
|
||||||
* @param pixels
|
* @param pixels
|
||||||
*/
|
*/
|
||||||
void readPixelsTo(ox::Vector<uint8_t> *pPixels, int8_t bpp) const noexcept {
|
constexpr void readPixelsTo(ox::Vector<uint8_t> *pPixels, int8_t bpp) const noexcept {
|
||||||
if (subsheets.size()) {
|
if (subsheets.size()) {
|
||||||
for (auto &s: subsheets) {
|
for (auto &s: subsheets) {
|
||||||
s.readPixelsTo(pPixels);
|
s.readPixelsTo(pPixels);
|
||||||
@ -148,7 +151,7 @@ struct TileSheet {
|
|||||||
* Reads all pixels of this sheet or its children into the given pixel list
|
* Reads all pixels of this sheet or its children into the given pixel list
|
||||||
* @param pixels
|
* @param pixels
|
||||||
*/
|
*/
|
||||||
void readPixelsTo(ox::Vector<uint8_t> *pPixels) const noexcept {
|
constexpr void readPixelsTo(ox::Vector<uint8_t> *pPixels) const noexcept {
|
||||||
if (subsheets.size()) {
|
if (subsheets.size()) {
|
||||||
for (auto &s: subsheets) {
|
for (auto &s: subsheets) {
|
||||||
s.readPixelsTo(pPixels);
|
s.readPixelsTo(pPixels);
|
||||||
@ -217,14 +220,19 @@ struct TileSheet {
|
|||||||
|
|
||||||
constexpr auto walkPixels(int8_t pBpp, auto callback) const noexcept {
|
constexpr auto walkPixels(int8_t pBpp, auto callback) const noexcept {
|
||||||
if (pBpp == 4) {
|
if (pBpp == 4) {
|
||||||
for (std::size_t i = 0; i < pixels.size(); ++i) {
|
const auto pixelCnt = ox::min<std::size_t>(static_cast<std::size_t>(columns * rows * PixelsPerTile) / 2,
|
||||||
|
pixels.size());
|
||||||
|
//oxAssert(pixels.size() == pixelCnt, "Pixel count does not match rows and columns");
|
||||||
|
for (std::size_t i = 0; i < pixelCnt; ++i) {
|
||||||
const auto colorIdx1 = pixels[i] & 0xF;
|
const auto colorIdx1 = pixels[i] & 0xF;
|
||||||
const auto colorIdx2 = pixels[i] >> 4;
|
const auto colorIdx2 = pixels[i] >> 4;
|
||||||
callback(i * 2 + 0, colorIdx1);
|
callback(i * 2 + 0, colorIdx1);
|
||||||
callback(i * 2 + 1, colorIdx2);
|
callback(i * 2 + 1, colorIdx2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (std::size_t i = 0; i < pixels.size(); ++i) {
|
const auto pixelCnt = ox::min<std::size_t>(static_cast<std::size_t>(columns * rows * PixelsPerTile),
|
||||||
|
pixels.size());
|
||||||
|
for (std::size_t i = 0; i < pixelCnt; ++i) {
|
||||||
const auto p = pixels[i];
|
const auto p = pixels[i];
|
||||||
callback(i, p);
|
callback(i, p);
|
||||||
}
|
}
|
||||||
@ -334,7 +342,8 @@ struct TileSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr static const auto &getSubSheet(const SubSheetIdx &idx, std::size_t idxIt, const SubSheet *pSubsheet) noexcept {
|
constexpr static const auto &getSubSheet(const SubSheetIdx &idx, std::size_t idxIt,
|
||||||
|
const SubSheet *pSubsheet) noexcept {
|
||||||
if (idxIt == idx.size()) {
|
if (idxIt == idx.size()) {
|
||||||
return *pSubsheet;
|
return *pSubsheet;
|
||||||
}
|
}
|
||||||
@ -502,7 +511,8 @@ void setBgCbb(Context *ctx, unsigned bgIdx, unsigned cbb) noexcept;
|
|||||||
/**
|
/**
|
||||||
* @param section describes which section of the selected TileSheetSpace to use (e.g. MEM_PALLETE_BG[section])
|
* @param section describes which section of the selected TileSheetSpace to use (e.g. MEM_PALLETE_BG[section])
|
||||||
*/
|
*/
|
||||||
ox::Error loadBgTileSheet(Context *ctx, unsigned cbb, const ox::FileAddress &tilesheet, const ox::FileAddress &palette = nullptr) noexcept;
|
ox::Error loadBgTileSheet(Context *ctx, unsigned cbb, const ox::FileAddress &tilesheet,
|
||||||
|
const ox::FileAddress &palette = nullptr) noexcept;
|
||||||
|
|
||||||
ox::Error loadSpriteTileSheet(Context *ctx,
|
ox::Error loadSpriteTileSheet(Context *ctx,
|
||||||
unsigned section,
|
unsigned section,
|
||||||
@ -517,7 +527,8 @@ void clearTileLayer(Context *ctx, unsigned bgIdx) noexcept;
|
|||||||
|
|
||||||
void hideSprite(Context *ctx, unsigned) noexcept;
|
void hideSprite(Context *ctx, unsigned) noexcept;
|
||||||
|
|
||||||
void setSprite(Context *ctx, unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0) noexcept;
|
void setSprite(Context *ctx, unsigned idx, unsigned x, unsigned y, unsigned tileIdx,
|
||||||
|
unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0) noexcept;
|
||||||
|
|
||||||
void setSprite(Context *ctx, const Sprite &s) noexcept;
|
void setSprite(Context *ctx, const Sprite &s) noexcept;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user