Adapt PS2 port to new SDK with newlib support (CDVDFS support is missing)

This commit is contained in:
Francisco Javier Trujillo Mata 2019-10-07 23:45:54 +02:00
parent a3d3e18369
commit 1eeb3dcf30
44 changed files with 70 additions and 3974 deletions

View File

@ -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

View File

@ -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)

View File

@ -16,7 +16,6 @@
#include "../frontend_driver.h"
#include <io_common.h>
#include <loadfile.h>
#include <unistd.h>
#include <sbv_patches.h>
@ -27,12 +26,8 @@
#include <libmtap.h>
#include <audsrv.h>
#include <libpad.h>
#include <libcdvd-common.h>
#include <cdvd_rpc.h>
#include <fileXio_cdvd.h>
#include <ps2_devices.h>
#include <ps2_irx_variables.h>
#include <ps2_descriptor.h>
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);
}

View File

@ -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;

View File

@ -13,17 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <gsKit.h>
#include <dmaKit.h>
#include <gsToolkit.h>
#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);
}

View File

@ -70,9 +70,7 @@
#endif
#if defined(PS2)
#include <kernel.h>
#include <timer.h>
#include <time.h>
#include <ps2sdkapi.h>
#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)

View File

@ -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

View File

@ -79,11 +79,6 @@
#include <pspkernel.h>
#endif
#if defined(PS2)
#include <fileXio_rpc.h>
#include <fileXio.h>
#endif
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
#include <cell/cell_fs.h>
#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 <unistd.h> /* stat() is defined here */
#endif

View File

@ -82,11 +82,6 @@
#include <pspkernel.h>
#endif
#if defined(PS2)
#include <fileXio_rpc.h>
#include <fileXio.h>
#endif
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
#include <cell/cell_fs.h>
#endif

View File

@ -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;

View File

@ -29,10 +29,6 @@
#include <compat/msvc.h>
#endif
#if defined(PS2)
#include <compat_ctype.h>
#endif
RETRO_BEGIN_DECLS
#ifdef _WIN32

View File

@ -25,10 +25,6 @@
#include <string.h>
#if defined(PS2)
#include <compat_ctype.h>
#endif
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
#include "../../../config.h"
#endif

View File

@ -33,7 +33,7 @@
#include <gsKit.h>
#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;

View File

@ -37,8 +37,6 @@
#include <pspthreadman.h>
#elif defined(VITA)
#include <psp2/kernel/threadmgr.h>
#elif defined(PS2)
#include <SDL/SDL_timer.h>
#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

View File

@ -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)

View File

@ -51,10 +51,6 @@
# if defined(PSP)
# include <pspiofilemgr.h>
# endif
# if defined(PS2)
# include <fileXio_rpc.h>
# include <fileXio_cdvd.h>
# endif
# include <sys/types.h>
# include <sys/stat.h>
# if !defined(VITA)
@ -93,16 +89,13 @@
# if defined(PSP)
# include <pspiofilemgr.h>
# endif
# if defined(PS2)
# include <fileXio_rpc.h>
# endif
# include <sys/types.h>
# include <sys/stat.h>
# include <dirent.h>
# include <unistd.h>
#endif
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) || defined(PS2)
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
#include <unistd.h> /* stat() is defined here */
#endif
@ -146,11 +139,6 @@
#include <pspkernel.h>
#endif
#if defined(PS2)
#include <fileXio_rpc.h>
#include <fileXio.h>
#endif
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
#include <cell/cell_fs.h>
#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)

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <compat_ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <fileXio_rpc.h>
#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); }

View File

@ -1,205 +0,0 @@
#include <stdio.h>
#include <tamtypes.h>
#include <kernel.h>
#include <string.h>
#include <time.h>
#include <sifrpc.h>
#include <sys/fcntl.h>
#include <cdvd_rpc.h>
#include <fileXio_cdvd.h>
#include <libcdvd-common.h>
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <ps2_descriptor.h>
#include <stdio.h>
#include <kernel.h>
#include <string.h>
#include <fileXio_rpc.h>
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;
}

View File

@ -15,9 +15,10 @@
#include <ps2_devices.h>
#include <stdio.h>
#include <stdlib.h>
#include <kernel.h>
#include <string.h>
#include <fileXio_rpc.h>
#include <dirent.h>
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/* 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 <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <SDL/SDL.h>
#include <libcdvd-common.h>
#include <osd_config.h>
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -1,37 +0,0 @@
#ifndef PS2_CD_H
#define PS2_CD_H
#include <stdint.h>
#include <fileXio_rpc.h>
#include <fileXio.h>
#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 */

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef INTTYPES_H
#define INTTYPES_H
#define PRId64 "lld"
#define PRIu64 "llu"
#define PRIuPTR "llu"
#endif /* INTTYPES_H */

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef MATH_H
#define MATH_H
#include <floatlib.h>
#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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef PS2_DESCRIPTOR_H
#define PS2_DESCRIPTOR_H
#include <stddef.h>
#include <fileXio_cdvd.h>
#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 */

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef PTE_TYPES_H
#define PTE_TYPES_H
#include <errno.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <tcpip.h>
/** 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 */

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 */

View File

@ -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

View File

@ -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 $<

View File

@ -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

View File

@ -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

View File

@ -1,135 +0,0 @@
#include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <stdarg.h>
#include <string.h>
#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];
}

View File

@ -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

View File

@ -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

View File

@ -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)

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -1,9 +0,0 @@
#include <cdvdman.h>
#include <intrman.h>
#include <ioman.h>
#include <sifcmd.h>
#include <sifman.h>
#include <stdio.h>
#include <sysclib.h>
#include <sysmem.h>
#include <thbase.h>

View File

@ -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.

View File

@ -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)