|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
#include "monoformat_parseonly.hpp" |
|
|
|
|
#include "monoformat_parsehelpers.hpp" |
|
|
|
|
#include "monoformat_fontreader.hpp" |
|
|
|
|
#include "monoformat_bithelpers.hpp" |
|
|
|
|
|
|
|
|
|
#include <string_view> |
|
|
|
|
#include <string> |
|
|
|
|
@ -23,18 +22,16 @@ struct TimeBasedDrawnSectionMetaData { |
|
|
|
|
std::int64_t endTimestamp{}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
static std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
|
|
|
|
|
static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
static std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
static std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
|
|
|
|
|
|
static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSection(std::span<std::byte const>& data) { |
|
|
|
|
auto type = readU8LE(data); |
|
|
|
|
if (!type) { |
|
|
|
|
return std::unexpected(type.error()); |
|
|
|
|
@ -61,21 +58,14 @@ static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSec |
|
|
|
|
data = data.subspan(*size - 8); |
|
|
|
|
|
|
|
|
|
AlwaysDrawnSectionMetaData result; |
|
|
|
|
result.drawOnFront = isBitSet(*flags, 0); |
|
|
|
|
result.drawOnBack = isBitSet(*flags, 1); |
|
|
|
|
result.clearBeforeDrawing = isBitSet(*flags, 2); |
|
|
|
|
result.drawOnFront = (((*flags) >> 0u) & 0x01u) == 0x01u; |
|
|
|
|
result.drawOnBack = (((*flags) >> 0u) & 0x02u) == 0x02u; |
|
|
|
|
result.clearBeforeDrawing = (((*flags) >> 0u) & 0x04u) == 0x04u; |
|
|
|
|
result.elementData = sectionData; |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] AlwaysDrawnSection, drawOnFront = " << result.drawOnFront << ", drawOnBack = " << result.drawOnBack << ", clearBeforeDrawing = " << result.clearBeforeDrawing << ", element data size = " << result.elementData.size() << " bytes" << std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDrawnSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDrawnSection(std::span<std::byte const>& data) { |
|
|
|
|
auto type = readU8LE(data); |
|
|
|
|
if (!type) { |
|
|
|
|
return std::unexpected(type.error()); |
|
|
|
|
@ -110,23 +100,16 @@ static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDr |
|
|
|
|
data = data.subspan(*size - 24); |
|
|
|
|
|
|
|
|
|
TimeBasedDrawnSectionMetaData result; |
|
|
|
|
result.base.drawOnFront = isBitSet(*flags, 0); |
|
|
|
|
result.base.drawOnBack = isBitSet(*flags, 1); |
|
|
|
|
result.base.clearBeforeDrawing = isBitSet(*flags, 2); |
|
|
|
|
result.base.drawOnFront = (((*flags) >> 0u) & 0x01u) == 0x01u; |
|
|
|
|
result.base.drawOnBack = (((*flags) >> 0u) & 0x02u) == 0x02u; |
|
|
|
|
result.base.clearBeforeDrawing = (((*flags) >> 0u) & 0x04u) == 0x04u; |
|
|
|
|
result.base.elementData = sectionData; |
|
|
|
|
result.startTimestamp = std::bit_cast<std::int64_t>(*startTimestamp); |
|
|
|
|
result.endTimestamp = std::bit_cast<std::int64_t>(*endTimestamp); |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] TimeBasedDrawnSection, drawOnFront = " << result.base.drawOnFront << ", drawOnBack = " << result.base.drawOnBack << ", clearBeforeDrawing = " << result.base.clearBeforeDrawing << ", element data size = " << result.base.elementData.size() << " bytes, timestamp between " << result.startTimestamp << " and " << result.endTimestamp << std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static std::expected<std::span<std::byte const>, ParseError> parseCustomFontSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
static std::expected<std::span<std::byte const>, ParseError> parseCustomFontSection(std::span<std::byte const>& data) { |
|
|
|
|
auto type = readU8LE(data); |
|
|
|
|
if (!type) { |
|
|
|
|
return std::unexpected(type.error()); |
|
|
|
|
@ -152,10 +135,6 @@ static std::expected<std::span<std::byte const>, ParseError> parseCustomFontSect |
|
|
|
|
auto fontData = data.subspan(0, *size - 8); |
|
|
|
|
data = data.subspan(*size - 8); |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] CustomFontSection, font data size = " << *actualSize << " bytes" << std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return readBuffer(fontData, *actualSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -203,7 +182,7 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::CustomFont) { |
|
|
|
|
auto fontData = parseCustomFontSection(*rawSectionData, *version); |
|
|
|
|
auto fontData = parseCustomFontSection(*rawSectionData); |
|
|
|
|
if (!fontData) { |
|
|
|
|
return std::unexpected(fontData.error()); |
|
|
|
|
} |
|
|
|
|
@ -215,13 +194,13 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
|
|
|
|
|
|
AlwaysDrawnSectionMetaData section; |
|
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::AlwaysDrawn) { |
|
|
|
|
auto metaData = parseAlwaysDrawnSection(*rawSectionData, *version); |
|
|
|
|
auto metaData = parseAlwaysDrawnSection(*rawSectionData); |
|
|
|
|
if (!metaData) { |
|
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
|
} |
|
|
|
|
section = *metaData; |
|
|
|
|
} else if (static_cast<SectionType>(*sectionType) == SectionType::TimeBasedDrawn) { |
|
|
|
|
auto metaData = parseTimeBasedDrawnSection(*rawSectionData, *version); |
|
|
|
|
auto metaData = parseTimeBasedDrawnSection(*rawSectionData); |
|
|
|
|
if (!metaData) { |
|
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
|
} |
|
|
|
|
@ -255,14 +234,14 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
|
auto eType = static_cast<ElementType>(*type); |
|
|
|
|
std::expected<void, ParseError> parseResult; |
|
|
|
|
switch (eType) { |
|
|
|
|
case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
|
case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
|
default: parseResult = std::unexpected(ParseError::InvalidValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -275,9 +254,7 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
|
if (!type) { |
|
|
|
|
return std::unexpected(type.error()); |
|
|
|
|
@ -315,10 +292,6 @@ std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, |
|
|
|
|
buffer = buffer.subspan(rounded - imageSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - Image, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) << std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::ignore = animationTick; |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
std::ignore = customFonts; |
|
|
|
|
@ -332,8 +305,7 @@ std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
@ -373,22 +345,15 @@ std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buff |
|
|
|
|
return std::unexpected(reserved_.error()); |
|
|
|
|
} |
|
|
|
|
std::size_t imageSize = ((*width) * (*height) + 8 - 1) / 8; |
|
|
|
|
auto imageData = readBuffer(buffer, imageSize * (*numberOfFrames)); |
|
|
|
|
auto imageData = readBuffer(buffer, imageSize); |
|
|
|
|
if (!imageData) { |
|
|
|
|
return std::unexpected(reserved_.error()); |
|
|
|
|
} |
|
|
|
|
std::size_t rounded = (imageSize * (*numberOfFrames) + 4 - 1) / 4 * 4; |
|
|
|
|
if (imageSize * (*numberOfFrames) < rounded) { |
|
|
|
|
buffer = buffer.subspan(rounded - imageSize * (*numberOfFrames)); |
|
|
|
|
std::size_t rounded = (imageSize + 4 - 1) / 4 * 4; |
|
|
|
|
if (imageSize < rounded) { |
|
|
|
|
buffer = buffer.subspan(rounded - imageSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - Animation, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", numberOfFrames = " << (*numberOfFrames) |
|
|
|
|
<< ", updateInterval = " << (*updateInterval) |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (*numberOfFrames == 0) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
@ -405,8 +370,7 @@ std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buff |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
@ -462,24 +426,14 @@ std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& b |
|
|
|
|
auto ownImage = ConstMemoryOneBitBuffer{*imageData, *contentWidth, *height}; |
|
|
|
|
ClippedImage target{screen, *x, *y, *width, *height}; |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - HScrollImage, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", contentWidth = " << (*contentWidth) |
|
|
|
|
<< ", scrollSpeed = " << int(*scrollSpeed) |
|
|
|
|
<< ", flags = " << int(*flags) |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (*contentWidth == 0) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ScrollFlags scrollFlags{*flags}; |
|
|
|
|
|
|
|
|
|
bool restarting = !scrollFlags.endless; |
|
|
|
|
bool invert = scrollFlags.invertDirection; |
|
|
|
|
bool padBefore = scrollFlags.padBefore; |
|
|
|
|
bool padAfter = scrollFlags.padAfter; |
|
|
|
|
bool restarting = ((*flags) & 0x01) == 0x00; |
|
|
|
|
bool invert = ((*flags) & 0x02) == 0x02; |
|
|
|
|
bool padBefore = ((*flags) & 0x04) == 0x04; |
|
|
|
|
bool padAfter = ((*flags) & 0x08) == 0x08; |
|
|
|
|
|
|
|
|
|
if (!padBefore && !padAfter && *contentWidth < *width) { |
|
|
|
|
std::int16_t offset = invert ? (*width - *contentWidth) : 0; |
|
|
|
|
@ -571,8 +525,7 @@ std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& b |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
@ -628,24 +581,14 @@ std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& b |
|
|
|
|
auto ownImage = ConstMemoryOneBitBuffer{*imageData, *width, *contentHeight}; |
|
|
|
|
ClippedImage target{screen, *x, *y, *width, *height}; |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - VScrollImage, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", contentHeight = " << (*contentHeight) |
|
|
|
|
<< ", scrollSpeed = " << int(*scrollSpeed) |
|
|
|
|
<< ", flags = " << int(*flags) |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (*contentHeight == 0) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ScrollFlags scrollFlags{*flags}; |
|
|
|
|
|
|
|
|
|
bool restarting = !scrollFlags.endless; |
|
|
|
|
bool invert = scrollFlags.invertDirection; |
|
|
|
|
bool padBefore = scrollFlags.padBefore; |
|
|
|
|
bool padAfter = scrollFlags.padAfter; |
|
|
|
|
bool restarting = ((*flags) & 0x01) == 0x00; |
|
|
|
|
bool invert = ((*flags) & 0x02) == 0x02; |
|
|
|
|
bool padBefore = ((*flags) & 0x04) == 0x04; |
|
|
|
|
bool padAfter = ((*flags) & 0x08) == 0x08; |
|
|
|
|
|
|
|
|
|
if (!padBefore && !padAfter && *contentHeight < *height) { |
|
|
|
|
std::int16_t offset = invert ? (*height - *contentHeight) : 0; |
|
|
|
|
@ -737,8 +680,7 @@ std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& b |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = animationTick; |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
std::ignore = customFonts; |
|
|
|
|
@ -778,15 +720,6 @@ std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, O |
|
|
|
|
return std::unexpected(flags.error()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - Line, originX = " << (*originX) << ", originY = " << (*originY) << ", targetX = " << (*targetX) << ", targetY = " << (*targetY) |
|
|
|
|
<< ", lineStyle = " << int(*lineStyle) |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
LineFlags lineFlags{*flags}; |
|
|
|
|
std::ignore = lineFlags; |
|
|
|
|
|
|
|
|
|
std::int32_t dx = static_cast<std::int32_t>(*targetX) - static_cast<std::int32_t>(*originX); |
|
|
|
|
std::int32_t dy = static_cast<std::int32_t>(*targetY) - static_cast<std::int32_t>(*originY); |
|
|
|
|
bool value = true; |
|
|
|
|
@ -810,8 +743,7 @@ std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, O |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = animationTick; |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
|
|
|
|
|
@ -853,16 +785,9 @@ std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& bu |
|
|
|
|
} |
|
|
|
|
std::string_view text{reinterpret_cast<char const*>(textData->data()), *textLength}; |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - ClippedText, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", fontIndex = " << int(*fontIndex) |
|
|
|
|
<< ", text = \"" << text << "\"" |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::span<std::byte const> fontData; |
|
|
|
|
if (isBitSet(*fontIndex, 15)) { |
|
|
|
|
unsetBit(*fontIndex, 15); |
|
|
|
|
if ((*fontIndex) & 0x8000u) { |
|
|
|
|
fontIndex = (*fontIndex) & ~0x8000u; |
|
|
|
|
if (*fontIndex >= customFonts.size()) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
@ -880,8 +805,7 @@ std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& bu |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
|
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
|
@ -930,18 +854,9 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu |
|
|
|
|
} |
|
|
|
|
std::string_view text{reinterpret_cast<char const*>(textData->data()), *textLength}; |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - HScrollText, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", scrollSpeed = " << int(*scrollSpeed) |
|
|
|
|
<< ", flags = " << int(*flags) |
|
|
|
|
<< ", fontIndex = " << int(*fontIndex) |
|
|
|
|
<< ", text = \"" << text << "\"" |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::span<std::byte const> fontData; |
|
|
|
|
if (isBitSet(*fontIndex, 15)) { |
|
|
|
|
unsetBit(*fontIndex, 15); |
|
|
|
|
if ((*fontIndex) & 0x8000u) { |
|
|
|
|
fontIndex = (*fontIndex) & ~0x8000u; |
|
|
|
|
if (*fontIndex >= customFonts.size()) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
@ -965,12 +880,10 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ScrollFlags scrollFlags{*flags}; |
|
|
|
|
|
|
|
|
|
bool restarting = !scrollFlags.endless; |
|
|
|
|
bool invert = scrollFlags.invertDirection; |
|
|
|
|
bool padBefore = scrollFlags.padBefore; |
|
|
|
|
bool padAfter = scrollFlags.padAfter; |
|
|
|
|
bool restarting = ((*flags) & 0x01) == 0x00; |
|
|
|
|
bool invert = ((*flags) & 0x02) == 0x02; |
|
|
|
|
bool padBefore = ((*flags) & 0x04) == 0x04; |
|
|
|
|
bool padAfter = ((*flags) & 0x08) == 0x08; |
|
|
|
|
|
|
|
|
|
if (!padBefore && !padAfter && contentWidth < *width) { |
|
|
|
|
std::uint16_t offset = invert ? (*width - contentWidth) : 0; |
|
|
|
|
@ -1042,8 +955,7 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
|
std::ignore = animationTick; |
|
|
|
|
|
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
|
@ -1082,17 +994,9 @@ std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& bu |
|
|
|
|
return std::unexpected(flags.error()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(DEBUG) |
|
|
|
|
std::cerr << "[Debug] - CurrentTime, x = " << (*x) << ", y = " << (*y) << ", width = " << (*width) << ", height = " << (*height) |
|
|
|
|
<< ", fontIndex = " << int(*fontIndex) |
|
|
|
|
<< ", utcOffset = " << int(*utcOffset) |
|
|
|
|
<< ", flags = " << int(*flags) |
|
|
|
|
<< std::endl; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
std::span<std::byte const> fontData; |
|
|
|
|
if (isBitSet(*fontIndex, 15)) { |
|
|
|
|
unsetBit(*fontIndex, 15); |
|
|
|
|
if ((*fontIndex) & 0x8000u) { |
|
|
|
|
fontIndex = (*fontIndex) & ~0x8000u; |
|
|
|
|
if (*fontIndex >= customFonts.size()) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
@ -1105,12 +1009,10 @@ std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& bu |
|
|
|
|
} |
|
|
|
|
ClippedImage target{screen, *x, *y, *width, *height}; |
|
|
|
|
|
|
|
|
|
TimeDisplayFlags timeDisplayFlags{*flags}; |
|
|
|
|
|
|
|
|
|
bool use12h = timeDisplayFlags.use12h; |
|
|
|
|
bool showHours = timeDisplayFlags.showHours; |
|
|
|
|
bool showMinutes = timeDisplayFlags.showMinutes; |
|
|
|
|
bool showSeconds = timeDisplayFlags.showSeconds; |
|
|
|
|
bool use12h = ((*flags) & 0x01u) == 0x01u; |
|
|
|
|
bool showHours = ((*flags) & 0x02u) == 0x02u; |
|
|
|
|
bool showMinutes = ((*flags) & 0x04u) == 0x04u; |
|
|
|
|
bool showSeconds = ((*flags) & 0x08u) == 0x08u; |
|
|
|
|
if (showHours && showSeconds) { |
|
|
|
|
showMinutes = true; |
|
|
|
|
} |
|
|
|
|
|