Nugget
Loading...
Searching...
No Matches
sprites.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
47struct Sprite {
48 static constexpr uint32_t BASE = 0b011'00'1 << 26;
49 Sprite() : command(BASE | 0x01000000) {}
50 Sprite(Color c) : command(BASE | c.packed) {}
52 uint32_t wasSemiTrans = command & 0x02000000;
53 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
54 return *this;
55 }
57 command &= ~0x02000000;
58 return *this;
59 }
61 command |= 0x02000000;
62 return *this;
63 }
64
65 private:
66 uint32_t command;
67
68 public:
72};
73static_assert(sizeof(Sprite) == (sizeof(uint32_t) * 4), "Sprite is not 128 bits");
74
84struct Sprite1x1 {
85 static constexpr uint32_t BASE = 0b011'01'1 << 26;
86 Sprite1x1() : command(BASE | 0x01000000) {}
87 Sprite1x1(Color c) : command(BASE | c.packed) {}
89 uint32_t wasSemiTrans = command & 0x02000000;
90 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
91 return *this;
92 }
94 command &= ~0x02000000;
95 return *this;
96 }
98 command |= 0x02000000;
99 return *this;
100 }
101
102 private:
103 uint32_t command;
104
105 public:
108};
109static_assert(sizeof(Sprite1x1) == (sizeof(uint32_t) * 3), "Sprite1x1 is not 3 words");
110
120struct Sprite8x8 {
121 static constexpr uint32_t BASE = 0b011'10'1 << 26;
122 Sprite8x8() : command(BASE | 0x01000000) {}
123 Sprite8x8(Color c) : command(BASE | c.packed) {}
125 uint32_t wasSemiTrans = command & 0x02000000;
126 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
127 return *this;
128 }
130 command &= ~0x02000000;
131 return *this;
132 }
134 command |= 0x02000000;
135 return *this;
136 }
137
138 private:
139 uint32_t command;
140
141 public:
144};
145static_assert(sizeof(Sprite8x8) == (sizeof(uint32_t) * 3), "Sprite8x8 is not 3 words");
146
157 static constexpr uint32_t BASE = 0b011'11'1 << 26;
158 Sprite16x16() : command(BASE | 0x01000000) {}
159 Sprite16x16(Color c) : command(BASE | c.packed) {}
161 uint32_t wasSemiTrans = command & 0x02000000;
162 command = BASE | (c.packed & 0xffffff) | wasSemiTrans;
163 return *this;
164 }
166 command &= ~0x02000000;
167 return *this;
168 }
170 command |= 0x02000000;
171 return *this;
172 }
173
174 private:
175 uint32_t command;
176
177 public:
180};
181static_assert(sizeof(Sprite16x16) == (sizeof(uint32_t) * 3), "Sprite16x16 is not 3 words");
182
183} // namespace Prim
184
185} // namespace psyqo
Definition cdrom-loader.hh:39
A primitive's texture information.
Definition common.hh:138
The 16x16 Sprite primitive.
Definition sprites.hh:156
Sprite16x16 & setOpaque()
Definition sprites.hh:165
static constexpr uint32_t BASE
Definition sprites.hh:157
Vertex position
Definition sprites.hh:178
PrimPieces::TexInfo texInfo
Definition sprites.hh:179
Sprite16x16 & setColor(Color c)
Definition sprites.hh:160
Sprite16x16 & setSemiTrans()
Definition sprites.hh:169
Sprite16x16()
Definition sprites.hh:158
Sprite16x16(Color c)
Definition sprites.hh:159
The 1x1 Sprite primitive.
Definition sprites.hh:84
Sprite1x1 & setColor(Color c)
Definition sprites.hh:88
PrimPieces::TexInfo texInfo
Definition sprites.hh:107
Sprite1x1 & setSemiTrans()
Definition sprites.hh:97
Sprite1x1 & setOpaque()
Definition sprites.hh:93
static constexpr uint32_t BASE
Definition sprites.hh:85
Sprite1x1()
Definition sprites.hh:86
Vertex position
Definition sprites.hh:106
Sprite1x1(Color c)
Definition sprites.hh:87
The 8x8 Sprite primitive.
Definition sprites.hh:120
PrimPieces::TexInfo texInfo
Definition sprites.hh:143
Sprite8x8()
Definition sprites.hh:122
Vertex position
Definition sprites.hh:142
Sprite8x8(Color c)
Definition sprites.hh:123
Sprite8x8 & setOpaque()
Definition sprites.hh:129
Sprite8x8 & setColor(Color c)
Definition sprites.hh:124
static constexpr uint32_t BASE
Definition sprites.hh:121
Sprite8x8 & setSemiTrans()
Definition sprites.hh:133
The Sprite primitive.
Definition sprites.hh:47
Sprite & setOpaque()
Definition sprites.hh:56
Vertex position
Definition sprites.hh:69
Sprite & setSemiTrans()
Definition sprites.hh:60
Sprite(Color c)
Definition sprites.hh:50
PrimPieces::TexInfo texInfo
Definition sprites.hh:70
Vertex size
Definition sprites.hh:71
Sprite & setColor(Color c)
Definition sprites.hh:51
static constexpr uint32_t BASE
Definition sprites.hh:48
Sprite()
Definition sprites.hh:49
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