aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxcd
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-10-16 23:52:19 +0200
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-10-16 23:52:19 +0200
commit03434a230d8c3ed2e32a3885128e05e42ee11769 (patch)
treed7b06d4bce91472a1f01b9fb3a5965a9822c1a90 /libpsn00b/psxcd
parent6eabb5aa549254c2272cedee26d4245f31f2dc7a (diff)
downloadpsn00bsdk-03434a230d8c3ed2e32a3885128e05e42ee11769.tar.gz
Add mdec/strvideo example, fix psxpress bug
Diffstat (limited to 'libpsn00b/psxcd')
-rw-r--r--libpsn00b/psxcd/getsector.c23
-rw-r--r--libpsn00b/psxcd/psxcd.c10
2 files changed, 24 insertions, 9 deletions
diff --git a/libpsn00b/psxcd/getsector.c b/libpsn00b/psxcd/getsector.c
index bc1c8ae..ee5315a 100644
--- a/libpsn00b/psxcd/getsector.c
+++ b/libpsn00b/psxcd/getsector.c
@@ -7,6 +7,16 @@
#include <psxcd.h>
#include <hwregs_c.h>
+#define DATA_SYNC_TIMEOUT 0x100000
+
+/* Private utilities */
+
+#ifdef NDEBUG
+#define _LOG(...)
+#else
+#define _LOG(...) printf(__VA_ARGS__)
+#endif
+
/* DMA transfer functions */
int CdGetSector(void *madr, int size) {
@@ -33,3 +43,16 @@ int CdGetSector2(void *madr, int size) {
return 1;
}
+
+int CdDataSync(int mode) {
+ if (mode)
+ return (DMA_CHCR(3) >> 24) & 1;
+
+ for (int i = DATA_SYNC_TIMEOUT; i; i--) {
+ if (!(DMA_CHCR(3) & (1 << 24)))
+ return 0;
+ }
+
+ _LOG("psxcd: CdDataSync() timeout\n");
+ return -1;
+}
diff --git a/libpsn00b/psxcd/psxcd.c b/libpsn00b/psxcd/psxcd.c
index 160a1ed..f48542d 100644
--- a/libpsn00b/psxcd/psxcd.c
+++ b/libpsn00b/psxcd/psxcd.c
@@ -285,18 +285,10 @@ int CdRead(int sectors, uint32_t *buf, int mode)
_cd_read_addr = buf;
// Determine sector based on mode flags
- if( mode & CdlModeSize0 )
- {
- _cd_read_sector_sz = 2328 / 4;
- }
- else if( mode & CdlModeSize1 )
- {
+ if( mode & CdlModeSize )
_cd_read_sector_sz = 2340 / 4;
- }
else
- {
_cd_read_sector_sz = 2048 / 4;
- }
_cd_read_counter = VSync(-1);