diff --git a/Makefile.ps2 b/Makefile.ps2 index 05cadc6ab9..a1376e4ff3 100644 --- a/Makefile.ps2 +++ b/Makefile.ps2 @@ -11,8 +11,6 @@ PS2_IP = 192.168.1.150 TARGET = retroarchps2.elf TARGET_RELEASE = retroarchps2-release.elf -# Lib CDVD -CDVD_DIR = ps2/libcdvd # Compile the IRXs first IRX_DIR = ps2/irx @@ -30,7 +28,7 @@ ifeq ($(MUTE_WARNINGS), 1) DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses endif -INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(CDVD_DIR)/ee +INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip INCDIR += -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper GPVAL = -G0 @@ -41,9 +39,9 @@ RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHA RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER LIBDIR = -LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L$(CDVD_DIR)/lib -L. -LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lmf -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz -LIBS += -lcdvdfs -lpatches -lpoweroff +LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L. +LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz +LIBS += -lpatches -lpoweroff ifeq ($(BUILD_FOR_PCSX2), 1) RARCH_DEFINES += -DBUILD_FOR_PCSX2 @@ -71,13 +69,10 @@ CFLAGS += $(RARCH_DEFINES) EE_OBJS += $(IRX_DIR)/freemtap_irx.o $(IRX_DIR)/freepad_irx.o $(IRX_DIR)/freesio2_irx.o $(IRX_DIR)/iomanX_irx.o EE_OBJS += $(IRX_DIR)/fileXio_irx.o $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o $(IRX_DIR)/usbd_irx.o EE_OBJS += $(IRX_DIR)/usbhdfsd_irx.o $(IRX_DIR)/freesd_irx.o $(IRX_DIR)/audsrv_irx.o $(IRX_DIR)/poweroff_irx.o -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/fileXio_cdvd.o ps2/compat_files/ps2_descriptor.o +EE_OBJS += ps2/compat_files/ps2_devices.o -#EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o EE_OBJS += griffin/griffin.o EE_CFLAGS = $(CFLAGS) @@ -106,7 +101,10 @@ prepare: run: ps2client -h $(PS2_IP) execee host:$(EE_BIN) -debug: clean prepare all run +sim: + PCSX2 --elf=$(PWD)/$(EE_BIN) --nogui + +debug: clean all run package: ps2-packer $(EE_BIN) $(TARGET_RELEASE) @@ -115,9 +113,4 @@ release: clean all package #Include preferences include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal - -#Linking with C++ -$(EE_BIN): $(EE_OBJS) $(PS2SDK)/ee/startup/crt0.o - $(EE_CXX) $(EE_NO_CRT) -T$(PS2SDK)/ee/startup/linkfile $(EE_CXXFLAGS) \ - -o $(EE_BIN) $(PS2SDK)/ee/startup/crt0.o $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(EE_OBJS) $(CRTEND_OBJ) $(CRTN_OBJ) $(EE_LDFLAGS) $(EE_LIBS) +include $(PS2SDK)/samples/Makefile.eeglobal_cpp diff --git a/core_info.c b/core_info.c index 9d82943909..e198ed782f 100644 --- a/core_info.c +++ b/core_info.c @@ -232,7 +232,7 @@ static config_file_t *core_info_list_iterate( current_path, info_path_base_size); -#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(PS2) && !defined(HW_WUP)) +#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA) && !defined(HW_WUP)) { char *substr = strrchr(info_path_base, '_'); if (substr) diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index e45f0b1953..f815fa1d33 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -16,7 +16,6 @@ #include "../frontend_driver.h" -#include #include #include #include @@ -27,12 +26,8 @@ #include #include #include -#include -#include -#include #include #include -#include char eboot_path[512]; char user_path[512]; @@ -186,9 +181,6 @@ static void frontend_ps2_init(void *data) SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, NULL); SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, NULL); - /* CDVD */ - SifExecModuleBuffer(&cdvd_irx, size_cdvd_irx, 0, NULL, NULL); - if (mcInit(MC_TYPE_XMC)) { RARCH_ERR("mcInit library not initalizated\n"); } @@ -210,20 +202,6 @@ static void frontend_ps2_init(void *data) RARCH_ERR("mtapPortOpen library not initalizated\n"); } - /* Initializes CDVD library */ - /* SCECdINoD init without check for a disc. Reduces risk of a lockup if the drive is in a erroneous state. */ - sceCdInit(SCECdINoD); - if (CDVD_Init() != 1) { - RARCH_ERR("CDVD_Init library not initalizated\n"); - } - - _init_ps2_io(); - - /* Prepare device */ - getcwd(cwd, sizeof(cwd)); - bootDeviceID=getBootDeviceID(cwd); - waitUntilDeviceIsReady(bootDeviceID); - #if defined(HAVE_FILE_LOGGER) retro_main_log_file_init("retroarch.log", false); verbosity_enable(); @@ -237,11 +215,8 @@ static void frontend_ps2_deinit(void *data) verbosity_disable(); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); #endif - _free_ps2_io(); - CDVD_Stop(); padEnd(); audsrv_quit(); - fileXioExit(); Exit(0); } diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index 5d6f86146b..6b7a977b2f 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -33,7 +33,6 @@ typedef struct ps2_video { - bool clearVRAM; /* I need to create this additional field * to be used in the font driver*/ bool clearVRAM_font; @@ -93,6 +92,8 @@ static GSTEXTURE *prepare_new_texture(void) static void init_ps2_video(ps2_video_t *ps2) { ps2->gsGlobal = init_GSGlobal(); + gsKit_TexManager_init(ps2->gsGlobal); + ps2->menuTexture = prepare_new_texture(); ps2->coreTexture = prepare_new_texture(); @@ -108,16 +109,8 @@ static void ps2_gfx_deinit_texture(GSTEXTURE *texture) texture->Clut = NULL; } -static bool texture_need_prepare(GSTEXTURE *texture, - int width, int height, int PSM) -{ - return texture->Width != width || - texture->Height != height || - texture->PSM != PSM; -} - -static void transfer_texture(GSTEXTURE *texture, const void *frame, - int width, int height, int PSM, int filter, bool color_correction) +static void set_texture(GSTEXTURE *texture, const void *frame, + int width, int height, int PSM, int filter) { texture->Width = width; texture->Height = height; @@ -126,25 +119,6 @@ static void transfer_texture(GSTEXTURE *texture, const void *frame, texture->Mem = (void *)frame; } -static void vram_alloc(GSGLOBAL *gsGlobal, GSTEXTURE *texture) -{ - uint32_t size = gsKit_texture_size(texture->Width, - texture->Height, texture->PSM); - texture->Vram = gsKit_vram_alloc(gsGlobal, size, GSKIT_ALLOC_USERBUFFER); - - if(texture->Vram == GSKIT_ALLOC_ERROR) - { - printf("VRAM Allocation Failed. Will not upload texture.\n"); - } - - if (texture->Clut) - { - /* Right now just supporting 16 x 16 = 256 colours */ - size = gsKit_texture_size(16, 16, texture->ClutPSM); - texture->VramClut = gsKit_vram_alloc(gsGlobal, size , GSKIT_ALLOC_USERBUFFER); - } -} - static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, bool force_aspect, struct retro_hw_ps2_insets padding) { float x1, y1, x2, y2; @@ -185,65 +159,13 @@ static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, GS_TEXT); } -static void clearVRAMIfNeeded(ps2_video_t *ps2, - const void *frame, int width, int height) -{ - if (!ps2->clearVRAM) - { - if(frame && frame != RETRO_HW_FRAME_BUFFER_VALID) - { - bool coreVRAMClear = texture_need_prepare( - ps2->coreTexture, width, height, ps2->PSM); - ps2->clearVRAM = ps2->clearVRAM || coreVRAMClear; - } - } - - if (ps2->clearVRAM) - { - gsKit_vram_clear(ps2->gsGlobal); - ps2->iface.updatedPalette = true; - /* we need to upload also palette in the font driver */ - ps2->clearVRAM_font = true; - } -} - static void refreshScreen(ps2_video_t *ps2) { if (ps2->vsync) gsKit_sync_flip(ps2->gsGlobal); gsKit_queue_exec(ps2->gsGlobal); + gsKit_TexManager_nextFrame(ps2->gsGlobal); - /* Here we are just puting in false the ps2->clearVRAM field - however, the ps2->clearVRAM_font should be done in the ps2_font driver */ - ps2->clearVRAM = false; -} - -static void ps2_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, - bool sendPalette) -{ - gsKit_setup_tbw(Texture); - - if (Texture->PSM == GS_PSM_T8) - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) - { - gsKit_texture_send(Texture->Clut, 16, 16, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); - } - - } - else if (Texture->PSM == GS_PSM_T4) - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_TEXTURE); - if (sendPalette) - { - gsKit_texture_send(Texture->Clut, 8, 2, Texture->VramClut, Texture->ClutPSM, 1, GS_CLUT_PALLETE); - } - } - else - { - gsKit_texture_send(Texture->Mem, Texture->Width, Texture->Height, Texture->Vram, Texture->PSM, Texture->TBW, GS_CLUT_NONE); - } } static void *ps2_gfx_init(const video_info_t *video, @@ -270,7 +192,6 @@ static void *ps2_gfx_init(const video_info_t *video, ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; ps2->force_aspect = video->force_aspect; ps2->vsync = video->vsync; - ps2->clearVRAM = true; if (input && input_data) { @@ -294,43 +215,30 @@ static bool ps2_gfx_frame(void *data, const void *frame, return false; #if defined(DEBUG) - if (frame_count%60==0) - { + if (frame_count%180==0) printf("ps2_gfx_frame %lu\n", frame_count); - } #endif - clearVRAMIfNeeded(ps2, frame, width, height); - gsKit_clear(ps2->gsGlobal, GS_BLACK); - if (frame) { - bool sendPalette = false; struct retro_hw_ps2_insets padding = empty_ps2_insets; + /* Checking if the transfer is done in the core */ if (frame != RETRO_HW_FRAME_BUFFER_VALID) - { - /* Checking if the transfer is done in the core */ + { /* calculate proper width based in the pitch */ - int bytes_per_pixel = (ps2->PSM == GS_PSM_CT32) ? 4 : 2; - int real_width = pitch / bytes_per_pixel; - - transfer_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter, 1); + int shifh_per_bytes = (ps2->PSM == GS_PSM_CT32) ? 2 : 1; + int real_width = pitch >> shifh_per_bytes; + set_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter); padding.right = real_width - width; } else { - sendPalette = ps2->iface.updatedPalette; - ps2->iface.updatedPalette = false; padding = ps2->iface.padding; - if (ps2->iface.clearTexture) - ps2->iface.clearTexture = false; } - if(ps2->clearVRAM) - vram_alloc(ps2->gsGlobal, ps2->coreTexture); - - ps2_texture_upload(ps2->gsGlobal, ps2->coreTexture, sendPalette); + gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->coreTexture); + gsKit_TexManager_bind(ps2->gsGlobal, ps2->coreTexture); prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, ps2->force_aspect, padding); } @@ -339,9 +247,6 @@ static bool ps2_gfx_frame(void *data, const void *frame, bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height; if (!texture_empty) { - if(ps2->clearVRAM) - vram_alloc(ps2->gsGlobal, ps2->menuTexture); - gsKit_texture_upload(ps2->gsGlobal, ps2->menuTexture); prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, ps2->fullscreen, empty_ps2_insets); } } @@ -412,12 +317,11 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, { ps2_video_t *ps2 = (ps2_video_t*)data; - bool color_correction = false; int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); - bool texture_changed = texture_need_prepare(ps2->menuTexture, width, height, PSM); - transfer_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter, color_correction); - ps2->clearVRAM = ps2->clearVRAM || texture_changed; + set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter); + gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture); + gsKit_TexManager_bind(ps2->gsGlobal, ps2->menuTexture); } static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) @@ -426,10 +330,8 @@ static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) if (ps2->menuVisible != enable) { - /* If Menu change status, CLEAR VRAM */ - ps2->clearVRAM = true; - ps2->iface.clearTexture = true; - ps2->iface.updatedPalette = true; + /* If Menu change status, CLEAR SCREEN */ + gsKit_clear(ps2->gsGlobal, GS_BLACK); } ps2->menuVisible = enable; ps2->fullscreen = fullscreen; @@ -439,8 +341,6 @@ static bool ps2_get_hw_render_interface(void* data, const struct retro_hw_render_interface** iface) { ps2_video_t *ps2 = (ps2_video_t*)data; - ps2->iface.clearTexture = ps2->clearVRAM; - ps2->iface.updatedPalette = true; ps2->iface.padding = empty_ps2_insets; *iface = (const struct retro_hw_render_interface*)&ps2->iface; diff --git a/gfx/drivers_font/ps2_font.c b/gfx/drivers_font/ps2_font.c index d0406a5b88..2010500708 100644 --- a/gfx/drivers_font/ps2_font.c +++ b/gfx/drivers_font/ps2_font.c @@ -13,17 +13,16 @@ * If not, see . */ +#include +#include +#include #include #include #include #include "../font_driver.h" -#define FONTM_VRAM_SIZE 4096 #define FONTM_TEXTURE_COLOR GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) -#define FONTM_TEXTURE_WIDTH 52 -#define FONTM_TEXTURE_HEIGHT 832 -#define FONTM_TEXTURE_SPACING 1.0f #define FONTM_TEXTURE_SCALED 0.5f #define FONTM_TEXTURE_LEFT_MARGIN 0 #define FONTM_TEXTURE_BOTTOM_MARGIN 15 @@ -35,87 +34,14 @@ typedef struct ps2_font_info GSFONTM *gsFontM; } ps2_font_info_t; -/* Copied from GSKIT FONTM CLUT - FONTM Textures are GS_PSM_T4, and need a 16x16 CLUT - This is a greyscale ramp CLUT, with linear alpha. */ -static u32 gsKit_fontm_clut[16] = { - 0x00000000, 0x11111111, 0x22222222, 0x33333333, \ - 0x44444444, 0x55555555, 0x66666666, 0x77777777, \ - 0x80888888, 0x80999999, 0x80AAAAAA, 0x80BBBBBB, \ - 0x80CCCCCC, 0x80DDDDDD, 0x80EEEEEE, 0x80FFFFFF -}; - -static void deinit_gsfont_texture(GSTEXTURE *texture) -{ - if (texture->Mem) - free(texture->Mem); - texture->Mem = NULL; - - if (texture->Mem) - free(texture->Clut); - texture->Clut = NULL; -} - -static void deinit_gsfont(GSFONTM *gsFontM) -{ - deinit_gsfont_texture(gsFontM->Texture); - free(gsFontM->TexBase); - gsFontM->TexBase = NULL; - free(gsFontM); -} - -static void ps2_prepare_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM) -{ - if (gsKit_fontm_unpack(gsFontM) == 0) - { - gsFontM->Texture->Width = FONTM_TEXTURE_WIDTH; - gsFontM->Texture->Height = FONTM_TEXTURE_HEIGHT; - gsFontM->Texture->PSM = GS_PSM_T4; - gsFontM->Texture->ClutPSM = GS_PSM_CT32; - gsFontM->Texture->Filter = GS_FILTER_LINEAR; - gsKit_setup_tbw(gsFontM->Texture); - } -} - -static void ps2_upload_font(GSGLOBAL *gsGlobal, GSFONTM *gsFontM) -{ - unsigned i; - int TexSize = gsKit_texture_size( - gsFontM->Texture->Width, - gsFontM->Texture->Height, - gsFontM->Texture->PSM); - - gsFontM->Texture->VramClut = gsKit_vram_alloc( - gsGlobal, FONTM_VRAM_SIZE, GSKIT_ALLOC_USERBUFFER); - - for (i = 0; i < GS_FONTM_PAGE_COUNT; ++i) - { - gsFontM->Vram[i] = gsKit_vram_alloc( - gsGlobal, TexSize, GSKIT_ALLOC_USERBUFFER); - gsFontM->LastPage[i] = (u32) -1; - } - - gsFontM->Texture->Vram = gsFontM->Vram[0]; - gsFontM->VramIdx = 0; - gsFontM->Spacing = FONTM_TEXTURE_SPACING; - gsFontM->Align = GSKIT_FALIGN_LEFT; - - gsFontM->Texture->Clut = memalign(GS_VRAM_TBWALIGN_CLUT, GS_VRAM_TBWALIGN); - memcpy(gsFontM->Texture->Clut, gsKit_fontm_clut, GS_VRAM_TBWALIGN); - gsKit_texture_send(gsFontM->Texture->Clut, 8, 2, gsFontM->Texture->VramClut, gsFontM->Texture->ClutPSM, 1, GS_CLUT_PALLETE); - free(gsFontM->Texture->Clut); -} - static void *ps2_font_init_font(void *gl_data, const char *font_path, float font_size, bool is_threaded) { ps2_font_info_t *ps2 = (ps2_font_info_t*)calloc(1, sizeof(ps2_font_info_t)); + ps2->ps2_video = (ps2_video_t *)gl_data; + ps2->gsFontM = gsKit_init_fontm(); - ps2->ps2_video = (ps2_video_t *)gl_data; - ps2->gsFontM = gsKit_init_fontm(); - - ps2_prepare_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); - ps2_upload_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); + gsKit_fontm_upload(ps2->ps2_video->gsGlobal, ps2->gsFontM); return ps2; } @@ -123,34 +49,26 @@ static void *ps2_font_init_font(void *gl_data, const char *font_path, static void ps2_font_free_font(void *data, bool is_threaded) { ps2_font_info_t *ps2 = (ps2_font_info_t *)data; - - deinit_gsfont(ps2->gsFontM); - + gsKit_free_fontm(ps2->ps2_video->gsGlobal, ps2->gsFontM); ps2->ps2_video = NULL; - ps2 = NULL; + + free(ps2); + ps2 = NULL; } static void ps2_font_render_msg( - void *userdata, - void *data, - const char *msg, + video_frame_info_t *video_info, + void *data, const char *msg, const struct font_params *params) { ps2_font_info_t *ps2 = (ps2_font_info_t *)data; - if (ps2) + if (ps2) { int x = FONTM_TEXTURE_LEFT_MARGIN; int y = ps2->ps2_video->gsGlobal->Height - FONTM_TEXTURE_BOTTOM_MARGIN; - - if (ps2->ps2_video->clearVRAM_font) - { - ps2_upload_font(ps2->ps2_video->gsGlobal, ps2->gsFontM); - ps2->ps2_video->clearVRAM_font = false; - } - gsKit_fontm_print_scaled( - ps2->ps2_video->gsGlobal, + ps2->ps2_video->gsGlobal, ps2->gsFontM, x, y, FONTM_TEXTURE_ZPOSITION, FONTM_TEXTURE_SCALED , FONTM_TEXTURE_COLOR, msg); } diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 63d01427a4..09fd5462ca 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -70,9 +70,7 @@ #endif #if defined(PS2) -#include -#include -#include +#include #endif #if defined(__PSL1GHT__) @@ -192,7 +190,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) #elif defined(PSP) || defined(VITA) time_ticks = sceKernelGetSystemTimeWide(); #elif defined(PS2) - time_ticks = clock()*294912; // 294,912MHZ / 1000 msecs + time_ticks = ps2_clock(); #elif defined(_3DS) time_ticks = svcGetSystemTick(); #elif defined(WIIU) @@ -244,7 +242,7 @@ retro_time_t cpu_features_get_time_usec(void) #elif defined(EMSCRIPTEN) return emscripten_get_now() * 1000; #elif defined(PS2) - return clock()*1000; + return ps2_clock() / PS2_CLOCKS_PER_MSEC * 1000; #elif defined(VITA) || defined(PSP) return sceKernelGetSystemTimeWide(); #elif defined(_3DS) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index a1b7de00a6..28ebf03233 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1079,7 +1079,7 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort) return false; /* TODO: this is only useful for a few platforms, find which and add ifdef */ -#if !defined(PS2) && !defined(PSP) +#if !defined(PSP) buf = calloc(1, 0x4000); setvbuf(file, (char*)buf, _IOFBF, 0x4000); #endif diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index e8cd688308..866d54e4cd 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -79,11 +79,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif @@ -92,7 +87,7 @@ #define FIO_S_ISDIR SCE_S_ISDIR #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2) +#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include /* stat() is defined here */ #endif diff --git a/libretro-common/file/file_path_io.c b/libretro-common/file/file_path_io.c index 4ca02051df..a473f12a60 100644 --- a/libretro-common/file/file_path_io.c +++ b/libretro-common/file/file_path_io.c @@ -82,11 +82,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif diff --git a/libretro-common/include/compat/intrinsics.h b/libretro-common/include/compat/intrinsics.h index 56fcaff90d..6c7ecafcb8 100644 --- a/libretro-common/include/compat/intrinsics.h +++ b/libretro-common/include/compat/intrinsics.h @@ -41,7 +41,7 @@ RETRO_BEGIN_DECLS /* Count Leading Zero, unsigned 16bit input value */ static INLINE unsigned compat_clz_u16(uint16_t val) { -#if defined(__GNUC__) && !defined(PS2) +#if defined(__GNUC__) return __builtin_clz(val << 16 | 0x8000); #else unsigned ret = 0; diff --git a/libretro-common/include/compat/posix_string.h b/libretro-common/include/compat/posix_string.h index 51b2ec144f..47964b2a0f 100644 --- a/libretro-common/include/compat/posix_string.h +++ b/libretro-common/include/compat/posix_string.h @@ -29,10 +29,6 @@ #include #endif -#if defined(PS2) -#include -#endif - RETRO_BEGIN_DECLS #ifdef _WIN32 diff --git a/libretro-common/include/compat/strcasestr.h b/libretro-common/include/compat/strcasestr.h index ef6231217e..227e253e7b 100644 --- a/libretro-common/include/compat/strcasestr.h +++ b/libretro-common/include/compat/strcasestr.h @@ -25,10 +25,6 @@ #include -#if defined(PS2) -#include -#endif - #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) #include "../../../config.h" #endif diff --git a/libretro-common/include/libretro_gskit_ps2.h b/libretro-common/include/libretro_gskit_ps2.h index 9bbe272422..033bb1f681 100644 --- a/libretro-common/include/libretro_gskit_ps2.h +++ b/libretro-common/include/libretro_gskit_ps2.h @@ -33,7 +33,7 @@ #include -#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 1 +#define RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION 2 struct retro_hw_ps2_insets { @@ -57,8 +57,6 @@ struct retro_hw_render_interface_gskit_ps2 * in this interface. */ GSTEXTURE *coreTexture; - bool clearTexture; - bool updatedPalette; struct retro_hw_ps2_insets padding; }; typedef struct retro_hw_render_interface_gskit_ps2 RETRO_HW_RENDER_INTEFACE_GSKIT_PS2; diff --git a/libretro-common/include/retro_timers.h b/libretro-common/include/retro_timers.h index 0e6dd923e7..1b4b0c1d10 100644 --- a/libretro-common/include/retro_timers.h +++ b/libretro-common/include/retro_timers.h @@ -37,8 +37,6 @@ #include #elif defined(VITA) #include -#elif defined(PS2) -#include #elif defined(_3DS) #include <3ds.h> #else @@ -91,8 +89,6 @@ static INLINE void retro_sleep(unsigned msec) sys_timer_usleep(1000 * msec); #elif defined(PSP) || defined(VITA) sceKernelDelayThread(1000 * msec); -#elif defined(PS2) - SDL_Delay(msec); #elif defined(_3DS) svcSleepThread(1000000 * (s64)msec); #elif defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index d69069b1a5..97a7a1f834 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -872,7 +872,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us) now.tv_sec = s; now.tv_nsec = n; #elif defined(PS2) - int tickms = clock(); + int tickms = ps2_clock(); now.tv_sec = tickms/1000; now.tv_nsec = tickms * 1000; #elif defined(__mips__) || defined(VITA) || defined(_3DS) diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 38d844bbc0..ab6bdacf6c 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -51,10 +51,6 @@ # if defined(PSP) # include # endif -# if defined(PS2) -# include -# include -# endif # include # include # if !defined(VITA) @@ -93,16 +89,13 @@ # if defined(PSP) # include # endif -# if defined(PS2) -# include -# endif # include # include # include # include #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2) +#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include /* stat() is defined here */ #endif @@ -146,11 +139,6 @@ #include #endif -#if defined(PS2) -#include -#include -#endif - #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) #include #endif @@ -207,14 +195,6 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i return _fseeki64(stream->fp, offset, whence); #elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310 return fseek(stream->fp, (long)offset, whence); -#elif defined(PS2) - { - int64_t ret = fileXioLseek(fileno(stream->fp), (off_t)offset, whence); - /* fileXioLseek could return positive numbers */ - if (ret > 0) - return 0; - return ret; - } #elif defined(ORBIS) { int ret = orbisLseek(stream->fd, offset, whence); @@ -350,9 +330,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( flags = O_WRONLY | O_CREAT | O_TRUNC; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -364,9 +342,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( mode_str = "w+b"; flags = O_RDWR | O_CREAT | O_TRUNC; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -380,9 +356,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( flags = O_RDWR; #if !defined(ORBIS) -#if defined(PS2) - flags |= FIO_S_IRUSR | FIO_S_IWUSR; -#elif !defined(_WIN32) +#if !defined(_WIN32) flags |= S_IRUSR | S_IWUSR; #else flags |= O_BINARY; @@ -438,7 +412,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ -#if !defined(PS2) && !defined(PSP) +#if !defined(PSP) if (stream->scheme != VFS_SCHEME_CDROM) { stream->buf = (char*)calloc(1, 0x4000); @@ -913,42 +887,6 @@ int retro_vfs_stat_impl(const char *path, int32_t *size) return RETRO_VFS_STAT_IS_VALID | (is_dir ? RETRO_VFS_STAT_IS_DIRECTORY : 0) | (is_character_special ? RETRO_VFS_STAT_IS_CHARACTER_SPECIAL : 0); -#elif defined(PS2) - /* PS2 */ - iox_stat_t buf; - bool is_dir; - bool is_character_special = false; - char *tmp = NULL; - size_t len = 0; - - if (!path || !*path) - return 0; - - tmp = strdup(path); - len = strlen(tmp); - if (tmp[len-1] == '/') - tmp[len-1] = '\0'; - - fileXioGetStat(tmp, &buf); - free(tmp); - - if (size) - *size = (int32_t)buf.size; - - if (!buf.mode) - { - /* if fileXioGetStat fails */ - int dir_ret = fileXioDopen(path); - is_dir = dir_ret > 0; - if (is_dir) { - fileXioDclose(dir_ret); - } - } - else - is_dir = FIO_S_ISDIR(buf.mode); - - return RETRO_VFS_STAT_IS_VALID | (is_dir ? RETRO_VFS_STAT_IS_DIRECTORY : 0) | (is_character_special ? RETRO_VFS_STAT_IS_CHARACTER_SPECIAL : 0); - #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) /* CellOS Lv2 */ bool is_dir; @@ -1058,8 +996,6 @@ int retro_vfs_mkdir_impl(const char *dir) int ret = mkdir(dir, 0755); #elif defined(VITA) || defined(PSP) int ret = sceIoMkdir(dir, 0777); -#elif defined(PS2) - int ret = fileXioMkdir(dir, 0777); #elif defined(ORBIS) int ret = orbisMkdir(dir, 0755); #elif defined(__QNX__) @@ -1092,9 +1028,6 @@ struct libretro_vfs_implementation_dir #elif defined(VITA) || defined(PSP) SceUID directory; SceIoDirent entry; -#elif defined(PS2) - int directory; - iox_dirent_t entry; #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) CellFsErrno error; int directory; @@ -1112,7 +1045,7 @@ static bool dirent_check_error(libretro_vfs_implementation_dir *rdir) { #if defined(_WIN32) return (rdir->directory == INVALID_HANDLE_VALUE); -#elif defined(VITA) || defined(PSP) || defined(PS2) || defined(ORBIS) +#elif defined(VITA) || defined(PSP) || defined(ORBIS) return (rdir->directory < 0); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) return (rdir->error != CELL_FS_SUCCEEDED); @@ -1176,8 +1109,6 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl( #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); -#elif defined(PS2) - rdir->directory = ps2fileXioDopen(name); #elif defined(_3DS) rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; @@ -1218,11 +1149,6 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir) return (rdir->directory != INVALID_HANDLE_VALUE); #elif defined(VITA) || defined(PSP) return (sceIoDread(rdir->directory, &rdir->entry) > 0); -#elif defined(PS2) - iox_dirent_t record; - int ret = ps2fileXioDread(rdir->directory, &record); - rdir->entry = record; - return ( ret > 0); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) uint64_t nread; rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread); @@ -1259,8 +1185,6 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir return (char*)rdir->entry.cFileName; #elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) || defined(ORBIS) return rdir->entry.d_name; -#elif defined(PS2) - return rdir->entry.name; #else if (!rdir || !rdir->entry) return NULL; @@ -1280,9 +1204,6 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir) #elif defined(VITA) return SCE_S_ISDIR(entry->d_stat.st_mode); #endif -#elif defined(PS2) - const iox_dirent_t *entry = (const iox_dirent_t*)&rdir->entry; - return FIO_S_ISDIR(entry->stat.mode); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) CellFsDirent *entry = (CellFsDirent*)&rdir->entry; return (entry->d_type == CELL_FS_TYPE_DIRECTORY); @@ -1322,8 +1243,6 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir) FindClose(rdir->directory); #elif defined(VITA) || defined(PSP) sceIoDclose(rdir->directory); -#elif defined(PS2) - ps2fileXioDclose(rdir->directory); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) rdir->error = cellFsClosedir(rdir->directory); #elif defined(ORBIS) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index c1b13ef273..f6083484ed 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2162,10 +2162,8 @@ static bool menu_init(menu_handle_t *menu_data) configuration_set_bool(settings, settings->bools.menu_show_start_screen, false); -#if !(defined(PS2) && defined(DEBUG)) /* TODO: PS2 IMPROVEMENT */ if (config_save_on_exit) command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); -#endif } #endif diff --git a/ps2/compat_files/compat_ctype.c b/ps2/compat_files/compat_ctype.c deleted file mode 100644 index 1766833c05..0000000000 --- a/ps2/compat_files/compat_ctype.c +++ /dev/null @@ -1,476 +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 -#include - -#define ULLONG_MAX UINT64_C(0xffffffffffffffff) - -/* All the functions included in this file either could be: - - Because the PS2SDK doesn't contains this specific functionality - - Because the PS2SDK implementation is wrong - - Overrriding these methods here, make that the RetroArch will execute this code - rather than the code in the linked libraries - */ - -int islower(int c) -{ - if ((c < 'a') || (c > 'z')) - return 0; - - /* passed both criteria, so it - * is a lower case alpha char */ - return 1; -} - -int tolower(int ch) -{ - if (ch >= 'A' && ch <= 'Z') - return ('a' + ch - 'A'); - return ch; -} - -int toupper(int c) -{ - if (islower(c)) - c -= 32; - - return c; -} - -int memcmp(const void *s1, const void *s2, unsigned int length) -{ - const char *a = s1; - const char *b = s2; - - while (length--) - { - if (*a++ != *b++) - return 1; - } - - return 0; -} - -void * memcpy (void *dest, const void *src, size_t len) -{ - char *d = dest; - const char *s = src; - while (len--) - *d++ = *s++; - return dest; -} - -void * memset (void *dest, int val, size_t len) -{ - unsigned char *ptr = dest; - while (len-- > 0) - *ptr++ = val; - return dest; -} - -int sprintf (char *s, const char *format, ...) -{ - va_list arg; - int done; - va_start (arg, format); - done = vsprintf (s, format, arg); - va_end (arg); - return done; -} - -char * strcat(char *dest, const char *src) -{ - size_t i,j; - for (i = 0; dest[i] != '\0'; i++) - ; - for (j = 0; src[j] != '\0'; j++) - dest[i+j] = src[j]; - dest[i+j] = '\0'; - return dest; -} - -char *strchr(const char *string, int c) -{ - while (*string) - { - if (*string == c) - return (char *)string; - string++; - } - - if (*string == c) - return (char *)string; - - return NULL; -} - -int strcmp(const char *s1, const char *s2) -{ - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} - -char * strcpy(char *to, const char *from) -{ - char *save = to; - - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); -} - -size_t strcspn(const char *s1, const char *s2) -{ - const char *p, *spanp; - char c, sc; - - /* - * Stop as soon as we find any character from s2. Note that there - * must be a NUL in s2; it suffices to stop when we find that, too. - */ - for (p = s1;;) - { - c = *p++; - spanp = s2; - do - { - if ((sc = *spanp++) == c) - return (p - 1 - s1); - }while(sc != 0); - } - /* NOTREACHED */ -} - -size_t strlen(const char *str) -{ - const char *s; - - for (s = str; *s; ++s) - ; - return (s - str); -} - -char * strncat(char *dst, const char *src, size_t n) -{ - if (n != 0) - { - char *d = dst; - const char *s = src; - - while (*d != 0) - d++; - do - { - if ((*d = *s++) == 0) - break; - d++; - }while(--n != 0); - *d = 0; - } - return (dst); -} - -int strncmp(const char *s1, const char *s2, size_t n) -{ - if (n == 0) - return (0); - - do - { - if (*s1 != *s2++) - return (*(unsigned char *)s1 - *(unsigned char *)--s2); - if (*s1++ == 0) - break; - }while (--n != 0); - - return (0); -} - -char * strncpy(char *dst, const char *src, size_t n) -{ - if (n != 0) - { - char *d = dst; - const char *s = src; - - do - { - if ((*d++ = *s++) == 0) - { - /* NUL pad the remaining n-1 bytes */ - while (--n != 0) - *d++ = 0; - break; - } - }while(--n != 0); - } - return (dst); -} - -char * strpbrk(const char *s1, const char *s2) -{ - const char *scanp; - int c, sc; - - while ((c = *s1++) != 0) - { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) - return ((char *)(s1 - 1)); - } - return (NULL); -} - -/* Do not link to strrchr() from libc */ -char * strrchr(const char *p, int ch) -{ - char *save; - - for (save = NULL;; ++p) - { - if (*p == (char) ch) - save = (char *)p; - if (!*p) - return(save); - } -} - -size_t strspn(const char *s1, const char *s2) -{ - const char *p = s1, *spanp; - char c, sc; - - /* - * Skip any characters in s2, excluding the terminating \0. - */ -cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (p - 1 - s1); -} - -char *strstr(const char *string, const char *substring) -{ - char *strpos; - - if (string == 0) - return 0; - - if (strlen(substring) == 0) - return (char *)string; - - strpos = (char *)string; - - while (*strpos != 0) - { - if (strncmp(strpos, substring, strlen(substring)) == 0) - return strpos; - - strpos++; - } - - return 0; -} - -size_t strnlen(const char *str, size_t maxlen) -{ - const char *cp; - - for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) - ; - - return (size_t)(cp - str); -} - -char *strtok(char *strToken, const char *strDelimit) -{ - static char *start; - static char *end; - - if (strToken) - start = strToken; - else - { - if (*end == 0) - return 0; - - start = end; - } - - if (*start == 0) - return 0; - - /* Strip out any leading delimiters */ - while (strchr(strDelimit, *start)) - { - /* If a character from the delimiting string - * then skip past it */ - start++; - - if (*start == 0) - return 0; - } - - if (*start == 0) - return 0; - - end = start; - - while (*end != 0) - { - if (strchr(strDelimit, *end)) - { - /* if we find a delimiting character - * before the end of the string, then - * terminate the token and move the end - * pointer to the next character - */ - *end = 0; - end++; - return start; - } - end++; - } - - /* reached the end of the string before finding a delimiter - * so dont move on to the next character */ - return start; -} - -char * strtok_r (char *s, const char *delim, char **save_ptr) -{ - char *end; - if (!s) - s = *save_ptr; - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - /* Scan leading delimiters. */ - s += strspn (s, delim); - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - /* Find the end of the token. */ - end = s + strcspn (s, delim); - if (*end == '\0') - { - *save_ptr = end; - return s; - } - /* Terminate the token and make *SAVE_PTR point past it. */ - *end = '\0'; - *save_ptr = end + 1; - return s; -} - -unsigned long long strtoull(const char * __restrict nptr, - char ** __restrict endptr, int base) -{ - char c; - unsigned long long acc; - unsigned long long cutoff; - int neg, any, cutlim; - /* - * See strtoq for comments as to the logic used. - */ - const char *s = nptr; - - do - { - c = *s++; - }while(isspace((unsigned char)c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else - { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - acc = any = 0; - if (base < 2 || base > 36) - goto noconv; - - cutoff = ULLONG_MAX / base; - cutlim = ULLONG_MAX % base; - for ( ; ; c = *s++) - { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = ULLONG_MAX; - errno = ERANGE; - } - else if (!any) - { -noconv: - errno = EINVAL; - } - else if (neg) - acc = -acc; - if (endptr) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} - -float strtof(const char* str, char** endptr) -{ - return (float) strtod(str, endptr); -} - -int link(const char *oldpath, const char *newpath) { return fileXioSymlink(oldpath, newpath); } -int unlink(const char *path) { return fileXioRemove(path); } -int rename(const char *source, const char *dest) { return fileXioRename(source, dest); } diff --git a/ps2/compat_files/fileXio_cdvd.c b/ps2/compat_files/fileXio_cdvd.c deleted file mode 100644 index 66ca035ad2..0000000000 --- a/ps2/compat_files/fileXio_cdvd.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ps2_devices.h" -#include "ps2_descriptor.h" - -/* I dont know why but this line is totally needed */ -static SifRpcClientData_t clientInit __attribute__ ((aligned(64))); - -static int comp_entries_by_filename(const void *elem1, const void *elem2) -{ - return strcmp(((entries*)elem1)->filename, ((entries*)elem2)->filename); -} - -/* returns 1 if disc valid, else returns 0 */ -static int ps2_cdDiscValid(void) -{ - int cdmode = sceCdGetDiskType(); - - switch (cdmode) - { - case SCECdPSCD: - case SCECdPSCDDA: - case SCECdPS2CD: - case SCECdPS2CDDA: - case SCECdPS2DVD: - case SCECdCDDA: - case SCECdDVDV: - return 1; - case SCECdNODISC: - case SCECdDETCT: - case SCECdDETCTCD: - case SCECdDETCTDVDS: - case SCECdDETCTDVDD: - case SCECdUNKNOWN: - case SCECdIllegalMedia: - default: - return 0; - } -} - -static u64 cd_Timer(void) -{ - return (clock() / (CLOCKS_PER_SEC / 1000)); -} - -static void ps2_cdStop(void) -{ - CDVD_Stop(); - sceCdSync(0); -} - -static int prepareCDVD(void) -{ - u64 wait_start; - int cdmode = sceCdGetDiskType(); - - if (sceCdGetDiskType() <= SCECdUNKNOWN) - { - wait_start = cd_Timer(); - while ((cd_Timer() < wait_start + 500) && !ps2_cdDiscValid()) - { - if (cdmode == SCECdNODISC) - return 0; - } - if (cdmode == SCECdNODISC) - return 0; - if ((cdmode < SCECdPSCD) || (cdmode > SCECdPS2DVD)) - { - ps2_cdStop(); - return 0; - } - } - - return 1; -} - -static int listcdvd(const char *path, entries *FileEntry) -{ - static struct TocEntry TocEntryList[FILEENTRY_SIZE]; - char dir[1025]; - int i, n; - int t = 0; - int first_file_index; - - strcpy(dir, &path[5]); - - /* Directories first... */ - - CDVD_FlushCache(); - n = CDVD_GetDir(dir, NULL, CDVD_GET_DIRS_ONLY, - TocEntryList, FILEENTRY_SIZE, dir); - - for (i = 0; i < n; i++) - { - /* Skip pseudopaths "." and ".." */ - if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( - TocEntryList[i].filename, ".."))) - continue; - - FileEntry[t].dircheck = 1; - strcpy(FileEntry[t].filename, TocEntryList[i].filename); - t++; - - if (t >= FILEENTRY_SIZE - 2) - break; - } - - qsort(FileEntry, t, sizeof(entries), comp_entries_by_filename); - first_file_index = t; - - /* Now files only */ - - CDVD_FlushCache(); - n = CDVD_GetDir(dir, NULL, CDVD_GET_FILES_ONLY, TocEntryList, FILEENTRY_SIZE, dir); - - for (i = 0; i < n; i++) - { - /* Skip pseudopaths "." and ".." */ - if (TocEntryList[i].fileProperties & 0x02 && (!strcmp( - TocEntryList[i].filename, ".") || !strcmp( - TocEntryList[i].filename, ".."))) - continue; - - FileEntry[t].dircheck = 0; - strcpy(FileEntry[t].filename, TocEntryList[i].filename); - t++; - - if (t >= FILEENTRY_SIZE - 2) - break; - } - - qsort(FileEntry + first_file_index, t - first_file_index, - sizeof(entries), comp_entries_by_filename); - - return t; -} - -static int fileXioCDDread(int fd, iox_dirent_t *dirent) -{ - DescriptorTranslation *descriptor = __ps2_fd_grab(fd); - - if (descriptor && descriptor->current_folder_position < descriptor->items) - { - strcpy(dirent->name, descriptor->FileEntry[descriptor->current_folder_position].filename); - if (descriptor->FileEntry[descriptor->current_folder_position].dircheck) - dirent->stat.mode = FIO_S_IFDIR; - else - dirent->stat.mode = FIO_S_IFREG; - descriptor->current_folder_position++; - } - else - { - descriptor->current_folder_position = 0; - return 0; - } - - return 1; -} - -static int fileXioCDDopen(const char *name) -{ - if (prepareCDVD()) - { - int fd = __ps2_acquire_descriptor(); - DescriptorTranslation *descriptor = __ps2_fd_grab(fd); - descriptor->current_folder_position = 0; - descriptor->items = listcdvd(name, descriptor->FileEntry); - return fd; - } - return -1; -} - - -int ps2fileXioDopen(const char *name) -{ - enum BootDeviceIDs deviceID = getBootDeviceID((char *)name); - if (deviceID == BOOT_DEVICE_CDFS) - return fileXioCDDopen(name); - return fileXioDopen(name); -} - -int ps2fileXioDread(int fd, iox_dirent_t *dirent) -{ - if (is_fd_valid(fd)) - return fileXioCDDread(fd, dirent); - return fileXioDread(fd, dirent); -} - -int ps2fileXioDclose(int fd) -{ - if (is_fd_valid(fd)) - return __ps2_release_descriptor(fd); - else if (fd > 0) - return fileXioDclose(fd); - return -19; -} diff --git a/ps2/compat_files/ps2_descriptor.c b/ps2/compat_files/ps2_descriptor.c deleted file mode 100644 index e74807ab1e..0000000000 --- a/ps2/compat_files/ps2_descriptor.c +++ /dev/null @@ -1,145 +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 -#include - -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)); } - -static inline int _unlock(void) { return(SignalSema(_lock_sema_id)); } - -static int __ps2_fd_drop(DescriptorTranslation *map) -{ - _lock(); - - if (map->ref_count == 1) - { - map->ref_count--; - map->current_folder_position = -1; - 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) -{ - ee_sema_t sp; - - 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); -} - -void _free_ps2_io(void) -{ - _lock(); - _unlock(); - if(_lock_sema_id >= 0) DeleteSema(_lock_sema_id); -} - -int __ps2_acquire_descriptor(void) -{ - int fd = -1; - int i = 0; - _lock(); - - /* get free descriptor */ - for (fd = 0; fd < MAX_OPEN_FILES; ++fd) - { - if (!__ps2_fdmap[fd]) - { - /* get free pool */ - for (i = 0; i < MAX_OPEN_FILES; ++i) - { - if (__ps2_fdmap_pool[i].ref_count == 0) - { - __ps2_fdmap[fd] = &__ps2_fdmap_pool[i]; - __ps2_fdmap[fd]->ref_count = 1; - __ps2_fdmap[fd]->current_folder_position = -1; - __ps2_fdmap[fd]->FileEntry = - calloc(sizeof(entries), FILEENTRY_SIZE); - _unlock(); - return MAX_OPEN_FILES - fd; - } - } - } - } - - /* no mores descriptors available... */ - _unlock(); - return -1; -} - -int __ps2_release_descriptor(int fd) -{ - int res = -1; - - if (is_fd_valid(fd) && - __ps2_fd_drop(__ps2_fdmap[MAX_OPEN_FILES - fd]) >= 0) - { - _lock(); - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - __ps2_fdmap[fd] = NULL; - res = 0; - _unlock(); - } - - return res; -} - -DescriptorTranslation *__ps2_fd_grab(int fd) -{ - DescriptorTranslation *map = NULL; - - _lock(); - - if (is_fd_valid(fd)) - { - /* Correct fd value */ - fd = MAX_OPEN_FILES - fd; - map = __ps2_fdmap[fd]; - - if (map) - map->ref_count++; - } - - _unlock(); - return map; -} diff --git a/ps2/compat_files/ps2_devices.c b/ps2/compat_files/ps2_devices.c index e9bb2ae405..7ba3fe87b2 100644 --- a/ps2/compat_files/ps2_devices.c +++ b/ps2/compat_files/ps2_devices.c @@ -15,9 +15,10 @@ #include #include +#include #include #include -#include +#include #define DEVICE_SLASH "/" @@ -160,14 +161,14 @@ enum BootDeviceIDs getBootDeviceID(char *path) bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) { - int openFile = - 1; - /* just in case we tried a unit that is not working/connected */ + DIR *dir; + int ret = 0; int retries = 3; char *rootDevice = rootDevicePath(device_id); - while(openFile < 0 && retries > 0) + while(dir == NULL && retries > 0) { - openFile = fileXioDopen(rootDevice); + dir = opendir(rootDevice); /* Wait untill the device is ready */ nopdelay(); nopdelay(); @@ -180,9 +181,10 @@ bool waitUntilDeviceIsReady(enum BootDeviceIDs device_id) retries--; } - - if (openFile > 0) - fileXioDclose(openFile); + if (dir) { + ret = 1; + closedir(dir); + } - return openFile >= 0; + return ret; } diff --git a/ps2/compat_files/time.c b/ps2/compat_files/time.c deleted file mode 100644 index 5bdf1642bf..0000000000 --- a/ps2/compat_files/time.c +++ /dev/null @@ -1,138 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2019 - 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 . - */ - -/* This file improve the content of the original time.c file that belong to the PS2SDK. -The original time.c contains 4 non-static methods - -void _ps2sdk_time_init(void); -void _ps2sdk_time_deinit(void); -clock_t clock(void); -time_t time(time_t *t); - -So we need to duplicate all the method because this way the compiler will avoid to import -the code that belong to the PS2SDK */ - -#include -#include -#include -#include -#include -#include - -#define STARTING_YEAR 2000 -#define MIN_SUPPORTED_YEAR 1970 -#define MAX_SUPPORTED_YEAR 2108 -#define SECS_MIN 60L -#define MINS_HOUR 60L -#define HOURS_DAY 24L -#define DAYS_YEAR 365L -#define DEC(x) (10*(x/16)+(x%16)) -int _days[] = {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364}; - -static time_t _gmtotime_t ( - int yr, /* 0 based */ - int mo, /* 1 based */ - int dy, /* 1 based */ - int hr, - int mn, - int sc - ) -{ - time_t seconds_from_1970 = -1; - - if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) - { - long passed_seconds_current_day; - int passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */ - /* Calculate days for these years */ - long passed_days = passed_years * DAYS_YEAR; - passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */ - passed_days += dy + _days[mo - 1]; /* passed days in the year */ - - if (!(yr & 3) && (mo > 2)) - passed_days++; /* if current year, is a leap year */ - - passed_seconds_current_day = (((hr * MINS_HOUR) + mn) * SECS_MIN) + sc; - seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day; - } - - return seconds_from_1970; -} - -time_t ps2_time(time_t *t) -{ - time_t tim; - sceCdCLOCK clocktime; /* defined in libcdvd.h */ - - sceCdReadClock(&clocktime); /* libcdvd.a */ - configConvertToLocalTime(&clocktime); - - tim = _gmtotime_t (DEC(clocktime.year)+ STARTING_YEAR, - DEC(clocktime.month), - DEC(clocktime.day), - DEC(clocktime.hour), - DEC(clocktime.minute), - DEC(clocktime.second)); - - if (t) - *t = tim; - - return tim; -} - -/* Protected methods in libc */ -void _ps2sdk_time_init(void) -{ - SDL_Init(SDL_INIT_TIMER); -} - -/* Protected methods in libc */ -void _ps2sdk_time_deinit(void) -{ - SDL_QuitSubSystem(SDL_INIT_TIMER); -} - -clock_t clock(void) -{ - return SDL_GetTicks(); -} - -time_t time(time_t *t) -{ - time_t tim = -1; - /* TODO: This function need to be implemented again because the SDK one is not working fine */ - return tim; -} - -time_t mktime(struct tm *timeptr) -{ - time_t tim = -1; - /* TODO: This function need to be implemented again because the SDK one is not working fine */ - return tim; -} - -struct tm *localtime(const time_t *timep) -{ - return NULL; -} - -size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) -{ - return -1; -} - -char *setlocale(int category, const char *locale) -{ - return NULL; -} diff --git a/ps2/include/compat_ctype.h b/ps2/include/compat_ctype.h deleted file mode 100644 index 2a0e17c993..0000000000 --- a/ps2/include/compat_ctype.h +++ /dev/null @@ -1,27 +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 COMPAT_CTYPE_H -#define COMPAT_CTYPE_H - -char *strtok_r(char *str, const char *delim, char **saveptr); - -unsigned long long strtoull(const char * __restrict nptr, char ** __restrict endptr, int base); - -int link(const char *oldpath, const char *newpath); -int unlink(const char *path); - -float strtof (const char* str, char** endptr); - -#endif diff --git a/ps2/include/fileXio_cdvd.h b/ps2/include/fileXio_cdvd.h deleted file mode 100644 index ada31a1006..0000000000 --- a/ps2/include/fileXio_cdvd.h +++ /dev/null @@ -1,37 +0,0 @@ -#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/inttypes.h b/ps2/include/inttypes.h deleted file mode 100644 index a41fb2c406..0000000000 --- a/ps2/include/inttypes.h +++ /dev/null @@ -1,22 +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 INTTYPES_H -#define INTTYPES_H - -#define PRId64 "lld" -#define PRIu64 "llu" -#define PRIuPTR "llu" - -#endif /* INTTYPES_H */ diff --git a/ps2/include/math.h b/ps2/include/math.h deleted file mode 100644 index 71f0f858fb..0000000000 --- a/ps2/include/math.h +++ /dev/null @@ -1,38 +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 MATH_H -#define MATH_H - -#include -#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) - -#define cos(x) ((double)cosf((float)x)) -#define pow(x, y) ((double)powf((float)x, (float)y)) -#define sin(x) ((double)sinf((float)x)) -#define ceil(x) ((double)ceilf((float)x)) -#define floor(x) ((double)floorf((float)x)) -#define sqrt(x) ((double)sqrtf((float)x)) -#define fabs(x) ((double)fabsf((float)(x))) -#define round(x) ((double)roundf((float)(x))) - -#define fmaxf(a, b) (((a) > (b)) ? (a) : (b)) -#define fminf(a, b) (((a) < (b)) ? (a) : (b)) - -#define exp(a) ((double)expf((float)a)) -#define log(a) ((double)logf((float)a)) - -#define fmod(a, b) (a - b * floor(a / b)); - -#endif //MATH_H diff --git a/ps2/include/ps2_descriptor.h b/ps2/include/ps2_descriptor.h deleted file mode 100644 index b54c8def7f..0000000000 --- a/ps2/include/ps2_descriptor.h +++ /dev/null @@ -1,44 +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_DESCRIPTOR_H -#define PS2_DESCRIPTOR_H - -#include -#include - -#define MAX_OPEN_FILES 256 -#define FILEENTRY_SIZE 2048 - -typedef struct { - int dircheck; - char filename[256]; -} entries; - -typedef struct -{ - int ref_count; - int items; - int current_folder_position; - entries *FileEntry; -} DescriptorTranslation; - -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); -DescriptorTranslation *__ps2_fd_grab(int fd); - -#endif /* PS2_DESCRIPTOR_H */ diff --git a/ps2/include/ps2_irx_variables.h b/ps2/include/ps2_irx_variables.h index 856d82e209..6bd3c8e9c6 100644 --- a/ps2/include/ps2_irx_variables.h +++ b/ps2/include/ps2_irx_variables.h @@ -57,9 +57,6 @@ extern unsigned int size_usbd_irx; extern unsigned char usbhdfsd_irx; extern unsigned int size_usbhdfsd_irx; -extern unsigned char cdvd_irx; -extern unsigned int size_cdvd_irx; - extern unsigned char audsrv_irx; extern unsigned int size_audsrv_irx; diff --git a/ps2/include/pte_types.h b/ps2/include/pte_types.h deleted file mode 100644 index 4da1ebac65..0000000000 --- a/ps2/include/pte_types.h +++ /dev/null @@ -1,38 +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 PTE_TYPES_H -#define PTE_TYPES_H - -#include -#include -#include -#include - -/** UIDs are used to describe many different kernel objects. */ -typedef int SceUID; - -/* Misc. kernel types. */ -typedef unsigned int SceSize; -typedef int SceSSize; - -typedef unsigned char SceUChar; -typedef unsigned int SceUInt; - -/* File I/O types. */ -typedef int SceMode; -typedef long SceOff; -typedef long SceIores; - -#endif /* PTE_TYPES_H */ diff --git a/ps2/include/stdint.h b/ps2/include/stdint.h deleted file mode 100644 index cc2582c1f3..0000000000 --- a/ps2/include/stdint.h +++ /dev/null @@ -1,44 +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 STDINT_H -#define STDINT_H - -typedef unsigned long uintptr_t; -typedef signed long intptr_t; - -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef signed long int64_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long uint64_t; - -#define STDIN_FILENO 0 /* standard input file descriptor */ -#define STDOUT_FILENO 1 /* standard output file descriptor */ -#define STDERR_FILENO 2 /* standard error file descriptor */ - -#define INT8_C(val) val##c -#define INT16_C(val) val##h -#define INT32_C(val) val##i -#define INT64_C(val) val##l - -#define UINT8_C(val) val##uc -#define UINT16_C(val) val##uh -#define UINT32_C(val) val##ui -#define UINT64_C(val) val##ul - -#endif /* STDINT_H */ diff --git a/ps2/irx/Makefile b/ps2/irx/Makefile index ce28efa15b..cc22763f9e 100644 --- a/ps2/irx/Makefile +++ b/ps2/irx/Makefile @@ -2,17 +2,13 @@ EE_BIN2C = bin2c IRX_DIR = $(PS2SDK)/iop/irx -#Specific folder for cdvd.irx -LIBCDVD_DIR = ../libcdvd -LIBCDVD_IRX_DIR = $(LIBCDVD_DIR)/lib - #IRX modules # IRX modules - modules have to be in IRX_DIR IRX_FILES += freemtap.irx freepad.irx freesio2.irx iomanX.irx fileXio.irx mcman.irx mcserv.irx usbd.irx usbhdfsd.irx IRX_FILES += freesd.irx audsrv.irx poweroff.irx -IRX_C_FILES = $(IRX_FILES:.irx=_irx.c) cdvd_irx.c +IRX_C_FILES = $(IRX_FILES:.irx=_irx.c) -all: cdvd irxs +all: irxs # Specific file name and output per IRX Module %.irx: @@ -20,13 +16,8 @@ all: cdvd irxs irxs: $(IRX_FILES) -cdvd: - $(MAKE) -C $(LIBCDVD_DIR) - $(EE_BIN2C) $(LIBCDVD_IRX_DIR)/$@.irx $@_irx.c $@_irx - clean: rm -f $(IRX_C_FILES) - $(MAKE) -C $(LIBCDVD_DIR) clean #Include preferences include $(PS2SDK)/samples/Makefile.pref diff --git a/ps2/libcdvd/Makefile b/ps2/libcdvd/Makefile deleted file mode 100644 index 765a8e05e4..0000000000 --- a/ps2/libcdvd/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Remove the line below, if you want to disable silent mode -#.SILENT: - -all: lib/libcdvdfs.a lib/cdvd.irx - -lib: - mkdir -p $@ - -clean: - $(MAKE) -C ee clean - $(MAKE) -C iop clean - -lib/cdvd.irx: iop | lib - @echo Building IRX - $(MAKE) -C $< - -lib/libcdvdfs.a: ee | lib - @echo Building EE client - $(MAKE) -C $< diff --git a/ps2/libcdvd/common/cdvd.h b/ps2/libcdvd/common/cdvd.h deleted file mode 100644 index 516e0fc9dd..0000000000 --- a/ps2/libcdvd/common/cdvd.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _CDVD_H -#define _CDVD_H - -// This header contains the common definitions for libcdvd -// that are used by both IOP and EE sides - -#define CDVD_IRX 0xB001337 -#define CDVD_FINDFILE 0x01 -#define CDVD_GETDIR 0x02 -#define CDVD_STOP 0x04 -#define CDVD_TRAYREQ 0x05 -#define CDVD_DISKREADY 0x06 -#define CDVD_FLUSHCACHE 0x07 -#define CDVD_GETSIZE 0x08 - - -struct TocEntry -{ - u32 fileLBA; - u32 fileSize; - u8 fileProperties; - u8 padding1[3]; - char filename[128 + 1]; - u8 padding2[3]; -} __attribute__((packed)); - - -enum CDVD_getMode { - CDVD_GET_FILES_ONLY = 1, - CDVD_GET_DIRS_ONLY = 2, - CDVD_GET_FILES_AND_DIRS = 3 -}; - -// Macros for TrayReq -#define CdTrayOpen 0 -#define CdTrayClose 1 -#define CdTrayCheck 2 - -// Macros for DiskReady -#define CdComplete 0x02 -#define CdNotReady 0x06 -#define CdBlock 0x00 -#define CdNonBlock 0x01 - -#endif // _CDVD_H diff --git a/ps2/libcdvd/ee/Makefile b/ps2/libcdvd/ee/Makefile deleted file mode 100644 index 9a079c88eb..0000000000 --- a/ps2/libcdvd/ee/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -EE_LIB = ../lib/libcdvdfs.a -EE_OBJS = cdvd_rpc.o - -all: $(EE_LIB) - -clean: - rm -f $(EE_LIB) $(EE_OBJS) - -include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/ps2/libcdvd/ee/cdvd_rpc.c b/ps2/libcdvd/ee/cdvd_rpc.c deleted file mode 100644 index 14227a5bb8..0000000000 --- a/ps2/libcdvd/ee/cdvd_rpc.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include -#include -#include -#include - -#include "cdvd_rpc.h" - -int k_sceSifDmaStat(unsigned int id); -static unsigned sbuff[0x1300] __attribute__((aligned(64))); -static SifRpcClientData_t cd0; - -int cdvd_inited = 0; - -int CDVD_Init() -{ - int i; - - while (1) { - if (SifBindRpc(&cd0, CDVD_IRX, 0) < 0) - return -1; // bind error - if (cd0.server != 0) - break; - i = 0x10000; - while (i--) - ; - } - - cdvd_inited = 1; - - return 0; -} - -int CDVD_DiskReady(int mode) -{ - if (!cdvd_inited) - return -1; - - sbuff[0] = mode; - - SifCallRpc(&cd0, CDVD_DISKREADY, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} - -int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry) -{ - if (!cdvd_inited) - return -1; - - strncpy((char *)&sbuff, fname, 1024); - - SifCallRpc(&cd0, CDVD_FINDFILE, 0, (void *)(&sbuff[0]), 1024, (void *)(&sbuff[0]), sizeof(struct TocEntry) + 1024, 0, 0); - - memcpy(tocEntry, &sbuff[256], sizeof(struct TocEntry)); - - return sbuff[0]; -} - -void CDVD_Stop() -{ - if (!cdvd_inited) - return; - - SifCallRpc(&cd0, CDVD_STOP, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0); - - return; -} - -int CDVD_TrayReq(int mode) -{ - if (!cdvd_inited) - return -1; - - SifCallRpc(&cd0, CDVD_TRAYREQ, 0, (void *)(&sbuff[0]), 4, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} - -int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname) -{ - unsigned int num_entries; - - if (!cdvd_inited) - return -1; - - // copy the requested pathname to the rpc buffer - strncpy((char *)sbuff, pathname, 1023); - - // copy in the extension list to the rpc buffer - if (extensions == NULL) { - // Can't copy in the extension list since there isnt one, so just null the string in the rpc buffer - sbuff[1024 / 4] = 0; - } else { - strncpy((char *)&sbuff[1024 / 4], extensions, 127); - } - - sbuff[1152 / 4] = getMode; - - sbuff[1156 / 4] = (int)tocEntry; - - sbuff[1160 / 4] = req_entries; - - SifWriteBackDCache(tocEntry, req_entries * sizeof(struct TocEntry)); - - // This will get the directory contents, and fill tocEntry via DMA - SifCallRpc(&cd0, CDVD_GETDIR, 0, (void *)(&sbuff[0]), 1024 + 128 + 4 + 4 + 4, (void *)(&sbuff[0]), 4 + 1024, 0, 0); - - num_entries = sbuff[0]; - - if (new_pathname != NULL) - strncpy(new_pathname, (char *)&sbuff[1], 1023); - - return (num_entries); -} - -void CDVD_FlushCache() -{ - if (!cdvd_inited) - return; - - SifCallRpc(&cd0, CDVD_FLUSHCACHE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 0, 0, 0); - - return; -} - -unsigned int CDVD_GetSize() -{ - if (!cdvd_inited) - return -1; - - SifCallRpc(&cd0, CDVD_GETSIZE, 0, (void *)(&sbuff[0]), 0, (void *)(&sbuff[0]), 4, 0, 0); - - return sbuff[0]; -} diff --git a/ps2/libcdvd/ee/cdvd_rpc.h b/ps2/libcdvd/ee/cdvd_rpc.h deleted file mode 100644 index 394adb73e7..0000000000 --- a/ps2/libcdvd/ee/cdvd_rpc.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _CDVD_RPC_H -#define _CDVD_RPC_H - -// include the common definitions -#include "../common/cdvd.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -int CDVD_Init(); -int CDVD_DiskReady(int mode); -int CDVD_FindFile(const char *fname, struct TocEntry *tocEntry); -void CDVD_Stop(); -int CDVD_TrayReq(int mode); -int CDVD_DiskReady(int mode); -int CDVD_GetDir(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries, char *new_pathname); -void CDVD_FlushCache(); -unsigned int CDVD_GetSize(); - - -#ifdef __cplusplus -} -#endif - - -#endif // _CDVD_H diff --git a/ps2/libcdvd/iop/Makefile b/ps2/libcdvd/iop/Makefile deleted file mode 100644 index c1dfd7c6c3..0000000000 --- a/ps2/libcdvd/iop/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -IOP_BIN = ../lib/cdvd.irx - -IOP_OBJS = cdvd_iop.o imports.o - - -all: $(IOP_BIN) - -clean: - rm -f $(IOP_BIN) $(IOP_OBJS) - -include $(PS2SDK)/Defs.make -include Rules.make diff --git a/ps2/libcdvd/iop/Rules.make b/ps2/libcdvd/iop/Rules.make deleted file mode 100644 index 3a53febbe3..0000000000 --- a/ps2/libcdvd/iop/Rules.make +++ /dev/null @@ -1,54 +0,0 @@ -# _____ ___ ____ ___ ____ -# ____| | ____| | | |____| -# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. -#----------------------------------------------------------------------- -# Copyright 2001-2004. -# Licenced under Academic Free License version 2.0 -# Review ps2sdk README & LICENSE files for further details. - - -IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p') - -ASFLAGS_TARGET = -mcpu=r3000 - -ifeq ($(IOP_CC_VERSION),3.2.2) -CFLAGS_TARGET = -miop -ASFLAGS_TARGET = -march=r3000 -LDFLAGS_TARGET = -miop -endif - -IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include - -IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -D_IOP -c $(IOP_INCS) $(IOP_CFLAGS) -IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS) -IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS) - -# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB - -%.o : %.c - $(IOP_CC) $(IOP_CFLAGS) $< -o $@ - -%.o : %.s - $(IOP_AS) $(IOP_ASFLAGS) $< -o $@ - -# A rule to build imports.lst. -%.o : %.lst - echo "#include \"irx_imports.h\"" > build-imports.c - cat $< >> build-imports.c - $(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@ - -rm -f build-imports.c - -# A rule to build exports.tab. -%.o : %.tab - echo "#include \"irx.h\"" > build-exports.c - cat $< >> build-exports.c - $(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@ - -rm -f build-exports.c - - -$(IOP_BIN) : $(IOP_OBJS) - $(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS) - -$(IOP_LIB) : $(IOP_OBJS) - $(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS) - diff --git a/ps2/libcdvd/iop/cdvd_iop.c b/ps2/libcdvd/iop/cdvd_iop.c deleted file mode 100644 index 6fd3b8dd6c..0000000000 --- a/ps2/libcdvd/iop/cdvd_iop.c +++ /dev/null @@ -1,1852 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cdvd_iop.h" - -#define TRUE 1 -#define FALSE 0 - -enum PathMatch { - NOT_MATCH = 0, - MATCH, - SUBDIR -}; - -//#define DEBUG - -// 16 sectors worth of toc entry -#define MAX_DIR_CACHE_SECTORS 32 - - -//static u8 cdVolDescriptor[2048]; -static sceCdRMode cdReadMode; - -int lastsector; -int last_bk = 0; - - -struct rootDirTocHeader -{ - u16 length; - u32 tocLBA; - u32 tocLBA_bigend; - u32 tocSize; - u32 tocSize_bigend; - u8 dateStamp[8]; - u8 reserved[6]; - u8 reserved2; - u8 reserved3; -} __attribute__((packed)); - -struct asciiDate -{ - char year[4]; - char month[2]; - char day[2]; - char hours[2]; - char minutes[2]; - char seconds[2]; - char hundreths[2]; - char terminator[1]; -} __attribute__((packed)); - -struct cdVolDesc -{ - u8 filesystemType; // 0x01 = ISO9660, 0x02 = Joliet, 0xFF = NULL - u8 volID[5]; // "CD001" - u8 reserved2; - u8 reserved3; - u8 sysIdName[32]; - u8 volName[32]; // The ISO9660 Volume Name - u8 reserved5[8]; - u32 volSize; // Volume Size - u32 volSizeBig; // Volume Size Big-Endian - u8 reserved6[32]; - u32 unknown1; - u32 unknown1_bigend; - u16 volDescSize; - u16 volDescSize_bigend; - u32 unknown3; - u32 unknown3_bigend; - u32 priDirTableLBA; // LBA of Primary Dir Table - u32 reserved7; - u32 secDirTableLBA; // LBA of Secondary Dir Table - u32 reserved8; - struct rootDirTocHeader rootToc; - u8 volSetName[128]; - u8 publisherName[128]; - u8 preparerName[128]; - u8 applicationName[128]; - u8 copyrightFileName[37]; - u8 abstractFileName[37]; - u8 bibliographyFileName[37]; - struct asciiDate creationDate; - struct asciiDate modificationDate; - struct asciiDate effectiveDate; - struct asciiDate expirationDate; - u8 reserved10; - u8 reserved11[1166]; -} __attribute__((packed)); - -struct dirTableEntry -{ - u8 dirNameLength; - u8 reserved; - u32 dirTOCLBA; - u16 dirDepth; - u8 dirName[32]; -} __attribute__((packed)); - -struct dirTocEntry -{ - short length; - unsigned int fileLBA; - unsigned int fileLBA_bigend; - unsigned int fileSize; - unsigned int fileSize_bigend; - unsigned char dateStamp[6]; - unsigned char reserved1; - unsigned char fileProperties; - unsigned char reserved2[6]; - unsigned char filenameLength; - unsigned char filename[128]; -} __attribute__((packed)); // This is the internal format on the CD -// a file with a single character filename will have a 34byte toc entry -// (max 60 entries per sector)6 - -// TocEntry structure contains only the important stuff needed for export -// - -struct fdtable -{ - iop_file_t *fd; - int fileSize; - int LBA; - int filePos; -}; - - -struct dir_cache_info -{ - char pathname[1024]; // The pathname of the cached directory - unsigned int valid; // TRUE if cache data is valid, FALSE if not - - unsigned int path_depth; // The path depth of the cached directory (0 = root) - - unsigned int sector_start; // The start sector (LBA) of the cached directory - unsigned int sector_num; // The total size of the directory (in sectors) - unsigned int cache_offset; // The offset from sector_start of the cached area - unsigned int cache_size; // The size of the cached directory area (in sectors) - - char *cache; // The actual cached data -}; - - -static struct dir_cache_info CachedDirInfo; - -enum Cache_getMode { - CACHE_START = 0, - CACHE_NEXT = 1 -}; - -static struct cdVolDesc CDVolDesc; - -static unsigned int *buffer; // RPC send/receive buffer -struct t_SifRpcDataQueue qd; -struct t_SifRpcServerData sd0; - - -static struct fdtable fd_table[16]; -static int fd_used[16]; -static int files_open; - -static iop_device_t file_driver; - -/* Filing-system exported functions */ -int CDVD_init(iop_device_t *driver); -int CDVD_open(iop_file_t *f, const char *name, int mode); -int CDVD_lseek(iop_file_t *f, int offset, int whence); -int CDVD_read(iop_file_t *f, void *buffer, int size); -int CDVD_write(iop_file_t *f, void *buffer, int size); -int CDVD_close(iop_file_t *f); - -/* RPC exported functions */ -int CDVD_findfile(const char *fname, struct TocEntry *tocEntry); -int CDVD_stop(void); -int CDVD_trayreq(int mode); -int CDVD_diskready(void); -int CDVD_GetDir_RPC(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries); - -int CDVD_getdir_IOP(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries); - - -// Functions called by the RPC server -void *CDVDRpc_Stop(); -void *CDVDRpc_FlushCache(); -void *CDVDRpc_TrayReq(unsigned int *sbuff); -void *CDVDRpc_DiskReady(unsigned int *sbuff); -void *CDVDRpc_FindFile(unsigned int *sbuff); -void *CDVDRpc_Getdir(unsigned int *sbuff); -void *CDVDRpc_GetSize(unsigned int *sbuff); - - -/* Internal use functions */ -int isValidDisc(void); -int strcasecmp(const char *s1, const char *s2); -int strncasecmp(const char *s1, const char *s2, int limit); -int CDVD_GetVolumeDescriptor(void); -void _splitpath(const char *constpath, char *dir, char *fname); -void TocEntryCopy(struct TocEntry *tocEntry, struct dirTocEntry *internalTocEntry); -int TocEntryCompare(char *filename, const char *extensions); - -enum PathMatch ComparePath(const char *path); - -int CDVD_Cache_Dir(const char *pathname, enum Cache_getMode getMode); -int FindPath(char *pathname); - - -void *CDVD_rpc_server(int fno, void *data, int size); -void CDVD_Thread(void *param); - - - -/******************** -* Optimised CD Read * -********************/ - -int ReadSect(u32 lsn, u32 sectors, void *buf, sceCdRMode *mode) -{ - int retry; - int result = 0; - cdReadMode.trycount = 32; - - for (retry = 0; retry < 32; retry++) // 32 retries - { - if (retry <= 8) - cdReadMode.spindlctrl = 1; // Try fast reads for first 8 tries - else - cdReadMode.spindlctrl = 0; // Then try slow reads - - if (!isValidDisc()) - return FALSE; - - sceCdDiskReady(0); - - if (sceCdRead(lsn, sectors, buf, mode) != TRUE) { - // Failed to read - if (retry == 31) { - // Still failed after last retry - memset(buf, 0, (sectors << 11)); - // printf("Couldn't Read from file for some reason\n"); - return FALSE; // error - } - } else { - // Read okay - sceCdSync(0); - break; - } - - result = sceCdGetError(); - if (result == 0) - break; - } - - cdReadMode.trycount = 32; - cdReadMode.spindlctrl = 1; - - if (result == 0) - return TRUE; - - memset(buf, 0, (sectors << 11)); - - return FALSE; // error -} - -/*********************************************** -* Determines if there is a valid disc inserted * -***********************************************/ -int isValidDisc(void) -{ - int result; - - switch (sceCdGetDiskType()) { - case SCECdPSCD: - case SCECdPSCDDA: - case SCECdPS2CD: - case SCECdPS2CDDA: - case SCECdPS2DVD: - result = 1; - break; - default: - result = 0; - } - - return result; -} - -/************************************************************* -* The functions below are the normal file-system operations, * -* used to provide a standard filesystem interface. There is * -* no need to export these functions for calling via RPC * -*************************************************************/ -int dummy() -{ -#ifdef DEBUG - printf("CDVD: dummy function called\n"); -#endif - - return -5; -} - -int CDVD_init(iop_device_t *driver) -{ - printf("CDVD: CDVD Filesystem v1.15\n"); - printf("by A.Lee (aka Hiryu) & Nicholas Van Veen (aka Sjeep)\n"); - printf("CDVD: Initializing '%s' file driver.\n", driver->name); - - sceCdInit(SCECdINoD); - - memset(fd_table, 0, sizeof(fd_table)); - memset(fd_used, 0, 16 * 4); - - return 0; -} - -int CDVD_deinit(iop_device_t *driver) -{ - return 0; -} - -int CDVD_open(iop_file_t *f, const char *name, int mode) -{ - int j; - static struct TocEntry tocEntry; - -#ifdef DEBUG - printf("CDVD: fd_open called.\n"); - printf(" kernel_fd.. %p\n", f); - printf(" name....... %s %x\n", name, (int)name); - printf(" mode....... %d\n\n", mode); -#endif - - // check if the file exists - if (CDVD_findfile(name, &tocEntry) != TRUE) { - return -1; - } - - if (mode != O_RDONLY) - return -2; - - // set up a new file descriptor - for (j = 0; j < 16; j++) { - if (fd_used[j] == 0) - break; - } - - if (j >= 16) - return -3; - - - fd_used[j] = 1; - files_open++; - -#ifdef DEBUG - printf("CDVD: internal fd %d\n", j); -#endif - - fd_table[j].fd = f; - fd_table[j].fileSize = tocEntry.fileSize; - fd_table[j].LBA = tocEntry.fileLBA; - fd_table[j].filePos = 0; - -#ifdef DEBUG - printf("tocEntry.fileSize = %d\n", tocEntry.fileSize); - - printf("Opened file: %s\n", name); -#endif - - return j; -} - - - -int CDVD_lseek(iop_file_t *f, int offset, int whence) -{ - int i; - -#ifdef DEBUG - printf("CDVD: fd_seek called.\n"); - printf(" kernel_fd... %p\n", f); - printf(" offset...... %d\n", offset); - printf(" whence...... %d\n\n", whence); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_lseek: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - - switch (whence) { - case SEEK_SET: - fd_table[i].filePos = offset; - break; - - case SEEK_CUR: - fd_table[i].filePos += offset; - break; - - case SEEK_END: - fd_table[i].filePos = fd_table[i].fileSize + offset; - break; - - default: - return -1; - } - - if (fd_table[i].filePos < 0) - fd_table[i].filePos = 0; - - if (fd_table[i].filePos > fd_table[i].fileSize) - fd_table[i].filePos = fd_table[i].fileSize; - - return fd_table[i].filePos; -} - - -int CDVD_read(iop_file_t *f, void *buffer, int size) -{ - int i; - - int start_sector; - int off_sector; - int num_sectors; - - int read = 0; - // int sector; - - // int size_left; - // int copy_size; - - static char local_buffer[9 * 2048]; - - -#ifdef DEBUG - printf("CDVD: read called\n"); - printf(" kernel_fd... %p\n", f); - printf(" buffer...... 0x%X\n", (int)buffer); - printf(" size........ %d\n\n", size); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_read: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - - - // A few sanity checks - if (fd_table[i].filePos > fd_table[i].fileSize) { - // We cant start reading from past the beginning of the file - return 0; // File exists but we couldnt read anything from it - } - - if ((fd_table[i].filePos + size) > fd_table[i].fileSize) - size = fd_table[i].fileSize - fd_table[i].filePos; - - if (size <= 0) - return 0; - - if (size > 16384) - size = 16384; - - // Now work out where we want to start reading from - start_sector = fd_table[i].LBA + (fd_table[i].filePos >> 11); - off_sector = (fd_table[i].filePos & 0x7FF); - - num_sectors = (off_sector + size); - num_sectors = (num_sectors >> 11) + ((num_sectors & 2047) != 0); - -#ifdef DEBUG - printf("CDVD_read: read sectors %d to %d\n", start_sector, start_sector + num_sectors); -#endif - - // Skip a Sector for equal (use the last sector in buffer) - if (start_sector == lastsector) { - read = 1; - if (last_bk > 0) - memcpy(local_buffer, local_buffer + 2048 * (last_bk), 2048); - last_bk = 0; - } - - lastsector = start_sector + num_sectors - 1; - // Read the data (we only ever get 16KB max request at once) - - if (read == 0 || (read == 1 && num_sectors > 1)) { - if (ReadSect(start_sector + read, num_sectors - read, local_buffer + ((read) << 11), &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from file for some reason\n"); -#endif - } - - last_bk = num_sectors - 1; - } - - memcpy(buffer, local_buffer + off_sector, size); - - fd_table[i].filePos += size; - - return (size); -} - - -int CDVD_write(iop_file_t *f, void *buffer, int size) -{ - if (size == 0) - return 0; - else - return -1; -} - - - -int CDVD_close(iop_file_t *f) -{ - int i; - -#ifdef DEBUG - printf("CDVD: fd_close called.\n"); - printf(" kernel fd.. %p\n\n", f); -#endif - - for (i = 0; i < 16; i++) { - if (fd_table[i].fd == f) - break; - } - - if (i >= 16) { -#ifdef DEBUG - printf("CDVD_close: ERROR: File does not appear to be open!\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("CDVD: internal fd %d\n", i); -#endif - - fd_used[i] = 0; - files_open--; - - return 0; -} - - -static iop_device_ops_t filedriver_ops = { - &CDVD_init, - &CDVD_deinit, - (void *)&dummy, - &CDVD_open, - &CDVD_close, - &CDVD_read, - &CDVD_write, - &CDVD_lseek, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy, - (void *)&dummy}; - -int _start(int argc, char **argv) -{ - int i; - struct _iop_thread param; - int th; - - // Initialise the directory cache - strcpy(CachedDirInfo.pathname, ""); // The pathname of the cached directory - CachedDirInfo.valid = FALSE; // Cache is not valid - CachedDirInfo.path_depth = 0; // 0 = root) - CachedDirInfo.sector_start = 0; // The start sector (LBA) of the cached directory - CachedDirInfo.sector_num = 0; // The total size of the directory (in sectors) - CachedDirInfo.cache_offset = 0; // The offset from sector_start of the cached area - CachedDirInfo.cache_size = 0; // The size of the cached directory area (in sectors) - - if (CachedDirInfo.cache == NULL) - CachedDirInfo.cache = (char *)AllocSysMemory(0, MAX_DIR_CACHE_SECTORS * 2048, NULL); - - - // setup the cdReadMode structure - cdReadMode.trycount = 0; - cdReadMode.spindlctrl = SCECdSpinStm; - cdReadMode.datapattern = SCECdSecS2048; - - // setup the file_driver structure - file_driver.name = "cdfs"; - file_driver.type = IOP_DT_FS; - file_driver.version = 1; - file_driver.desc = "CDVD Filedriver"; - file_driver.ops = &filedriver_ops; - - DelDrv("cdfs"); - AddDrv(&file_driver); - - param.attr = TH_C; - param.thread = (void *)CDVD_Thread; - param.priority = 40; - param.stacksize = 0x8000; - param.option = 0; - - th = CreateThread(¶m); - - if (th > 0) { - StartThread(th, NULL); - return MODULE_RESIDENT_END; - } else - return MODULE_NO_RESIDENT_END; -} - -/************************************************************** -* The functions below are not exported for normal file-system * -* operations, but are used by the file-system operations, and * -* may also be exported for use via RPC * -**************************************************************/ - - -int CDVD_GetVolumeDescriptor(void) -{ - // Read until we find the last valid Volume Descriptor - int volDescSector; - - static struct cdVolDesc localVolDesc; - -#ifdef DEBUG - printf("CDVD_GetVolumeDescriptor called\n"); -#endif - - for (volDescSector = 16; volDescSector < 20; volDescSector++) { - ReadSect(volDescSector, 1, &localVolDesc, &cdReadMode); - - // If this is still a volume Descriptor - if (strncmp(localVolDesc.volID, "CD001", 5) == 0) { - if ((localVolDesc.filesystemType == 1) || - (localVolDesc.filesystemType == 2)) { - memcpy(&CDVolDesc, &localVolDesc, sizeof(struct cdVolDesc)); - } - } else - break; - } - -#ifdef DEBUG - switch (CDVolDesc.filesystemType) { - case 1: - printf("CD FileSystem is ISO9660\n"); - break; - - case 2: - printf("CD FileSystem is Joliet\n"); - break; - - default: - printf("CD FileSystem is unknown type\n"); - break; - } -#endif - // sceCdStop(); - - return TRUE; -} - - -int CDVD_findfile(const char *fname, struct TocEntry *tocEntry) -{ - static char filename[128 + 1]; - static char pathname[1024 + 1]; - - struct dirTocEntry *tocEntryPointer; - -#ifdef DEBUG - printf("CDVD_findfile called\n"); -#endif - - _splitpath(fname, pathname, filename); - -#ifdef DEBUG - printf("Trying to find file: %s in directory: %s\n", filename, pathname); -#endif - - // if ((CachedDirInfo.valid==TRUE) - // && (strcasecmp(pathname, CachedDirInfo.pathname)==0)) - - if ((CachedDirInfo.valid == TRUE) && (ComparePath(pathname) == MATCH)) { - // the directory is already cached, so check through the currently - // cached chunk of the directory first - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // reached the end of the cache block - break; - } - - if ((tocEntryPointer->fileProperties & 0x02) == 0) { - // It's a file - TocEntryCopy(tocEntry, tocEntryPointer); - - if (strcasecmp(tocEntry->filename, filename) == 0) { - // and it matches !! - return TRUE; - } - } - } // end of for loop - - - - // If that was the only dir block, and we havent found it, then fail - if (CachedDirInfo.cache_size == CachedDirInfo.sector_num) - return FALSE; - - // Otherwise there is more dir to check - if (CachedDirInfo.cache_offset == 0) { - // If that was the first block then continue with the next block - if (CDVD_Cache_Dir(pathname, CACHE_NEXT) != TRUE) - return FALSE; - } else { - // otherwise (if that wasnt the first block) then start checking from the start - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) - return FALSE; - } - } else { -#ifdef DEBUG - printf("Trying to cache directory\n"); -#endif - // The wanted directory wasnt already cached, so cache it now - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("Failed to cache directory\n"); -#endif - - return FALSE; - } - } - -// If we've got here, then we have a block of the directory cached, and want to check -// from this point, to the end of the dir -#ifdef DEBUG - printf("cache_size = %d\n", CachedDirInfo.cache_size); -#endif - - while (CachedDirInfo.cache_size > 0) { - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - if (CachedDirInfo.cache_offset == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); - printf("Offset into cache = %d bytes\n", (char *)tocEntryPointer - CachedDirInfo.cache); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // reached the end of the cache block - break; - } - - TocEntryCopy(tocEntry, tocEntryPointer); - - if (strcasecmp(tocEntry->filename, filename) == 0) { -#ifdef DEBUG - printf("Found a matching file\n"); -#endif - // and it matches !! - return TRUE; - } - -#ifdef DEBUG - printf("Non-matching file - looking for %s , found %s\n", filename, tocEntry->filename); -#endif - } // end of for loop - -#ifdef DEBUG - printf("Reached end of cache block\n"); -#endif - // cache the next block - CDVD_Cache_Dir(pathname, CACHE_NEXT); - } - -// we've run out of dir blocks to cache, and still not found it, so fail - -#ifdef DEBUG - printf("CDVD_findfile: could not find file\n"); -#endif - - return FALSE; -} - - - -// Find, and cache, the requested directory, for use by GetDir or (and thus open) -// provide an optional offset variable, for use when caching dirs of greater than 500 files - -// returns TRUE if all TOC entries have been retrieved, or -// returns FALSE if there are more TOC entries to be retrieved -int CDVD_Cache_Dir(const char *pathname, enum Cache_getMode getMode) -{ - - // macke sure that the requested pathname is not directly modified - static char dirname[1024]; - - int path_len; - -#ifdef DEBUG - printf("Attempting to find, and cache, directory: %s\n", pathname); -#endif - - // only take any notice of the existing cache, if it's valid - if (CachedDirInfo.valid == TRUE) { - // Check if the requested path is already cached - // if (strcasecmp(pathname,CachedDirInfo.pathname)==0) - if (ComparePath(pathname) == MATCH) { -#ifdef DEBUG - printf("CacheDir: The requested path is already cached\n"); -#endif - - // If so, is the request ot cache the start of the directory, or to resume the next block ? - if (getMode == CACHE_START) { -#ifdef DEBUG - printf(" and requested cache from start of dir\n"); -#endif - - if (CachedDirInfo.cache_offset == 0) { -// requested cache of start of the directory, and thats what's already cached -// so sit back and do nothing -#ifdef DEBUG - printf(" and start of dir is already cached so nothing to do :o)\n"); -#endif - - CachedDirInfo.valid = TRUE; - return TRUE; - } else { -// Requested cache of start of the directory, but thats not what's cached -// so re-cache the start of the directory - -#ifdef DEBUG - printf(" but dir isn't cached from start, so re-cache existing dir from start\n"); -#endif - - // reset cache data to start of existing directory - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read first time? - return FALSE; - } - - CachedDirInfo.valid = TRUE; - return TRUE; - } - } else // getMode == CACHE_NEXT - { - // So get the next block of the existing directory - - CachedDirInfo.cache_offset += CachedDirInfo.cache_size; - - CachedDirInfo.cache_size = CachedDirInfo.sector_num - CachedDirInfo.cache_offset; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read first time? - return FALSE; - } - - CachedDirInfo.valid = TRUE; - return TRUE; - } - } else // requested directory is not the cached directory (but cache is still valid) - { -#ifdef DEBUG - printf("Cache is valid, but cached directory, is not the requested one\n" - "so check if the requested directory is a sub-dir of the cached one\n"); - - printf("Requested Path = %s , Cached Path = %s\n", pathname, CachedDirInfo.pathname); -#endif - - - // Is the requested pathname a sub-directory of the current-directory ? - - // if the requested pathname is longer than the pathname of the cached dir - // and the pathname of the cached dir matches the beginning of the requested pathname - // and the next character in the requested pathname is a dir seperator - // printf("Length of Cached pathname = %d, length of req'd pathname = %d\n",path_len, strlen(pathname)); - // printf("Result of strncasecmp = %d\n",strncasecmp(pathname, CachedDirInfo.pathname, path_len)); - // printf("next character after length of cached name = %c\n",pathname[path_len]); - - // if ((strlen(pathname) > path_len) - // && (strncasecmp(pathname, CachedDirInfo.pathname, path_len)==0) - // && ((pathname[path_len]=='/') || (pathname[path_len]=='\\'))) - - if (ComparePath(pathname) == SUBDIR) { -// If so then we can start our search for the path, from the currently cached directory -#ifdef DEBUG - printf("Requested dir is a sub-dir of the cached directory,\n" - "so start search from current cached dir\n"); -#endif - // if the cached chunk, is not the start of the dir, - // then we will need to re-load it before starting search - if (CachedDirInfo.cache_offset != 0) { - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - } - - // start the search, with the path after the current directory - path_len = strlen(CachedDirInfo.pathname); - strcpy(dirname, pathname + path_len); - - // FindPath should use the current directory cache to start it's search - // and should change CachedDirInfo.pathname, to the path of the dir it finds - // it should also cache the first chunk of directory sectors, - // and fill the contents of the other elements of CachedDirInfo appropriately - - return (FindPath(dirname)); - } - } - } - -// If we've got here, then either the cache was not valid to start with -// or the requested path is not a subdirectory of the currently cached directory -// so lets start again -#ifdef DEBUG - printf("The cache is not valid, or the requested directory is not a sub-dir of the cached one\n"); -#endif - - if (!isValidDisc()) { -#ifdef DEBUG - printf("No supported disc inserted.\n"); -#endif - - return -1; - } - - sceCdDiskReady(0); - - // Read the main volume descriptor - if (CDVD_GetVolumeDescriptor() != TRUE) { -#ifdef DEBUG - printf("Could not read the CD/DVD Volume Descriptor\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("Read the CD Volume Descriptor\n"); -#endif - - CachedDirInfo.path_depth = 0; - - strcpy(CachedDirInfo.pathname, ""); - - // Setup the lba and sector size, for retrieving the root toc - CachedDirInfo.cache_offset = 0; - CachedDirInfo.sector_start = CDVolDesc.rootToc.tocLBA; - CachedDirInfo.sector_num = (CDVolDesc.rootToc.tocSize >> 11) + ((CDVolDesc.rootToc.tocSize & 2047) != 0); - - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - - // Now fill the cache with the specified sectors - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - -#ifdef DEBUG - printf("Read the first block from the root directory\n"); -#endif - -// FindPath should use the current directory cache to start it's search (in this case the root) -// and should change CachedDirInfo.pathname, to the path of the dir it finds -// it should also cache the first chunk of directory sectors, -// and fill the contents of the other elements of CachedDirInfo appropriately -#ifdef DEBUG - printf("Calling FindPath\n"); -#endif - strcpy(dirname, pathname); - - return (FindPath(dirname)); -} - -int FindPath(char *pathname) -{ - char *dirname; - char *seperator; - - int dir_entry; - int found_dir; - - struct dirTocEntry *tocEntryPointer; - struct TocEntry localTocEntry; - - dirname = strtok(pathname, "\\/"); - -#ifdef DEBUG - printf("FindPath: trying to find directory %s\n", pathname); -#endif - - if (!isValidDisc()) - return FALSE; - - sceCdDiskReady(0); - - while (dirname != NULL) { - found_dir = FALSE; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // Always skip the first entry (self-refencing entry) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - // If we have a null toc entry, then we've either reached the end of the dir, or have reached a sector boundary - if (tocEntryPointer->length == 0) { -#ifdef DEBUG - printf("Got a null pointer entry, so either reached end of dir, or end of sector\n"); -#endif - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // If we've gone past the end of the cache - // then check if there are more sectors to load into the cache - - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - // If there are more sectors to load, then load them - CachedDirInfo.cache_offset += CachedDirInfo.cache_size; - CachedDirInfo.cache_size = CachedDirInfo.sector_num - CachedDirInfo.cache_offset; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD !\n"); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } else { - CachedDirInfo.valid = FALSE; - return FALSE; - } - } - - // If the toc Entry is a directory ... - if (tocEntryPointer->fileProperties & 0x02) { - // Convert to our format (inc ascii name), for the check - TocEntryCopy(&localTocEntry, tocEntryPointer); - - // If it's the link to the parent directory, then give it the name ".." - if (dir_entry == 0) { - if (CachedDirInfo.path_depth != 0) { -#ifdef DEBUG - printf("First directory entry in dir, so name it '..'\n"); -#endif - - strcpy(localTocEntry.filename, ".."); - } - } - - // Check if this is the directory that we are looking for - if (strcasecmp(dirname, localTocEntry.filename) == 0) { -#ifdef DEBUG - printf("Found the matching sub-directory\n"); -#endif - - found_dir = TRUE; - - if (dir_entry == 0) { - // We've matched with the parent directory - // so truncate the pathname by one level - - if (CachedDirInfo.path_depth > 0) - CachedDirInfo.path_depth--; - - if (CachedDirInfo.path_depth == 0) { - // If at root then just clear the path to root - // (simpler than finding the colon seperator etc) - CachedDirInfo.pathname[0] = 0; - } else { - seperator = strrchr(CachedDirInfo.pathname, '/'); - - if (seperator != NULL) - *seperator = 0; - } - } else { - // otherwise append a seperator, and the matched directory - // to the pathname - strcat(CachedDirInfo.pathname, "/"); - -#ifdef DEBUG - printf("Adding '%s' to cached pathname - path depth = %d\n", dirname, CachedDirInfo.path_depth); -#endif - - strcat(CachedDirInfo.pathname, dirname); - - CachedDirInfo.path_depth++; - } - - // Exit out of the search loop - // (and find the next sub-directory, if there is one) - break; - } else { -#ifdef DEBUG - printf("Found a directory, but it doesn't match\n"); -#endif - } - } - - dir_entry++; - - } // end of cache block search loop - - - // if we've reached here, without finding the directory, then it's not there - if (found_dir != TRUE) { - CachedDirInfo.valid = FALSE; - return FALSE; - } - - // find name of next dir - dirname = strtok(NULL, "\\/"); - - CachedDirInfo.sector_start = localTocEntry.fileLBA; - CachedDirInfo.sector_num = (localTocEntry.fileSize >> 11) + ((CDVolDesc.rootToc.tocSize & 2047) != 0); - - // Cache the start of the found directory - // (used in searching if this isn't the last dir, - // or used by whatever requested the cache in the first place if it is the last dir) - CachedDirInfo.cache_offset = 0; - CachedDirInfo.cache_size = CachedDirInfo.sector_num; - - if (CachedDirInfo.cache_size > MAX_DIR_CACHE_SECTORS) - CachedDirInfo.cache_size = MAX_DIR_CACHE_SECTORS; - - if (ReadSect(CachedDirInfo.sector_start + CachedDirInfo.cache_offset, CachedDirInfo.cache_size, CachedDirInfo.cache, &cdReadMode) != TRUE) { -#ifdef DEBUG - printf("Couldn't Read from CD, trying to read %d sectors, starting at sector %d !\n", - CachedDirInfo.cache_size, CachedDirInfo.sector_start + CachedDirInfo.cache_offset); -#endif - - CachedDirInfo.valid = FALSE; // should we completely invalidate just because we couldnt read time? - return FALSE; - } - } - -// If we've got here then we found the requested directory -#ifdef DEBUG - printf("FindPath found the path\n"); -#endif - - CachedDirInfo.valid = TRUE; - return TRUE; -} - - - -// This is the getdir for use by IOP clients -// fills an array of TocEntry stucts in IOP memory -int CDVD_getdir_IOP(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries) -{ - // TO DO - return FALSE; -} - - -// This is the getdir for use by the EE RPC client -// It DMA's entries to the specified buffer in EE memory -int CDVD_GetDir_RPC(const char *pathname, const char *extensions, enum CDVD_getMode getMode, struct TocEntry tocEntry[], unsigned int req_entries) -{ - int matched_entries; - int dir_entry; - - struct TocEntry localTocEntry; - - struct dirTocEntry *tocEntryPointer; - - int intStatus; // interrupt status - for dis/en-abling interrupts - - struct t_SifDmaTransfer dmaStruct; - int dmaID; - - dmaID = 0; - -#ifdef DEBUG - printf("RPC GetDir Request\n"); -#endif - - matched_entries = 0; - - // pre-cache the dir (and get the new pathname - in-case selected "..") - if (CDVD_Cache_Dir(pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - -#ifdef DEBUG - printf("requested directory is %d sectors\n", CachedDirInfo.sector_num); -#endif - - if ((getMode == CDVD_GET_DIRS_ONLY) || (getMode == CDVD_GET_FILES_AND_DIRS)) { - // Cache the start of the requested directory - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // skip the first self-referencing entry - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - // skip the parent entry if this is the root - if (CachedDirInfo.path_depth == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - while (1) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - inside while-loop\n"); -#endif - - // parse the current cache block - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { - // if we have a toc entry length of zero, - // then we've either reached the end of the sector, or the end of the dir - // so point to next sector (if there is one - will be checked by next condition) - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // we've reached the end of the current cache block (which may be end of entire dir - // so just break the loop - break; - } - - // Check if the current entry is a dir or a file - if (tocEntryPointer->fileProperties & 0x02) { -#ifdef DEBUG - printf("We found a dir, and we want all dirs\n"); -#endif - - // wait for any previous DMA to complete - // before over-writing localTocEntry - while (sceSifDmaStat(dmaID) >= 0) - ; - - TocEntryCopy(&localTocEntry, tocEntryPointer); - - if (dir_entry == 0) { - if (CachedDirInfo.path_depth != 0) { -#ifdef DEBUG - printf("It's the first directory entry, so name it '..'\n"); -#endif - - strcpy(localTocEntry.filename, ".."); - } - } - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } else // it must be a file - { -#ifdef DEBUG - printf("We found a file, but we dont want files (at least not yet)\n"); -#endif - } - - dir_entry++; - - if (matched_entries >= req_entries) // if we've filled the requested buffer - return (matched_entries); // then just return - - } // end of the current cache block - - // if there is more dir to load, then load next chunk, else finish - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_NEXT) != TRUE) { - // failed to cache next block (should return TRUE even if - // there is no more directory, as long as a CD read didnt fail - return -1; - } - } else - break; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } - } - - // Next do files - if ((getMode == CDVD_GET_FILES_ONLY) || (getMode == CDVD_GET_FILES_AND_DIRS)) { - // Cache the start of the requested directory - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_START) != TRUE) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - Call of CDVD_Cache_Dir failed\n"); -#endif - - return -1; - } - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - - // skip the first self-referencing entry - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - // skip the parent entry if this is the root - if (CachedDirInfo.path_depth == 0) - tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length); - - dir_entry = 0; - - while (1) { -#ifdef DEBUG - printf("CDVD_GetDir_RPC - inside while-loop\n"); -#endif - - // parse the current cache block - for (; tocEntryPointer < (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048)); tocEntryPointer = (struct dirTocEntry *)((u8 *)tocEntryPointer + tocEntryPointer->length)) { - if (tocEntryPointer->length == 0) { - // if we have a toc entry length of zero, - // then we've either reached the end of the sector, or the end of the dir - // so point to next sector (if there is one - will be checked by next condition) - - tocEntryPointer = (struct dirTocEntry *)(CachedDirInfo.cache + (((((char *)tocEntryPointer - CachedDirInfo.cache) / 2048) + 1) * 2048)); - } - - if (tocEntryPointer >= (struct dirTocEntry *)(CachedDirInfo.cache + (CachedDirInfo.cache_size * 2048))) { - // we've reached the end of the current cache block (which may be end of entire dir - // so just break the loop - break; - } - - // Check if the current entry is a dir or a file - if (tocEntryPointer->fileProperties & 0x02) { -#ifdef DEBUG - printf("We don't want files now\n"); -#endif - } else // it must be a file - { - // wait for any previous DMA to complete - // before over-writing localTocEntry - while (sceSifDmaStat(dmaID) >= 0) - ; - - TocEntryCopy(&localTocEntry, tocEntryPointer); - - if (strlen(extensions) > 0) { - // check if the file matches the extension list - if (TocEntryCompare(localTocEntry.filename, extensions) == TRUE) { -#ifdef DEBUG - printf("We found a file that matches the requested extension list\n"); -#endif - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } else { -#ifdef DEBUG - printf("We found a file, but it didnt match the requested extension list\n"); -#endif - } - } else // no extension list to match against - { -#ifdef DEBUG - printf("We found a file, and there is not extension list to match against\n"); -#endif - - // DMA localTocEntry to the address specified by tocEntry[matched_entries] - - // setup the dma struct - dmaStruct.src = &localTocEntry; - dmaStruct.dest = &tocEntry[matched_entries]; - dmaStruct.size = sizeof(struct TocEntry); - dmaStruct.attr = 0; - - // Do the DMA transfer - CpuSuspendIntr(&intStatus); - - dmaID = sceSifSetDma(&dmaStruct, 1); - - CpuResumeIntr(intStatus); - - matched_entries++; - } - } - - dir_entry++; - - if (matched_entries >= req_entries) // if we've filled the requested buffer - return (matched_entries); // then just return - - } // end of the current cache block - - - // if there is more dir to load, then load next chunk, else finish - if ((CachedDirInfo.cache_offset + CachedDirInfo.cache_size) < CachedDirInfo.sector_num) { - if (CDVD_Cache_Dir(CachedDirInfo.pathname, CACHE_NEXT) != TRUE) { - // failed to cache next block (should return TRUE even if - // there is no more directory, as long as a CD read didnt fail - return -1; - } - } else - break; - - tocEntryPointer = (struct dirTocEntry *)CachedDirInfo.cache; - } - } - // reached the end of the dir, before filling up the requested entries - - return (matched_entries); -} - -int CdFlushCache(void) -{ - strcpy(CachedDirInfo.pathname, ""); // The pathname of the cached directory - CachedDirInfo.valid = FALSE; // Cache is not valid - CachedDirInfo.path_depth = 0; // 0 = root) - CachedDirInfo.sector_start = 0; // The start sector (LBA) of the cached directory - CachedDirInfo.sector_num = 0; // The total size of the directory (in sectors) - CachedDirInfo.cache_offset = 0; // The offset from sector_start of the cached area - CachedDirInfo.cache_size = 0; // The size of the cached directory area (in sectors) - - return TRUE; -} - -unsigned int CdGetSize(void) -{ - if (CDVD_GetVolumeDescriptor() != TRUE) - return TRUE; - - return CDVolDesc.volSize; -} - -void *CDVDRpc_FlushCache() -{ - CdFlushCache(); - - return NULL; -} - - -void *CDVDRpc_Stop() -{ - if (isValidDisc()) { - sceCdStop(); - sceCdSync(0); - } - - return NULL; -} - -// Send: Offset 0 = mode. Size = int -// Return: Offset 0 = traycnt. Size = int -void *CDVDRpc_TrayReq(unsigned int *sbuff) -{ - int ret; - - sceCdTrayReq(sbuff[0], (int *)&ret); - - sbuff[0] = ret; - return sbuff; -} - -// Send: Offset 0 = mode -// Return: Offset 0 = ret val (cd status) -void *CDVDRpc_DiskReady(unsigned int *sbuff) -{ - int ret; - - if (isValidDisc()) - ret = sceCdDiskReady(sbuff[0]); - else - ret = -1; - - sbuff[0] = ret; - return sbuff; -} - -// Send: Offset 0 = filename string (1024 bytes) -// Return: Offset 0 = ret val (true/false). Size = int -// Offset 1024 = start of TocEntry structure -void *CDVDRpc_FindFile(unsigned int *sbuff) -{ - int ret; - - ret = CDVD_findfile((char *)&sbuff[0], (struct TocEntry *)&sbuff[1024 / 4]); - - sbuff[0] = ret; - - return sbuff; -} - -// Send: Offset 0 = filename string (1024 bytes) -// Send: Offset 1024 = extension string (128 bytes) -// Send: Offset 1152 = CDVD_getMode -// Send: Offset 1156 = pointer to array of TocEntry structures in EE mem -// Send: Offset 1160 = requested number of entries - -// Return: Offset 0 = ret val (number of matched entries). Size = int -// Return: Offset 4 = updated pathname (for if path selected = ".." -void *CDVDRpc_Getdir(unsigned int *sbuff) -{ - int ret; - - ret = CDVD_GetDir_RPC( - (char *)&sbuff[0 / 4], // pathname string - (char *)&sbuff[1024 / 4], // extension string - sbuff[1152 / 4], // CDVD_getMode - (struct TocEntry *)sbuff[1156 / 4], // pointer to array of TocEntry structures in EE mem - sbuff[1160 / 4] // requested number of entries - ); - - sbuff[0] = ret; - strcpy((char *)&sbuff[1], CachedDirInfo.pathname); - return sbuff; -} - -void *CDVDRpc_GetSize(unsigned int *sbuff) -{ - sbuff[0] = CdGetSize(); - return sbuff; -} - -/************************************************* -* The functions below are for internal use only, * -* and are not to be exported * -*************************************************/ - -void CDVD_Thread(void *param) -{ -#ifdef DEBUG - printf("CDVD: RPC Initialize\n"); -#endif - - sceSifInitRpc(0); - - // 0x4800 bytes for TocEntry structures (can fit 128 of them) - // 0x400 bytes for the filename string - buffer = AllocSysMemory(0, 0x4C00, NULL); - if (buffer == NULL) { -#ifdef DEBUG - printf("Failed to allocate memory for RPC buffer!\n"); -#endif - - SleepThread(); - } - - sceSifSetRpcQueue(&qd, GetThreadId()); - sceSifRegisterRpc(&sd0, CDVD_IRX, CDVD_rpc_server, (void *)buffer, 0, 0, &qd); - sceSifRpcLoop(&qd); -} - -void *CDVD_rpc_server(int fno, void *data, int size) -{ - - switch (fno) { - case CDVD_FINDFILE: - return CDVDRpc_FindFile((unsigned *)data); - case CDVD_GETDIR: - return CDVDRpc_Getdir((unsigned *)data); - case CDVD_STOP: - return CDVDRpc_Stop(); - case CDVD_TRAYREQ: - return CDVDRpc_TrayReq((unsigned *)data); - case CDVD_DISKREADY: - return CDVDRpc_DiskReady((unsigned *)data); - case CDVD_FLUSHCACHE: - return CDVDRpc_FlushCache(); - } - - return NULL; -} - -void _splitpath(const char *constpath, char *dir, char *fname) -{ - // 255 char max path-length is an ISO9660 restriction - // we must change this for Joliet or relaxed iso restriction support - static char pathcopy[1024 + 1]; - - char *slash; - - strncpy(pathcopy, constpath, 1024); - - slash = strrchr(pathcopy, '/'); - - // if the path doesn't contain a '/' then look for a '\' - if (!slash) - slash = strrchr(pathcopy, (int)'\\'); - - // if a slash was found - if (slash != NULL) { - // null terminate the path - slash[0] = 0; - // and copy the path into 'dir' - strncpy(dir, pathcopy, 1024); - dir[255] = 0; - - // copy the filename into 'fname' - strncpy(fname, slash + 1, 128); - fname[128] = 0; - } else { - dir[0] = 0; - - strncpy(fname, pathcopy, 128); - fname[128] = 0; - } -} - -// Copy a TOC Entry from the CD native format to our tidier format -void TocEntryCopy(struct TocEntry *tocEntry, struct dirTocEntry *internalTocEntry) -{ - int i; - int filenamelen; - - tocEntry->fileSize = internalTocEntry->fileSize; - tocEntry->fileLBA = internalTocEntry->fileLBA; - tocEntry->fileProperties = internalTocEntry->fileProperties; - - if (CDVolDesc.filesystemType == 2) { - // This is a Joliet Filesystem, so use Unicode to ISO string copy - filenamelen = internalTocEntry->filenameLength / 2; - - for (i = 0; i < filenamelen; i++) - tocEntry->filename[i] = internalTocEntry->filename[(i << 1) + 1]; - } else { - filenamelen = internalTocEntry->filenameLength; - - // use normal string copy - strncpy(tocEntry->filename, internalTocEntry->filename, 128); - } - - tocEntry->filename[filenamelen] = 0; - - if (!(tocEntry->fileProperties & 0x02)) { - // strip the ;1 from the filename (if it's there) - strtok(tocEntry->filename, ";"); - } -} - -// Check if a TOC Entry matches our extension list -int TocEntryCompare(char *filename, const char *extensions) -{ - static char ext_list[129]; - - char *token; - - char *ext_point; - - strncpy(ext_list, extensions, 128); - ext_list[128] = 0; - - token = strtok(ext_list, " ,"); - while (token != NULL) { - // if 'token' matches extension of 'filename' - // then return a match - ext_point = strrchr(filename, '.'); - - if (strcasecmp(ext_point, token) == 0) - return (TRUE); - - /* Get next token: */ - token = strtok(NULL, " ,"); - } - - // If not match found then return FALSE - return (FALSE); -} - -// Used in findfile -//int tolower(int c); -int strcasecmp(const char *s1, const char *s2) -{ - while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) { - s1++; - s2++; - } - - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); -} - -int strncasecmp(const char *s1, const char *s2, int limit) -{ - int i; - - for (i = 0; i < limit; i++) { - if (*s1 == '\0') - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); - - if (tolower(*s1) != tolower(*s2)) - return tolower(*(unsigned char *)s1) - tolower(*(unsigned char *)s2); - - s1++; - s2++; - } - - return 0; -} - -enum PathMatch ComparePath(const char *path) -{ - int length; - int i; - - length = strlen(CachedDirInfo.pathname); - - for (i = 0; i < length; i++) { - // check if character matches - if (path[i] != CachedDirInfo.pathname[i]) { - // if not, then is it just because of different path seperator ? - if ((path[i] == '/') || (path[i] == '\\')) { - if ((CachedDirInfo.pathname[i] == '/') || (CachedDirInfo.pathname[i] == '\\')) { - continue; - } - } - - // if the characters don't match for any other reason then report a failure - return NOT_MATCH; - } - } - - // Reached the end of the Cached pathname - - // if requested path is same length, then report exact match - if (path[length] == 0) - return MATCH; - - // if requested path is longer, and next char is a dir seperator - // then report sub-dir match - if ((path[length] == '/') || (path[length] == '\\')) - return SUBDIR; - else - return NOT_MATCH; -} diff --git a/ps2/libcdvd/iop/cdvd_iop.h b/ps2/libcdvd/iop/cdvd_iop.h deleted file mode 100644 index 989ed12cef..0000000000 --- a/ps2/libcdvd/iop/cdvd_iop.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _CDVD_IOP_H -#define _CDVD_IOP_H - -#include "../common/cdvd.h" - -// Macros for READ Data pattan -#define CdSecS2048 0 // sector size 2048 -#define CdSecS2328 1 // sector size 2328 -#define CdSecS2340 2 // sector size 2340 - -// Macros for Spindle control -#define CdSpinMax 0 -#define CdSpinNom 1 // Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced. -#define CdSpinStm 0 // Recommended stream rotation speed. - -typedef struct -{ - u8 stat; // 0: normal. Any other: error - u8 second; // second (BCD value) - u8 minute; // minute (BCD value) - u8 hour; // hour (BCD value) - u8 week; // week (BCD value) - u8 day; // day (BCD value) - u8 month; // month (BCD value) - u8 year; // year (BCD value) -} CdCLOCK; - -typedef struct -{ - u32 lsn; // Logical sector number of file - u32 size; // File size (in bytes) - char name[16]; // Filename - u8 date[8]; // 1th: Seconds - // 2th: Minutes - // 3th: Hours - // 4th: Date - // 5th: Month - // 6th 7th: Year (4 digits) -} CdlFILE; - -typedef struct -{ - u8 minute; // Minutes - u8 second; // Seconds - u8 sector; // Sector - u8 track; // Track number -} CdlLOCCD; - -typedef struct -{ - u8 trycount; // Read try count (No. of error retries + 1) (0 - 255) - u8 spindlctrl; // SCECdSpinStm: Recommended stream rotation speed. - // SCECdSpinNom: Starts reading data at maximum rotational velocity and if a read error occurs, the rotational velocity is reduced. - u8 datapattern; // SCECdSecS2048: Data size 2048 bytes - // SCECdSecS2328: 2328 bytes - // SCECdSecS2340: 2340 bytes - u8 pad; // Padding data produced by alignment. -} CdRMode; - - -int CdBreak(void); -int CdCallback(void (*func)()); -int CdDiskReady(int mode); -int CdGetDiskType(void); -int CdGetError(void); -u32 CdGetReadPos(void); -int CdGetToc(u8 *toc); -int CdInit(int init_mode); -CdlLOCCD *CdIntToPos(int i, CdlLOCCD *p); -int CdPause(void); -int CdPosToInt(CdlLOCCD *p); -int CdRead(u32 lsn, u32 sectors, void *buf, CdRMode *mode); -int CdReadClock(CdCLOCK *rtc); -int CdSearchFile(CdlFILE *fp, const char *name); -int CdSeek(u32 lsn); -int CdStandby(void); -int CdStatus(void); -int CdStop(void); -int CdSync(int mode); -int CdTrayReq(int mode, u32 *traycnt); -int CdFlushCache(void); -unsigned int CdGetSize(void); - -#endif // _CDVD_H diff --git a/ps2/libcdvd/iop/imports.lst b/ps2/libcdvd/iop/imports.lst deleted file mode 100644 index f47423c148..0000000000 --- a/ps2/libcdvd/iop/imports.lst +++ /dev/null @@ -1,62 +0,0 @@ -cdvdman_IMPORTS_start -I_sceCdInit -I_sceCdGetError -I_sceCdRead -I_sceCdStop -I_sceCdSync -I_sceCdDiskReady -I_sceCdGetDiskType -I_sceCdTrayReq -cdvdman_IMPORTS_end - -intrman_IMPORTS_start -I_CpuSuspendIntr -I_CpuResumeIntr -intrman_IMPORTS_end - -ioman_IMPORTS_start -I_AddDrv -I_DelDrv -ioman_IMPORTS_end - -sifcmd_IMPORTS_start -I_sceSifInitRpc -I_sceSifSetRpcQueue -I_sceSifRegisterRpc -I_sceSifRpcLoop -sifcmd_IMPORTS_end - -sifman_IMPORTS_start -I_sceSifSetDma -I_sceSifDmaStat -sifman_IMPORTS_end - -stdio_IMPORTS_start -I_printf -I_puts -stdio_IMPORTS_end - -sysclib_IMPORTS_start -I_tolower -I_strcpy -I_strncpy -I_strncmp -I_strtok -I_strrchr -I_strcat -I_strlen -I_memset -I_memcpy -I_memcmp -sysclib_IMPORTS_end - -sysmem_IMPORTS_start -I_AllocSysMemory -sysmem_IMPORTS_end - -thbase_IMPORTS_start -I_GetThreadId -I_CreateThread -I_StartThread -I_SleepThread -thbase_IMPORTS_end diff --git a/ps2/libcdvd/iop/irx_imports.h b/ps2/libcdvd/iop/irx_imports.h deleted file mode 100644 index 4048b3d831..0000000000 --- a/ps2/libcdvd/iop/irx_imports.h +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/ps2/libcdvd/license.txt b/ps2/libcdvd/license.txt deleted file mode 100644 index bd0a0cb71d..0000000000 --- a/ps2/libcdvd/license.txt +++ /dev/null @@ -1,45 +0,0 @@ -Copyright (c) 2002, A.Lee & Nicholas Van Veen -All rights reserved. - -Redistribution and use of this software, in source and binary forms, with or -without modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. You are granted a license to use this software for academic, research and - non-commercial purposes only. - -4. The copyright holder imposes no restrictions on any code developed using - this software. However, the copyright holder retains a non-exclusive - royalty-free license to any modifications to the distribution made by the - licensee. - -5. Any licensee wishing to make commercial use of this software should contact - the copyright holder to execute the appropriate license for such commercial - use. Commercial use includes: - - - Integration of all or part of the source code into a product for sale - or commercial license by or on behalf of Licensee to third parties, or - - - Distribution of the binary code or source code to third parties that - need it to utilize a commercial product sold or licensed by or on - behalf of Licensee. - - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE. - diff --git a/verbosity.c b/verbosity.c index 6a7e091081..23425582fa 100644 --- a/verbosity.c +++ b/verbosity.c @@ -177,11 +177,9 @@ void retro_main_log_file_init(const char *path, bool append) g_verbosity->fp = tmp; g_verbosity->initialized = true; -#if !defined(PS2) /* TODO: PS2 IMPROVEMENT */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ g_verbosity->buf = calloc(1, 0x4000); setvbuf(g_verbosity->fp, (char*)g_verbosity->buf, _IOFBF, 0x4000); -#endif } void retro_main_log_file_deinit(void)