aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-08-10 22:49:49 +0200
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-08-10 22:49:49 +0200
commita1081f296bca4f718cf31e5b6a262661d132e9e4 (patch)
treeee979fe0120fed803d0c63ca824dbff3921dadc6 /libpsn00b
parentce33eee403c678d3e2850046955f265585af76d7 (diff)
downloadpsn00bsdk-a1081f296bca4f718cf31e5b6a262661d132e9e4.tar.gz
Misc. fixes, add texturing to graphics/gte example
Diffstat (limited to 'libpsn00b')
-rw-r--r--libpsn00b/cmake/sdk.cmake2
-rw-r--r--libpsn00b/include/psxspu.h2
-rw-r--r--libpsn00b/psxgpu/common.c9
-rw-r--r--libpsn00b/psxspu/common.c4
4 files changed, 10 insertions, 7 deletions
diff --git a/libpsn00b/cmake/sdk.cmake b/libpsn00b/cmake/sdk.cmake
index d6d9bcd..8965e79 100644
--- a/libpsn00b/cmake/sdk.cmake
+++ b/libpsn00b/cmake/sdk.cmake
@@ -38,6 +38,8 @@ find_program(
HINTS
${PSN00BSDK_TC}/bin
${PSN00BSDK_TC}/../bin
+ # Same as ${CMAKE_INSTALL_PREFIX}/bin
+ ${CMAKE_CURRENT_LIST_DIR}/../../../bin
# Same as ${CMAKE_INSTALL_PREFIX}/${PSN00BSDK_TARGET}/bin
${CMAKE_CURRENT_LIST_DIR}/../../../${PSN00BSDK_TARGET}/bin
PATHS
diff --git a/libpsn00b/include/psxspu.h b/libpsn00b/include/psxspu.h
index e4c667a..cf78e3d 100644
--- a/libpsn00b/include/psxspu.h
+++ b/libpsn00b/include/psxspu.h
@@ -111,7 +111,7 @@ extern "C" {
void SpuInit(void);
-void SpuRead(const uint32_t *data, size_t size);
+void SpuRead(uint32_t *data, size_t size);
void SpuWrite(const uint32_t *data, size_t size);
SPU_TransferMode SpuSetTransferMode(SPU_TransferMode mode);
uint32_t SpuSetTransferStartAddr(uint32_t addr);
diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c
index a65e0c9..4591012 100644
--- a/libpsn00b/psxgpu/common.c
+++ b/libpsn00b/psxgpu/common.c
@@ -122,12 +122,13 @@ static void _vsync_halt(void) {
int VSync(int mode) {
if (mode < 0)
return _vblank_counter;
+ if (mode == 1)
+ return TIMER_VALUE(1) - _last_hblank;
uint32_t status = GPU_GP1;
- // If mode = 0, wait for one vertical blank event to occur. If mode = 1, do
- // not wait.
- for (int i = ((mode < 2) ? (mode ^ 1) : mode); i; i--) {
+ // Wait for at least one vertical blank event to occur.
+ do {
_vsync_halt();
// If interlaced mode is enabled, wait until the GPU starts displaying
@@ -136,7 +137,7 @@ int VSync(int mode) {
while (!((GPU_GP1 ^ status) & (1 << 31)))
__asm__ volatile("");
}
- }
+ } while ((--mode) > 0);
// Update the horizontal blank counter and return the time elapsed since
// the last time it was updated.
diff --git a/libpsn00b/psxspu/common.c b/libpsn00b/psxspu/common.c
index 306cfd2..c1e8cab 100644
--- a/libpsn00b/psxspu/common.c
+++ b/libpsn00b/psxspu/common.c
@@ -105,7 +105,7 @@ static void _load_store_data(uint32_t *data, size_t length, int mode) {
DMA_CHCR(4) = 0x01000200 | ((mode & 1) ^ 1);
}
-void SpuRead(const uint32_t *data, size_t size) {
+void SpuRead(uint32_t *data, size_t size) {
_load_store_data(data, size, 3);
}
@@ -129,7 +129,7 @@ void SpuWrite(const uint32_t *data, size_t size) {
return;
}
- _load_store_data(data, size, 2);
+ _load_store_data((uint32_t *) data, size, 2);
}
SPU_TransferMode SpuSetTransferMode(SPU_TransferMode mode) {