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 | |
| parent | 3095b4571dabc8d6cee90673d679f3e77b21b164 (diff) | |
| download | psn00bsdk-a21e949c9aea98cb4b3feee48bb98579bbdfba70.tar.gz | |
Fix VSync(), assert(), warnings and some examples
Diffstat (limited to 'libpsn00b')
| -rw-r--r-- | libpsn00b/include/assert.h | 8 | ||||
| -rw-r--r-- | libpsn00b/psxcd/misc.c | 6 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 11 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/libpsn00b/include/assert.h b/libpsn00b/include/assert.h index 1b2bda2..d18a56f 100644 --- a/libpsn00b/include/assert.h +++ b/libpsn00b/include/assert.h @@ -1,6 +1,6 @@ /* * PSn00bSDK assert macro and internal logging - * (C) 2022 spicyjpeg - MPL licensed + * (C) 2022-2023 spicyjpeg - MPL licensed * * Note that the _sdk_log() macro is used internally by PSn00bSDK to output * debug messages and warnings. @@ -32,9 +32,11 @@ void _assert_abort(const char *file, int line, const char *expr); ((expr) ? ((void) 0) : _assert_abort(__FILE__, __LINE__, #expr)) #ifdef SDK_LIBRARY_NAME -#define _sdk_log(fmt, ...) printf(SDK_LIBRARY_NAME ": " fmt, ##__VA_ARGS__) +#define _sdk_log(fmt, ...) \ + printf(SDK_LIBRARY_NAME ": " fmt __VA_OPT__(,) __VA_ARGS__) #else -#define _sdk_log(fmt, ...) printf(fmt, ##__VA_ARGS__) +#define _sdk_log(fmt, ...) \ + printf(fmt __VA_OPT__(,) __VA_ARGS__) #endif #endif diff --git a/libpsn00b/psxcd/misc.c b/libpsn00b/psxcd/misc.c index fc87676..851fea6 100644 --- a/libpsn00b/psxcd/misc.c +++ b/libpsn00b/psxcd/misc.c @@ -14,7 +14,7 @@ /* Unlock command strings */ -static char *_unlock_strings[] = { +static const char *_unlock_strings[] = { "", "Licensed by", "Sony", @@ -24,7 +24,7 @@ static char *_unlock_strings[] = { "" }; -static const char *_unlock_regions[] = { +static const char *const _unlock_regions[] = { "of America", // CdlRegionSCEA "(Europe)", // CdlRegionSCEE "World wide" // CdlRegionSCEW @@ -66,7 +66,7 @@ int CdDataSync(int mode) { return 0; } - _sdk_log("CdDataSync() timeout\n"); + _sdk_log("CdDataSync() timeout, CHCR=0x%08x\n", DMA_CHCR(DMA_CD)); return -1; } 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; |
