aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxgpu/env.c
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2023-01-13 18:04:49 +0100
committerspicyjpeg <thatspicyjpeg@gmail.com>2023-01-13 18:04:49 +0100
commit3095b4571dabc8d6cee90673d679f3e77b21b164 (patch)
tree125ec0f4792fb9b9a213cbd6247e8e9518d14033 /libpsn00b/psxgpu/env.c
parent50faf92a8cb099420aa956dcac3a8105067e117c (diff)
downloadpsn00bsdk-3095b4571dabc8d6cee90673d679f3e77b21b164.tar.gz
Fix VSync() rate limiter, add missing tagless packets
Diffstat (limited to 'libpsn00b/psxgpu/env.c')
-rw-r--r--libpsn00b/psxgpu/env.c60
1 files changed, 24 insertions, 36 deletions
diff --git a/libpsn00b/psxgpu/env.c b/libpsn00b/psxgpu/env.c
index 96e065e..b90a431 100644
--- a/libpsn00b/psxgpu/env.c
+++ b/libpsn00b/psxgpu/env.c
@@ -1,6 +1,6 @@
/*
* PSn00bSDK GPU library (DRAWENV/DISPENV functions)
- * (C) 2022 spicyjpeg - MPL licensed
+ * (C) 2022-2023 spicyjpeg - MPL licensed
*/
#include <stdint.h>
@@ -60,54 +60,42 @@ DRAWENV *SetDefDrawEnv(DRAWENV *env, int x, int y, int w, int h) {
}
int DrawOTagEnv(const uint32_t *ot, DRAWENV *env) {
- DR_ENV *prim = &(env->dr_env);
-
// All commands are grouped into a single display list packet for
- // performance reasons (the GPU does not care about the grouping as the
- // display list is parsed by the DMA unit in the CPU).
+ // performance reasons using tagless primitives (the GPU does not care
+ // about the grouping as the display list is parsed by the CPU).
+ DR_ENV *prim = &(env->dr_env);
setaddr(prim, ot);
setlen(prim, 5);
// Texture page (reset active page and set dither/mask bits)
- prim->code[0] = 0xe1000000 | env->tpage;
- prim->code[0] |= (env->dtd & 1) << 9;
- prim->code[0] |= (env->dfe & 1) << 10;
+ setDrawTPage_T(&(prim->tpage), env->dfe & 1, env->dtd & 1, env->tpage);
// Texture window
- prim->code[1] = 0xe2000000;
- prim->code[1] |= _get_window_mask(env->tw.w);
- prim->code[1] |= _get_window_mask(env->tw.h) << 5;
- prim->code[1] |= (env->tw.x & 0xf8) << 7; // ((tw.x / 8) & 0x1f) << 10
- prim->code[1] |= (env->tw.y & 0xf8) << 12; // ((tw.y / 8) & 0x1f) << 15
-
- // Set drawing area top left
- prim->code[2] = 0xe3000000;
- prim->code[2] |= env->clip.x & 0x3ff;
- prim->code[2] |= (env->clip.y & 0x3ff) << 10;
-
- // Set drawing area bottom right
- prim->code[3] = 0xe4000000;
- prim->code[3] |= (env->clip.x + (env->clip.w - 1)) & 0x3ff;
- prim->code[3] |= ((env->clip.y + (env->clip.h - 1)) & 0x3ff) << 10;
-
- // Set drawing offset
- prim->code[4] = 0xe5000000;
- prim->code[4] |= (env->clip.x + env->ofs[0]) & 0x7ff;
- prim->code[4] |= ((env->clip.y + env->ofs[1]) & 0x7ff) << 11;
+ //setTexWindow_T(&(prim->twin), &(env->tw));
+ prim->twin.code[0] = 0xe2000000;
+ prim->twin.code[0] |= _get_window_mask(env->tw.w);
+ prim->twin.code[0] |= _get_window_mask(env->tw.h) << 5;
+ prim->twin.code[0] |= (env->tw.x & 0xf8) << 7; // ((tw.x / 8) & 0x1f) << 10
+ prim->twin.code[0] |= (env->tw.y & 0xf8) << 12; // ((tw.y / 8) & 0x1f) << 15
+
+ // Set drawing area
+ setDrawArea_T(&(prim->area), &(env->clip));
+ setDrawOffset_T(
+ &(prim->offset),
+ env->clip.x + env->ofs[0],
+ env->clip.y + env->ofs[1]
+ );
if (env->isbg) {
+ FILL_T *fill = &(prim->fill);
setlen(prim, 8);
// Rectangle fill
// FIXME: reportedly this command doesn't accept height values >511...
- prim->code[5] = 0x02000000;
- //prim->code[5] |= env->r0 | (env->g0 << 8) | (env->b0 << 16);
- //prim->code[6] = env->clip.x;
- //prim->code[6] |= env->clip.y << 16;
- prim->code[5] |= *((const uint32_t *) &(env->isbg)) >> 8;
- prim->code[6] = *((const uint32_t *) &(env->clip.x));
- prim->code[7] = env->clip.w;
- prim->code[7] |= _min(env->clip.h, 0x1ff) << 16;
+ setFill_T(fill);
+ setColor0(fill, *((const uint32_t *) &(env->isbg)) >> 8);
+ setXY0(fill, env->clip.x, env->clip.y);
+ setWH(fill, env->clip.w, _min(env->clip.h, 0x1ff));
}
return EnqueueDrawOp((void *) &DrawOTag2, (uint32_t) prim, 0, 0);