[nostalgia/core] Add a setSprite function that takes a Sprite type

This commit is contained in:
Gary Talent 2021-01-22 22:39:31 -06:00
parent c1239b5656
commit 9db256699d

View File

@ -50,14 +50,14 @@ struct NostalgiaGraphic {
};
template<typename T>
ox::Error model(T *io, NostalgiaPalette *pal) {
constexpr ox::Error model(T *io, NostalgiaPalette *pal) {
io->template setTypeInfo<NostalgiaPalette>();
oxReturnError(io->field("colors", &pal->colors));
return OxError(0);
}
template<typename T>
ox::Error model(T *io, NostalgiaGraphic *ng) {
constexpr ox::Error model(T *io, NostalgiaGraphic *ng) {
io->template setTypeInfo<NostalgiaGraphic>();
oxReturnError(io->field("bpp", &ng->bpp));
oxReturnError(io->field("rows", &ng->rows));
@ -68,6 +68,16 @@ ox::Error model(T *io, NostalgiaGraphic *ng) {
return OxError(0);
}
struct Sprite {
unsigned idx = 0;
unsigned x = 0;
unsigned y = 0;
unsigned tileIdx = 0;
unsigned spriteShape = 0;
unsigned spriteSize = 0;
unsigned flipX = 0;
};
ox::Error initGfx(Context *ctx);
ox::Error shutdownGfx(Context*);
@ -133,4 +143,8 @@ void hideSprite(Context*, unsigned);
void setSprite(Context*, unsigned idx, unsigned x, unsigned y, unsigned tileIdx, unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0);
inline void setSprite(Context *c, const Sprite &s) {
setSprite(c, s.idx, s.x, s.y, s.tileIdx, s.spriteShape, s.spriteSize, s.flipX);
}
}