diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-10-06 12:15:24 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2022-10-06 12:15:24 +0200 |
| commit | 6ee55c23b042a1559e8cabfccf3b9d3320c4c5cc (patch) | |
| tree | 1bc6862819944ecbe8a19054ad18597c473b81b5 /libpsn00b/psxcd | |
| parent | c4a2533d21dfd05cde841ea48c67b05e0e6a853f (diff) | |
| download | psn00bsdk-6ee55c23b042a1559e8cabfccf3b9d3320c4c5cc.tar.gz | |
Replace psxgpu debug font, add CdGetSector2()
Diffstat (limited to 'libpsn00b/psxcd')
| -rw-r--r-- | libpsn00b/psxcd/cdgetsector.s | 56 | ||||
| -rw-r--r-- | libpsn00b/psxcd/getsector.c | 35 | ||||
| -rw-r--r-- | libpsn00b/psxcd/isofs.c | 8 | ||||
| -rw-r--r-- | libpsn00b/psxcd/psxcd_asm.s | 8 |
4 files changed, 40 insertions, 67 deletions
diff --git a/libpsn00b/psxcd/cdgetsector.s b/libpsn00b/psxcd/cdgetsector.s deleted file mode 100644 index 6a29069..0000000 --- a/libpsn00b/psxcd/cdgetsector.s +++ /dev/null @@ -1,56 +0,0 @@ -.set noreorder - -.include "hwregs_a.inc" - -.section .text - -.global CdGetSector -.type CdGetSector, @function -CdGetSector: - - lui $a2, IOBASE - -#.Lwait_fifo: # Probably redundant as the BIOS CD-ROM -# lbu $v0, CD_REG0($a2) # routines do not not wait for this -# nop -# andi $v0, 0x40 -# beqz $v0, .Lwait_fifo -# nop - - lui $v0, 0x1 -# srl $a1, 2 # (the official implementation expects $a1/size - # to be in 32-bit words rather than bytes) - or $v0, $a1 - sw $a0, DMA3_MADR($a2) # Set DMA base address and transfer length - sw $v0, DMA3_BCR($a2) - - lui $v0, 0x1100 # Start DMA transfer - sw $v0, DMA3_CHCR($a2) - nop - nop - -.Ldma_wait: # Ensure DMA transfer has completed - lw $v0, DMA3_CHCR($a2) - nop - srl $v0, 24 - andi $v0, 0x1 - - bnez $v0, .Ldma_wait - nop - -# Not stable -# sb $0 , CD_REG0($a2) -#.Lflush_fifo: # Read out any remaining bytes in the buffer -# lbu $v1, CD_REG0($a2) -# li $v0, 0x40 -# and $v1, $v0 -# beqz $v1, .Lend_flush -# nop -# lbu $v0, CD_REG2($a2) -# b .Lflush_fifo -# nop -#.Lend_flush: - - jr $ra - li $v0, 1 - diff --git a/libpsn00b/psxcd/getsector.c b/libpsn00b/psxcd/getsector.c new file mode 100644 index 0000000..bc1c8ae --- /dev/null +++ b/libpsn00b/psxcd/getsector.c @@ -0,0 +1,35 @@ +/* + * PSn00bSDK CD drive library (sector DMA API) + * (C) 2022 spicyjpeg - MPL licensed + */ + +#include <stdint.h> +#include <psxcd.h> +#include <hwregs_c.h> + +/* DMA transfer functions */ + +int CdGetSector(void *madr, int size) { + //while (!(CD_STAT & (1 << 6))) + //__asm__ volatile(""); + + DMA_MADR(3) = (uint32_t) madr; + DMA_BCR(3) = size | (1 << 16); + DMA_CHCR(3) = 0x11000000; + + while (DMA_CHCR(3) & (1 << 24)) + __asm__ volatile(""); + + return 1; +} + +int CdGetSector2(void *madr, int size) { + //while (!(CD_STAT & (1 << 6))) + //__asm__ volatile(""); + + DMA_MADR(3) = (uint32_t) madr; + DMA_BCR(3) = size | (1 << 16); + DMA_CHCR(3) = 0x11400100; // Transfer 1 word every 16 CPU cycles + + return 1; +} diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c index 582b8d9..d620377 100644 --- a/libpsn00b/psxcd/isofs.c +++ b/libpsn00b/psxcd/isofs.c @@ -434,8 +434,8 @@ static int find_dir_entry(const char *name, ISO_DIR_ENTRY *dirent) static char* get_pathname(char *path, const char *filename) { - char *c = 0; - for (char *i = filename; *i; i++) { + const char *c = 0; + for (const char *i = filename; *i; i++) { if (IS_PATH_SEP(*i)) c = i; } @@ -453,8 +453,8 @@ static char* get_pathname(char *path, const char *filename) static char* get_filename(char *name, const char *filename) { - char *c = 0; - for (char *i = filename; *i; i++) { + const char *c = 0; + for (const char *i = filename; *i; i++) { if (IS_PATH_SEP(*i)) c = i; } diff --git a/libpsn00b/psxcd/psxcd_asm.s b/libpsn00b/psxcd/psxcd_asm.s index 906ab32..16e17d8 100644 --- a/libpsn00b/psxcd/psxcd_asm.s +++ b/libpsn00b/psxcd/psxcd_asm.s @@ -490,13 +490,7 @@ CdSyncCallback: .section .data - -.global psxcd_credits -.type psxcd_credits, @object -psxgpu_credits: - .ascii "psxcd library programs by Lameguy64\n" - .asciiz "2020 PSn00bSDK Project / Meido-Tek Productions\n" - + .comm _cd_last_cmd, 1, 1 .comm _cd_last_mode, 1, 1 .comm _cd_ack_wait, 1, 1 |
