diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-11-15 08:07:24 +0100 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-11-15 08:07:24 +0100 |
| commit | 85d765f30595fe7f27c1b065c5a1934c3d389cef (patch) | |
| tree | b2a30eaa7f61b8238fdcdfd33867a5e44a4efbf0 /libpsn00b/psxgpu | |
| parent | 4139331d233b7a962e747c5564fa68a285f81cc8 (diff) | |
| download | psn00bsdk-85d765f30595fe7f27c1b065c5a1934c3d389cef.tar.gz | |
Misc. libpsn00b bugfixes, new critical section macros
Diffstat (limited to 'libpsn00b/psxgpu')
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 27 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/env.c | 2 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 12 |
3 files changed, 21 insertions, 20 deletions
diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index 9f45f10..93fdb52 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -38,9 +38,6 @@ static volatile uint16_t _last_hblank; /* Private interrupt handlers */ -#define _ENTER_CRITICAL() uint16_t mask = IRQ_MASK; IRQ_MASK = 0; -#define _EXIT_CRITICAL() IRQ_MASK = mask; - static void _vblank_handler(void) { _vblank_counter++; @@ -74,8 +71,8 @@ void ResetGraph(int mode) { // the first time. if (!ResetCallback()) { EnterCriticalSection(); - InterruptCallback(0, &_vblank_handler); - DMACallback(2, &_gpu_dma_handler); + InterruptCallback(IRQ_VBLANK, &_vblank_handler); + DMACallback(DMA_GPU, &_gpu_dma_handler); _gpu_video_mode = (GPU_GP1 >> 20) & 1; ExitCriticalSection(); @@ -149,22 +146,22 @@ int VSync(int mode) { } void *VSyncHaltFunction(void (*func)(void)) { - //_ENTER_CRITICAL(); + //FastEnterCriticalSection(); void *old_callback = _vsync_halt_func; _vsync_halt_func = func; - //_EXIT_CRITICAL(); + //FastExitCriticalSection(); return old_callback; } void *VSyncCallback(void (*func)(void)) { - _ENTER_CRITICAL(); + FastEnterCriticalSection(); void *old_callback = _vsync_callback; _vsync_callback = func; - _EXIT_CRITICAL(); + FastExitCriticalSection(); return old_callback; } @@ -184,18 +181,18 @@ int EnqueueDrawOp( // race condition where the DMA transfer could end while interrupts are // being disabled. Interrupts are disabled through the IRQ_MASK register // rather than via syscalls for performance reasons. - _ENTER_CRITICAL(); + FastEnterCriticalSection(); int length = _queue_length; if (!length) { _queue_length = 1; - _EXIT_CRITICAL(); + FastExitCriticalSection(); func(arg1, arg2, arg3); return 0; } if (length >= QUEUE_LENGTH) { - _EXIT_CRITICAL(); + FastExitCriticalSection(); _sdk_log("draw queue overflow, dropping commands\n"); return -1; @@ -211,7 +208,7 @@ int EnqueueDrawOp( entry->arg2 = arg2; entry->arg3 = arg3; - _EXIT_CRITICAL(); + FastExitCriticalSection(); return length; } @@ -242,12 +239,12 @@ int DrawSync(int mode) { } void *DrawSyncCallback(void (*func)(void)) { - _ENTER_CRITICAL(); + FastEnterCriticalSection(); void *old_callback = _drawsync_callback; _drawsync_callback = func; - _EXIT_CRITICAL(); + FastExitCriticalSection(); return old_callback; } diff --git a/libpsn00b/psxgpu/env.c b/libpsn00b/psxgpu/env.c index f513727..07edacf 100644 --- a/libpsn00b/psxgpu/env.c +++ b/libpsn00b/psxgpu/env.c @@ -63,7 +63,7 @@ int DrawOTagEnv(const uint32_t *ot, DRAWENV *env) { prim->code[2] |= ((env->clip.y + env->ofs[1]) & 0x7ff) << 11; // Texture page (reset active page and set dither/mask bits) - prim->code[3] = 0xe1000000; + prim->code[3] = 0xe1000000 | env->tpage; prim->code[3] |= (env->dtd & 1) << 9; prim->code[3] |= (env->dfe & 1) << 10; diff --git a/libpsn00b/psxgpu/image.c b/libpsn00b/psxgpu/image.c index bbdb7c8..e73505f 100644 --- a/libpsn00b/psxgpu/image.c +++ b/libpsn00b/psxgpu/image.c @@ -1,6 +1,10 @@ /* * PSn00bSDK GPU library (image and VRAM transfer functions) * (C) 2022 spicyjpeg - MPL licensed + * + * TODO: MoveImage() is currently commented out as it won't trigger a DMA IRQ, + * making it unusable as a draw queue command. A way around this (perhaps using + * the GPU IRQ?) shall be found. */ #include <stdint.h> @@ -58,9 +62,9 @@ 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) { return EnqueueDrawOp((void *) &MoveImage2, (uint32_t) rect, x, y); -} +}*/ void LoadImage2(const RECT *rect, const uint32_t *data) { _dma_transfer(rect, (uint32_t *) data, 1); @@ -70,14 +74,14 @@ void StoreImage2(const RECT *rect, uint32_t *data) { _dma_transfer(rect, data, 0); } -void MoveImage2(const RECT *rect, int x, int y) { +/*void MoveImage2(const RECT *rect, int x, int y) { GPU_GP0 = 0x80000000; //GPU_GP0 = rect->x | (rect->y << 16); GPU_GP0 = *((const uint32_t *) &(rect->x)); GPU_GP0 = (x & 0xffff) | (y << 16); //GPU_GP0 = rect->w | (rect->h << 16); GPU_GP0 = *((const uint32_t *) &(rect->w)); -} +}*/ /* .TIM image parsers */ |
