diff --git a/.gitignore b/.gitignore index 6d6bad97d8..caa622d541 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,7 @@ retroarch_switch.nso # PS2 ps2/irx/*.c +ps2/libcdvd/lib/ # Wayland gfx/common/wayland/idle-inhibit-unstable-v1.c diff --git a/Makefile.ps2 b/Makefile.ps2 index 881f950860..9638fd087c 100644 --- a/Makefile.ps2 +++ b/Makefile.ps2 @@ -72,7 +72,7 @@ EE_OBJS += $(IRX_DIR)/cdvd_irx.o # Missing objecst on the PS2SDK EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o ps2/compat_files/ps2_devices.o -EE_OBJS += ps2/compat_files/cd.o ps2/compat_files/ps2_hashtable.o ps2/compat_files/murmur3.o ps2/compat_files/ps2_descriptor.o +EE_OBJS += ps2/compat_files/fileXio_cdvd.o ps2/compat_files/ps2_descriptor.o #EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o EE_OBJS += griffin/griffin.o diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index 8cc839c79a..d28986d4d8 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 09bdca60d5..6dfb9b83b5 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -52,7 +52,7 @@ # endif # if defined(PS2) # include -# include +# include # endif # include # include @@ -1046,7 +1046,7 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool i #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); #elif defined(PS2) - rdir->directory = newfileXioDopen(name); + rdir->directory = ps2fileXioDopen(name); #elif defined(_3DS) rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; @@ -1089,7 +1089,7 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir) return (sceIoDread(rdir->directory, &rdir->entry) > 0); #elif defined(PS2) iox_dirent_t record; - int ret = newfileXioDread(rdir->directory, &record); + int ret = ps2fileXioDread(rdir->directory, &record); rdir->entry = record; return ( ret > 0); #elif defined(__CELLOS_LV2__) @@ -1187,7 +1187,7 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir) #elif defined(VITA) || defined(PSP) sceIoDclose(rdir->directory); #elif defined(PS2) - newfileXioDclose(rdir->directory); + ps2fileXioDclose(rdir->directory); #elif defined(__CELLOS_LV2__) rdir->error = cellFsClosedir(rdir->directory); #elif defined(ORBIS) diff --git a/ps2/compat_files/cd.c b/ps2/compat_files/fileXio_cdvd.c similarity index 77% rename from ps2/compat_files/cd.c rename to ps2/compat_files/fileXio_cdvd.c index 4369139720..09074c7094 100644 --- a/ps2/compat_files/cd.c +++ b/ps2/compat_files/fileXio_cdvd.c @@ -5,9 +5,7 @@ #include #include #include -//#include -#include "cd.h" - +#include #include "ps2_devices.h" #include "ps2_descriptor.h" @@ -17,32 +15,34 @@ static SifRpcClientData_t clientInit __attribute__ ((aligned(64))); static u32 initMode __attribute__ ((aligned(64))); -static s32 cdThreadId = 0; -static s32 bindSearchFile = -1; -static s32 bindDiskReady = -1; -static s32 bindInit = -1; -static s32 bindNCmd = -1; -static s32 bindSCmd = -1; -static s32 nCmdSemaId = -1; // n-cmd semaphore id -static s32 sCmdSemaId = -1; // s-cmd semaphore id -static s32 callbackSemaId = -1; // callback semaphore id -static s32 cdDebug = 0; -static s32 sCmdNum = 0; +static int cdThreadId = 0; +static int bindSearchFile = -1; +static int bindDiskReady = -1; +static int bindInit = -1; +static int bindNCmd = -1; +static int bindSCmd = -1; +static int nCmdSemaId = -1; // n-cmd semaphore id +static int sCmdSemaId = -1; // s-cmd semaphore id +static int callbackSemaId = -1; // callback semaphore id +static int cdDebug = 0; +static int sCmdNum = 0; static SifRpcClientData_t clientSCmd __attribute__ ((aligned(64))); static u8 sCmdRecvBuff[48] __attribute__ ((aligned(64))); -static volatile s32 cbSema = 0; +static volatile int cbSema = 0; static ee_thread_status_t cdThreadParam; -static s32 callbackThreadId = 0; -volatile s32 cdCallbackNum __attribute__ ((aligned(64))); +static int callbackThreadId = 0; +volatile int cdCallbackNum __attribute__ ((aligned(64))); static void cdSemaInit(void); -static s32 cdCheckSCmd(s32 cur_cmd); -static s32 cdSyncS(s32 mode); +static int cdCheckSCmd(int cur_cmd); +static int cdSyncS(int mode); static void cdSemaExit(void); -s32 cdInit(s32 mode) +static int first_file_index; + +int cdInit(int mode) { - s32 i; + int i; if (cdSyncS(1)) return 0; @@ -108,9 +108,9 @@ static void cdSemaInit(void) cbSema = 0; } -static s32 cdCheckSCmd(s32 cur_cmd) +static int cdCheckSCmd(int cur_cmd) { - s32 i; + int i; cdSemaInit(); if (PollSema(sCmdSemaId) != sCmdSemaId) { if (cdDebug > 0) @@ -144,7 +144,7 @@ static s32 cdCheckSCmd(s32 cur_cmd) return 1; } -static s32 cdSyncS(s32 mode) +static int cdSyncS(int mode) { if (mode == 0) { if (cdDebug > 0) @@ -156,33 +156,6 @@ static s32 cdSyncS(s32 mode) return SifCheckStatRpc(&clientSCmd); } -CdvdDiscType_t cdGetDiscType(void) -{ - if (cdCheckSCmd(CD_SCMD_GETDISCTYPE) == 0) - return 0; - - if (SifCallRpc(&clientSCmd, CD_SCMD_GETDISCTYPE, 0, 0, 0, sCmdRecvBuff, 4, 0, 0) < 0) { - SignalSema(sCmdSemaId); - return 0; - } - - SignalSema(sCmdSemaId); - return *(s32 *) UNCACHED_SEG(sCmdRecvBuff); -} - - - - - - - - - - - - -static int first_file_index; - static int comp_entries_by_filename(const void *elem1, const void *elem2) { return strcmp(((entries*)elem1)->filename, ((entries*)elem2)->filename); @@ -193,15 +166,12 @@ static inline char* strzncpy(char *d, const char *s, size_t l) d[0] = 0; return strncat(d, s, l); } - - - - -int listcdvd(const char *path, entries *FileEntry) +static int listcdvd(const char *path, entries *FileEntry) { static struct TocEntry TocEntryList[FILEENTRY_SIZE]; char dir[1025]; - int i, n, t; + int i, n; + int t = 0; strcpy(dir, &path[5]); // Directories first... @@ -254,19 +224,12 @@ int listcdvd(const char *path, entries *FileEntry) return t; } - - - - - - -int fileXioCDDread(int fd, iox_dirent_t *dirent) +static int fileXioCDDread(int fd, iox_dirent_t *dirent) { DescriptorTranslation *descriptor = __ps2_fd_grab(fd); if (descriptor->current_folder_position == -1) { descriptor->current_folder_position = 0; descriptor->items = listcdvd(descriptor->path, descriptor->FileEntry); - printf("Items in cdfs %i\n", descriptor->items); } if (descriptor->current_folder_position < descriptor->items) { @@ -274,7 +237,6 @@ int fileXioCDDread(int fd, iox_dirent_t *dirent) if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) { dirent->stat.mode = FIO_S_IFDIR; } - printf("Reading files from CDVD %s\n", dirent->name); descriptor->current_folder_position++; } else { descriptor->current_folder_position = 0; @@ -284,10 +246,9 @@ int fileXioCDDread(int fd, iox_dirent_t *dirent) return 1; } - -int newfileXioDopen(const char *name) +int ps2fileXioDopen(const char *name) { - enum BootDeviceIDs deviceID = getBootDeviceID(name); + enum BootDeviceIDs deviceID = getBootDeviceID((char *)name); int fd; if (deviceID == BOOT_DEVICE_CDFS) { fd = __ps2_acquire_descriptor(); @@ -300,18 +261,7 @@ int newfileXioDopen(const char *name) return fd; } -int newfileXioDclose(int fd) -{ - // if (is_fd_valid(fd)) { - // int res = __ps2_release_descriptor(fd); - // printf("Releassssinggggg %i\n", res); - // return res; - // } else { - return fileXioDclose(fd); - // } -} - -int newfileXioDread(int fd, iox_dirent_t *dirent) +int ps2fileXioDread(int fd, iox_dirent_t *dirent) { if (is_fd_valid(fd)) { return fileXioCDDread(fd, dirent); @@ -320,4 +270,11 @@ int newfileXioDread(int fd, iox_dirent_t *dirent) } } - +int ps2fileXioDclose(int fd) +{ + if (is_fd_valid(fd)) { + return __ps2_release_descriptor(fd); + } else { + return fileXioDclose(fd); + } +} diff --git a/ps2/compat_files/murmur3.c b/ps2/compat_files/murmur3.c deleted file mode 100755 index 8abd92bca7..0000000000 --- a/ps2/compat_files/murmur3.c +++ /dev/null @@ -1,317 +0,0 @@ -//----------------------------------------------------------------------------- -// MurmurHash3 was written by Austin Appleby, and is placed in the public -// domain. The author hereby disclaims copyright to this source code. - -// Note - The x86 and x64 versions do _not_ produce the same results, as the -// algorithms are optimized for their respective platforms. You can still -// compile and run any of them on any platform, but your performance with the -// non-native version will be less than optimal. - -#include "murmur3.h" - -/*----------------------------------------------------------------------------- - Platform-specific functions and macros -*/ - -#ifdef __GNUC__ -#define FORCE_INLINE __attribute__((always_inline)) inline -#else -#define FORCE_INLINE inline -#endif - -static FORCE_INLINE uint32_t rotl32 ( uint32_t x, int8_t r ) -{ - return (x << r) | (x >> (32 - r)); -} - -static FORCE_INLINE uint64_t rotl64 ( uint64_t x, int8_t r ) -{ - return (x << r) | (x >> (64 - r)); -} - -#define ROTL32(x,y) rotl32(x,y) -#define ROTL64(x,y) rotl64(x,y) - -#define BIG_CONSTANT(x) (x##LLU) - -/*----------------------------------------------------------------------------- - Block read - if your platform needs to do endian-swapping or can only - handle aligned reads, do the conversion here -*/ - -#define getblock(p, i) (p[i]) - -/*-----------------------------------------------------------------------------*/ -/* Finalization mix - force all bits of a hash block to avalanche */ - -static FORCE_INLINE uint32_t fmix32 ( uint32_t h ) -{ - h ^= h >> 16; - h *= 0x85ebca6b; - h ^= h >> 13; - h *= 0xc2b2ae35; - h ^= h >> 16; - - return h; -} - -/*----------*/ - -static FORCE_INLINE uint64_t fmix64 ( uint64_t k ) -{ - k ^= k >> 33; - k *= BIG_CONSTANT(0xff51afd7ed558ccd); - k ^= k >> 33; - k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53); - k ^= k >> 33; - - return k; -} - -/*-----------------------------------------------------------------------------*/ - -void MurmurHash3_x86_32( const void * key, int len, - uint32_t seed, void * out ) -{ - const uint8_t * data = (const uint8_t*)key; - const int nblocks = len / 4; - int i; - - uint32_t h1 = seed; - - uint32_t c1 = 0xcc9e2d51; - uint32_t c2 = 0x1b873593; - - /*----------*/ - /* body */ - - const uint32_t * blocks = (const uint32_t *)(data + nblocks*4); - - for(i = -nblocks; i; i++) - { - uint32_t k1 = getblock(blocks,i); - - k1 *= c1; - k1 = ROTL32(k1,15); - k1 *= c2; - - h1 ^= k1; - h1 = ROTL32(h1,13); - h1 = h1*5+0xe6546b64; - } - - /*----------*/ - /* tail */ - - const uint8_t * tail = (const uint8_t*)(data + nblocks*4); - - uint32_t k1 = 0; - - switch(len & 3) - { - case 3: k1 ^= tail[2] << 16; - case 2: k1 ^= tail[1] << 8; - case 1: k1 ^= tail[0]; - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; - }; - - /*----------*/ - /* finalization */ - - h1 ^= len; - - h1 = fmix32(h1); - - *(uint32_t*)out = h1; -} - -/*-----------------------------------------------------------------------------*/ - -void MurmurHash3_x86_128 ( const void * key, const int len, - uint32_t seed, void * out ) -{ - const uint8_t * data = (const uint8_t*)key; - const int nblocks = len / 16; - int i; - - uint32_t h1 = seed; - uint32_t h2 = seed; - uint32_t h3 = seed; - uint32_t h4 = seed; - - uint32_t c1 = 0x239b961b; - uint32_t c2 = 0xab0e9789; - uint32_t c3 = 0x38b34ae5; - uint32_t c4 = 0xa1e38b93; - - /*----------*/ - /* body */ - - const uint32_t * blocks = (const uint32_t *)(data + nblocks*16); - - for(i = -nblocks; i; i++) - { - uint32_t k1 = getblock(blocks,i*4+0); - uint32_t k2 = getblock(blocks,i*4+1); - uint32_t k3 = getblock(blocks,i*4+2); - uint32_t k4 = getblock(blocks,i*4+3); - - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; - - h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b; - - k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; - - h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747; - - k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; - - h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35; - - k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; - - h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17; - } - - /*----------*/ - /* tail */ - - const uint8_t * tail = (const uint8_t*)(data + nblocks*16); - - uint32_t k1 = 0; - uint32_t k2 = 0; - uint32_t k3 = 0; - uint32_t k4 = 0; - - switch(len & 15) - { - case 15: k4 ^= tail[14] << 16; - case 14: k4 ^= tail[13] << 8; - case 13: k4 ^= tail[12] << 0; - k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; - - case 12: k3 ^= tail[11] << 24; - case 11: k3 ^= tail[10] << 16; - case 10: k3 ^= tail[ 9] << 8; - case 9: k3 ^= tail[ 8] << 0; - k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; - - case 8: k2 ^= tail[ 7] << 24; - case 7: k2 ^= tail[ 6] << 16; - case 6: k2 ^= tail[ 5] << 8; - case 5: k2 ^= tail[ 4] << 0; - k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; - - case 4: k1 ^= tail[ 3] << 24; - case 3: k1 ^= tail[ 2] << 16; - case 2: k1 ^= tail[ 1] << 8; - case 1: k1 ^= tail[ 0] << 0; - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; - }; - - /*----------*/ - /* finalization */ - - h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; - - h1 += h2; h1 += h3; h1 += h4; - h2 += h1; h3 += h1; h4 += h1; - - h1 = fmix32(h1); - h2 = fmix32(h2); - h3 = fmix32(h3); - h4 = fmix32(h4); - - h1 += h2; h1 += h3; h1 += h4; - h2 += h1; h3 += h1; h4 += h1; - - ((uint32_t*)out)[0] = h1; - ((uint32_t*)out)[1] = h2; - ((uint32_t*)out)[2] = h3; - ((uint32_t*)out)[3] = h4; -} - -/*-----------------------------------------------------------------------------*/ - -void MurmurHash3_x64_128( const void * key, const int len, - const uint32_t seed, void * out ) -{ - const uint8_t * data = (const uint8_t*)key; - const int nblocks = len / 16; - int i; - - uint64_t h1 = seed; - uint64_t h2 = seed; - - uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5); - uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f); - - /*----------*/ - /* body */ - - const uint64_t * blocks = (const uint64_t *)(data); - - for(i = 0; i < nblocks; i++) - { - uint64_t k1 = getblock(blocks,i*2+0); - uint64_t k2 = getblock(blocks,i*2+1); - - k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; - - h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729; - - k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; - - h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5; - } - - /*----------*/ - /* tail */ - - const uint8_t * tail = (const uint8_t*)(data + nblocks*16); - - uint64_t k1 = 0; - uint64_t k2 = 0; - - switch(len & 15) - { - case 15: k2 ^= (uint64_t)(tail[14]) << 48; - case 14: k2 ^= (uint64_t)(tail[13]) << 40; - case 13: k2 ^= (uint64_t)(tail[12]) << 32; - case 12: k2 ^= (uint64_t)(tail[11]) << 24; - case 11: k2 ^= (uint64_t)(tail[10]) << 16; - case 10: k2 ^= (uint64_t)(tail[ 9]) << 8; - case 9: k2 ^= (uint64_t)(tail[ 8]) << 0; - k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; - - case 8: k1 ^= (uint64_t)(tail[ 7]) << 56; - case 7: k1 ^= (uint64_t)(tail[ 6]) << 48; - case 6: k1 ^= (uint64_t)(tail[ 5]) << 40; - case 5: k1 ^= (uint64_t)(tail[ 4]) << 32; - case 4: k1 ^= (uint64_t)(tail[ 3]) << 24; - case 3: k1 ^= (uint64_t)(tail[ 2]) << 16; - case 2: k1 ^= (uint64_t)(tail[ 1]) << 8; - case 1: k1 ^= (uint64_t)(tail[ 0]) << 0; - k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; - }; - - /*----------*/ - /* finalization */ - - h1 ^= len; h2 ^= len; - - h1 += h2; - h2 += h1; - - h1 = fmix64(h1); - h2 = fmix64(h2); - - h1 += h2; - h2 += h1; - - ((uint64_t*)out)[0] = h1; - ((uint64_t*)out)[1] = h2; -} - -/*-----------------------------------------------------------------------------*/ - diff --git a/ps2/compat_files/ps2_descriptor.c b/ps2/compat_files/ps2_descriptor.c index 3c95c16905..6af1106aac 100644 --- a/ps2/compat_files/ps2_descriptor.c +++ b/ps2/compat_files/ps2_descriptor.c @@ -19,40 +19,65 @@ #include #include -#define SCE_ERRNO_MASK 0xFF - -DescriptorTranslation *__ps2_fdmap[MAX_OPEN_FILES]; -DescriptorTranslation __ps2_fdmap_pool[MAX_OPEN_FILES]; - +static DescriptorTranslation *__ps2_fdmap[MAX_OPEN_FILES]; +static DescriptorTranslation __ps2_fdmap_pool[MAX_OPEN_FILES]; static int _lock_sema_id = -1; + static inline int _lock(void) { - return(WaitSema(_lock_sema_id)); + return(WaitSema(_lock_sema_id)); } static inline int _unlock(void) { - return(SignalSema(_lock_sema_id)); + return(SignalSema(_lock_sema_id)); +} + +static int __ps2_fd_drop(DescriptorTranslation *map) +{ + _lock(); + + if (map->ref_count == 1) + { + map->ref_count--; + free(map->FileEntry); + memset(map, 0, sizeof(DescriptorTranslation)); + } + else + { + map->ref_count--; + } + + _unlock(); + return 0; +} + +int is_fd_valid(int fd) +{ + /* Correct fd value */ + fd = MAX_OPEN_FILES - fd; + + return (fd > 0) && (fd < MAX_OPEN_FILES) && (__ps2_fdmap[fd] != NULL); } void _init_ps2_io(void) { - int ret; + int ret; ee_sema_t sp; - memset(__ps2_fdmap, 0, sizeof(__ps2_fdmap)); - memset(__ps2_fdmap_pool, 0, sizeof(__ps2_fdmap_pool)); + memset(__ps2_fdmap, 0, sizeof(__ps2_fdmap)); + memset(__ps2_fdmap_pool, 0, sizeof(__ps2_fdmap_pool)); sp.init_count = 1; - sp.max_count = 1; - sp.option = 0; - _lock_sema_id = CreateSema(&sp); + sp.max_count = 1; + sp.option = 0; + _lock_sema_id = CreateSema(&sp); } void _free_ps2_io(void) { - _lock(); - _unlock(); - if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id); + _lock(); + _unlock(); + if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id); } int __ps2_acquire_descriptor(void) @@ -61,13 +86,12 @@ int __ps2_acquire_descriptor(void) int i = 0; _lock(); - // get free descriptor - // only allocate descriptors after stdin/stdout/stderr -> aka 0/1/2 - for (fd = 1; fd < MAX_OPEN_FILES; ++fd) + /* get free descriptor */ + for (fd = 0; fd < MAX_OPEN_FILES; ++fd) { if (__ps2_fdmap[fd] == NULL) { - // get free pool + /* get free pool */ for (i = 0; i < MAX_OPEN_FILES; ++i) { if (__ps2_fdmap_pool[i].ref_count == 0) @@ -83,107 +107,44 @@ int __ps2_acquire_descriptor(void) } } - // // no mores descriptors available... + /* no mores descriptors available... */ _unlock(); return -1; } int __ps2_release_descriptor(int fd) { - DescriptorTranslation *map = NULL; - int res = -1; + int res = -1; - _lock(); - - if (is_fd_valid(fd) && __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) - { + if (is_fd_valid(fd) && __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) + { + _lock(); /* Correct fd value */ fd = MAX_OPEN_FILES - fd; - free(__ps2_fdmap[fd]->FileEntry); - __ps2_fdmap[fd] = NULL; - res = 0; - } + __ps2_fdmap[fd] = NULL; + res = 0; + _unlock(); + } - _unlock(); - return res; -} - -int __ps2_duplicate_descriptor(int fd) -{ - int fd2 = -1; - - _lock(); - - if (is_fd_valid(fd)) - { - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - // get free descriptor - // only allocate descriptors after stdin/stdout/stderr -> aka 0/1/2 - for (fd2 = 0; fd2 < MAX_OPEN_FILES; ++fd2) - { - if (__ps2_fdmap[fd2] == NULL) - { - __ps2_fdmap[fd2] = __ps2_fdmap[fd]; - __ps2_fdmap[fd2]->ref_count++; - _unlock(); - return fd2; - } - } - } - - _unlock(); - return -1; -} - -int __ps2_descriptor_ref_count(int fd) -{ - int res = 0; - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - - _lock(); - res = __ps2_fdmap[fd]->ref_count; - _unlock(); - return res; + return res; } DescriptorTranslation *__ps2_fd_grab(int fd) { - DescriptorTranslation *map = NULL; - - _lock(); + DescriptorTranslation *map = NULL; - if (is_fd_valid(fd)) - { + _lock(); + + if (is_fd_valid(fd)) + { /* Correct fd value */ fd = MAX_OPEN_FILES - fd; - map = __ps2_fdmap[fd]; + map = __ps2_fdmap[fd]; - if (map) - map->ref_count++; - } + if (map) + map->ref_count++; + } - _unlock(); - return map; -} - -int __ps2_fd_drop(DescriptorTranslation *map) -{ - _lock(); - - if (map->ref_count == 1) - { - int ret = 0; - - map->ref_count--; - memset(map, 0, sizeof(DescriptorTranslation)); - } - else - { - map->ref_count--; - } - - _unlock(); - return 0; + _unlock(); + return map; } diff --git a/ps2/compat_files/ps2_hashtable.c b/ps2/compat_files/ps2_hashtable.c deleted file mode 100644 index abeaa86d3c..0000000000 --- a/ps2/compat_files/ps2_hashtable.c +++ /dev/null @@ -1,159 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include - -#include -#include -#include - -HashTable *crb_hashtable_create(uint32_t _size) { - HashTable *tbl = malloc(sizeof(HashTable)); - tbl->size = 0; - tbl->capacity = 0; - tbl->table = NULL; - return tbl; -} - -void crb_hashtable_destroy(HashTable **_tbl) { - if (_tbl == NULL || *_tbl == NULL) return; - - if ((*_tbl)->table != NULL) { - free((*_tbl)->table); - (*_tbl)->table = NULL; - } - - free(*_tbl); - - *_tbl = NULL; -} - -void crb_hashtable_grow(HashTable *_tbl) { - unsigned int oldCapacity; - struct table_entry **oldTable; - unsigned int i; - - if (_tbl == NULL) return; - - oldCapacity = _tbl->capacity; - if (_tbl->capacity > 0) { - _tbl->capacity *= 2; - } else { - _tbl->capacity = 32; - } - oldTable = _tbl->table; - _tbl->table = calloc(_tbl->capacity, sizeof(struct table_entry*)); - for (i = 0; i < oldCapacity; i++) { - if (oldTable[i] != NULL) { - crb_hashtable_insert(_tbl, oldTable[i]->key, oldTable[i]->value); - free(oldTable[i]); - } - } - free(oldTable); -} - -void crb_hashtable_hash(const char *_key, uint32_t *hash) { - MurmurHash3_x86_32(_key, strlen(_key), 0, hash); -} - -bool crb_hashtable_insert(HashTable *_tbl, const char *_key, void *_data) { - struct table_entry *entry, *next_entry; - uint32_t index; - - if (_tbl == NULL || _key == NULL || _data == NULL) return false; - - if (_tbl->size == _tbl->capacity) { - crb_hashtable_grow(_tbl); - } - - entry = malloc(sizeof(struct table_entry)); - if (entry == NULL) return false; - crb_hashtable_hash(_key, &entry->hash); - index = entry->hash % _tbl->capacity; - entry->key = strdup(_key); - entry->value = _data; - entry->next = NULL; - - if (_tbl->table[index] == NULL) { - _tbl->table[index] = entry; - } else { - next_entry = _tbl->table[index]; - while (next_entry != NULL) { - if (next_entry->next == NULL) { - next_entry->next = entry; - break; - } - next_entry = next_entry->next; - } - } - _tbl->size++; - return true; -} - -void *crb_hashtable_find(HashTable *_tbl, const char *_key) { - uint32_t hash; - struct table_entry *entry; - - if (_tbl == NULL || _key == NULL) return NULL; - - crb_hashtable_hash(_key, &hash); - - for (entry = _tbl->table[hash % _tbl->capacity]; entry != NULL; entry = entry->next) { - if (strcmp(_key, entry->key) == 0) return entry->value; - } - - return NULL; -} - -void *crb_hashtable_remove(HashTable *_tbl, const char *_key) { - uint32_t hash; - struct table_entry *entry, *sibling; - bool top = true; - void *data; - - if (_tbl == NULL || _key == NULL) return NULL; - - crb_hashtable_hash(_key, &hash); - - for (entry = _tbl->table[hash % _tbl->capacity]; entry != NULL; sibling = entry, entry = entry->next) { - if (strcmp(_key, entry->key) == 0) { - break; - } else { - top = false; - } - } - if (entry != NULL) { - data = entry->value; - if (top) { - if (entry->next != NULL) { - _tbl->table[hash % _tbl->capacity] = entry->next; - } else { - _tbl->table[hash % _tbl->capacity] = NULL; - } - } else { - if (entry->next != NULL) { - sibling->next = entry->next; - } else { - sibling->next = NULL; - } - } - free(entry->key); - free(entry); - entry = NULL; - _tbl->size--; - return data; - } - - return NULL; -} diff --git a/ps2/include/cd.h b/ps2/include/cd.h deleted file mode 100644 index 31a050063d..0000000000 --- a/ps2/include/cd.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef CD_H -#define CD_H - -#include -#include -#include - -#define CDVD_INIT_INIT 0x00 -#define CDVD_INIT_NOCHECK 0x01 -#define CDVD_INIT_EXIT 0x05 - -typedef enum { - CDVD_TYPE_NODISK = 0x00, // No Disc inserted - CDVD_TYPE_DETECT, // Detecting disc type - CDVD_TYPE_DETECT_CD, - CDVD_TYPE_DETECT_DVDSINGLE, - CDVD_TYPE_DETECT_DVDDUAL, - CDVD_TYPE_UNKNOWN, // Unknown disc type - - CDVD_TYPE_PS1CD = 0x10, // PS1 CD with no CDDA tracks - CDVD_TYPE_PS1CDDA, // PS1 CD with CDDA tracks - CDVD_TYPE_PS2CD, // PS2 CD with no CDDA tracks - CDVD_TYPE_PS2CDDA, // PS2 CD with CDDA tracks - CDVD_TYPE_PS2DVD, // PS2 DVD - - CDVD_TYPE_CDDA = 0xFD, // CDDA - CDVD_TYPE_DVDVIDEO, // DVD Video - CDVD_TYPE_ILLEGAL, // Illegal disk type -} CdvdDiscType_t; - -s32 cdInit(s32); -CdvdDiscType_t cdGetDiscType(void); - - - - -int newfileXioDopen(const char *name); -int newfileXioDread(int fd, iox_dirent_t *dirent); - -#endif diff --git a/ps2/include/fileXio_cdvd.h b/ps2/include/fileXio_cdvd.h new file mode 100644 index 0000000000..ada31a1006 --- /dev/null +++ b/ps2/include/fileXio_cdvd.h @@ -0,0 +1,37 @@ +#ifndef PS2_CD_H +#define PS2_CD_H + +#include +#include +#include + +#define CDVD_INIT_INIT 0x00 +#define CDVD_INIT_NOCHECK 0x01 +#define CDVD_INIT_EXIT 0x05 + +typedef enum { + CDVD_TYPE_NODISK = 0x00, /* No Disc inserted */ + CDVD_TYPE_DETECT, /* Detecting disc type */ + CDVD_TYPE_DETECT_CD, + CDVD_TYPE_DETECT_DVDSINGLE, + CDVD_TYPE_DETECT_DVDDUAL, + CDVD_TYPE_UNKNOWN, /* Unknown disc type */ + + CDVD_TYPE_PS1CD = 0x10, /* PS1 CD with no CDDA tracks */ + CDVD_TYPE_PS1CDDA, /* PS1 CD with CDDA tracks */ + CDVD_TYPE_PS2CD, /* PS2 CD with no CDDA tracks */ + CDVD_TYPE_PS2CDDA, /* PS2 CD with CDDA tracks */ + CDVD_TYPE_PS2DVD, /* PS2 DVD */ + + CDVD_TYPE_CDDA = 0xFD, /* CDDA */ + CDVD_TYPE_DVDVIDEO, /* DVD Video */ + CDVD_TYPE_ILLEGAL, /* Illegal disk type */ +} CdvdDiscType_t; + +int cdInit(int); + +int ps2fileXioDopen(const char *name); +int ps2fileXioDread(int fd, iox_dirent_t *dirent); +int ps2fileXioDclose(int fd); + +#endif /* PS2_CD_H */ diff --git a/ps2/include/murmur3.h b/ps2/include/murmur3.h deleted file mode 100755 index 555659f620..0000000000 --- a/ps2/include/murmur3.h +++ /dev/null @@ -1,29 +0,0 @@ -//----------------------------------------------------------------------------- -// MurmurHash3 was written by Austin Appleby, and is placed in the -// public domain. The author hereby disclaims copyright to this source -// code. - -#ifndef _MURMURHASH3_H_ -#define _MURMURHASH3_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*-----------------------------------------------------------------------------*/ - -void MurmurHash3_x86_32(const void *key, int len, uint32_t seed, void *out); - -void MurmurHash3_x86_128(const void *key, int len, uint32_t seed, void *out); - -void MurmurHash3_x64_128(const void *key, int len, uint32_t seed, void *out); - -/*-----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _MURMURHASH3_H_ */ diff --git a/ps2/include/ps2_descriptor.h b/ps2/include/ps2_descriptor.h index 5a4f0fcbd3..1d9e84c3a8 100644 --- a/ps2/include/ps2_descriptor.h +++ b/ps2/include/ps2_descriptor.h @@ -16,7 +16,7 @@ #define PS2_DESCRIPTOR_H #include -#include +#include #define MAX_OPEN_FILES 256 #define FILEENTRY_SIZE 2048 @@ -40,20 +40,9 @@ extern DescriptorTranslation *__ps2_fdmap[]; void _init_ps2_io(void); void _free_ps2_io(void); - +int is_fd_valid(int fd); int __ps2_acquire_descriptor(void); int __ps2_release_descriptor(int fd); -int __ps2_duplicate_descriptor(int fd); -int __ps2_descriptor_ref_count(int fd); DescriptorTranslation *__ps2_fd_grab(int fd); -int __ps2_fd_drop(DescriptorTranslation *fdmap); - -static inline int is_fd_valid(int fd) -{ - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - - return (fd > 0) && (fd < MAX_OPEN_FILES) && (__ps2_fdmap[fd] != NULL); -} #endif /* PS2_DESCRIPTOR_H */ diff --git a/ps2/include/ps2_hashtable.h b/ps2/include/ps2_hashtable.h deleted file mode 100644 index 2b3d86a50f..0000000000 --- a/ps2/include/ps2_hashtable.h +++ /dev/null @@ -1,45 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2018 - Francisco Javier Trujillo Mata - fjtrujy - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef PS2_HASHTABLE_H -#define PS2_HASHTABLE_H - -#include -#include - -struct table_entry { - char *key; - void *value; - uint32_t hash; - struct table_entry *next; -}; - -struct hash_table { - uint32_t capacity; - uint32_t size; - struct table_entry **table; -}; - -typedef struct hash_table HashTable; - -HashTable *crb_hashtable_create(uint32_t _size); -void crb_hashtable_destroy(HashTable **_tbl); - -void crb_hashtable_grow(HashTable *_tbl); -void crb_hashtable_hash(const char *_key, uint32_t *hash); -bool crb_hashtable_insert(HashTable *_tbl, const char *_key, void *_data); -void *crb_hashtable_find(HashTable *_tbl, const char *_key); -void *crb_hashtable_remove(HashTable *_tbl, const char *_key); - -#endif diff --git a/ps2/libcdvd/docs/libcdvd_ref.pdf b/ps2/libcdvd/docs/libcdvd_ref.pdf deleted file mode 100644 index b8a99aa09d..0000000000 Binary files a/ps2/libcdvd/docs/libcdvd_ref.pdf and /dev/null differ diff --git a/ps2/libcdvd/example/Makefile b/ps2/libcdvd/example/Makefile deleted file mode 100644 index bc02ebc7ac..0000000000 --- a/ps2/libcdvd/example/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -#update this to point to the location of gslib -GSLIB = /ps2dev/gslib - -EE_BIN = example.elf -EE_OBJS = example.o - -EE_LDFLAGS += -L../lib -L$(GSLIB)/lib -EE_LIBS += -lkernel -lcdvdfs -lgs -lgcc -lsupc++ -lpad -EE_INCS += -I $(GSLIB)/source -I ../ee - -all: $(EE_BIN) - -clean: - rm -f *.elf *.o *.a - -include $(PS2LIB)/Makefile.pref -include $(PS2LIB)/Makefile.eeglobal diff --git a/ps2/libcdvd/example/example.cpp b/ps2/libcdvd/example/example.cpp deleted file mode 100644 index 8f42e44db6..0000000000 --- a/ps2/libcdvd/example/example.cpp +++ /dev/null @@ -1,425 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include "cdvd_rpc.h" - -#define scr_w 640 -#define scr_h 480 - - -#define TEXT_COL_BRIGHT GS_SET_RGBA(0xFF, 0xFF, 0xFF, 0x80) -#define TEXT_COL_DIM GS_SET_RGBA(0x40, 0x40, 0xFF, 0x80) - -#define TRUE 1 -#define FALSE 0 - -gsDriver *pDisplay; - -extern int screen; -int filelisty = 60; - -static float selected = 1; // The currently selected file/dir - - -int button_released = TRUE; - -//A pointer to an array of TocEntries to be alloc'd later -static struct TocEntry *TocEntryList; - - - -gsFontTex *fontTex; - - - -// pathname on CD -char pathname[1024 + 1] __attribute__((aligned(64))); - -gsFont myFont; - -int WaitPadReady(int port, int slot); -void SetPadMode(int port, int slot); - - -void ClearScreen(void) -{ - pDisplay->drawPipe.setAlphaEnable(GS_DISABLE); - pDisplay->drawPipe.RectFlat(0, 0, scr_w, scr_h, 0, GS_SET_RGBA(0, 0, 0, 0x80)); - pDisplay->drawPipe.setAlphaEnable(GS_ENABLE); - pDisplay->drawPipe.Flush(); -} - - -int main(void) -{ - SifInitRpc(0); - - SifLoadModule("rom0:SIO2MAN", 0, NULL); /* load sio2 manager irx */ - SifLoadModule("rom0:PADMAN", 0, NULL); /* load pad manager irx */ - - SifLoadModule("host:cdvd.irx", 0, NULL); - - CDVD_Init(); - - padInit(0); - - char *padBuf = (char *)memalign(64, 256); - - padPortOpen(0, 0, padBuf); - - SetPadMode(0, 0); - - // allocate the memory for a large file list - TocEntryList = (TocEntry *)memalign(64, 4000 * sizeof(struct TocEntry)); - - - // open the font file, find the size of the file, allocate memory for it, and load it - int fontfile = fioOpen("host:font.fnt", O_RDONLY); - int fontsize = fioLseek(fontfile, 0, SEEK_END); - fioLseek(fontfile, 0, SEEK_SET); - fontTex = (gsFontTex *)memalign(64, fontsize); - fioRead(fontfile, fontTex, fontsize); - fioClose(fontfile); - - // Upload the background to the texture buffer - pDisplay = new gsDriver; - - pDisplay->setDisplayMode(scr_w, scr_h, - 170, 80, - GS_PSMCT32, 2, - GS_TV_AUTO, GS_TV_INTERLACE, - GS_DISABLE, GS_DISABLE); - - // Enable Alpha Blending - pDisplay->drawPipe.setAlphaEnable(GS_ENABLE); - - myFont.assignPipe(&(pDisplay->drawPipe)); - - // Upload the font into the texture memory past the screen buffers - myFont.uploadFont(fontTex, pDisplay->getTextureBufferBase(), - fontTex->TexWidth, // Use the fontTex width as texbuffer width (can use diff width) - 0, 0); - - -#define list_max 21 - int list_size = 21; // Number of files to display in list - int first_file = 1; // The first file to display in the on-screen list - int num_files = 0; // The total number of files in the list - int offset; // Offset of the selected file into the displayed list - - struct padButtonStatus padButtons; - int ps2_buttons; - - button_released = TRUE; - - while (1) { - - while (1) // until we've selected a file - { - // Get entries from specified path, don't filter by file extension, - // get files and directories, get a maximum of 4000 entries, and update path if dir changed - num_files = CDVD_GetDir(pathname, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList, 4000, pathname); - - if (num_files < list_max) - list_size = num_files; - else - list_size = list_max; - - // Don't leave the drive spinning, it's annoying ! - CDVD_Stop(); - - while (1) // Until we've selected something (dir or file) - { - - // Get button presses - // If X then select the previously highlighted file - // If up/down then increase/decrease the selected file - int padState; - - // only listen to pad input if it's plugged in, and stable - padState = padGetState(0, 0); - if (padState == PAD_STATE_STABLE) { - padRead(0, 0, &padButtons); - ps2_buttons = (padButtons.btns[0] << 8) | padButtons.btns[1]; - ps2_buttons = ~ps2_buttons; - - if (num_files > 0) { - // file Selected - if (ps2_buttons & PAD_CROSS) { - if (button_released == TRUE) { - button_released = FALSE; - break; - } - } else - button_released = TRUE; - - // DPAD + Shoulder file Selection - if (ps2_buttons & PAD_UP) - selected -= 0.15; - else if (ps2_buttons & PAD_DOWN) - selected += 0.15; - else if (ps2_buttons & PAD_R1) - selected -= 1; - else if (ps2_buttons & PAD_R2) - selected += 1; - else if (ps2_buttons & PAD_L1) - selected = 1; - else if (ps2_buttons & PAD_L2) - selected = num_files; - } - - if (ps2_buttons & PAD_SELECT) { - strcpy(pathname, "/"); - - ClearScreen(); - - myFont.Print(0, 640, 220, 4, - TEXT_COL_BRIGHT, - GSFONT_ALIGN_CENTRE, "Please Change CD\nThen Press 'X'"); - - pDisplay->drawPipe.Flush(); - - // Wait for VSync and then swap buffers - pDisplay->WaitForVSync(); - - pDisplay->swapBuffers(); - - - CDVD_FlushCache(); - strcpy(pathname, "/"); - - while (1) { - int padState; - - // only listen to pad input if it's plugged in, and stable - padState = padGetState(0, 0); - if (padState == PAD_STATE_STABLE) { - padRead(0, 0, &padButtons); - ps2_buttons = (padButtons.btns[0] << 8) | padButtons.btns[1]; - ps2_buttons = ~ps2_buttons; - - // ROM Selected - if (ps2_buttons & PAD_CROSS) { - break; - } - } - - pDisplay->WaitForVSync(); - } - - num_files = CDVD_GetDir(pathname, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList, 4000, pathname); - - if (num_files < list_max) - list_size = num_files; - else - list_size = list_max; - - selected = 1; - - CDVD_Stop(); - } - - if ((padButtons.mode >> 4) == 0x07) { - // Analogue file selection - float pad_v; - - pad_v = (float)(padButtons.ljoy_v - 128); // Range = +127 to -128 - - - if (pad_v > 32) { - // scrolling down, so incrementing selected tom - pad_v -= 32; - selected += (pad_v / 96); - } - - if (pad_v < -32) { - // scrolling down, so incrementing selected tom - pad_v += 32; - selected += (pad_v / 96); - } - } - - - - if (selected < 1) - selected = 1; - - if ((int)selected > num_files) - selected = (float)num_files; - } - - // calculate which file to display first in the list - if ((int)selected <= list_size / 2) - first_file = 1; - else { - if ((int)selected >= (num_files - (list_size / 2) + 1)) - first_file = num_files - list_size + 1; - else - first_file = (int)selected - ((list_size / 2)); - } - - // calculate the offset of the selected file into the displayed list - offset = (int)selected - first_file; - - - ClearScreen(); - - if (num_files > 0) { - // pDisplay->drawPipe.setScissorRect(list_xpos,list_ypos,list_xpos+list_width,list_ypos+list_height); - - for (int file = 0; file < list_size; file++) { - // if the entry is a dir, then display the directory symbol before the name - if (TocEntryList[first_file + file - 1].fileProperties & 0x02) { - // display a dir symbol (character 001 in the bitmap font) - myFont.Print(128, 640, filelisty + (file * 18), 4, GS_SET_RGBA(0x80, 0x80, 0x80, 0x80), GSFONT_ALIGN_LEFT, "\001"); - - if (file == ((int)selected - first_file)) { - myFont.Print(148, 640, filelisty + (file * 18), 4, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - TocEntryList[first_file + file - 1].filename); - } else { - myFont.Print(148, 640, filelisty + (file * 18), 4, TEXT_COL_DIM, GSFONT_ALIGN_LEFT, - TocEntryList[first_file + file - 1].filename); - } - } else { - if (file == ((int)selected - first_file)) { - myFont.Print(128, 640, filelisty + (file * 18), 4, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - TocEntryList[first_file + file - 1].filename); - } else { - myFont.Print(128, 640, filelisty + (file * 18), 4, TEXT_COL_DIM, GSFONT_ALIGN_LEFT, - TocEntryList[first_file + file - 1].filename); - } - } - } - - myFont.Print(420, 640, 440, 0, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - "Press X to Select"); - - myFont.Print(420, 640, 458, 0, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - "Press SELECT to Change CD"); - } - - - pDisplay->drawPipe.Flush(); - - // Wait for VSync and then swap buffers - pDisplay->WaitForVSync(); - - pDisplay->swapBuffers(); - } - - // We've selected something, but is it a file or a dir ? - if (TocEntryList[((int)selected) - 1].fileProperties & 0x02) { - // Append name onto current path - //gui_getfile_dispname((int)selected, tempname); - strcat(pathname, "/"); - strcat(pathname, TocEntryList[((int)selected) - 1].filename); - - // file list will be got next time round the while loop - - // Start from top of list - selected = 1; - } else { - // It's not a dir, so it must be a file - break; - } - } - - char size_string[64]; - - if (TocEntryList[((int)selected) - 1].fileSize < (2 * 1024)) - sprintf(size_string, "%d bytes", TocEntryList[((int)selected) - 1].fileSize); - else { - if (TocEntryList[((int)selected) - 1].fileSize < (2 * 1024 * 1024)) - sprintf(size_string, "%d Kb", TocEntryList[((int)selected) - 1].fileSize / 1024); - else - sprintf(size_string, "%d Mb", TocEntryList[((int)selected) - 1].fileSize / (1024 * 1024)); - } - - - for (int frame = 0; frame < 200; frame++) { - - // Selected a file, so display file properties for a couple of seconds - ClearScreen(); - - myFont.Print(100, 200, 220, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - "File name:"); - - myFont.Print(200, 640, 220, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - TocEntryList[((int)selected) - 1].filename); - - myFont.Print(100, 200, 240, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - "File path:"); - - myFont.Print(200, 640, 240, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - pathname); - - - myFont.Print(100, 200, 260, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - "File size:"); - - myFont.Print(200, 640, 260, 1, TEXT_COL_BRIGHT, GSFONT_ALIGN_LEFT, - size_string); - - pDisplay->drawPipe.Flush(); - - // Wait for VSync and then swap buffers - pDisplay->WaitForVSync(); - - pDisplay->swapBuffers(); - } - } - - free(fontTex); - - free(TocEntryList); - - delete pDisplay; - - return 0; -} - - -int WaitPadReady(int port, int slot) -{ - int state = 0; - - while ((state != PAD_STATE_STABLE) && - (state != PAD_STATE_FINDCTP1)) { - state = padGetState(port, slot); - - if (state == PAD_STATE_DISCONN) - break; // If no pad connected then dont wait for it to be plugged in - - //pEmuDisplay->WaitForVSync(); - } - - return state; -} - - -void SetPadMode(int port, int slot) -{ - // If the controller is already plugged in then - // put the controller into Analogue mode (and lock it) - // so that analogue stick can be used - - if (WaitPadReady(port, slot) == PAD_STATE_STABLE) // if pad is connected then initialise it - { - padSetMainMode(port, slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); - - WaitPadReady(port, slot); - } -} diff --git a/ps2/libcdvd/example/font.fnt b/ps2/libcdvd/example/font.fnt deleted file mode 100644 index 8d747f8826..0000000000 Binary files a/ps2/libcdvd/example/font.fnt and /dev/null differ diff --git a/ps2/libcdvd/iop/cdvd_iop.c b/ps2/libcdvd/iop/cdvd_iop.c index 3e82b57267..6fd3b8dd6c 100644 --- a/ps2/libcdvd/iop/cdvd_iop.c +++ b/ps2/libcdvd/iop/cdvd_iop.c @@ -1574,7 +1574,7 @@ void *CDVDRpc_TrayReq(unsigned int *sbuff) { int ret; - sceCdTrayReq(sbuff[0], (s32 *)&ret); + sceCdTrayReq(sbuff[0], (int *)&ret); sbuff[0] = ret; return sbuff;