void LibESPlatform::Initialize () { sys_spu_initialize(6, 1); cellSysutilRegisterCallback(0, (CellSysutilCallback)sysutil_callback, NULL); while(true) { CellVideoOutState videoState; cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &videoState); if(videoState.state == CELL_VIDEO_OUT_OUTPUT_STATE_ENABLED) { break; } } cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_NET); }
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 initializeSpursTaskSet(CellSpurs *pSpurs, int iSPUCount, uint8_t *puiPriorities) { uint8_t auiLocalPriorities[8]={1,1,1,1,1,1,1,1}; uint8_t *pPriorities=auiLocalPriorities; int iReturn; int iNumSPUs=iSPUCount; // Not loading from a file anymore // if (loadBulletSpursElfs()!=CELL_SPURS_OK) { // fprintf(stderr, "Bullet: Cannot load SPURS programs."); // return CELL_SPURS_EINVAL; // } if (pSpurs) { g_bUserSpursGiven=true; pPriorities=puiPriorities; iNumSPUs=iSPUCount; g_spursInstance=pSpurs; } else { g_bUserSpursGiven=false; // E We need to figure out the priority for the SPURS handler thread. // E We'll do this by getting the current thread priority, and making // E the SPURS handler thread slightly higher priority. sys_ppu_thread_t idCurrentThread; int iCurrentThreadPriority; iReturn=sys_ppu_thread_get_id(&idCurrentThread); if (iReturn!=CELL_OK) { //fprintf(stderr, "Bullet: Cannot get current thread ID (%d)\n", iReturn); return CELL_SPURS_EINVAL; } iReturn=sys_ppu_thread_get_priority(idCurrentThread, &iCurrentThreadPriority); if (iReturn!=CELL_OK) { //fprintf(stderr, "Bullet: Cannot get current thread priority (%d)\n", iReturn); return CELL_SPURS_EINVAL; } g_spursInstance=(CellSpurs *) memalign(128, sizeof(CellSpurs)); if (!g_spursInstance) { //fprintf(stderr,"Cannot allocate room for SPURS\n"); return CELL_SPURS_EINVAL; } sys_spu_initialize(iNumSPUs, 0); // E Initialize spurs, setting SPU count, priorities, and letting SPURS // E know that it should NOT release the SPUs when there is no work to // E be done. iReturn=cellSpursInitialize(g_spursInstance, iNumSPUs, SPURS_SPU_THREAD_PRIORITY, iCurrentThreadPriority - 1, false); if (iReturn!=CELL_OK) { //fprintf(stderr, "Bullet: Cannot initialize SPURS (%d)\n", iReturn); free(g_spursInstance); return CELL_SPURS_EINVAL; } } // Create SPU printf support. // sys_event_queue_attribute_t queue_attr; /* Event queue attributes */ // E Create an event queue that the SPU can use to send printf // E commands to the PPU for debugging. // sys_event_queue_attribute_initialize(queue_attr); // iReturn=sys_event_queue_create(&_g_SpuPrintfEventQueue, &queue_attr, // _SpursSupportGetUniqueEventQueueKey(), // SPU_PRINTF_EVENT_QUEUE_SIZE); // // if (iReturn!=CELL_OK) // { // return CELL_SPURS_EMISC; // } // E We need a thread on the PPU side to handle SPU printf requests. // E It will wait indefinitely for messages in the queue we just created. // iReturn = sys_ppu_thread_create (&_g_SpursPrintfThread, // _SpursPrintfThreadMain, // (uint64_t) 0, SPU_PRINTF_THREAD_PRIO, // SPU_PRINTF_THREAD_STACK_SIZE, // SYS_PPU_THREAD_CREATE_JOINABLE, // "Bullet_spu_printf_handler"); // if (iReturn != CELL_OK) // { // return CELL_SPURS_EMISC; // } // E Now, we attach the PPU-side printf support to SPURS // uint8_t uiPrintfPort=SPU_PRINTF_EVENT_QUEUE_PORT; // // iReturn=cellSpursAttachLv2EventQueue(g_spursInstance, _g_SpuPrintfEventQueue, // &uiPrintfPort, 0); // if (iReturn!=CELL_OK) { // return CELL_SPURS_EMISC; // } iReturn=cellSpursCreateTaskset(g_spursInstance, &g_spursTaskSet, 0, pPriorities, iNumSPUs); if (iReturn!=CELL_OK) { cellSpursFinalize(g_spursInstance); free(g_spursInstance); return CELL_SPURS_EINVAL; } g_bSpursInitialized=true; return CELL_SPURS_OK; }
static bool gfx_ctx_init(void *data) { (void)data; #if defined(HAVE_PSGL) PSGLinitOptions options = { .enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS, .maxSPUs = 1, .initializeSPUs = GL_FALSE, }; // Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL sys_spu_initialize(6, 1); psglInit(&options); 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; if (g_extern.lifecycle_state & (1ULL << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE)) { RARCH_LOG("[PSGL Context]: Setting triple buffering.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_BUFFERING_MODE; params.bufferingMode = PSGL_BUFFERING_MODE_TRIPLE; } if (g_extern.console.screen.resolutions.current.id) { params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = gfx_ctx_get_resolution_width(g_extern.console.screen.resolutions.current.id); params.height = gfx_ctx_get_resolution_height(g_extern.console.screen.resolutions.current.id); if (params.width == 720 && params.height == 576) { RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n"); g_extern.lifecycle_state |= (1ULL << MODE_VIDEO_PAL_ENABLE); } else g_extern.lifecycle_state &= ~(1ULL << MODE_VIDEO_PAL_ENABLE); } if (g_extern.lifecycle_state & (1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE)) { RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE; params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE; params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE; params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN; } gl_device = psglCreateDeviceExtended(¶ms); gl_context = psglCreateContext(); psglMakeCurrent(gl_context, gl_device); psglResetCurrentContext(); #endif g_extern.console.screen.pal_enable = cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); gfx_ctx_get_available_resolutions(); return true; } static bool gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { (void)data; return true; }
static void *gfx_ctx_ps3_init(void *video_driver) { #ifdef HAVE_PSGL PSGLdeviceParameters params; PSGLinitOptions options; #endif global_t *global = global_get_ptr(); gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*) calloc(1, sizeof(gfx_ctx_ps3_data_t)); (void)video_driver; (void)global; if (!ps3) return NULL; #if defined(HAVE_PSGL) options.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS; options.maxSPUs = 1; options.initializeSPUs = GL_FALSE; /* Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL. */ sys_spu_initialize(6, 1); psglInit(&options); 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; if (global->console.screen.resolutions.current.id) { params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; gfx_ctx_ps3_get_resolution( global->console.screen.resolutions.current.id, ¶ms.width, ¶ms.height); global->console.screen.pal_enable = false; if (params.width == 720 && params.height == 576) { RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n"); global->console.screen.pal_enable = true; } } if (global->console.screen.pal60_enable) { RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n"); params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE; params.enable |= PSGL_DEVICE_PARAMETERS_RESC_RATIO_MODE; params.rescPalTemporalMode = RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE; params.rescRatioMode = RESC_RATIO_MODE_FULLSCREEN; } ps3->gl_device = psglCreateDeviceExtended(¶ms); ps3->gl_context = psglCreateContext(); psglMakeCurrent(ps3->gl_context, ps3->gl_device); psglResetCurrentContext(); #endif global->console.screen.pal_enable = cellVideoOutGetResolutionAvailability( CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); gfx_ctx_ps3_get_available_resolutions(); return ps3; }
int main() { struct stat st; sys_spu_initialize(6, 1); cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_IO); cellSysutilRegisterCallback(0, sysutil_exit_callback, NULL); LOG_INIT(); LOG_DBG("LOG INIT\n"); mode_switch = MODE_MENU; Graphics = new PS3Graphics(); LOG_DBG("Graphics->Init()\n"); Graphics->Init(); CellInput = new CellInputFacade(); LOG_DBG("CellInput->Init()\n"); CellInput->Init(); oskutil = new OSKUtil(); // FIXME: Is this necessary? if (Graphics->InitCg() != CELL_OK) { LOG_DBG("Failed to InitCg: %d\n", __LINE__); exit(0); } LOG_DBG("Graphics->InitDbgFont()\n"); Graphics->InitDbgFont(); Emulator_ToggleSound(); emulation_running = true; /* if (ini_parse("/dev_hdd0/game/GENP00001/USRDIR/GenesisConf.ini", handler, &Iniconfig) < 0) { gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Could not load /dev_hdd0/game/GENP00001/GenesisConf.ini\n"); sys_timer_sleep(5); gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Now exiting to XMB...\n"); sys_timer_sleep(5); sys_process_exit(0); } */ //REPLACEMENT if (load_settings) { Emulator_InitSettings(); load_settings = false; } /* //main path - Check if not present - create all folders and exit if(stat(Iniconfig.rompath,&st) != 0) { gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Creating generic folder tree for Genesisplus...\n"); sys_timer_sleep(5); CreateFolder(Iniconfig.rompath); CreateFolder(Iniconfig.savpath); CreateFolder(Iniconfig.cartpath); CreateFolder(Iniconfig.sram_path); CreateFolder(Iniconfig.biospath); gl_dprintf(0.09f,0.05f,Emulator_GetFontSize(),"Generic folder tree done! Will now exit to XMB...\nPlease put all your ROMs inside %s\n",Iniconfig.rompath); sys_timer_sleep(5); sys_process_exit(0); } */ ////Set Bios //sprintf(Iniconfig.biospath,"%s/bios.bin",Iniconfig.biospath); while(1) { switch(mode_switch) { case MODE_MENU: MenuMainLoop(); break; case MODE_EMULATION: Emulator_Start(); CellAudio->pause(); break; case MODE_EXIT: Emulator_Shutdown(); } } return 0; }