Header.h
Go to the documentation of this file.
1 /****
2  * Header.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: May 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "Command.h"
25 #include "Registers.h"
26 
27 namespace Graphics
28 {
29 namespace Drawing
30 {
34 #pragma pack(1)
35 union Header {
36  enum class Type : uint8_t {
37  uint8,
38  uint16,
39  uint32,
40  resource,
41  };
42  enum class DataType : uint8_t {
43  charArray,
44  };
45  enum class ResourceKind : uint8_t {
46  text,
47  image,
48  };
49  // type = uint8, uint16, uint32
50  struct {
51  uint8_t index : 4;
52  Type type : 2;
53  OpCode opcode : 2;
54  uint32_t param;
55  };
57  enum class LengthSize : uint8_t {
58  uint8,
59  uint16,
60  };
61  // type = resource
62  struct {
66  Type type : 2;
67  OpCode opcode : 2;
69  Command cmd : 6;
70 };
71 #pragma pack()
72 
73 static_assert(sizeof(Header) == 5, "Header wrong size");
74 
75 } // namespace Drawing
76 } // namespace Graphics
Command
Definition: Graphics/src/include/Graphics/Drawing/Command.h:84
OpCode
Definition: Registers.h:51
Definition: Virtual.h:31
Command header structure.
Definition: Header.h:35
uint8_t index
Register index.
Definition: Header.h:51
ResourceKind kind
Definition: Header.h:63
DataType dataType
Definition: Header.h:65
Type
Definition: Header.h:36
ResourceKind
Definition: Header.h:45
Command cmd
Definition: Header.h:69
DataType
Definition: Header.h:42
OpCode opcode
Operation to perform.
Definition: Header.h:53
LengthSize
Definition: Header.h:57
struct Graphics::Drawing::Header::@69 resource
Type type
Definition: Header.h:52
LengthSize lengthSize
Definition: Header.h:64
uint32_t param
Definition: Header.h:54