1#ifndef YAZE_ZELDA3_GRAPHICS_SHEET_STORE_H
2#define YAZE_ZELDA3_GRAPHICS_SHEET_STORE_H
10#include "absl/status/status.h"
11#include "absl/types/span.h"
49 absl::Span<const uint8_t>
Sheet(uint16_t sheet)
const;
52 uint64_t
Revision(uint16_t sheet)
const;
58 uint8_t max_index = 0x0F);
83 uint8_t
Get(
int x,
int y)
const;
86 bool Set(
int x,
int y, uint8_t index);
90 absl::Span<const uint8_t>
pixels()
const;
GraphicsSheetStore * store_
void Commit()
Bumps the revision once if any pixel changed since the last commit.
bool Set(int x, int y, uint8_t index)
Edit(GraphicsSheetStore &store, uint16_t sheet)
ok() is false when store does not hold sheet.
Edit & operator=(const Edit &)=delete
static constexpr int width()
absl::Span< const uint8_t > pixels() const
The sheet now, including uncommitted pixels.
Edit(const Edit &)=delete
std::vector< uint8_t > before_
const std::vector< uint8_t > & before() const
The sheet as it was when the Edit began.
uint8_t Get(int x, int y) const
The pixel at (x, y), or 0 outside the sheet.
static constexpr int height()
std::vector< uint8_t > pixels_
void MarkAllSheetsChanged()
Call after the loader refills the buffer: bumps every revision.
bool HasSheet(uint16_t sheet) const
True when the buffer holds all 4096 bytes of sheet.
void Clear()
Empties the buffer and bumps every revision.
const std::vector< uint8_t > & pixels() const
uint64_t Revision(uint16_t sheet) const
static constexpr uint16_t kSheetCount
std::array< uint64_t, kSheetCount > revisions_
absl::Span< const uint8_t > Sheet(uint16_t sheet) const
The sheet's 4096 pixels, or an empty span when it is not held.
absl::Status WriteSheet(uint16_t sheet, absl::Span< const uint8_t > pixels, uint8_t max_index=0x0F)
static constexpr size_t kSheetWidth
static constexpr size_t kSheetBytes
static constexpr size_t kSheetHeight
std::vector< uint8_t > & mutable_pixels()
For the graphics_buffer alias and the loader only.
GraphicsSheetStoreHolder & operator=(const GraphicsSheetStoreHolder &other)
GraphicsSheetStoreHolder()=default
GraphicsSheetStoreHolder(GraphicsSheetStoreHolder &&other) noexcept
GraphicsSheetStoreHolder & operator=(GraphicsSheetStoreHolder &&other) noexcept
GraphicsSheetStoreHolder(const GraphicsSheetStoreHolder &other)
std::vector< uint8_t > & graphics_buffer
Legacy name for sheet_store.mutable_pixels().
GraphicsSheetStore sheet_store