Nugget
control.hh
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2022 PCSX-Redux authors
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 
27 #pragma once
28 
29 #include <stdint.h>
30 
31 #include "psyqo/primitives/common.hh"
32 
33 namespace psyqo {
34 
35 namespace Prim {
36 
37 struct TPage {
38  TPage() : command(0xe100) {}
39  TPageAttr attr;
40 
41  private:
42  uint16_t command;
43 };
44 static_assert(sizeof(TPage) == sizeof(uint32_t), "TPage is not 32 bits");
45 
55  DrawingAreaStart(Vertex p) : command(0xe3000000 | p.x | (p.y << 10)) {}
56 
57  private:
58  uint32_t command;
59 };
60 static_assert(sizeof(DrawingAreaStart) == sizeof(uint32_t), "DrawingAreaStart is not 32 bits");
61 
71  DrawingAreaEnd(Vertex p) : command(0xe4000000 | (p.x - 1) | ((p.y - 1) << 10)) {}
72 
73  private:
74  uint32_t command;
75 };
76 static_assert(sizeof(DrawingAreaEnd) == sizeof(uint32_t), "DrawingAreaEnd is not 32 bits");
77 
86 struct DrawingOffset {
87  DrawingOffset(Vertex p) : command(0xe5000000 | p.x | (p.y << 11)) {}
88 
89  private:
90  uint32_t command;
91 };
92 static_assert(sizeof(DrawingOffset) == sizeof(uint32_t), "DrawingOffset is not 32 bits");
93 
104 struct Scissor {
105  DrawingAreaStart start = DrawingAreaStart(Vertex{{.x = 0, .y = 0}});
106  DrawingAreaEnd end = DrawingAreaEnd(Vertex{{.x = 1024, .y = 512}});
107  DrawingOffset offset = DrawingOffset(Vertex{{.x = 0, .y = 0}});
108 };
109 
116 struct VRAMUpload {
117  VRAMUpload() : command(0xa0000000) {}
118 
119  private:
120  uint32_t command;
121 
122  public:
123  Rect region;
124 };
125 static_assert(sizeof(VRAMUpload) == (sizeof(uint32_t) * 3), "VRAMUpload is not 96 bits");
126 
127 } // namespace Prim
128 
129 } // namespace psyqo
The DrawingAreaEnd primitive.
Definition: control.hh:70
The DrawingAreaStart primitive.
Definition: control.hh:54
The DrawingOffset primitive.
Definition: control.hh:86
A compounded Scissor primitive.
Definition: control.hh:104
A primitive's tpage attribute.
Definition: common.hh:149
Definition: control.hh:37
Initiates a VRAM upload.
Definition: control.hh:116
The Rect struct.
Definition: common.hh:74
The Vertex struct.
Definition: common.hh:47