/* Initialize/Cleanup the network API */ int SDLNet_Init(void) { if ( !SDLNet_started ) { #ifdef __USE_W32_SOCKETS /* Start up the windows networking */ WORD version_wanted = MAKEWORD(1,1); WSADATA wsaData; if ( WSAStartup(version_wanted, &wsaData) != 0 ) { SDLNet_SetError("Couldn't initialize Winsock 1.1\n"); return(-1); } #else #ifdef __CELLOS_LV2__ /* Start the stack */ cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); #endif #ifndef __CELLOS_LV2__ /* No signals on cell */ /* SIGPIPE is generated when a remote socket is closed */ void (*handler)(int); handler = signal(SIGPIPE, SIG_IGN); if ( handler != SIG_DFL ) { signal(SIGPIPE, handler); } #endif #endif } ++SDLNet_started; return(0); }
/*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int socket_open(void) { /* instals a handler to ignore sigpipe or it will crash us */ #if APIABSTRACTION_PS3 sys_net_initialize_network(); #elif PE_PLAT_IS_PSVITA static char memory[256 * 1024]; static int initialized = 0; if (!initialized) { initialized = 1; SceNetInitParam param; int ret = 0; /* initialize libnet */ param.memory = memory; param.size = sizeof(memory); param.flags = 0; ret = sceNetInit(¶m); if(ret < 0){ printf("sceNetInit() failed. ret = 0x%x\n", ret); } } #else signal(SIGPIPE, SIG_IGN); // make sure we ignore SIGPIPE signal that is called whenever sockets close #endif return 1; }
/** * network_init: * * Platform specific socket library initialization. * * Returns: true (1) if successful, otherwise false (0). **/ bool network_init(void) { #ifdef _WIN32 WSADATA wsaData; #endif static bool inited = false; if (inited) return true; #if defined(_WIN32) if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { network_deinit(); return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif inited = true; return true; }
void log_init(const char *host, unsigned short port) { #ifdef ENABLE_LOG unsigned int temp; struct hostent *hp; (void) cellSysmoduleLoadModule(CELL_SYSMODULE_NET); (void) sys_net_initialize_network(); memset(&address, 0, sizeof(address)); if ((unsigned int)-1 != (temp = inet_addr(host))) { address.sin_family = AF_INET; address.sin_addr.s_addr = temp; } else { if (NULL == (hp = gethostbyname(host))) { return; } address.sin_family = hp->h_addrtype; memcpy(&address.sin_addr, hp->h_addr, hp->h_length); } address.sin_port = htons(port); socket_fd = socket(AF_INET, SOCK_DGRAM, 0); if (socket_fd < 0) { return; } log("%s: created udp socket, address setup towards %s:%d\n", __func__, inet_ntoa(address.sin_addr), port); #endif }
bool LoadModules(void) { cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); cellScreenShotEnable(); int ret = cellSysmoduleLoadModule( CELL_SYSMODULE_FS ); if ( ret < 0 ) { //printf( "\nError loading module FS!!!\n" ); return false; } ret = cellSysmoduleLoadModule( CELL_SYSMODULE_USBD ); if ( ret < 0 ) { //printf( "\nError loading module USBD!!!\n" ); return false; } ret = cellSysmoduleLoadModule(CELL_SYSMODULE_HTTP); if ( ret < 0 ) { //printf( "\nError loading module HTTP!!!\n" ); return false; } sys_net_initialize_network(); //printf( "\nLoading libnet\n" ); ret = cellSysmoduleLoadModule( CELL_SYSMODULE_NET ); if ( ret < 0 ) { //printf( "\nError loading module NET!!!\n" ); return false; } cellNetCtlInit(); //printf( "\nLoading libio\n" ); ret = cellSysmoduleLoadModule( CELL_SYSMODULE_IO ); if ( ret < 0 ) { //printf( "\nError loading module IO!!!\n" ); return false; } //printf( "\nLoading libaudio\n" ); ret = cellSysmoduleLoadModule( CELL_SYSMODULE_AUDIO ); if ( ret < 0 ) { //printf( "\nError loading module AUDIO!!!\n" ); return false; } ret = cellSysmoduleLoadModule( CELL_SYSMODULE_RESC ); if ( ret < 0 ) { //printf( "\nError loading module RESC!!!\n" ); return false; } return true; }
static void system_init(void *data) { (void)data; #ifdef HAVE_SYSUTILS RARCH_LOG("Registering system utility callback...\n"); cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); #endif #ifdef HAVE_SYSMODULES #ifdef HAVE_FREETYPE cellSysmoduleLoadModule(CELL_SYSMODULE_FONT); cellSysmoduleLoadModule(CELL_SYSMODULE_FREETYPE); cellSysmoduleLoadModule(CELL_SYSMODULE_FONTFT); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); #ifndef __PSL1GHT__ cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME); #endif #ifndef IS_SALAMANDER #ifndef __PSL1GHT__ cellSysmoduleLoadModule(CELL_SYSMODULE_AVCONF_EXT); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_PNGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_JPGDEC); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP); #endif #ifndef __PSL1GHT__ sys_net_initialize_network(); sceNpInit(NP_POOL_SIZE, np_pool); #endif #ifndef IS_SALAMANDER #if (CELL_SDK_VERSION > 0x340000) && !defined(__PSL1GHT__) #ifdef HAVE_SYSMODULES cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); #endif #ifdef HAVE_SYSUTILS CellScreenShotSetParam screenshot_param = {0, 0, 0, 0}; screenshot_param.photo_title = "RetroArch PS3"; screenshot_param.game_title = "RetroArch PS3"; cellScreenShotSetParameter (&screenshot_param); cellScreenShotEnable(); #endif #ifdef HAVE_SYSUTILS //if (g_extern.lifecycle_state & (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE)) cellSysutilEnableBgmPlayback(); #endif #endif #endif }
static void system_init(void) { #ifdef HAVE_SYSUTILS RARCH_LOG("Registering system utility callback...\n"); cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); #endif #ifdef HAVE_SYSMODULES #ifdef HAVE_FREETYPE cellSysmoduleLoadModule(CELL_SYSMODULE_FONT); cellSysmoduleLoadModule(CELL_SYSMODULE_FREETYPE); cellSysmoduleLoadModule(CELL_SYSMODULE_FONTFT); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); #ifndef __PSL1GHT__ cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME); #endif #ifndef IS_SALAMANDER #ifndef __PSL1GHT__ cellSysmoduleLoadModule(CELL_SYSMODULE_AVCONF_EXT); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_PNGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_JPGDEC); #endif cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP); #endif #ifndef __PSL1GHT__ sys_net_initialize_network(); #endif #if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) inl_logger_init(); #endif #ifndef __PSL1GHT__ sceNpInit(NP_POOL_SIZE, np_pool); #endif }
// Platform specific socket library init. bool netplay_init_network(void) { static bool inited = false; if (inited) return true; #if defined(_WIN32) WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { WSACleanup(); return false; } #elif defined(__CELLOS_LV2__) cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); #else signal(SIGPIPE, SIG_IGN); // Do not like SIGPIPE killing our app :( #endif inited = true; return true; }
/** * network_init: * * Platform specific socket library initialization. * * Returns: true (1) if successful, otherwise false (0). **/ bool network_init(void) { #ifdef _WIN32 WSADATA wsaData; #endif static bool inited = false; if (inited) return true; #if defined(_WIN32) if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { network_deinit(); return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) int timeout_count = 10; cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); if (cellNetCtlInit() < 0) return false; for (;;) { int state; if (cellNetCtlGetState(&state) < 0) return false; if (state == CELL_NET_CTL_STATE_IPObtained) break; retro_sleep(500); timeout_count--; if (timeout_count < 0) return 0; } #elif defined(VITA) SceNetInitParam initparam; if (sceNetShowNetstat() == SCE_NET_ERROR_ENOTINIT) { _net_compat_net_memory = malloc(COMPAT_NET_INIT_SIZE); initparam.memory = _net_compat_net_memory; initparam.size = COMPAT_NET_INIT_SIZE; initparam.flags = 0; sceNetInit(&initparam); sceNetCtlInit(); } retro_epoll_fd = sceNetEpollCreate("epoll", 0); #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE, 10) < 0) return false; #elif defined(WIIU) socket_lib_init(); #elif defined(_3DS) _net_compat_net_memory = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE); if (_net_compat_net_memory == NULL) return false; Result ret = socInit(_net_compat_net_memory, SOC_BUFFERSIZE);//WIFI init if (ret != 0) return false; #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif inited = true; return true; }
int main(int argc, char *argv[]) { #ifdef HAVE_SYSUTILS RARCH_LOG("Registering system utility callback...\n"); cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); #endif #ifdef HAVE_SYSMODULES cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_AVCONF_EXT); cellSysmoduleLoadModule(CELL_SYSMODULE_PNGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_JPGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP); #endif sys_net_initialize_network(); #ifdef HAVE_LOGGER logger_init(); #endif sceNpInit(NP_POOL_SIZE, np_pool); rarch_main_clear_state(); get_environment_settings(argc, argv); config_set_defaults(); input_ps3.init(); char tmp_path[PATH_MAX]; snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir); rarch_configure_libretro(&input_ps3, tmp_path, default_paths.executable_extension); #if(CELL_SDK_VERSION > 0x340000) if (g_console.screenshots_enable) { #ifdef HAVE_SYSMODULES cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); #endif #ifdef HAVE_SYSUTILS CellScreenShotSetParam screenshot_param = {0, 0, 0, 0}; screenshot_param.photo_title = "RetroArch PS3"; screenshot_param.game_title = "RetroArch PS3"; cellScreenShotSetParameter (&screenshot_param); cellScreenShotEnable(); #endif } #ifdef HAVE_SYSUTILS if (g_console.custom_bgm_enable) cellSysutilEnableBgmPlayback(); #endif #endif video_gl.start(); #ifdef HAVE_OSKUTIL oskutil_init(&g_console.oskutil_handle, 0); #endif rarch_input_set_default_keybind_names_for_emulator(); menu_init(); switch(g_console.external_launcher_support) { case EXTERN_LAUNCHER_SALAMANDER: g_console.mode_switch = MODE_MENU; break; #ifdef HAVE_MULTIMAN case EXTERN_LAUNCHER_MULTIMAN: RARCH_LOG("Started from multiMAN, will auto-start game.\n"); strlcpy(g_console.rom_path, argv[1], sizeof(g_console.rom_path)); rarch_settings_change(S_START_RARCH); rarch_startup(default_paths.config_file); break; #endif default: break; } begin_loop: if(g_console.mode_switch == MODE_EMULATION) { bool repeat = false; input_ps3.poll(NULL); rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); do{ repeat = rarch_main_iterate(); }while(repeat && !g_console.frame_advance_enable); } else if(g_console.mode_switch == MODE_MENU) { menu_loop(); rarch_startup(default_paths.config_file); } else goto begin_shutdown; goto begin_loop; begin_shutdown: if(path_file_exists(default_paths.config_file)) rarch_config_save(default_paths.config_file); if(g_console.emulator_initialized) rarch_main_deinit(); input_ps3.free(NULL); video_gl.stop(); menu_free(); #ifdef HAVE_OSKUTIL if(g_console.oskutil_handle.is_running) oskutil_unload(&g_console.oskutil_handle); #endif #ifdef HAVE_LOGGER logger_shutdown(); #endif #ifdef HAVE_SYSMODULES if(g_console.screenshots_enable) cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); cellSysmoduleUnloadModule(CELL_SYSMODULE_JPGDEC); cellSysmoduleUnloadModule(CELL_SYSMODULE_PNGDEC); cellSysmoduleUnloadModule(CELL_SYSMODULE_AVCONF_EXT); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); #endif #ifdef HAVE_HDD_CACHE_PARTITION int ret = cellSysCacheClear(); if(ret != CELL_SYSCACHE_RET_OK_CLEARED) { RARCH_ERR("System cache partition could not be cleared on exit.\n"); } #endif rarch_exec(); return 1; }
bool CapApp::onInit(int argc, char* argv[]) { (void)argc; (void)argv; // ---------------------------------------------- // FTP cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellNetCtlInit(); cellSysmoduleLoadModule(CELL_SYSMODULE_HTTP); sys_net_initialize_network(); ftp_on(); // Load settings... if(!iniRead()) { iniWrite(); // create settings file... } cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_SCREENSHOT); cellScreenShotEnable(); InputInit(); while(!videoOutIsReady()) { // ... } PSGLinitOptions options = { enable: PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS, maxSPUs: 1, initializeSPUs: GL_FALSE, persistentMemorySize: 0, transientMemorySize: 0, errorConsole: 0, fifoSize: 0, hostMemorySize: 128* 1024*1024, // 128 mbs for host memory }; #if CELL_SDK_VERSION < 0x340000 options.enable |= PSGL_INIT_HOST_MEMORY_SIZE; #endif // Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL sys_spu_initialize(6, 1); psglInit(&options); const unsigned int resolutions[] = { CELL_VIDEO_OUT_RESOLUTION_1080, CELL_VIDEO_OUT_RESOLUTION_960x1080, CELL_VIDEO_OUT_RESOLUTION_720, CELL_VIDEO_OUT_RESOLUTION_480 }; const int numResolutions = sizeof(resolutions) / sizeof(resolutions[0]); int bestResolution = chooseBestResolution(resolutions,numResolutions); getResolutionWidthHeight(bestResolution, deviceWidth, deviceHeight); if(bestResolution) { PSGLdeviceParameters params; params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; params.colorFormat = GL_ARGB_SCE; params.depthFormat = GL_NONE; params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE; params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = deviceWidth; params.height = deviceHeight; device = psglCreateDeviceExtended(¶ms); context = psglCreateContext(); psglMakeCurrent(context, device); psglResetCurrentContext(); initGraphics(); if( cellSysutilRegisterCallback( 0, callback_sysutil_exit, NULL ) < 0 ) { //... } dbgFontInit(); fbaRL = new c_fbaRL(); while(bRun) { onRender(); onUpdate(); cellSysutilCheckCallback(); } } else { // resolution error... } ftp_off(); onShutdown(); return false; } void CapApp::onRender() { if(fbaRL) { fbaRL->DlgDisplayFrame(); } // get render target buffer dimensions and set viewport psglGetRenderBufferDimensions(device,&app.renderWidth,&app.renderHeight); glViewport(0, 0, app.renderWidth, app.renderHeight); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(fbaRL) { fbaRL->RenderBackground(); } if(fbaRL) { fbaRL->nFrameStep = 0; fbaRL->DisplayFrame(); } if(fbaRL) { fbaRL->nFrameStep = 1; fbaRL->DisplayFrame(); } dbgFontDraw(); psglSwap(); } bool CapApp::onUpdate() { if(!mFrame) mFrame = 0; mFrame++; InputFrameStart(); if(fbaRL) fbaRL->InputFrame(); InputFrameEnd(); return true; } void CapApp::onShutdown() { iniWrite(); // save settings if(context) psglDestroyContext(context); if(device) psglDestroyDevice(device); InputExit(); psglExit(); }
int main(int argc, char *argv[]) { int ret; #if defined(_XBOX) XINPUT_STATE state; get_environment_settings(); XInputGetState(0, &state); if(state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) { //override path, boot first executable in cores directory RARCH_LOG("Fallback - Will boot first executable in RetroArch cores directory.\n"); find_and_set_first_file(); } else { //normal executable loading path init_settings(); } XLaunchNewImage(libretro_path, NULL); RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret); #elif defined(__CELLOS_LV2__) CellPadData pad_data; char spawn_data[256], spawn_data_size[16]; SceNpDrmKey * k_licensee = NULL; cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP); sys_net_initialize_network(); #ifdef HAVE_LOGGER logger_init(); #endif sceNpInit(NP_POOL_SIZE, np_pool); get_environment_settings(); cellPadInit(7); cellPadGetData(0, &pad_data); if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) { //override path, boot first executable in cores directory RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n"); find_and_set_first_file(); } else { //normal executable loading path init_settings(); } cellPadEnd(); #ifdef HAVE_LOGGER logger_shutdown(); #endif for(unsigned int i = 0; i < sizeof(spawn_data); ++i) spawn_data[i] = i & 0xff; snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256); const char * const spawn_argv[] = { spawn_data_size, "test argv for", "sceNpDrmProcessExitSpawn2()", NULL }; ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret); if(ret < 0) { RARCH_LOG("Executable file is not of NPDRM type, trying another approach to boot it...\n"); sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M); } sceNpTerm(); sys_net_finalize_network(); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP); cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); #endif return 1; }