Nugget
Loading...
Searching...
No Matches
rectangles.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2022 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdint.h>
30
32
33namespace psyqo {
34
35namespace Prim {
36
46struct Rectangle {
47 static constexpr uint32_t BASE = 0b011'00'0 << 26;
48 Rectangle() : command(BASE) {}
49 Rectangle(Color c) : command(BASE | c.packed) {}
51 uint32_t wasSemiTrans = command & 0x02000000;
52 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
53 return *this;
54 }
56 command &= ~0x02000000;
57 return *this;
58 }
60 command |= 0x02000000;
61 return *this;
62 }
63
64 private:
65 uint32_t command;
66
67 public:
70};
71static_assert(sizeof(Rectangle) == (sizeof(uint32_t) * 3), "Rectangle is not 3 words");
72
81struct Pixel {
82 static constexpr uint32_t BASE = 0b011'01'0 << 26;
83 Pixel() : command(BASE) {}
84 Pixel(Color c) : command(BASE | c.packed) {}
86 uint32_t wasSemiTrans = command & 0x02000000;
87 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
88 return *this;
89 }
91 command &= ~0x02000000;
92 return *this;
93 }
95 command |= 0x02000000;
96 return *this;
97 }
98
99 private:
100 uint32_t command;
101
102 public:
104};
105static_assert(sizeof(Pixel) == (sizeof(uint64_t)), "Pixel is not 64 bits");
106
116 static constexpr uint32_t BASE = 0b011'10'0 << 26;
117 Rectangle8x8() : command(BASE) {}
118 Rectangle8x8(Color c) : command(BASE | c.packed) {}
120 uint32_t wasSemiTrans = command & 0x02000000;
121 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
122 return *this;
123 }
125 command &= ~0x02000000;
126 return *this;
127 }
129 command |= 0x02000000;
130 return *this;
131 }
132
133 private:
134 uint32_t command;
135
136 public:
138};
139static_assert(sizeof(Rectangle8x8) == (sizeof(uint64_t)), "Rectangle8x8 is not 64 bits");
140
150 static constexpr uint32_t BASE = 0b011'11'0 << 26;
151 Rectangle16x16() : command(BASE) {}
152 Rectangle16x16(Color c) : command(BASE | c.packed) {}
154 uint32_t wasSemiTrans = command & 0x02000000;
155 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
156 return *this;
157 }
159 command &= ~0x02000000;
160 return *this;
161 }
163 command |= 0x02000000;
164 return *this;
165 }
166
167 private:
168 uint32_t command;
169
170 public:
172};
173static_assert(sizeof(Rectangle16x16) == (sizeof(uint64_t)), "Rectangle16x16 is not 64 bits");
174
175} // namespace Prim
176
177} // namespace psyqo
Definition cdrom-loader.hh:39
The Pixel primitive.
Definition rectangles.hh:81
Pixel & setSemiTrans()
Definition rectangles.hh:94
Pixel()
Definition rectangles.hh:83
Pixel & setOpaque()
Definition rectangles.hh:90
Pixel(Color c)
Definition rectangles.hh:84
static constexpr uint32_t BASE
Definition rectangles.hh:82
Vertex position
Definition rectangles.hh:103
Pixel & setColor(Color c)
Definition rectangles.hh:85
The 16x16 Rectangle primitive.
Definition rectangles.hh:149
Rectangle16x16 & setSemiTrans()
Definition rectangles.hh:162
Rectangle16x16()
Definition rectangles.hh:151
Rectangle16x16 & setOpaque()
Definition rectangles.hh:158
Rectangle16x16(Color c)
Definition rectangles.hh:152
static constexpr uint32_t BASE
Definition rectangles.hh:150
Vertex position
Definition rectangles.hh:171
Rectangle16x16 & setColor(Color c)
Definition rectangles.hh:153
The 8x8 Rectangle primitive.
Definition rectangles.hh:115
Rectangle8x8(Color c)
Definition rectangles.hh:118
static constexpr uint32_t BASE
Definition rectangles.hh:116
Rectangle8x8 & setSemiTrans()
Definition rectangles.hh:128
Rectangle8x8 & setOpaque()
Definition rectangles.hh:124
Rectangle8x8()
Definition rectangles.hh:117
Rectangle8x8 & setColor(Color c)
Definition rectangles.hh:119
Vertex position
Definition rectangles.hh:137
The Rectangle primitive.
Definition rectangles.hh:46
Rectangle & setColor(Color c)
Definition rectangles.hh:50
Rectangle(Color c)
Definition rectangles.hh:49
Vertex size
Definition rectangles.hh:69
static constexpr uint32_t BASE
Definition rectangles.hh:47
Rectangle & setSemiTrans()
Definition rectangles.hh:59
Rectangle()
Definition rectangles.hh:48
Vertex position
Definition rectangles.hh:68
Rectangle & setOpaque()
Definition rectangles.hh:55
static int c
Definition syscalls.h:121
void uint32_t(classId, spec)
The Color struct.
Definition common.hh:91
The Vertex struct.
Definition common.hh:47