diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-01-22 15:40:14 +0100 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-01-22 15:40:14 +0100 |
| commit | a21e949c9aea98cb4b3feee48bb98579bbdfba70 (patch) | |
| tree | 5fad8655bc674bebdbecb385d3e4878acbac3597 /libpsn00b/psxgpu | |
| parent | 3095b4571dabc8d6cee90673d679f3e77b21b164 (diff) | |
| download | psn00bsdk-a21e949c9aea98cb4b3feee48bb98579bbdfba70.tar.gz | |
Fix VSync(), assert(), warnings and some examples
Diffstat (limited to 'libpsn00b/psxgpu')
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 11 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index c52ab8a..537f672 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -133,12 +133,13 @@ int VSync(int mode) { return delta; if (mode < 0) return _vblank_counter; - if (!mode) - mode = 1; // VSync(0) = wait for one vblank - // Wait for at least one vertical blank event since the last call to - // VSync() to occur. - for (uint32_t target = _last_vblank + mode; _vblank_counter < target;) { + // Wait for the specified number of vertical blank events since the last + // call to VSync() to occur (if mode >= 2) or just for a single vertical + // blank (if mode = 0). + uint32_t target = mode ? (_last_vblank + mode) : (_vblank_counter + 1); + + while (_vblank_counter < target) { uint32_t status = GPU_GP1; _vsync_halt_func(); diff --git a/libpsn00b/psxgpu/image.c b/libpsn00b/psxgpu/image.c index 61ac484..ba5c445 100644 --- a/libpsn00b/psxgpu/image.c +++ b/libpsn00b/psxgpu/image.c @@ -53,7 +53,7 @@ static void _dma_transfer(const RECT *rect, uint32_t *data, int write) { // Enable DMA request, route to GP0 (2) or from GPU_READ (3) GPU_GP1 = 0x04000002 | (write ^ 1); - while (DMA_CHCR(DMA_GPU) & (1 << 24)) + while ((DMA_CHCR(DMA_GPU) & (1 << 24)) || !(GPU_GP1 & (1 << 28))) __asm__ volatile(""); DMA_MADR(DMA_GPU) = (uint32_t) data; |
