diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-07-31 18:04:59 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-07-31 18:04:59 +0200 |
| commit | 9560a1427aec1681c5d0c2bc30190ce4b1ad8557 (patch) | |
| tree | 3aad9d0f632687b86b9639c714d49a1a9f1c2397 /libpsn00b/psxgpu | |
| parent | 073a859acf16ccbc0f49364e38126bf2bf03aa3d (diff) | |
| download | psn00bsdk-9560a1427aec1681c5d0c2bc30190ce4b1ad8557.tar.gz | |
Rewrite libpsxspu in C and update sound examples
Diffstat (limited to 'libpsn00b/psxgpu')
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 3 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 14 |
2 files changed, 8 insertions, 9 deletions
diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index bf115a1..a65e0c9 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -117,7 +117,6 @@ static void _vsync_halt(void) { printf("psxgpu: VSync() timeout\n"); ChangeClearPAD(0); ChangeClearRCnt(3, 0); - return; } int VSync(int mode) { @@ -152,7 +151,7 @@ int DrawSync(int mode) { if (mode) return (DMA_BCR(2) >> 16); - // Wait for the queue to become empty, to make sure no . + // Wait for the queue to become empty. // TODO: add a timeout while (_queue_length) __asm__ volatile(""); diff --git a/libpsn00b/psxgpu/image.c b/libpsn00b/psxgpu/image.c index b3e5678..da51e7d 100644 --- a/libpsn00b/psxgpu/image.c +++ b/libpsn00b/psxgpu/image.c @@ -10,7 +10,7 @@ #define DMA_CHUNK_LENGTH 8 -/* Common internal load/store function */ +/* VRAM transfer API */ static void _load_store_image( uint32_t command, @@ -23,8 +23,10 @@ static void _load_store_image( printf("psxgpu: can't transfer an odd number of pixels\n"); length /= 2; - if ((length >= DMA_CHUNK_LENGTH) && (length % DMA_CHUNK_LENGTH)) - printf("psxgpu: transfer data length (%d) is not a multiple of %d\n", length, DMA_CHUNK_LENGTH); + if ((length >= DMA_CHUNK_LENGTH) && (length % DMA_CHUNK_LENGTH)) { + printf("psxgpu: transfer data length (%d) is not a multiple of %d, rounding\n", length, DMA_CHUNK_LENGTH); + length += DMA_CHUNK_LENGTH - 1; + } DrawSync(0); GPU_GP1 = 0x04000000; // Disable DMA request @@ -45,17 +47,15 @@ static void _load_store_image( else DMA_BCR(2) = DMA_CHUNK_LENGTH | ((length / DMA_CHUNK_LENGTH) << 16); - DMA_CHCR(2) = 0x01000200 | !(mode & 1); + DMA_CHCR(2) = 0x01000200 | ((mode & 1) ^ 1); } -/* Public VRAM API */ - void LoadImage(const RECT *rect, const uint32_t *data) { _load_store_image(0xa0000000, 2, rect, (uint32_t *) data); } void StoreImage(const RECT *rect, uint32_t *data) { - _load_store_image(0xc0000000, 3, rect, (uint32_t *) data); + _load_store_image(0xc0000000, 3, rect, data); } /* .TIM image parsers */ |
