@@ -142,6 +142,34 @@ struct TexInfo {
142
142
};
143
143
static_assert (sizeof (TexInfo) == sizeof (uint32_t ), " TexInfo is not 32 bits" );
144
144
145
+ struct TPageAttr ;
146
+ /* *
147
+ * @brief A primitive's tpage location.
148
+ *
149
+ * @details This represents the location of a texture page in the VRAM space, and is
150
+ * used in the `TPageAttr` struct. This can be used to easily set the page location
151
+ * in a primitive's attribute while keeping the other attributes intact.
152
+ */
153
+ struct TPageLoc {
154
+ TPageLoc& setPageX (uint8_t x) {
155
+ info &= ~0x000f ;
156
+ x &= 0x000f ;
157
+ info |= x;
158
+ return *this ;
159
+ }
160
+ TPageLoc& setPageY (uint8_t y) {
161
+ info &= ~0x0010 ;
162
+ y &= 0x0001 ;
163
+ info |= y << 4 ;
164
+ return *this ;
165
+ }
166
+
167
+ private:
168
+ uint8_t info = 0 ;
169
+ friend struct TPageAttr ;
170
+ };
171
+ static_assert (sizeof (TPageLoc) == sizeof (uint8_t ), " TPageLoc is not 8 bits" );
172
+
145
173
/* *
146
174
* @brief A primitive's tpage attribute.
147
175
*
@@ -156,6 +184,21 @@ static_assert(sizeof(TexInfo) == sizeof(uint32_t), "TexInfo is not 32 bits");
156
184
* as the compiler will better optimize the former sequence of operations.
157
185
*/
158
186
struct TPageAttr {
187
+ TPageAttr () {}
188
+ TPageAttr (TPageAttr&& other) : info(other.info) {}
189
+ TPageAttr (const TPageAttr& other) : info(other.info) {}
190
+ TPageAttr& operator =(TPageAttr&& other) {
191
+ info = other.info ;
192
+ return *this ;
193
+ }
194
+ TPageAttr& operator =(const TPageAttr& other) {
195
+ info = other.info ;
196
+ return *this ;
197
+ }
198
+ TPageAttr& copy (const TPageAttr& other) {
199
+ info = other.info ;
200
+ return *this ;
201
+ }
159
202
TPageAttr& setPageX (uint8_t x) {
160
203
info &= ~0x000f ;
161
204
x &= 0x000f ;
@@ -168,6 +211,11 @@ struct TPageAttr {
168
211
info |= y << 4 ;
169
212
return *this ;
170
213
}
214
+ TPageAttr& setPageLoc (TPageLoc loc) {
215
+ info &= ~0x001f ;
216
+ info |= loc.info ;
217
+ return *this ;
218
+ }
171
219
TPageAttr& set (Prim::TPageAttr::SemiTrans trans) {
172
220
info &= ~0x0060 ;
173
221
uint32_t t = static_cast <uint32_t >(trans);
@@ -196,6 +244,17 @@ struct TPageAttr {
196
244
info |= 0x0400 ;
197
245
return *this ;
198
246
}
247
+ uint8_t getPageX () const { return info & 0x000f ; }
248
+ uint8_t getPageY () const { return (info >> 4 ) & 0x0001 ; }
249
+ uint8_t getPageLoc () const { return info & 0x001f ; }
250
+ Prim::TPageAttr::SemiTrans getSemiTrans () const {
251
+ return static_cast <Prim::TPageAttr::SemiTrans>((info >> 5 ) & 0x0003 );
252
+ }
253
+ Prim::TPageAttr::ColorMode getColorMode () const {
254
+ return static_cast <Prim::TPageAttr::ColorMode>((info >> 7 ) & 0x0003 );
255
+ }
256
+ bool hasDithering () const { return (info & 0x0200 ) != 0 ; }
257
+ bool isDisplayAreaEnabled () const { return (info & 0x0400 ) != 0 ; }
199
258
200
259
private:
201
260
uint16_t info = 0 ;
0 commit comments