31ES_CONST(hex, ts=TILEMAP_BLOB_MAGIC_V1)
35ES_CONST(hex, ts=TILEMAP_BLOB_MAGIC_V2)
89 auto put = [&out](
const void* p,
usize n) {
90 const u8* b =
static_cast<const u8*
>(p);
91 out.insert(out.end(), b, b + n);
94 put(fields,
sizeof(fields));
95 put(&chunkCount,
sizeof(chunkCount));
106 std::memcpy(&magic, raw,
sizeof(magic));
111 std::memcpy(fields, raw +
sizeof(
u32),
sizeof(fields));
112 out.
wrote = { fields[0], fields[1], fields[2], fields[3], fields[4] };
133 if (
id > to.
idMask)
return false;
135 if (word & from.
flipH) next =
static_cast<u16>(next | to.
flipH);
136 if (word & from.
flipV) next =
static_cast<u16>(next | to.
flipV);
137 if (word & from.
flipD) next =
static_cast<u16>(next | to.
flipD);
150 const usize perChunk =
sizeof(
i32) * 2 +
static_cast<usize>(side) * side *
sizeof(
u16);
156 std::memcpy(&cx, raw + at,
sizeof(cx));
157 std::memcpy(&cy, raw + at +
sizeof(
i32),
sizeof(cy));
158 const u8* cells = raw + at +
sizeof(
i32) * 2;
159 for (
u32 i = 0; i < side * side; ++i) {
161 std::memcpy(&word, cells +
static_cast<usize>(i) *
sizeof(
u16),
sizeof(word));
163 emit(
static_cast<i32>(cx *
static_cast<i32>(side) +
static_cast<i32>(i % side)),
164 static_cast<i32>(cy *
static_cast<i32>(side) +
static_cast<i32>(i / side)), word);
Reflection and metadata system for automatic binding generation.
#define ES_CONST(...)
Mark a constant that CROSSES the boundary, so EHT emits its TS twin.
Core type definitions and utilities for ESEngine.
bool recodeCell(u16 word, const CellEncoding &from, const CellEncoding &to, u16 &out)
static constexpr u32 V1_CHUNK_SIZE
static constexpr u32 BLOB_MAGIC_V1
i32 floorMod(i32 a, i32 b)
bool parseBlobHeader(const u8 *raw, usize size, BlobHeader &out)
static constexpr u16 V1_TILE_FLIP_V
static constexpr u32 CHUNK_SIZE
void appendBlobHeader(std::vector< u8 > &out, u32 chunkCount)
i32 floorDiv(i32 a, i32 b)
static constexpr u16 V1_TILE_ID_MASK
static constexpr u16 TILE_FLIP_D
static constexpr u16 TILE_FLIP_H
constexpr usize BLOB_HEADER_V2_BYTES
constexpr usize BLOB_HEADER_V1_BYTES
static constexpr u16 EMPTY_TILE
static constexpr u32 BLOB_MAGIC_V2
CellEncoding runningEncoding()
static constexpr u16 TILE_FLIP_V
static constexpr u16 V1_TILE_FLIP_H
static constexpr u16 TILE_ID_MASK
CellEncoding v1Encoding()
static constexpr u16 V1_TILE_FLIP_D
bool walkBlobCells(const u8 *raw, usize size, const BlobHeader &header, Fn &&emit)
std::int32_t i32
Signed 32-bit integer.
std::size_t usize
Size type for indexing and sizes.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
std::uint16_t u16
Unsigned 16-bit integer.
bool operator==(const CellEncoding &o) const