diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2022-01-18 08:31:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-18 08:31:14 +0800 |
| commit | 05d44488bd5587786f4bd0286fc0f555c79aa46a (patch) | |
| tree | 5740f396d10a9580c3a39ca536544436898ff1b6 /libpsn00b/psxcd | |
| parent | 08de895e8582dbc70b639ae5f511ab9ebfb4d68a (diff) | |
| parent | e9475e283a82665fe6c19bebc3318b5084f15a2e (diff) | |
| download | psn00bsdk-05d44488bd5587786f4bd0286fc0f555c79aa46a.tar.gz | |
Merge pull request #44 from spicyjpeg/actions
GitHub Actions CI, psxcd and libc fixes, new examples
Diffstat (limited to 'libpsn00b/psxcd')
| -rw-r--r-- | libpsn00b/psxcd/cdgetsector.s | 3 | ||||
| -rw-r--r-- | libpsn00b/psxcd/isofs.c | 30 | ||||
| -rw-r--r-- | libpsn00b/psxcd/psxcd.c | 16 |
3 files changed, 31 insertions, 18 deletions
diff --git a/libpsn00b/psxcd/cdgetsector.s b/libpsn00b/psxcd/cdgetsector.s index 9af3543..dbe95cb 100644 --- a/libpsn00b/psxcd/cdgetsector.s +++ b/libpsn00b/psxcd/cdgetsector.s @@ -18,7 +18,8 @@ CdGetSector: # nop lui $v0, 0x1 - srl $a1, 2 +# srl $a1, 2 # (the official implementation expects $a1/size + # to be in 32-bit words rather than bytes) or $v0, $a1 sw $a0, D3_MADR($a2) # Set DMA base address and transfer length sw $v0, D3_BCR($a2) diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c index 40a40af..d1c1b18 100644 --- a/libpsn00b/psxcd/isofs.c +++ b/libpsn00b/psxcd/isofs.c @@ -10,6 +10,9 @@ // Uncommend to enable debug output //#define DEBUG +#define DEFAULT_PATH_SEP '\\' +#define IS_PATH_SEP(ch) (((ch) == '/') || ((ch) == '\\')) + typedef struct _CdlDIR_INT { u_long _pos; @@ -374,7 +377,7 @@ static char* resolve_pathtable_path(int entry, char *rbuff) rbuff -= tbl_entry.nameLength; memcpy(rbuff, namebuff, tbl_entry.nameLength); rbuff--; - *rbuff = '\\'; + *rbuff = DEFAULT_PATH_SEP; // Parse to the parent entry = tbl_entry.dirLevel; @@ -431,12 +434,15 @@ static int find_dir_entry(const char *name, ISO_DIR_ENTRY *dirent) static char* get_pathname(char *path, const char *filename) { - char *c; - c = strrchr(filename, '\\'); + char *c = 0; + for (char *i = filename; *i; i++) { + if (IS_PATH_SEP(*i)) + c = i; + } if(( c == filename ) || ( !c )) { - path[0] = '\\'; + path[0] = DEFAULT_PATH_SEP; path[1] = 0; return NULL; } @@ -447,11 +453,17 @@ static char* get_pathname(char *path, const char *filename) static char* get_filename(char *name, const char *filename) { - char *c; - c = strrchr(filename, '\\'); + char *c = 0; + for (char *i = filename; *i; i++) { + if (IS_PATH_SEP(*i)) + c = i; + } - if(( c == filename ) || ( !c )) - { + if (!c) { + strcpy(name, filename); + return name; + } + if (c == filename) { strcpy(name, filename+1); return name; } @@ -783,7 +795,7 @@ static void _scan_callback(int status, unsigned char *result) { if( status == CdlDataReady ) { - CdGetSector((void*)_ses_scanbuff, 2048); + CdGetSector((void*)_ses_scanbuff, 512); if( _ses_scanbuff[0] == 0x1 ) { diff --git a/libpsn00b/psxcd/psxcd.c b/libpsn00b/psxcd/psxcd.c index 74c6c1c..8f19c8d 100644 --- a/libpsn00b/psxcd/psxcd.c +++ b/libpsn00b/psxcd/psxcd.c @@ -21,7 +21,7 @@ volatile int _cd_last_sector_count; int _cd_media_changed; void _cd_init(void); -void _cd_control(unsigned char com, unsigned char *param, int plen); +void _cd_control(unsigned char com, const void *param, int plen); void _cd_wait_ack(void); void _cd_wait(void); @@ -50,7 +50,7 @@ int CdInit(void) return 1; } -int CdControl(unsigned char com, unsigned char *param, unsigned char *result) +int CdControl(unsigned char com, const void *param, unsigned char *result) { // Don't issue command if ack is not received yet if( _cd_ack_wait ) @@ -72,7 +72,7 @@ int CdControl(unsigned char com, unsigned char *param, unsigned char *result) return 1; } -int CdControlB(unsigned char com, unsigned char *param, unsigned char *result) +int CdControlB(unsigned char com, const void *param, unsigned char *result) { if( !CdControl(com, param, result) ) { @@ -83,7 +83,7 @@ int CdControlB(unsigned char com, unsigned char *param, unsigned char *result) return 1; } -int CdControlF(unsigned char com, unsigned char *param) +int CdControlF(unsigned char com, const void *param) { int param_len=0; @@ -255,7 +255,7 @@ static void _CdReadReadyCallback(int status, unsigned char *result) CdGetSector((void*)_cd_read_addr, _cd_read_sector_sz); // Increment destination address - _cd_read_addr += _cd_read_sector_sz>>2; + _cd_read_addr += _cd_read_sector_sz; // Subtract sector count _cd_sector_count--; @@ -290,15 +290,15 @@ int CdRead(int sectors, u_long *buf, int mode) // Determine sector based on mode flags if( mode & CdlModeSize0 ) { - _cd_read_sector_sz = 2328; + _cd_read_sector_sz = 2328 / 4; } else if( mode & CdlModeSize1 ) { - _cd_read_sector_sz = 2340; + _cd_read_sector_sz = 2340 / 4; } else { - _cd_read_sector_sz = 2048; + _cd_read_sector_sz = 2048 / 4; } _cd_read_counter = VSync(-1); |
