s32 main(s32 argc, const char* argv[]) { PadInfo padinfo; PadData paddata; int i; atexit(unload_modules); if(SysLoadModule(SYSMODULE_FS)!=0) return 0; else module_flag |=1; if(SysLoadModule(SYSMODULE_PNGDEC)!=0) return 0; else module_flag |=2; //if(SysLoadModule(SYSMODULE_NET)!=0) return 0; else module_flag |=3; //net_initialize_network(); init_screen(); ioPadInit(7); //init_pggl(); int pressed = 0; // Ok, everything is setup. Now for the main loop. while(1){ // Check the pads. ioPadGetInfo(&padinfo); for(i=0; i<MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_TRIANGLE){ if(!pressed){ pressed = 1; //tcp_test(); httpGet("174.121.34.92", "nzhawk.co.cc", "/vers.txt"); } } else if(paddata.BTN_CIRCLE){ //httpGet("174.121.34.92"); } else if(paddata.BTN_CROSS){ sysProcessExitSpawn2("/dev_hdd0/ps3load.self", 0, 0, NULL, 0, 1001, SYS_PROCESS_SPAWN_STACK_SIZE_1M); } else { pressed = 0; } } } waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer setBackColour(buffer[currentBuffer], 0xFFFFFFFF); // setBuffer to white /* PGGL Demo */ //drawInt(frame, 0, res.height - 80); //draw("PSL1GHT GRAPHICAL\n GAME L1BRARY", (res.width/2) - ((80 * 8) + 40), 20); //draw("ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n0123456789", (res.width/2) - ((80 * 6) + 40), 500); /* */ flip(currentBuffer); // Flip buffer onto screen currentBuffer = !currentBuffer; if(frame < 1000000) frame++; else frame = 0; } return 0; }
static void video_ps3_vdec_init(void) { vdec_mpeg2_loaded = !SysLoadModule(SYSMODULE_VDEC_MPEG2); if(!vdec_mpeg2_loaded) TRACE(TRACE_ERROR, "VDEC", "Unable to load MPEG2 decoder"); vdec_h264_loaded = !SysLoadModule(SYSMODULE_VDEC_H264); if(!vdec_h264_loaded) TRACE(TRACE_ERROR, "VDEC", "Unable to load H264 decoder"); }
int main (int argc, char* argv[]) { SysLoadModule(SYSMODULE_FS); lua_State *L = lua_open(); luaL_openlibs(L); if(!luaL_dofile(L, "/dev_usb000/app.lua") == 0) fprintf(stderr, "Failed to load file /dev_usb000/app.lua"); return 0; }
int netInitialize() { if (__netMemory) return 0; s32 ret = SysLoadModule(SYSMODULE_NET); if (ret < 0) return lv2Errno(ret); __netMemory = malloc(LIBNET_MEMORY_SIZE); netInitialization init; memset(&init, 0, sizeof(init)); init.memory = (lv2_void)(u64)__netMemory; init.memory_size = LIBNET_MEMORY_SIZE; init.flags = 0; ret = netInitializeNetworkEx(&init); if (ret) { free(__netMemory); __netMemory = NULL; } return ret; }
s32 main(s32 argc, const char* argv[]) { PadInfo padinfo; PadData paddata; int i; int frame = 0; tiny3d_Init(1024*1024); ioPadInit(7); SysLoadModule(SYSMODULE_PNGDEC); atexit(exiting); // Tiny3D register the event 3 and do exit() call when you exit to the menu // Load texture LoadTexture(); // Ok, everything is setup. Now for the main loop. while(1) { /* DRAWING STARTS HERE */ // clear the screen, buffer Z and initializes environment to 2D tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); // Enable alpha Test tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); // Enable alpha blending. tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); drawScene(frame); frame++; // Check the pads. ioPadGetInfo(&padinfo); for(i = 0; i < MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_CROSS){ return 0; } } } /* DRAWING FINISH HERE */ tiny3d_Flip(); } return 0; }
static int video_ps3_vdec_codec_create(media_codec_t *mc, const media_codec_params_t *mcp, media_pipe_t *mp) { vdec_decoder_t *vdd; struct vdec_type dec_type = {0}; struct vdec_attr dec_attr = {0}; int spu_threads; int r; int crop_right = 0; int crop_bottom = 0; switch(mc->codec_id) { case AV_CODEC_ID_MPEG2VIDEO: hts_lwmutex_lock(&ps3_codec_sysmodule_mutex); if(vdec_mpeg2_loaded == -1) vdec_mpeg2_loaded = !SysLoadModule(SYSMODULE_VDEC_MPEG2); if(!vdec_mpeg2_loaded) { hts_lwmutex_unlock(&ps3_codec_sysmodule_mutex); return no_lib(mp, "MPEG-2"); } hts_lwmutex_unlock(&ps3_codec_sysmodule_mutex); dec_type.codec_type = VDEC_CODEC_TYPE_MPEG2; dec_type.profile_level = VDEC_MPEG2_MP_HL; spu_threads = 1; break; case AV_CODEC_ID_H264: if(mcp != NULL) { TRACE(TRACE_DEBUG, "VDEC", "H264: Profile:%d Level:%d", mcp->profile, mcp->level); if(mcp->profile != FF_PROFILE_H264_CONSTRAINED_BASELINE && mcp->profile >= FF_PROFILE_H264_HIGH_10) { TRACE(TRACE_DEBUG, "VDEC", "Refusing to play h264 profile %d", mcp->profile); return 1; // No 10bit support } if(mcp->extradata != NULL) { h264_parser_t hp; hexdump("extradata", mcp->extradata, mcp->extradata_size); if(h264_parser_init(&hp, mcp->extradata, mcp->extradata_size)) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 10, _("Cell-h264: Broken headers, Disabling acceleration")); return -1; } TRACE(TRACE_DEBUG, "VDEC", "Dumping SPS"); int too_big_refframes = 0; int mb_height = 0; for(int i = 0; i < H264_PARSER_NUM_SPS; i++) { const h264_sps_t *s = &hp.sps_array[i]; if(!s->present) continue; TRACE(TRACE_DEBUG, "VDEC", "SPS[%d]: %d x %d profile:%d level:%d.%d ref-frames:%d", i, s->mb_width * 16, s->mb_height * 16, s->profile, s->level / 10, s->level % 10, s->num_ref_frames); TRACE(TRACE_DEBUG, "VDEC", " crop: left:%d right:%d top:%d bottom:%d", s->crop_left, s->crop_right, s->crop_top, s->crop_bottom); crop_right = s->crop_right; crop_bottom = s->crop_bottom; if(s->mb_height >= 45 && s->num_ref_frames > 9) too_big_refframes = s->num_ref_frames; if(s->mb_height >= 68 && s->num_ref_frames > 4) too_big_refframes = s->num_ref_frames; mb_height = s->mb_height; } h264_parser_fini(&hp); if(too_big_refframes) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 10, _("Cell-h264: %d Ref-frames for %d content is incompatible with PS3 HW decoder. Disabling acceleration"), too_big_refframes, mb_height * 16); return -1; } } } hts_lwmutex_lock(&ps3_codec_sysmodule_mutex); if(vdec_h264_loaded == -1) vdec_h264_loaded = !SysLoadModule(SYSMODULE_VDEC_H264); if(!vdec_h264_loaded) { hts_lwmutex_unlock(&ps3_codec_sysmodule_mutex); return no_lib(mp, "h264"); } hts_lwmutex_unlock(&ps3_codec_sysmodule_mutex); dec_type.codec_type = VDEC_CODEC_TYPE_H264; if(mcp != NULL && mcp->level > 42) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 5, _("Cell-h264: Forcing level 4.2 for content in level %d.%d. This may break video playback."), mcp->level / 10, mcp->level % 10); } dec_type.profile_level = 42; spu_threads = 4; break; default: return 1; } r = vdec_query_attr(&dec_type, &dec_attr); if(r) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 10, _("Unable to query Cell codec. Error 0x%x"), r); return 1; } vdd = calloc(1, sizeof(vdec_decoder_t)); #define ROUND_UP(p, round) ((p + round - 1) & ~(round - 1)) size_t allocsize = ROUND_UP(dec_attr.mem_size, 1024*1024); u32 taddr; if(Lv2Syscall3(348, allocsize, 0x400, (u64)&taddr)) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 10, _("Unable to open Cell codec. Unable to allocate %d bytes of RAM"), dec_attr.mem_size); return 1; } vdd->mem = (void *)(uint64_t)taddr; TRACE(TRACE_DEBUG, "VDEC", "Opening codec %s level %d using %d bytes of RAM", mc->codec_id == AV_CODEC_ID_H264 ? "h264" : "MPEG2", dec_type.profile_level, dec_attr.mem_size); vdd->config.mem_addr = (intptr_t)vdd->mem; vdd->config.mem_size = dec_attr.mem_size; vdd->config.num_spus = spu_threads; vdd->config.ppu_thread_prio = THREAD_PRIO_VDEC; vdd->config.spu_thread_prio = VDEC_SPU_PRIO; vdd->config.ppu_thread_stack_size = 1 << 14; vdec_closure c; c.fn = (intptr_t)OPD32(decoder_callback); c.arg = (intptr_t)vdd; r = vdec_open(&dec_type, &vdd->config, &c, &vdd->handle); if(r) { notify_add(mp->mp_prop_notifications, NOTIFY_WARNING, NULL, 10, _("Unable to open Cell codec. Error 0x%x"), r); Lv2Syscall1(349, (uint64_t)vdd->mem); free(vdd); return 1; } if(mcp != NULL) { vdd->level_major = mcp->level / 10; vdd->level_minor = mcp->level % 10; vdd->filter_aud = mcp->broken_aud_placement; } if(mc->codec_id == AV_CODEC_ID_H264 && mcp != NULL && mcp->extradata_size) h264_to_annexb_init(&vdd->annexb, mcp->extradata, mcp->extradata_size); vdd->max_order = -1; hts_mutex_init(&vdd->mtx); hts_cond_init(&vdd->audone, &vdd->mtx); hts_cond_init(&vdd->seqdone, &vdd->mtx); TRACE(TRACE_DEBUG, "VDEC", "Cell accelerated codec created using %d bytes of RAM", dec_attr.mem_size); mc->opaque = vdd; mc->decode = decoder_decode; mc->flush = decoder_flush; mc->close = decoder_close; vdd->crop_right = crop_right; vdd->crop_bottom = crop_bottom; vdec_start_sequence(vdd->handle); return 0; }
s32 main(s32 argc, const char* argv[]) { atexit(unload_modules); InitVideo(); // Initialize video SetupPads(); // Initialize input #ifdef TOPORT InitAudio(); // Initialize audio fatInitDefault(); // Initialize file system #endif #ifdef TOPORT InitFreeType((u8*)font_ttf, font_ttf_size); // Initialize font system InitGUIThreads(); // Initialize GUI DefaultSettings(); MainMenu(MENU_SETTINGS); #endif #ifdef PSL1GHT if(SysLoadModule(SYSMODULE_FS)!=0) return 0; else module_flag |=1; if(SysLoadModule(SYSMODULE_PNGDEC)!=0) return 0; else module_flag |=2; #endif VideoModule * video = VideoModule::getVideoModule(); InputPadModule * inpad = InputPadModule::getInputPadModule(); #ifdef PSL1GHT PngDatas png1; LoadPNG(&png1, (char *)"/dev_usb/PS3_GAME/ICON0.PNG"); #endif long frame = 0; // To keep track of how many frames we have rendered. int x = DEBUG_X, y = DEBUG_Y; // Ok, everything is setup. Now for the main loop. while(1) { char str [300]; sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame); inpad->refreshPadConnections(); // Check the pads. for( size_t i = 0; i < inpad->getPadNumber(); i++) { if( inpad->getPad(i)->isPressed( eAbsButUp) && y > 0) y--; if( inpad->getPad(i)->isPressed( eAbsButDown) && y < 1080) y++; if( inpad->getPad(i)->isPressed( eAbsButLeft) && x > 0) x--; if( inpad->getPad(i)->isPressed( eAbsButRight) && x > 0) x++; else if( inpad->getPad(i)->isPressed( eAbsButExecute)) return 0; } sprintf(str, "Pad number : %d, frame %d", (int) inpad->getPadNumber(),(int)frame); video->waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer #ifdef PSL1GHT drawFrame(video->getCurrentBuffer(), frame++); // Draw into the unused buffer if(png1.bmp_out) { video->displayBitmap( (u32 *)png1.bmp_out, png1.height, png1.width, png1.wpitch); } #endif video->printf(x, y, str); video->flip(); // Flip buffer onto screen } return 0; }
int main(int argc, char *argv[]) { int list_s; /* listening socket */ int conn_s; /* connection socket */ short int port; /* port number */ struct sockaddr_in servaddr; /* socket address structure */ char buffer[MAX_LINE]; /* character buffer */ char *endptr; /* for strtol() */ fprintf(stdout, "Starting ECHOServer.\n"); /* Get port number from the command line, and set to default port if no arguments were supplied */ if ( argc == 2 ) { port = strtol(argv[1], &endptr, 0); if ( *endptr ) { fprintf(stderr, "ECHOSERV: Invalid port number.\n"); exit(EXIT_FAILURE); } }else if ( argc < 2 ) { port = ECHO_PORT; }else{ fprintf(stderr, "ECHOSERV: Invalid arguments.\n"); exit(EXIT_FAILURE); } printf("SysLoadModule(NET)=%d\n", SysLoadModule(SYSMODULE_NET)); printf("net_init()=%d\n", net_initialize_network()); /* Create the listening socket */ if ( (list_s = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { fprintf(stderr, "ECHOSERV: Error creating listening socket.\n"); printf("errno: %d\n", errno); exit(EXIT_FAILURE); } /* Set all bytes in socket address structure to zero, and fill in the relevant data members */ memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); /* Bind our socket addresss to the listening socket, and call listen() */ if ( bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling bind()\n"); exit(EXIT_FAILURE); } if ( listen(list_s, LISTENQ) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling listen()\n"); exit(EXIT_FAILURE); } char* message = "Welcome to ECHOServer test.\nType exit and hit enter to close app, otherwise type anything you want and hit enter and I will replay it back to you free of charge. :)"; /* Enter an infinite loop to respond to client requests and echo input */ int run = 1; while ( run ) { /* Wait for a connection, then accept() it */ if ( (conn_s = accept(list_s, NULL, NULL) ) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling accept()\n"); exit(EXIT_FAILURE); } Writeline(conn_s, message, strlen(message)); /* Retrieve an input line from the connected socket then simply write it back to the same socket. */ Readline(conn_s, buffer, MAX_LINE-1); if(strncmp("exit", buffer, 4) == 0) run = 0; Writeline(conn_s, buffer, strlen(buffer)); /* Close the connected socket */ if ( closesocket(conn_s) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling closesocket()\n"); exit(EXIT_FAILURE); } } net_finalize_network(); SysUnloadModule(SYSMODULE_NET); }
s32 main(s32 argc, const char* argv[]) { PadInfo padinfo; PadData paddata; int i; tiny3d_Init(1024*1024); ioPadInit(7); SysLoadModule(SYSMODULE_PNGDEC); // Load texture LoadTexture(); /* data for the ghost */ ghost[0].x = 0.0f; ghost[0].y = 0.0f; ghost[0].dx = 1.5f; ghost[0].dy = 1.5f; ghost[0].frame = 0; ghost[0].color = 0xffffff80; ghost[1].x = (847.0f - 64.0f); ghost[1].y = 0.0f; ghost[1].dx = -1.5f; ghost[1].dy = 1.5f; ghost[1].frame = 0; ghost[1].color = 0x8f8fff80; ghost[2].x = 0.0f; ghost[2].y = (511.0f - 64.0f); ghost[2].dx = 1.5f; ghost[2].dy = -1.5f; ghost[2].frame = 0; ghost[2].color = 0xff8f8f80; ghost[3].x = (847.0f - 64.0f); ghost[3].y = (511.0f - 64.0f); ghost[3].dx = -1.5f; ghost[3].dy = -1.5f; ghost[3].frame = 0; ghost[3].color = 0x8fff8f80; // Ok, everything is setup. Now for the main loop. while(1) { /* DRAWING STARTS HERE */ // clear the screen, buffer Z and initializes environment to 2D tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); // Enable alpha Test tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); // Enable alpha blending. tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); // Check the pads. ioPadGetInfo(&padinfo); for(i = 0; i < MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_CROSS){ return 0; } } } drawScene(); // Draw /* DRAWING FINISH HERE */ tiny3d_Flip(); } SysUnloadModule(SYSMODULE_PNGDEC); return 0; }