Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
lines.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 <EASTL/array.h>
30#include <stdint.h>
31
33
34namespace psyqo {
35
36namespace Prim {
37
44struct Line {
45 Line() : command(0x40000000) {}
46 Line(Color c) : command(0x40000000 | c.packed) {}
48 uint32_t wasSemiTrans = command & 0x02000000;
49 command = 0x40000000 | (c.packed & 0xffffff) | wasSemiTrans;
50 return *this;
51 }
53 command &= ~0x02000000;
54 return *this;
55 }
57 command |= 0x02000000;
58 return *this;
59 }
60
61 private:
62 uint32_t command;
63
64 public:
67};
68static_assert(sizeof(Line) == sizeof(uint32_t) * 3, "Line is not 3 words");
69
80 GouraudLine() : command(0x50000000) {}
81 GouraudLine(Color c) : command(0x50000000 | c.packed) {}
83 uint32_t wasSemiTrans = command & 0x02000000;
84 command = 0x50000000 | (c.packed & 0xffffff) | wasSemiTrans;
85 return *this;
86 }
88 colorB = c;
89 return *this;
90 }
92 command &= ~0x02000000;
93 return *this;
94 }
102 uint32_t getCommandWord() const { return command & 0xff000000; }
111 command = packed;
112 return *this;
113 }
115 command |= 0x02000000;
116 return *this;
117 }
118
119 private:
120 uint32_t command;
121
122 public:
126};
127static_assert(sizeof(GouraudLine) == sizeof(uint32_t) * 4, "Line is not 4 words");
128
143 PolyLineBegin() : command(0x48000000) {}
144 PolyLineBegin(Color c) : command(0x48000000 | c.packed) {}
146 uint32_t wasSemiTrans = command & 0x02000000;
147 command = 0x48000000 | (c.packed & 0xffffff) | wasSemiTrans;
148 return *this;
149 }
151 command &= ~0x02000000;
152 return *this;
153 }
155 command |= 0x02000000;
156 return *this;
157 }
158
159 private:
160 uint32_t command;
161
162 public:
164};
165static_assert(sizeof(PolyLineBegin) == sizeof(uint32_t) * 2, "PolyLineBegin is not 2 words");
166
168 const uint32_t endMarker = 0x50005000;
169};
170
182template <unsigned N>
183struct PolyLine {
184 PolyLine() : command(0x48000000) {}
185 PolyLine(Color c) : command(0x48000000 | c.packed) {}
187 uint32_t wasSemiTrans = command & 0x02000000;
188 command = 0x48000000 | (c.packed & 0xffffff) | wasSemiTrans;
189 return *this;
190 }
192 command &= ~0x02000000;
193 return *this;
194 }
196 command |= 0x02000000;
197 return *this;
198 }
199
200 private:
201 uint32_t command;
202
203 public:
204 eastl::array<Vertex, N + 1> points;
205
206 private:
207 const uint32_t endMarker = 0x50005000;
208};
209
210} // namespace Prim
211
212} // namespace psyqo
Definition lua.hh:38
The Gouraud-shaded Line primitive.
Definition lines.hh:79
GouraudLine & setSemiTrans()
Definition lines.hh:114
uint32_t getCommandWord() const
The GP0 command word, minus any colour.
Definition lines.hh:102
GouraudLine & setOpaque()
Definition lines.hh:91
GouraudLine & setColorB(Color c)
Definition lines.hh:87
Vertex pointB
Definition lines.hh:125
GouraudLine(Color c)
Definition lines.hh:81
GouraudLine()
Definition lines.hh:80
GouraudLine & setColorAPacked(uint32_t packed)
Sets the command word and vertex A's colour in one go.
Definition lines.hh:110
Vertex pointA
Definition lines.hh:123
Color colorB
Definition lines.hh:124
GouraudLine & setColorA(Color c)
Definition lines.hh:82
The Line primitive.
Definition lines.hh:44
Vertex pointA
Definition lines.hh:65
Line & setSemiTrans()
Definition lines.hh:56
Vertex pointB
Definition lines.hh:66
Line()
Definition lines.hh:45
Line & setOpaque()
Definition lines.hh:52
Line(Color c)
Definition lines.hh:46
Line & setColor(Color c)
Definition lines.hh:47
The primitive used to begin a polyline.
Definition lines.hh:142
PolyLineBegin & setSemiTrans()
Definition lines.hh:154
PolyLineBegin(Color c)
Definition lines.hh:144
PolyLineBegin()
Definition lines.hh:143
Vertex point
Definition lines.hh:163
PolyLineBegin & setOpaque()
Definition lines.hh:150
PolyLineBegin & setColor(Color c)
Definition lines.hh:145
Definition lines.hh:167
const uint32_t endMarker
Definition lines.hh:168
The primitive used to draw a polyline.
Definition lines.hh:183
PolyLine & setSemiTrans()
Definition lines.hh:195
PolyLine(Color c)
Definition lines.hh:185
PolyLine()
Definition lines.hh:184
PolyLine & setOpaque()
Definition lines.hh:191
PolyLine & setColor(Color c)
Definition lines.hh:186
eastl::array< Vertex, N+1 > points
Definition lines.hh:204
static int c
Definition syscalls.h:122
void uint32_t(classId, spec)
The Color struct.
Definition common.hh:91
The Vertex struct.
Definition common.hh:47