[nostalgia/core/studio] Add scrolling support to TileSheetEditor
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
#include <nostalgia/common/point.hpp>
|
||||
#include <nostalgia/common/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
#include "ptidxconv.hpp"
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
@@ -36,6 +38,46 @@ struct NostalgiaGraphic {
|
||||
ox::FileAddress defaultPalette;
|
||||
NostalgiaPalette pal;
|
||||
ox::Vector<uint8_t> pixels;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel4Bpp(const common::Point &pt) const noexcept {
|
||||
oxAssert(bpp == 4, "NostalgiaGraphic::getPixel4Bpp: wrong bpp");
|
||||
const auto idx = ptToIdx(pt, this->columns);
|
||||
if (idx & 1) {
|
||||
return this->pixels[idx / 2];
|
||||
} else {
|
||||
return this->pixels[idx / 2];
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel8Bpp(const common::Point &pt) const noexcept {
|
||||
oxAssert(bpp == 8, "NostalgiaGraphic::getPixel8Bpp: wrong bpp");
|
||||
const auto idx = ptToIdx(pt, this->columns);
|
||||
return this->pixels[idx];
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel(const common::Point &pt) const noexcept {
|
||||
if (this->bpp == 4) {
|
||||
return getPixel4Bpp(pt);
|
||||
} else {
|
||||
return getPixel8Bpp(pt);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void setPixel(const common::Point &pt, uint8_t palIdx) noexcept {
|
||||
const auto idx = ptToIdx(pt, this->columns);
|
||||
if (bpp == 4) {
|
||||
if (idx & 1) {
|
||||
pixels[idx / 2] &= 0b0000'1111 | (palIdx << 4);
|
||||
} else {
|
||||
pixels[idx / 2] &= 0b1111'0000 | (palIdx);
|
||||
}
|
||||
} else {
|
||||
this->pixels[idx] = palIdx;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
oxModelBegin(NostalgiaPalette)
|
||||
|
||||
Reference in New Issue
Block a user