aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/include
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-12-28 14:27:34 +0100
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-12-28 14:27:34 +0100
commit50faf92a8cb099420aa956dcac3a8105067e117c (patch)
treefa817a7419bc06aee432fa9e608b173d628c3b5d /libpsn00b/include
parent7e350980d5c09bbc81a0de01bf016a87ecfc4feb (diff)
downloadpsn00bsdk-50faf92a8cb099420aa956dcac3a8105067e117c.tar.gz
Re-enable MoveImage(), add tagless primitive structs
Diffstat (limited to 'libpsn00b/include')
-rw-r--r--libpsn00b/include/psxgpu.h212
1 files changed, 111 insertions, 101 deletions
diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h
index 26e560f..4dbcc6c 100644
--- a/libpsn00b/include/psxgpu.h
+++ b/libpsn00b/include/psxgpu.h
@@ -101,9 +101,12 @@ typedef enum _GPU_VideoMode {
#define setlen(p, _len) (((P_TAG *) (p))->len = (uint8_t) (_len))
#define setaddr(p, _addr) (((P_TAG *) (p))->addr = (uint32_t) (_addr))
#define setcode(p, _code) (((P_TAG *) (p))->code = (uint8_t) (_code))
+#define setcode_T(p, _code) (((P_TAG_T *) (p))->code = (uint8_t) (_code))
+
#define getlen(p) (((P_TAG *) (p))->len)
#define getaddr(p) (((P_TAG *) (p))->addr)
#define getcode(p) (((P_TAG *) (p))->code)
+#define getcode_T(p) (((P_TAG_T *) (p))->code)
#define nextPrim(p) (void *) (0x80000000 | (((P_TAG *) (p))->addr))
#define isendprim(p) ((((P_TAG *) (p))->addr) == 0xffffff)
@@ -147,16 +150,41 @@ typedef enum _GPU_VideoMode {
#define setTile(p) setlen(p, 3), setcode(p, 0x60)
#define setLineF2(p) setlen(p, 3), setcode(p, 0x40)
#define setLineG2(p) setlen(p, 4), setcode(p, 0x50)
-#define setLineF3(p) setlen(p, 5), setcode(p, 0x48), \
- (p)->pad = 0x55555555
-#define setLineG3(p) setlen(p, 7), setcode(p, 0x58), \
- (p)->pad = 0x55555555, (p)->p1 = 0, (p)->p2 = 0
-#define setLineF4(p) setlen(p, 6), setcode(p, 0x4c), \
- (p)->pad = 0x55555555
-#define setLineG4(p) setlen(p, 9), setcode(p, 0x5c), \
- (p)->pad = 0x55555555, (p)->p1 = 0, (p)->p2 = 0, (p)->p3 = 0
-#define setFill(p) setlen(p, 3), setcode(p, 0x02)
-#define setVram2Vram(p) setlen(p, 8), setcode(p, 0x80), \
+#define setLineF3(p) setlen(p, 5), setcode(p, 0x48), (p)->pad = 0x55555555
+#define setLineG3(p) setlen(p, 7), setcode(p, 0x58), (p)->pad = 0x55555555, \
+ (p)->p1 = 0, (p)->p2 = 0
+#define setLineF4(p) setlen(p, 6), setcode(p, 0x4c), (p)->pad = 0x55555555
+#define setLineG4(p) setlen(p, 9), setcode(p, 0x5c), (p)->pad = 0x55555555, \
+ (p)->p1 = 0, (p)->p2 = 0, (p)->p3 = 0
+#define setFill(p) setlen(p, 3), setcode(p, 0x02)
+#define setBlit(p) setlen(p, 8), setcode(p, 0x80), \
+ (p)->pad[0] = 0, (p)->pad[1] = 0, (p)->pad[2] = 0, (p)->pad[3] = 0
+
+#define setPolyF3_T(p) setcode_T(p, 0x20)
+#define setPolyFT3_T(p) setcode_T(p, 0x24)
+#define setPolyG3_T(p) setcode_T(p, 0x30)
+#define setPolyGT3_T(p) setcode_T(p, 0x34)
+#define setPolyF4_T(p) setcode_T(p, 0x28)
+#define setPolyFT4_T(p) setcode_T(p, 0x2c)
+#define setPolyG4_T(p) setcode_T(p, 0x38)
+#define setPolyGT4_T(p) setcode_T(p, 0x3c)
+#define setSprt8_T(p) setcode_T(p, 0x74)
+#define setSprt16_T(p) setcode_T(p, 0x7c)
+#define setSprt_T(p) setcode_T(p, 0x64)
+#define setTile1_T(p) setcode_T(p, 0x68)
+#define setTile8_T(p) setcode_T(p, 0x70)
+#define setTile16_T(p) setcode_T(p, 0x78)
+#define setTile_T(p) setcode_T(p, 0x60)
+#define setLineF2_T(p) setcode_T(p, 0x40)
+#define setLineG2_T(p) setcode_T(p, 0x50)
+#define setLineF3_T(p) setcode_T(p, 0x48), (p)->pad = 0x55555555
+#define setLineG3_T(p) setcode_T(p, 0x58), (p)->pad = 0x55555555, \
+ (p)->p1 = 0, (p)->p2 = 0
+#define setLineF4_T(p) setcode_T(p, 0x4c), (p)->pad = 0x55555555
+#define setLineG4_T(p) setcode_T(p, 0x5c), (p)->pad = 0x55555555, \
+ (p)->p1 = 0, (p)->p2 = 0, (p)->p3 = 0
+#define setFill_T(p) setcode_T(p, 0x02)
+#define setBlit_T(p) setcode_T(p, 0x80), \
(p)->pad[0] = 0, (p)->pad[1] = 0, (p)->pad[2] = 0, (p)->pad[3] = 0
#define setDrawTPage(p, dfe, dtd, tpage) \
@@ -200,6 +228,11 @@ typedef enum _GPU_VideoMode {
/* Primitive structure definitions */
+typedef struct _P_TAG_T {
+ uint32_t color:24;
+ uint32_t code:8;
+} P_TAG_T;
+
typedef struct _P_TAG {
uint32_t addr:24;
uint32_t len:8;
@@ -212,25 +245,31 @@ typedef struct _P_COLOR {
uint32_t pad:8;
} P_COLOR;
-typedef struct _POLY_F3 {
- uint32_t tag;
+// These macros are used to define two variants of each primitive, a regular one
+// and a "tagless" one (_T suffix) without the OT/display list header.
+#define _DEF_PRIM(name, ...) \
+ typedef struct _##name##_T { __VA_ARGS__ } name##_T; \
+ typedef struct _##name { uint32_t tag; __VA_ARGS__ } name;
+#define _DEF_ALIAS(name, target) \
+ typedef struct _##target##_T name##_T; \
+ typedef struct _##target name;
+
+_DEF_PRIM(POLY_F3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t x1, y1;
int16_t x2, y2;
-} POLY_F3;
+)
-typedef struct _POLY_F4 {
- uint32_t tag;
+_DEF_PRIM(POLY_F4,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t x1, y1;
int16_t x2, y2;
int16_t x3, y3;
-} POLY_F4;
+)
-typedef struct _POLY_FT3 {
- uint32_t tag;
+_DEF_PRIM(POLY_FT3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t u0, v0;
@@ -241,10 +280,9 @@ typedef struct _POLY_FT3 {
int16_t x2, y2;
uint8_t u2, v2;
uint16_t pad;
-} POLY_FT3;
+)
-typedef struct _POLY_FT4 {
- uint32_t tag;
+_DEF_PRIM(POLY_FT4,
uint8_t r0, g0, b0, code;
uint16_t x0, y0;
uint8_t u0, v0;
@@ -258,20 +296,18 @@ typedef struct _POLY_FT4 {
int16_t x3, y3;
uint8_t u3, v3;
uint16_t pad1;
-} POLY_FT4;
+)
-typedef struct _POLY_G3 {
- uint32_t tag;
+_DEF_PRIM(POLY_G3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t r1, g1, b1, pad0;
int16_t x1, y1;
uint8_t r2, g2, b2, pad1;
int16_t x2, y2;
-} POLY_G3;
+)
-typedef struct _POLY_G4 {
- uint32_t tag;
+_DEF_PRIM(POLY_G4,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t r1, g1, b1, pad0;
@@ -280,10 +316,9 @@ typedef struct _POLY_G4 {
int16_t x2, y2;
uint8_t r3, g3, b3, pad2;
int16_t x3, y3;
-} POLY_G4;
+)
-typedef struct _POLY_GT3 {
- uint32_t tag;
+_DEF_PRIM(POLY_GT3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t u0, v0;
@@ -296,10 +331,9 @@ typedef struct _POLY_GT3 {
int16_t x2, y2;
uint8_t u2, v2;
uint16_t pad2;
-} POLY_GT3;
+)
-typedef struct _POLY_GT4 {
- uint32_t tag;
+_DEF_PRIM(POLY_GT4,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t u0, v0;
@@ -316,34 +350,30 @@ typedef struct _POLY_GT4 {
int16_t x3, y3;
uint8_t u3, v3;
uint16_t pad4;
-} POLY_GT4;
+)
-typedef struct _LINE_F2 {
- uint32_t tag;
+_DEF_PRIM(LINE_F2,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t x1, y1;
-} LINE_F2;
+)
-typedef struct _LINE_G2 {
- uint32_t tag;
+_DEF_PRIM(LINE_G2,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t r1, g1, b1, p1;
int16_t x1, y1;
-} LINE_G2;
+)
-typedef struct _LINE_F3 {
- uint32_t tag;
+_DEF_PRIM(LINE_F3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t x1, y1;
int16_t x2, y2;
uint32_t pad;
-} LINE_F3;
+)
-typedef struct _LINE_G3 {
- uint32_t tag;
+_DEF_PRIM(LINE_G3,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t r1, g1, b1, p1;
@@ -351,20 +381,18 @@ typedef struct _LINE_G3 {
uint8_t r2, g2, b2, p2;
int16_t x2, y2;
uint32_t pad;
-} LINE_G3;
+)
-typedef struct _LINE_F4 {
- uint32_t tag;
+_DEF_PRIM(LINE_F4,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t x1, y1;
int16_t x2, y2;
int16_t x3, y3;
uint32_t pad;
-} LINE_F4;
+)
-typedef struct _LINE_G4 {
- uint32_t tag;
+_DEF_PRIM(LINE_G4,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t r1, g1, b1, p1;
@@ -374,88 +402,70 @@ typedef struct _LINE_G4 {
uint8_t r3, g3, b3, p3;
int16_t x3, y3;
uint32_t pad;
-} LINE_G4;
+)
-typedef struct _TILE {
- uint32_t tag;
+_DEF_PRIM(TILE,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
int16_t w, h;
-} TILE;
+)
-struct _TILE_FIXED {
- uint32_t tag;
+_DEF_PRIM(TILE_1,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
-};
-typedef struct _TILE_FIXED TILE_1;
-typedef struct _TILE_FIXED TILE_8;
-typedef struct _TILE_FIXED TILE_16;
+)
+_DEF_ALIAS(TILE_8, TILE_1)
+_DEF_ALIAS(TILE_16, TILE_1)
-typedef struct _SPRT {
- uint32_t tag;
+_DEF_PRIM(SPRT,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t u0, v0;
uint16_t clut;
uint16_t w, h;
-} SPRT;
+)
-struct _SPRT_FIXED {
- uint32_t tag;
+_DEF_PRIM(SPRT_1,
uint8_t r0, g0, b0, code;
int16_t x0, y0;
uint8_t u0, v0;
uint16_t clut;
-};
-typedef struct _SPRT_FIXED SPRT_8;
-typedef struct _SPRT_FIXED SPRT_16;
+)
+_DEF_ALIAS(SPRT_8, SPRT_1)
+_DEF_ALIAS(SPRT_16, SPRT_1)
-typedef struct _DR_ENV {
- uint32_t tag;
+_DEF_PRIM(DR_ENV,
uint32_t code[8];
-} DR_ENV;
-
-typedef struct _DR_AREA {
- uint32_t tag;
+)
+_DEF_PRIM(DR_AREA,
uint32_t code[2];
-} DR_AREA;
-
-typedef struct _DR_OFFSET {
- uint32_t tag;
+)
+_DEF_PRIM(DR_OFFSET,
uint32_t code[1];
-} DR_OFFSET;
-
-typedef struct _DR_TWIN {
- uint32_t tag;
+)
+_DEF_PRIM(DR_TWIN,
uint32_t code[2];
-} DR_TWIN;
-
-typedef struct _DR_TPAGE {
- uint32_t tag;
+)
+_DEF_PRIM(DR_TPAGE,
uint32_t code[1];
-} DR_TPAGE;
-
-typedef struct _DR_MASK {
- uint32_t tag;
+)
+_DEF_PRIM(DR_MASK,
uint32_t code[1];
-} DR_MASK;
+)
-typedef struct _FILL {
- uint32_t tag;
+_DEF_PRIM(FILL,
uint8_t r0, g0, b0, code;
- uint16_t x0, y0; // Note: coordinates must be in 16 pixel steps
+ uint16_t x0, y0;
uint16_t w, h;
-} FILL;
+)
-typedef struct _VRAM2VRAM {
- uint32_t tag;
+_DEF_PRIM(BLIT,
uint8_t p0, p1, p2, code;
uint16_t x0, y0;
uint16_t x1, y1;
uint16_t w, h;
uint32_t pad[4];
-} VRAM2VRAM;
+)
/* Structure definitions */
@@ -536,10 +546,10 @@ void *DrawSyncCallback(void (*func)(void));
int LoadImage(const RECT *rect, const uint32_t *data);
int StoreImage(const RECT *rect, uint32_t *data);
-//int MoveImage(const RECT *rect, int x, int y);
+int MoveImage(const RECT *rect, int x, int y);
void LoadImage2(const RECT *rect, const uint32_t *data);
void StoreImage2(const RECT *rect, uint32_t *data);
-//void MoveImage2(const RECT *rect, int x, int y);
+void MoveImage2(const RECT *rect, int x, int y);
void ClearOTagR(uint32_t *ot, size_t length);
void ClearOTag(uint32_t *ot, size_t length);