Пример #1
0
int main()
{
	int i;

	init_screen();
	ioPadInit(7);
	sconsoleInit(FONT_COLOR_BLACK, FONT_COLOR_WHITE, res.width, res.height);

	xputs("== BootOS Installer ==");
	install_bootos();
	Lv2Syscall1(838, (u64) "/dev_rwflash");

	xputs("Press [X] to exit.");
	while (1) {
		ioPadGetInfo(&padinfo);
		for (i = 0; i < MAX_PADS; i++) {
			if (padinfo.status[i]) {
				ioPadGetData(i, &paddata);
				if (paddata.BTN_CROSS) {
					return 0;
				}
			}
		}
		usleep(100000);
	}
	return 0;
}
Пример #2
0
static void
handle_pads(glw_ps3_t *gp)
{
  PadInfo2 padinfo2;
  int i;

  if(gp->osk_widget) {
    clear_btns();
    return;
  }

  // Check the pads.
  ioPadGetInfo2(&padinfo2);
  for(i=0; i<7; i++){
    if(!padinfo2.port_status[i])
      continue;

    if(padinfo2.device_type[i] == 4) {
      uint32_t type = 4;
      int r = ioPadGetDataExtra(i, &type, &paddata[i]);

      if(r == 0) {
	int btn = paddata[i].button[25];
	if(btn != remote_last_btn[i]) {
	  if(remote_last_btn[i] < 0xff)
	    handle_btn(gp, i, bd_to_local_map[remote_last_btn[i]], 0, 0, 0);
	  remote_last_btn[i] = btn;
	}

	if(btn != 0xff)
	  handle_btn(gp, i, bd_to_local_map[btn], 1, 0, 0);
      }
      continue;
    }


    ioPadGetData(i, &paddata[i]);
    PadData *pd = &paddata[i];
    int sel = !!pd->BTN_SELECT;
    handle_btn(gp, i, BTN_LEFT,     pd->BTN_LEFT,     sel, pd->PRE_LEFT);
    handle_btn(gp, i, BTN_UP,       pd->BTN_UP,       sel, pd->PRE_UP);
    handle_btn(gp, i, BTN_RIGHT,    pd->BTN_RIGHT,    sel, pd->PRE_RIGHT);
    handle_btn(gp, i, BTN_DOWN,     pd->BTN_DOWN,     sel, pd->PRE_DOWN);
    handle_btn(gp, i, BTN_CROSS,    pd->BTN_CROSS,    sel, pd->PRE_CROSS);
    handle_btn(gp, i, BTN_CIRCLE,   pd->BTN_CIRCLE,   sel, pd->PRE_CIRCLE);
    handle_btn(gp, i, BTN_TRIANGLE, pd->BTN_TRIANGLE, sel, pd->PRE_TRIANGLE);
    handle_btn(gp, i, BTN_SQUARE,   pd->BTN_SQUARE,   sel, pd->PRE_SQUARE);
    handle_btn(gp, i, BTN_START,    pd->BTN_START,    sel, 0);
    handle_btn(gp, i, BTN_R1,       pd->BTN_R1,       sel, pd->PRE_R1);
    handle_btn(gp, i, BTN_L1,       pd->BTN_L1,       sel, pd->PRE_L1);
    handle_btn(gp, i, BTN_R3,       pd->BTN_R3,       sel, 0);
    handle_btn(gp, i, BTN_L3,       pd->BTN_L3,       sel, 0);


    if(gp->gp_seekmode == 0 || (gp->gp_seekmode == 1 && sel)) {
      handle_seek(gp, i, 1,        pd->BTN_R2,       pd->PRE_R2);
      handle_seek(gp, i, -1,       pd->BTN_L2,       pd->PRE_L2);
    }
  }
}
Пример #3
0
s32 main(s32 argc, const char* argv[])
{
	PadInfo padinfo;
	PadData paddata;
	int i;
	
	init_screen();
	ioPadInit(7);

	long frame = 0; // To keep track of how many frames we have rendered.
	
	// 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_CROSS){
					return 0;
				}
			}
			
		}

		waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer
		drawFrame(buffer[currentBuffer], frame++); // Draw into the unused buffer
		flip(currentBuffer); // Flip buffer onto screen
		currentBuffer = !currentBuffer;
	}
	
	return 0;
}
Пример #4
0
static void
handle_pads(glw_ps3_t *gp)
{
  PadInfo padinfo;
  PadData paddata;
  int i;

  // Check the pads.
  ioPadGetInfo(&padinfo);
  for(i=0; i<MAX_PADS; i++){
    if(!padinfo.status[i])
      continue;
    ioPadGetData(i, &paddata);

    btn(gp, &k_left,  paddata.BTN_LEFT,     ACTION_LEFT);
    btn(gp, &k_up,    paddata.BTN_UP,       ACTION_UP);
    btn(gp, &k_right, paddata.BTN_RIGHT,    ACTION_RIGHT);
    btn(gp, &k_down,  paddata.BTN_DOWN,     ACTION_DOWN);
    btn(gp, &k_enter, paddata.BTN_CROSS,    ACTION_ACTIVATE);
    btn(gp, &k_back,  paddata.BTN_CIRCLE,   ACTION_NAV_BACK);
    btn(gp, &k_menu,  paddata.BTN_TRIANGLE, ACTION_MENU);
    btn(gp, &k_sqr,   paddata.BTN_SQUARE,   ACTION_ENABLE_SCREENSAVER);
    btn(gp, &k_pp,    paddata.BTN_START,    ACTION_PLAYPAUSE);
    btn(gp, &k_home,  paddata.BTN_SELECT,   ACTION_HOME);
    btn(gp, &k_r3,    paddata.BTN_R3,       ACTION_LOGWINDOW);
    btn(gp, &k_l3,    paddata.BTN_L3,       ACTION_SHOW_MEDIA_STATS);
  }
}
Пример #5
0
s32 main(s32 argc, const char* argv[])
{
	padInfo padinfo;
	padData paddata;
	int i;
	
	tiny3d_Init(1024*1024);

	ioPadInit(7);

	// 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,
            TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_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();
		
	}

	return 0;
}
Пример #6
0
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;
}
Пример #7
0
int main(int argc,const char *argv[])
{
    s32 ret,i;
    padInfo padinfo;
    padData paddata;
    rsxProgramConst *consts = rsxFragmentProgramGetConsts(fpo);

    initialize();
    ioPadInit(7);

    sphere = createSphere(3.0f,32,32);
    donut = createDonut(3.0f,1.5f,32,32);
    cube = createCube(5.0f);

    rsxConstOffsetTable *co_table = rsxFragmentProgramGetConstOffsetTable(fpo,consts[lightColor_id].index);
    u32 const_addr = (u32)((u64)fp_buffer + co_table->offset[0]);
    setup_shared_buffer(const_addr,(u32)(u64)mem_align(128,128),(u32)(u64)gcmGetLabelAddress(64));
    signal_spu_ppu();
    signal_spu_rsx();

    P = transpose(Matrix4::perspective(DEGTORAD(45.0f),aspect_ratio,1.0f,3000.0f));

    setRenderTarget(curr_fb);
    rsxFinish(context,0);

    ret = atexit(program_exit_callback);
    ret = sysUtilRegisterCallback(0,sysutil_exit_callback,NULL);

    delete cube;

    running = 1;
    while(running) {
        ret = sysUtilCheckCallback();

        ioPadGetInfo(&padinfo);
        for(i=0; i<MAX_PADS; i++) {
            if(padinfo.status[i]) {
                ioPadGetData(i, &paddata);

                if(paddata.BTN_CROSS) {
                    return 0;
                }
            }

        }

        drawFrame();
        flip();
    }

    return 0;
}
Пример #8
0
static void
handle_pads(glw_ps3_t *gp)
{
  PadInfo2 padinfo2;
  int i;

  // Check the pads.
  ioPadGetInfo2(&padinfo2);
  for(i=0; i<MAX_PADS; i++){
    if(!padinfo2.port_status[i])
      continue;

    if(padinfo2.device_type[i] == 4) {
      uint32_t type = 4;
      int r = ioPadGetDataExtra(i, &type, &paddata[i]);

      if(r == 0) {
	int btn = paddata[i].button[25];
	if(btn != remote_last_btn[i]) {
	  if(remote_last_btn[i] < 0xff)
	    handle_btn(gp, i, bd_to_local_map[remote_last_btn[i]], 0);
	  remote_last_btn[i] = btn;
	}

	if(btn != 0xff)
	  handle_btn(gp, i, bd_to_local_map[btn], 1);
      }
      continue;
    }


    ioPadGetData(i, &paddata[i]);
    PadData *pd = &paddata[i];
    handle_btn(gp, i, BTN_LEFT,     pd->BTN_LEFT);
    handle_btn(gp, i, BTN_UP,       pd->BTN_UP);
    handle_btn(gp, i, BTN_RIGHT,    pd->BTN_RIGHT);
    handle_btn(gp, i, BTN_DOWN,     pd->BTN_DOWN);
    handle_btn(gp, i, BTN_CROSS,    pd->BTN_CROSS);
    handle_btn(gp, i, BTN_CIRCLE,   pd->BTN_CIRCLE);
    handle_btn(gp, i, BTN_TRIANGLE, pd->BTN_TRIANGLE);
    handle_btn(gp, i, BTN_SQUARE,   pd->BTN_SQUARE);
    handle_btn(gp, i, BTN_START,    pd->BTN_START);
    handle_btn(gp, i, BTN_SELECT,   pd->BTN_SELECT);
    handle_btn(gp, i, BTN_R1,       pd->BTN_R1);
    handle_btn(gp, i, BTN_L1,       pd->BTN_L1);
    handle_btn(gp, i, BTN_R2,       pd->BTN_R2);
    handle_btn(gp, i, BTN_L2,       pd->BTN_L2);
    handle_btn(gp, i, BTN_R3,       pd->BTN_R3);
    handle_btn(gp, i, BTN_L3,       pd->BTN_L3);
  }
}
Пример #9
0
s32 main(s32 argc, const char* argv[])
{
	PadInfo padinfo;
	PadData paddata;
	int i;
	
	atexit(appCleanup);
	init_screen();
	ioPadInit(7);
	sysRegisterCallback(EVENT_SLOT0, eventHandle, NULL);

	// Load texture
	dice = loadPng(dice_bin);
	assert(realityAddressToOffset(dice.data, &tx_offset) == 0);

	//load_acid_texture((uint8_t *)tx_mem, 0);

	// install fragment shader in rsx memory
	u32 *frag_mem = rsxMemAlign(256, 256);
	printf("frag_mem = 0x%08lx\n", (u64) frag_mem);
	realityInstallFragmentProgram_old(context, &nv30_fp, frag_mem);

	long frame = 0; // To keep track of how many frames we have rendered.
	
	// 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_CROSS || paddata.BTN_START){
					return 0;
				}
			}
			
		}

		waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer
		drawFrame(currentBuffer, frame++); // Draw into the unused buffer
		flip(currentBuffer); // Flip buffer onto screen
		currentBuffer = !currentBuffer;
		sysCheckCallback();

	}
	
	return 0;
}
Пример #10
0
s32 main(s32 argc, const char* argv[])
{
	padInfo padinfo ;
	padData paddata ;
	sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL);

	ioPadInit(7);

	pngData png;
	
	NoRSX *GFX = new NoRSX();
	Image IMG(GFX);
	Background BG(GFX);
	Object OBJ(GFX);
	Font F(GFX);
	

	IMG.LoadPNG_Buf(NoRSX_Image_bin,NoRSX_Image_bin_size, &png);
	u32 imgX =(GFX->width/2)-(png.width/2), imgY = (GFX->height/2)-(png.height/2);
	exitapp = 1;
	int frame=0;
	while(exitapp){
		static time_t starttime = 0;
		double fps = 0;
		if (starttime == 0) starttime = time (NULL);
		else fps = frame / difftime (time (NULL), starttime);
		ioPadGetInfo(&padinfo);
		if(padinfo.status[0]){
			ioPadGetData(0, &paddata);
			if(paddata.BTN_CROSS){
				exitapp = 0;
			}
		}
		BG.Mono(0xb4e83a); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX)
		OBJ.Circle(400,900,100,COLOR_YELLOW);
		OBJ.Rectangle(500,400,200,500,COLOR_ORANGE);
		OBJ.Line(400,400,900,100,COLOR_GREY);
		IMG.AlphaDrawIMG(imgX,imgY,&png);
		F.Printf(150,200,COLOR_BLACK,"SCREEN %d X %d",GFX->width,GFX->height);
		F.Print(150,250,COLOR_YELLOW,"PRESS X TO EXIT");
		F.Printf(150,100,COLOR_GREEN,"FPS %f", fps);
		GFX->Flip();
		frame ++;
		sysUtilCheckCallback();
	}
	GFX->NoRSX_Exit();
	ioPadEnd();
	return 0;
}
Пример #11
0
int main(int argc,const char *argv[])
{
	s32 ret,i;
	padInfo padinfo;
	padData paddata;
	void *host_addr = memalign(1024*1024,HOST_SIZE);

	printf("rsxtest started...\n");

	init_screen(host_addr,HOST_SIZE);
	ioPadInit(7);
	init_shader();
	init_texture();

	sphere = createSphere(3.0f,32,32);
	donut = createDonut(3.0f,1.5f,32,32);
	cube = createCube(5.0f);

	ret = atexit(program_exit_callback);
	ret = sysUtilRegisterCallback(0,sysutil_exit_callback,NULL);

	P = transpose(Matrix4::perspective(DEGTORAD(45.0f),aspect_ratio,1.0f,3000.0f));

	setTexture();
	setDrawEnv();
	setRenderTarget(curr_fb);

	running = 1;
	while(running) {
		ret = sysUtilCheckCallback();

		ioPadGetInfo(&padinfo);
		for(i=0; i<MAX_PADS; i++){
			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);

				if(paddata.BTN_CROSS){
					return 0;
				}
			}

		}
		
		drawFrame();
		flip();
	}

	return 0;
}
Пример #12
0
        bool pollHat(const HAT &h) {
#ifdef CURRENT_PLATFORM
            if(opened == false) return false;
            return SDL_JoystickGetHat(joy, static_cast<int>(h));
#else
            ioPadGetInfo (&padinfo);
            if(padinfo.status[cid]) {
                ioPadGetData (cid, &paddata);
                
                if(paddata.BTN_LEFT && h == HAT_LEFT)  return true;
                if(paddata.BTN_RIGHT && h == HAT_RIGHT)  return true;
                if(paddata.BTN_UP && h == HAT_UP)  return true;
                if(paddata.BTN_DOWN && h == HAT_DOWN)  return true;
            }
#endif
            return false;
        }
Пример #13
0
//**********************************************************************
//** PADS 
//**********************************************************************
int PS3_readPadButtons (uint32_t *digitalResult, uint32_t *analogResult, int id, int changesOnly) {

	padInfo info;
	padData data;

	sysUtilCheckCallback();

	ioPadGetInfo(&info);

	if (info.status[id]) {
		ioPadGetData(id, &data);

		if (data.len == 0) {
			return 0;
		}

		uint32_t buttons = (data.button[2] & 0xff) | ((data.button[3] & 0xFF) << 8);
		if (changesOnly) {
			new_pad = buttons & (~old_pad);
			old_pad = buttons;
		
			*digitalResult = new_pad;
		} else {
			*digitalResult = buttons;
		}
		{
			uint32_t analogR = data.button[6] & 0xFF;
			analogR <<= 8;
			analogR  |= (data.button[7] & 0xFF);
			analogR <<= 8;
			analogR  |= data.button[4] & 0xFF;
			analogR <<= 8;
			analogR  |= (data.button[5] & 0xFF);
			
			*analogResult = analogR;
			return 1;
		}
	}
	old_pad = new_pad = 0;
	return 0;
}
Пример #14
0
int main(int argc,char *argv[])
{
	u64 retval;
	s32 i,ret,running;
	sys_ppu_thread_t id;
	u64 prio = 1500;
	padInfo padinfo;
	padData paddata;
	size_t stacksize = 0x1000;
	char *threadname = "myThread";
	void *threadarg = (void*)0x1337;

	ioPadInit(7);

	ret = sysThreadCreate(&id,thread_start,threadarg,prio,stacksize,THREAD_JOINABLE,threadname);
	printf("sysThreadCreate: %d\n",ret);

	ret = sysThreadJoin(id,&retval);
	printf("sysThreadJoin: %d - %llX\n",ret,(unsigned long long int)retval);

	running = 1;
	while(running) {
		ioPadGetInfo(&padinfo);
		for(i=0; i<MAX_PADS; i++){
			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);

				if(paddata.BTN_CROSS){
					running = 0;
					break;
				}
			}
		}
	}

	printf("Exiting thread test\n");
	return 0;
}
Пример #15
0
        bool pollButton(const BUTTON &b) {
#ifdef CURRENT_PLATFORM
            if(opened == false) return false;
            return SDL_JoystickGetButton(joy, static_cast<int>(b));
#else
            ioPadGetInfo (&padinfo);
                if(padinfo.status[cid]) {
                    ioPadGetData (cid, &paddata);
                    if(paddata.BTN_CROSS && b == BUTTON_CROSS)  return true;
                    if(paddata.BTN_CIRCLE && b == BUTTON_CIRCLE) return true;
                    if(paddata.BTN_SQUARE && b == BUTTON_SQUARE) return true;
                    if(paddata.BTN_TRIANGLE && b == BUTTON_TRIANGLE) return true;
                    if(paddata.BTN_L1 && b == BUTTON_L1) return true;
                    if(paddata.BTN_L2 && b == BUTTON_L2) return true;
                    if(paddata.BTN_R1 && b == BUTTON_R1) return true;
                    if(paddata.BTN_R2 && b == BUTTON_R2) return true;
                    if(paddata.BTN_START && b == BUTTON_START) return true;
                }
            return false;
#endif
            return false;

}
Пример #16
0
void ps3_pad() {

  ioPadGetInfo(&padinfo);

  switch(app_state) {
  case 1: // are only screen open at the moment
	for(i=0; i<MAX_PADS; i++){
	  if(padinfo.status[i]){
	  ioPadGetData(i, &paddata);
	    if(paddata.BTN_START){
	    exit(0);
	    }else if(paddata.BTN_UP) {

            sprite_y -= 5;

            }else if(paddata.BTN_DOWN) {

            sprite_y += 5;

            }else if(paddata.BTN_LEFT) {

            sprite_x -= 5;

            }else if(paddata.BTN_RIGHT) {

            sprite_x += 5;

            }else{

            }

	  }		
	}
  break;
  }

}
Пример #17
0
s32 main(s32 argc, const char* argv[])
{
  gcmContextData *context;
  void *host_addr = NULL;
  rsxBuffer buffers[MAX_BUFFERS];
  int currentBuffer = 0;
  padInfo padinfo ;
  padData paddata ;
  u16 width;
  u16 height;
  int i;
  long frame = 0; /* to keep track of how many frames we have rendered */

  atexit(unload_modules);
  if(sysModuleLoad(SYSMODULE_FS) != 0)
    return 0;
  else
    module_flag |= 1;

  if(sysModuleLoad(SYSMODULE_PNGDEC) != 0)
    return 0;
  else
    module_flag |= 2;

  /* Allocate a 1Mb buffer, alligned to a 1Mb boundary
   * to be our shared IO memory with the RSX. */
  host_addr = memalign ( 1024*1024, HOST_SIZE ) ;
  context = screenInit ( host_addr, HOST_SIZE ) ;
  getResolution( &width, &height ) ;
  for (i = 0; i < MAX_BUFFERS; i++)
    makeBuffer( &buffers[i], width, height, i ) ;
  flip( context, MAX_BUFFERS - 1 ) ;
  setRenderTarget(context, &buffers[currentBuffer]) ;

  sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL);

  ioPadInit(7) ;

  /* png bitmap buffer */
  pngData png1;

#if USE_PNG_FROM_FILE == true
  const char *filename = PNG_FILE;
  /* load png from file */
  pngLoadFromFile(filename, &png1);
#endif
#if USE_PNG_FROM_FILE == false
  /* load png from memory */
  pngLoadFromBuffer((void *)psl1ght_png, psl1ght_png_size, &png1);
#endif

  /* Ok, everything is setup. Now for the main loop. */
  exitapp = 1;
  while(exitapp)
  {
    /* Check the pads. */
    ioPadGetInfo(&padinfo);
    for(i=0; i<MAX_PADS; i++){
      if(padinfo.status[i]){
        ioPadGetData(i, &paddata);

        if(paddata.BTN_CROSS){
          exitapp = 0;
          goto end;
        }
      }
    }

    waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer
    drawFrame(&buffers[currentBuffer], frame++); // Draw into the unused buffer

    if(png1.bmp_out)
    {
      static int x=0, y=0, dx=2, dy=2;
  
      u32 *scr = (u32 *)buffers[currentBuffer].ptr;
      u32 *png= (void *)png1.bmp_out;
      int n, m;
  
      /* update x, y coordinates */
      x+=dx;
      y+=dy;
  
      /* */
      if(x < 0)
      {
        x=0;
        dx=1;
      }

      /* screen width to png width */
      if(x > (buffers[currentBuffer].width - png1.width))
      {
        x=(buffers[currentBuffer].width - png1.width);
        dx=-2;
      }
  
      /* */
      if(y < 0)
      {
        y=0;
        dy=1;
      }

      /* screen height to png height */
      if(y > (buffers[currentBuffer].height - png1.height))
      {
        y = (buffers[currentBuffer].height - png1.height);
        dy=-2;
      }

      /* update screen buffer from coordinates */
      scr += y * buffers[currentBuffer].width + x;                     
  
      // draw PNG
      for(n=0;n<png1.height;n++)
      {
        if((y+n)>=buffers[currentBuffer].height) break;
        for(m=0;m<png1.width;m++)
        {
          if((x+m)>=buffers[currentBuffer].width) break;
          scr[m]=png[m];
        }
        png+=png1.pitch>>2;
        scr+=buffers[currentBuffer].width;
      }
    }

    flip(context, buffers[currentBuffer].id); /* Flip buffer onto screen */

    currentBuffer = !currentBuffer;
    setRenderTarget(context, &buffers[currentBuffer]) ; /* change buffer */

    sysUtilCheckCallback(); /* check user attention span */
  }

 end:

  gcmSetWaitFlip(context);
  for (i=0; i < MAX_BUFFERS; i++)
    rsxFree (buffers[i].ptr);
  rsxFinish (context, 1);
  free (host_addr);
  ioPadEnd();

  return 0;
}
Пример #18
0
int main()
{
	#ifdef ENABLE_LOG
	verbose = 1;
	Open_Log(LOG_PATH);
	#endif
	//Detect startup mode
    unsigned button = 0;
    padInfo padinfo;
    padData paddata;
    ioPadInit(7);
    int n, r;
    for(r=0; r<10; r++)
    {
        ioPadGetInfo(&padinfo);
        for(n = 0; n < 7; n++)
        {
            if(padinfo.status[n])
            {
                ioPadGetData(n, &paddata);
                button = (paddata.button[2] << 8) | (paddata.button[3] & 0xff);
                break;
            }
        }
        if(button) break;
		else usleep(20000);
    }
    ioPadEnd();
	switch(button)
	{
		case BUTTON_CROSS:
			install_autoloader=1;
		break;

		case BUTTON_SQUARE:
			uninstall_autoloader=1;
		break;

		case BUTTON_R1:
			noplugins=1;
		break;

		case BUTTON_L1:
			mamba_off=1;
		break;
	}
	//Install MAMBA/PRX Autoloader if cross was hold
	if(install_autoloader)
	{
		if (run_install_autoloader() ==  SUCCESS)
		{
			#ifdef ENABLE_LOG
			CloseLog();
			#endif
			{ BEEP1 } //1 Beep
			sysLv2FsUnlink("/dev_hdd0/tmp/turnoff");
			{lv2syscall3(SC_SYS_POWER, SYS_REBOOT, 0, 0);} // Reboot
			return SUCCESS;
		}
		else
		{
			goto err_back_to_xmb;
Пример #19
0
int
main (s32 argc, const char* argv[])
{
  gcmContextData *context;
  void *host_addr = NULL;
  rsxBuffer buffers[MAX_BUFFERS];
  int currentBuffer = 0;
  padInfo padinfo;
  padData paddata;
  u16 width;
  u16 height;
  int frame = 0;
  int i;

  /* Allocate a 1Mb buffer, alligned to a 1Mb boundary
   * to be our shared IO memory with the RSX. */
  host_addr = memalign (1024*1024, HOST_SIZE);
  context = initScreen (host_addr, HOST_SIZE);
  ioPadInit (7);

  getResolution(&width, &height);
  for (i = 0; i < MAX_BUFFERS; i++)
    makeBuffer (&buffers[i], width, height, i);

  flip(context, MAX_BUFFERS - 1);

  DEBUG ("Starting Cairo test\n");

  while (1) {
    ioPadGetInfo (&padinfo);
    for(i = 0; i < MAX_PADS; i++) {
        if(padinfo.status[i]) {
            ioPadGetData (i, &paddata);
            if(paddata.BTN_START) {
              goto end;
            }
        }
    }

    setRenderTarget(context, &buffers[currentBuffer]);

    DEBUG ("Drawing frame %d\n", frame);
    waitFlip ();
    drawFrame (&buffers[currentBuffer], frame++); /* Draw into the unused buffer */
    flip (context, buffers[currentBuffer].id); /* Flip buffer onto screen */

    currentBuffer++;
    if (currentBuffer >= MAX_BUFFERS)
      currentBuffer = 0;
  }

 end:

  gcmSetWaitFlip(context);
  for (i = 0; i < MAX_BUFFERS; i++)
    rsxFree (buffers[i].ptr);

  rsxFinish (context, 1);
  free (host_addr);
  ioPadEnd();

  return 0;
}
Пример #20
0
int main(int argc, const char* argv[])
{
  padInfo padinfo;
  padData paddata;
  s32 status;
  u32 joinstatus;

  displayData vdat;
  char filename[64];
  int picturecount = 0;

  atexit(appCleanup);
  sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandle, NULL);

  init_screen(&vdat);
  printf("screen res: %dx%d buffers: %p %p\n",
       vdat.res.width, vdat.res.height, vdat.buffer[0], vdat.buffer[1]);
  ioPadInit(7);

  sysSpuImage image;
  u32 group_id;
  sysSpuThreadAttribute attr = { ptr2ea("mythread"), 8+1, SPU_THREAD_ATTR_NONE };
  sysSpuThreadGroupAttribute grpattr = { 7+1, ptr2ea("mygroup"), 0, 0 };
  sysSpuThreadArgument arg[6];
  u32 cause;
  int i, j;
  volatile spustr_t *spu = memalign(16, 6*sizeof(spustr_t));

  printf("Initializing 6 SPUs... ");
  status = sysSpuInitialize(6, 0);
  printf("%08x\n", status);

  printf("Loading ELF image... ");
  status = sysSpuImageImport(&image, spu_bin, 0);
  printf("%08x\n", status);

  printf("Creating thread group... ");
  status = sysSpuThreadGroupCreate(&group_id, 6, 100, &grpattr);
  printf("%08x\n", status);
  printf("group id = %d\n", group_id);

  /* create 6 spu threads */
  for (i = 0; i < 6; i++) {
    /* Populate the data structure for the SPU */
    spu[i].rank = i;
    spu[i].count = 6;
    spu[i].sync = 0;
    spu[i].width = vdat.res.width;
    spu[i].height = vdat.res.height;
    spu[i].zoom = 1.0f;
    spu[i].xc = -0.5f;
    spu[i].yc = 0.f;

    /* The first argument of the main function for the SPU program is the
     * address of its dedicated structure, so it can fetch its contents via DMA
     */
    arg[i].arg0 = ptr2ea(&spu[i]);

    printf("Creating SPU thread... ");
    status = sysSpuThreadInitialize((u32*)&spu[i].id, group_id, i, &image, &attr, &arg[i]);
    printf("%08x\n", status);
    printf("thread id = %d\n", spu[i].id);

    printf("Configuring SPU... %08x\n",
    sysSpuThreadSetConfiguration(spu[i].id, SPU_SIGNAL1_OVERWRITE|SPU_SIGNAL2_OVERWRITE));
  }

  printf("Starting SPU thread group... ");
  status = sysSpuThreadGroupStart(group_id);
  printf("%08x\n", status);

  /* Now all the SPU threads have been started. For the moment they are blocked
   * waiting for a value in their signal notification register 1 (the
   * spu_read_signal1() call in SPU program).
   */

  int quit = 0;
  uint32_t scr_ea;

  while (!quit) {
    /* Check the pads. */
    ioPadGetInfo(&padinfo);
    for (i=0; i<MAX_PADS; i++) {
      if (padinfo.status[i]) {
        ioPadGetData(i, &paddata);
        if (paddata.BTN_CROSS)
          quit = 1;
        int ah = center0(paddata.ANA_L_H);
        int av = center0(paddata.ANA_L_V);
        int az = center0(paddata.ANA_R_V);
        for (j = 0; j < 6; j++) {
          spu[j].xc += ah*0.001f*spu[j].zoom;
          spu[j].yc += av*0.001f*spu[j].zoom;
          spu[j].zoom *= (1.f + az*0.0005f);
          if (spu[j].zoom < 0.0001)
            spu[j].zoom = 0.0001;
        }
        if (paddata.BTN_SQUARE) {
          sprintf(filename, "/dev_usb/mandel%04d.bmp", ++picturecount);
          export_bmp(filename, vdat.buffer[vdat.curr_fb], vdat.res.width, vdat.res.height);
        }
        if (paddata.BTN_START) {
          for (j = 0; j < 6; j++) {
            spu[j].xc = -.5f;
            spu[j].yc = 0.f;
            spu[j].zoom = 1.f;
          }
        }
      }
    }

    waitFlip(); /* Wait for the last flip to finish, so we can draw to the old buffer */
#if 0
    /* test code */
    int x, y;
    u32 *p=vdat.buffer[vdat.curr_fb];
    u32 c = 0x01010101 * (vdat.framecnt&0xff);
    for (y=0; y<1080; ++y) {
      for (x=0; x<1920; ++x) {
        *p++ = c;
      }
    }
#endif
    scr_ea = ptr2ea(vdat.buffer[vdat.curr_fb]);
    for (i = 0; i < 6; i++) {
      spu[i].sync = 0;
      status = sysSpuThreadWriteSignal(spu[i].id, 0, scr_ea);
      assert(status == 0);
    }
    for (i = 0; i < 6; i++) {
      while (spu[i].sync == 0);
    }
    flip(&vdat); /* Flip buffer onto screen */
    sysUtilCheckCallback();
  }

  for (i = 0; i < 6; i++) {
    status = sysSpuThreadWriteSignal(spu[i].id, 0, 0);
    assert(status == 0);
  }

  printf("Joining SPU thread group... ");
  status = sysSpuThreadGroupJoin(group_id, &cause, &joinstatus);
  printf("%08x\n", status);
  printf("cause=%d status=%d\n", cause, joinstatus);

  printf("Closing image... %08x\n", sysSpuImageClose(&image));
  free((void*)spu);

  return 0;
}
Пример #21
0
int main()
{
	FILE* f=NULL;
	sysFSStat stat;

//--- hold CROSS

    unsigned button = 0;

    padInfo padinfo;
    padData paddata;

    ioPadInit(7);

    int n, r;
    for(r=0; r<10; r++)
    {
        ioPadGetInfo(&padinfo);
        for(n = 0; n < 7; n++)
        {
            if(padinfo.status[n])
            {
                ioPadGetData(n, &paddata);
                button = (paddata.button[2] << 8) | (paddata.button[3] & 0xff);
                break;
            }
        }
        if(button) break; else usleep(20000);
    }
    ioPadEnd();

	if(button & 0x04) full=true; else
	if(button & 0x60) lite=true;  // circle / cross
	if(button & 0x0F) vsh_menu=true; else vsh_menu = (sysLv2FsStat("/dev_hdd0/plugins/wm_vsh_menu.sprx", &stat) == SUCCESS);  // r1/r2/l1/l2
//---

	sysLv2FsMkdir("/dev_hdd0/tmp", 0777);
	sysLv2FsMkdir("/dev_hdd0/tmp/wm_lang", 0777);
	sysLv2FsMkdir("/dev_hdd0/tmp/wm_combo", 0777);

	// remove language files (old location)
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_EN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_AR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_CN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_DE.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_ES.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_FR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_GR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_DK.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_HU.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_HR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_BG.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_CZ.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_SK.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_IN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_JP.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_KR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_IT.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_NL.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_PL.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_PT.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_RU.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_TR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_ZH.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/LANG_XX.TXT");

	// remove language files
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_EN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_AR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_CN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_DE.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_ES.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_FR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_GR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_DK.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_HU.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_HR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_BG.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_CZ.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_SK.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_IN.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_JP.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_KR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_IT.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_NL.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_PL.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_PT.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_RU.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_TR.TXT");
	sysLv2FsUnlink("/dev_hdd0/tmp/wm_lang/LANG_ZH.TXT");

	// remove old files
	sysLv2FsUnlink("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_multi19.sprx");
	sysLv2FsUnlink("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_multi20.sprx");
	sysLv2FsUnlink("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_multi21.sprx");
	sysLv2FsUnlink("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_webchat.sprx");

	// update languages
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_EN.TXT", "/dev_hdd0/tmp/wm_lang/LANG_EN.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_AR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_AR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_CN.TXT", "/dev_hdd0/tmp/wm_lang/LANG_CN.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_DE.TXT", "/dev_hdd0/tmp/wm_lang/LANG_DE.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_ES.TXT", "/dev_hdd0/tmp/wm_lang/LANG_ES.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_FR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_FR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_GR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_GR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_DK.TXT", "/dev_hdd0/tmp/wm_lang/LANG_DK.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_HU.TXT", "/dev_hdd0/tmp/wm_lang/LANG_HU.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_HR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_HR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_BG.TXT", "/dev_hdd0/tmp/wm_lang/LANG_BG.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_CZ.TXT", "/dev_hdd0/tmp/wm_lang/LANG_CZ.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_SK.TXT", "/dev_hdd0/tmp/wm_lang/LANG_SK.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_IN.TXT", "/dev_hdd0/tmp/wm_lang/LANG_IN.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_IT.TXT", "/dev_hdd0/tmp/wm_lang/LANG_IT.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_JP.TXT", "/dev_hdd0/tmp/wm_lang/LANG_JP.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_KR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_KR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_NL.TXT", "/dev_hdd0/tmp/wm_lang/LANG_NL.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_PL.TXT", "/dev_hdd0/tmp/wm_lang/LANG_PL.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_PT.TXT", "/dev_hdd0/tmp/wm_lang/LANG_PT.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_RU.TXT", "/dev_hdd0/tmp/wm_lang/LANG_RU.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_TR.TXT", "/dev_hdd0/tmp/wm_lang/LANG_TR.TXT");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_ZH.TXT", "/dev_hdd0/tmp/wm_lang/LANG_ZH.TXT");

	sysLv2FsMkdir("/dev_hdd0/xmlhost/game_plugin", 0777);
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/mobile.html", "/dev_hdd0/xmlhost/game_plugin/mobile.html");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/background.gif", "/dev_hdd0/xmlhost/game_plugin/background.gif");

	sysLv2FsMkdir("/dev_hdd0/tmp/wm_icons", 0777);

	// copy new icons
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_album_ps3.png", "/dev_hdd0/tmp/wm_icons/icon_wm_album_ps3.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_album_psx.png", "/dev_hdd0/tmp/wm_icons/icon_wm_album_psx.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_album_ps2.png", "/dev_hdd0/tmp/wm_icons/icon_wm_album_ps2.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_album_psp.png", "/dev_hdd0/tmp/wm_icons/icon_wm_album_psp.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_album_dvd.png", "/dev_hdd0/tmp/wm_icons/icon_wm_album_dvd.png");

	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_ps3.png"      , "/dev_hdd0/tmp/wm_icons/icon_wm_ps3.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_psx.png"      , "/dev_hdd0/tmp/wm_icons/icon_wm_psx.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_ps2.png"      , "/dev_hdd0/tmp/wm_icons/icon_wm_ps2.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_psp.png"      , "/dev_hdd0/tmp/wm_icons/icon_wm_psp.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_dvd.png"      , "/dev_hdd0/tmp/wm_icons/icon_wm_dvd.png");

	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_settings.png" , "/dev_hdd0/tmp/wm_icons/icon_wm_settings.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/icon_wm_eject.png"    , "/dev_hdd0/tmp/wm_icons/icon_wm_eject.png"   );

	// XMBM+ webMAN
	sysLv2FsMkdir("/dev_hdd0/game/XMBMANPLS", 0777);
	sysLv2FsMkdir("/dev_hdd0/game/XMBMANPLS/USRDIR", 0777);
	sysLv2FsMkdir("/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES", 0777);
	sysLv2FsMkdir("/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES", 0777);

	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN.xml"    ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_AR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_AR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_CN.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_CN.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_DE.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_DE.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_ES.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_ES.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_FR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_FR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_GR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_GR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_DK.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_DK.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_HU.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_HU.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_HR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_HR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_BG.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_BG.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_CZ.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_CZ.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_SK.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_SK.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_IN.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_IN.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_JP.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_JP.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_KR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_KR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_IT.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_IT.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_NL.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_NL.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_PL.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_PL.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_PT.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_PT.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_RU.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_RU.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_TR.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_TR.xml");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webMAN_ZH.xml" ,"/dev_hdd0/game/XMBMANPLS/USRDIR/FEATURES/webMAN_ZH.xml");

	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/bd.png"        	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/bd.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/cachefiles.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/cachefiles.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/filemanager.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/filemanager.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/devflash.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/devflash.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/gamesbrowser.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/gamesbrowser.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/gamedata.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/gamedata.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/homebrew.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/homebrew.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/multiman.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/multiman.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/network.png"   	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/network.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/pkgmanager.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/pkgmanager.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/refreshhtml.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/refreshhtml.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/refreshxml.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/refreshxml.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/restartps3.png"	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/restartps3.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/settings.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/settings.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/sysinfo.png"  	,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/sysinfo.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/tools.png"  		,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/tools.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/unload.png"  		,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/unload.png");
	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webman.png"  		,"/dev_hdd0/game/XMBMANPLS/USRDIR/IMAGES/webman.png");

	sysLv2FsMkdir("/dev_hdd0/plugins", 0777);

	// install vsh menu
	if(vsh_menu && sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS)
	{
		sysLv2FsMkdir("/dev_hdd0/plugins/images", 0777);

		// update images
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu.png",   &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu.png",   "/dev_hdd0/plugins/images/wm_vsh_menu.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_1.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_1.png", "/dev_hdd0/plugins/images/wm_vsh_menu_1.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_2.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_2.png", "/dev_hdd0/plugins/images/wm_vsh_menu_2.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_3.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_3.png", "/dev_hdd0/plugins/images/wm_vsh_menu_3.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_4.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_4.png", "/dev_hdd0/plugins/images/wm_vsh_menu_4.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_5.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_5.png", "/dev_hdd0/plugins/images/wm_vsh_menu_5.png");
		/* if(sysLv2FsStat("/dev_hdd0/plugins/images/wm_vsh_menu_6.png", &stat) != SUCCESS) */ CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/images/wm_vsh_menu_6.png", "/dev_hdd0/plugins/images/wm_vsh_menu_6.png");

		// append path if installing for first time
		if(sysLv2FsStat("/dev_hdd0/plugins/wm_vsh_menu.sprx", &stat) != SUCCESS)
		{
			if(is_cobra())
			{
				// append line to boot_plugins.txt
				if(sysLv2FsStat("/dev_hdd0/boot_plugins.txt", &stat) == SUCCESS)
					f=fopen("/dev_hdd0/boot_plugins.txt", "a");
				else
					f=fopen("/dev_hdd0/boot_plugins.txt", "w");
					fputs("\r\n/dev_hdd0/plugins/wm_vsh_menu.sprx", f);
					fclose(f);
			}
			if(is_mamba())
			{
				// append line to mamba_plugins.txt
				if(sysLv2FsStat("/dev_hdd0/mamba_plugins.txt", &stat) == SUCCESS)
					f=fopen("/dev_hdd0/mamba_plugins.txt", "a");
				else
					f=fopen("/dev_hdd0/mamba_plugins.txt", "w");
					fputs("\r\n/dev_hdd0/plugins/wm_vsh_menu.sprx", f);
					fclose(f);
			}
			if(sysLv2FsStat("/dev_hdd0/prx_plugins.txt", &stat) == SUCCESS)
			{
				// append line to prx_plugins.txt
				f=fopen("/dev_hdd0/prx_plugins.txt", "a");
				fputs("\r\n/dev_hdd0/plugins/wm_vsh_menu.sprx", f);
				fclose(f);
			}
		}

		CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/wm_vsh_menu.sprx", "/dev_hdd0/plugins/wm_vsh_menu.sprx");
	}

	// skip update custom language file
	if(sysLv2FsStat("/dev_hdd0/tmp/wm_lang/LANG_XX.TXT", &stat))
		CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/LANG_XX.TXT", "/dev_hdd0/tmp/wm_lang/LANG_XX.TXT");

	// skip update custom combo file
	if(sysLv2FsStat("/dev_hdd0/tmp/wm_custom_combo", &stat))
		CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/wm_custom_combo", "/dev_hdd0/tmp/wm_custom_combo");

	CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/libfs.sprx", "/dev_hdd0/tmp/libfs.sprx");

	// copy raw_iso.sprx to dev_flash
	if(sysLv2FsStat("/dev_flash/vsh/module/raw_iso.sprx", &stat) != SUCCESS)
	{
		if(sysLv2FsStat("/dev_blind", &stat) != SUCCESS)
			sys_fs_mount("CELL_FS_IOS:BUILTIN_FLSH1", "CELL_FS_FAT", "/dev_blind", 0);

		if(sysLv2FsStat("/dev_blind", &stat) == SUCCESS)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/raw_iso.sprx", "/dev_blind/vsh/module/raw_iso.sprx");
	}

	// copy raw_iso.sprx to dev_hdd (if failed to copy it to dev_flash)
	if(sysLv2FsStat("/dev_flash/vsh/module/raw_iso.sprx", &stat) != SUCCESS)
	{
		if(sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS)
		{
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/raw_iso.sprx", "/dev_hdd0/plugins/raw_iso.sprx");
            if(sysLv2FsStat("/dev_hdd0/plugins/raw_iso.sprx", &stat) == SUCCESS) sysLv2FsUnlink("/dev_hdd0/raw_iso.sprx");
		}
		else
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/raw_iso.sprx", "/dev_hdd0/raw_iso.sprx");
	}

	// copy standalone video recorder plugin (video_rec.sprx) to /plugins folder
	if((sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS))
		CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/video_rec.sprx", "/dev_hdd0/plugins/video_rec.sprx");

	// update PRX+Mamba Loader
	if((sysLv2FsStat("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx", &stat) == SUCCESS))
	{
		sysLv2FsChmod("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");

		if(full)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
		else if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS) && is_ps3mapi())
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
		else if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_multi23.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
		else if(lite)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
		else if(is_ps3mapi())
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
		else
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server.sprx");
	}
	else if((sysLv2FsStat("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server_ps3mapi.sprx", &stat) == SUCCESS))
	{
		sysLv2FsChmod("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server_ps3mapi.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server_ps3mapi.sprx");

		if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server_ps3mapi.sprx");
		else
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/game/IRISMAN01/USRDIR/webftp_server_ps3mapi.sprx");
	}

	char ligne[255];

	// update PRX Loader
	if(sysLv2FsStat("/dev_hdd0/game/PRXLOADER/USRDIR/plugins.txt", &stat) == SUCCESS)
	{
		f=fopen("/dev_hdd0/game/PRXLOADER/USRDIR/plugins.txt", "r");
		while(fgets(ligne, 255, f) != NULL)
		{
			if(strstr(ligne,"webftp_server") != NULL)
			{
				fclose(f);
				strtok(ligne, "\r\n");
				sysLv2FsUnlink(ligne);
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_noncobra.sprx",ligne);
				goto cont;
			}
		}
		fclose(f);
		f=fopen("/dev_hdd0/game/PRXLOADER/USRDIR/plugins.txt", "a");
		fputs("\r\n/dev_hdd0/game/PRXLOADER/USRDIR/webftp_server_noncobra.sprx", f);
		fclose(f);

		sysLv2FsChmod("/dev_hdd0/game/PRXLOADER/USRDIR/webftp_server_noncobra.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/game/PRXLOADER/USRDIR/webftp_server_noncobra.sprx");

		CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_noncobra.sprx", "/dev_hdd0/game/PRXLOADER/USRDIR/webftp_server_noncobra.sprx");
	}

cont:

	// update dev_flash (rebug)
	if((sysLv2FsStat("/dev_flash/vsh/module/webftp_server.sprx", &stat) == SUCCESS) || (sysLv2FsStat("/dev_flash/vsh/module/webftp_server.sprx.bak", &stat) == SUCCESS))
	{
		is_cobra(); // re-enable cobra if it's disabled

		if(sysLv2FsStat("/dev_blind", &stat) != SUCCESS)
			sys_fs_mount("CELL_FS_IOS:BUILTIN_FLSH1", "CELL_FS_FAT", "/dev_blind", 0);

		sysLv2FsChmod("/dev_blind/vsh/module/webftp_server.sprx", 0777);
		sysLv2FsUnlink("/dev_blind/vsh/module/webftp_server.sprx");

		sysLv2FsChmod("/dev_blind/vsh/module/webftp_server.sprx.bak", 0777);
		sysLv2FsUnlink("/dev_blind/vsh/module/webftp_server.sprx.bak");

		if(full)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_blind/vsh/module/webftp_server.sprx");
		else if(lite)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_blind/vsh/module/webftp_server.sprx");
		else if(is_ps3mapi())
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_blind/vsh/module/webftp_server.sprx");
		else
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_multi23.sprx", "/dev_blind/vsh/module/webftp_server.sprx");


		// delete webMAN from hdd0
		if((sysLv2FsStat("/dev_blind/vsh/module/webftp_server.sprx", &stat) == SUCCESS))
		{
			sysLv2FsChmod("/dev_hdd0/webftp_server.sprx", 0777);
			sysLv2FsUnlink("/dev_hdd0/webftp_server.sprx");

			sysLv2FsChmod("/dev_hdd0/plugins/webftp_server.sprx", 0777);
			sysLv2FsUnlink("/dev_hdd0/plugins/webftp_server.sprx");

			if(sysLv2FsStat("/dev_hdd0/boot_plugins.txt", &stat) == SUCCESS)
			{
				f=fopen("/dev_hdd0/boot_plugins.txt", "r");
				while(fgets(ligne, 255, f) != NULL)
				{
					if(strstr(ligne,"webftp_server") != NULL && strstr(ligne,"/dev_blind") == NULL)
					{
						strtok(ligne, "\r\n");
						sysLv2FsChmod(ligne, 0777);
						sysLv2FsUnlink(ligne);
						break;
					}
				}
				fclose(f);
			}
		}

		// reboot
		sysLv2FsUnlink("/dev_hdd0/tmp/turnoff");
		//{lv2syscall4(379,0x200,0,0,0); return_to_user_prog(int);}
		//{lv2syscall4(379,0x1200,0,0,0); return_to_user_prog(int);}
		{lv2syscall3(SC_SYS_POWER, SYS_REBOOT, 0, 0); return_to_user_prog(int);}
        //{lv2syscall3(SC_SYS_POWER, SYS_REBOOT, 0, 0);}

		return 0;
	}

	// update boot_plugins.txt
	if(lite || full || is_cobra())
	{
		// parse boot_plugins.txt (update existing path)
		if(sysLv2FsStat("/dev_hdd0/boot_plugins.txt", &stat) == SUCCESS)
		{
			f=fopen("/dev_hdd0/boot_plugins.txt", "r");
			while(fgets(ligne, 255, f) != NULL)
			{
				if(strstr(ligne,"webftp_server") != NULL)
				{
					fclose(f);
					strtok(ligne, "\r\n");
					sysLv2FsChmod(ligne, 0777);
					sysLv2FsUnlink(ligne);
					if(full)
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", ligne);
					else if(lite)
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", ligne);
					else
					{
						if(is_ps3mapi())
							CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", ligne);
						else
							CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server.sprx", ligne);
					}
					goto exit;
				}
			}
			fclose(f);
		}

		// append line to boot_plugins.txt
		if(sysLv2FsStat("/dev_hdd0/boot_plugins.txt", &stat) == SUCCESS)
			f=fopen("/dev_hdd0/boot_plugins.txt", "a");
		else
			f=fopen("/dev_hdd0/boot_plugins.txt", "w");
		if((sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS))
		{
			if(is_ps3mapi() && !lite && !full)
				fputs("\r\n/dev_hdd0/plugins/webftp_server_ps3mapi.sprx", f);
			else
				fputs("\r\n/dev_hdd0/plugins/webftp_server.sprx", f);
		}
		else
		{
			if(is_ps3mapi() && !lite && !full)
				fputs("\r\n/dev_hdd0/webftp_server_ps3mapi.sprx", f);
			else
				fputs("\r\n/dev_hdd0/webftp_server.sprx", f);
		}
		fclose(f);

		// delete old sprx
		sysLv2FsChmod("/dev_hdd0/webftp_server.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/webftp_server.sprx");

		sysLv2FsChmod("/dev_hdd0/plugins/webftp_server.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/plugins/webftp_server.sprx");

		sysLv2FsChmod("/dev_hdd0/webftp_server_ps3mapi.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/webftp_server_ps3mapi.sprx");

		sysLv2FsChmod("/dev_hdd0/plugins/webftp_server_ps3mapi.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");

		// copy ps3mapi/cobra/rebug/lite sprx
		if((sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS))
		{
			if(full)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_hdd0/plugins/webftp_server.sprx");
			else if(lite)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_hdd0/plugins/webftp_server.sprx");
			else
			{
				if(is_ps3mapi())
				{
					if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");
					else
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");
				}
				else
					CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server.sprx", "/dev_hdd0/plugins/webftp_server.sprx");
			}
		}
		else
		{
			if(full)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_hdd0/webftp_server.sprx");
			else if(lite)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_hdd0/webftp_server.sprx");
			else
			{
				if(is_ps3mapi())
				{
					if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/webftp_server_ps3mapi.sprx");
					else
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/webftp_server_ps3mapi.sprx");
				}
				else
					CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server.sprx", "/dev_hdd0/webftp_server.sprx");
			}
		}
	}

	// update mamba_plugins.txt
	if(is_mamba())
	{
		// parse mamba_plugins.txt (update existing path)
		if(sysLv2FsStat("/dev_hdd0/mamba_plugins.txt", &stat) == SUCCESS)
		{
			f=fopen("/dev_hdd0/mamba_plugins.txt", "r");
			while(fgets(ligne, 255, f) != NULL)
			{
				if(strstr(ligne,"webftp_server") != NULL)
				{
					fclose(f);
					strtok(ligne, "\r\n");
					sysLv2FsChmod(ligne, 0777);
					sysLv2FsUnlink(ligne);

					if(full)
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", ligne);
					else if(lite)
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", ligne);
					else
						CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", ligne);
					goto exit;
				}
			}
			fclose(f);
		}

		// append line to mamba_plugins.txt (Mamba/PRX Loader - PS3MAPI)
		if(sysLv2FsStat("/dev_hdd0/mamba_plugins.txt", &stat) == SUCCESS)
			f=fopen("/dev_hdd0/mamba_plugins.txt", "a");
		else
			f=fopen("/dev_hdd0/mamba_plugins.txt", "w");
		if((sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS))
		{
			if(full || lite)
				fputs("\r\n/dev_hdd0/plugins/webftp_server.sprx", f);
			else
				fputs("\r\n/dev_hdd0/plugins/webftp_server_ps3mapi.sprx", f);
		}
		else if(full || lite)
			fputs("\r\n/dev_hdd0/webftp_server.sprx", f);
		else
			fputs("\r\n/dev_hdd0/webftp_server_ps3mapi.sprx", f);
		fclose(f);

		// delete old sprx
		sysLv2FsChmod("/dev_hdd0/webftp_server_ps3mapi.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/webftp_server_ps3mapi.sprx");

		sysLv2FsChmod("/dev_hdd0/plugins/webftp_server_ps3mapi.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");

		// copy ps3mapi sprx
		if((sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS))
		{
			if(full)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_hdd0/plugins/webftp_server.sprx");
			else if(lite)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_hdd0/plugins/webftp_server.sprx");
			else if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");
			else
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/plugins/webftp_server_ps3mapi.sprx");
		}
		else
		{
			if(full)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_full.sprx", "/dev_hdd0/webftp_server.sprx");
			else if(lite)
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_lite.sprx", "/dev_hdd0/webftp_server.sprx");
			else if((sysLv2FsStat("/dev_flash/rebug", &stat) == SUCCESS))
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx", "/dev_hdd0/webftp_server_ps3mapi.sprx");
			else
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_ps3mapi.sprx", "/dev_hdd0/webftp_server_ps3mapi.sprx");
		}
	}

	// update prx_plugins.txt (PRX LOADER)
	if(sysLv2FsStat("/dev_hdd0/prx_plugins.txt", &stat) == SUCCESS)
	{
		// parse prx_plugins.txt (update existing path)
		f=fopen("/dev_hdd0/prx_plugins.txt", "r");
		while(fgets(ligne, 255, f) != NULL)
		{
			if(strstr(ligne,"webftp_server") != NULL)
			{
				fclose(f);
				strtok(ligne, "\r\n");
				sysLv2FsUnlink(ligne);
				CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_noncobra.sprx",ligne);
				goto exit;
			}
		}
		fclose(f);

		// append line to prx_plugins.txt
		f=fopen("/dev_hdd0/prx_plugins.txt", "a");

		if(sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS)
			fputs("\r\n/dev_hdd0/plugins/webftp_server_noncobra.sprx", f);
		else
			fputs("\r\n/dev_hdd0/webftp_server_noncobra.sprx", f);
		fclose(f);

		// delete old sprx
		sysLv2FsChmod("/dev_hdd0/webftp_server_noncobra.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/webftp_server_noncobra.sprx");

		sysLv2FsChmod("/dev_hdd0/plugins/webftp_server_noncobra.sprx", 0777);
		sysLv2FsUnlink("/dev_hdd0/plugins/webftp_server_noncobra.sprx");

		// copy non cobra sprx
		if(sysLv2FsStat("/dev_hdd0/plugins", &stat) == SUCCESS)
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_noncobra.sprx", "/dev_hdd0/plugins/webftp_server_noncobra.sprx");
		else
			CopyFile("/dev_hdd0/game/UPDWEBMOD/USRDIR/webftp_server_noncobra.sprx", "/dev_hdd0/webftp_server_noncobra.sprx");
	}
	// exit
exit:

	// update category_game.xml (add fb.xml)
	if(add_mygame() != -2);


	// reboot
	sysLv2FsUnlink("/dev_hdd0/tmp/turnoff");
	//{lv2syscall4(379,0x200,0,0,0); return_to_user_prog(int);}
	//{lv2syscall4(379,0x1200,0,0,0); return_to_user_prog(int);}
	{lv2syscall3(SC_SYS_POWER, SYS_REBOOT, 0, 0); return_to_user_prog(int);}

	return 0;
}
Пример #22
0
unsigned ps3pad_read()
{
    int n;

    PadActParam actparam;

    unsigned butt = 0;

    pad_alive = 0;

    sysCheckCallback();

    ioPadGetInfo(&padinfo);

    for(n = 0; n < MAX_PADS; n++) {
            
        if(padinfo.status[n])  {
                    
            ioPadGetData(n, &paddata);
            pad_alive = 1;
            butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff);

            /* Analog stick management */
            if (paddata.button[6] < 0x10)
                butt |= BUTTON_LEFT;
            else if (paddata.button[6] > 0xe0)
                butt |= BUTTON_RIGHT;
            if (paddata.button[7] < 0x10)
                butt |= BUTTON_UP;
            else if (paddata.button[7] > 0xe0)
                butt |= BUTTON_DOWN;
            break;
        
        }
    }

		
    if(!pad_alive) butt = 0;
    else {
        actparam.small_motor = 0;
		actparam.large_motor = 0;
        
        if(rumble1_on) {
            
			actparam.large_motor = 255;
              
            rumble1_on++;
          
            if(rumble1_on > 15) rumble1_on = 0;
          
        }

        if(rumble2_on) {
           
            actparam.small_motor = 1;

            rumble2_on++;

            if(rumble2_on > 10) rumble2_on = 0;
        }

        last_rumble = n;

        ioPadSetActDirect(n, &actparam);
    }

    temp_pad = butt;

    new_pad = temp_pad & (~old_pad); old_pad = temp_pad;


return butt;
}
Пример #23
0
unsigned ps3pad_read()
{
    int n;

    padActParam actparam;

    unsigned butt = 0;

    pad_alive = 0;

    static int count = 16;
    static u64 sec, nsec;
    count++;

    if(count > 15)
    {
        sysGetCurrentTime(&sec, &nsec);
        count = 0;

        if(pad_last_time == 0)
            pad_last_time = sec;

        if(iTimeoutByInactivity)
        {
            if((sec - pad_last_time) > (iTimeoutByInactivity * 3600))
            {
                if(DrawDialogYesNoTimer("System will be shutdown in two minutes by inactivity\nDo you want to abort the countdown?", 120000.0f) != 1)
                {
                    fun_exit();
                    sys_shutdown();
                    exit(0);
                }
                else
                    pad_last_time = 0;
            }
        }

        u32 temp = 0;
        u32 temp2 = 0;

        sys_game_get_temperature(0, &temp);
        sys_game_get_temperature(1, &temp2);

        if((temp >= 80 || temp2 >= 80))
        {
            if(!hot_temp_alarm) hot_temp_alarm = sec;
        } else
            hot_temp_alarm = 0;

        if(hot_temp_alarm && (sec - hot_temp_alarm) > 90)
        {
            DrawDialogOKTimer("WARNING: CPU/RSX Temperature is too high!\nSystem will be shutdown in 10 seconds\n", 10000.0f);
            fun_exit();
            sys_shutdown();
            exit(0);
        }
    }

    sysUtilCheckCallback();

    ioPadGetInfo(&padinfo);

    for(n = 0; n < MAX_PADS; n++)
    {
        if(padinfo.status[n])
        {
            ioPadGetData(n, &paddata);
            pad_alive = 1;
            butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff);

            /* Analog stick management */
            if (paddata.button[6] < 0x10)
                butt |= BUTTON_LEFT;
            else if (paddata.button[6] > 0xe0)
                butt |= BUTTON_RIGHT;

            if (paddata.button[7] < 0x10)
                butt |= BUTTON_UP;
            else if (paddata.button[7] > 0xe0)
                butt |= BUTTON_DOWN;

            if(butt) pad_last_time = sec;

            break;
        }
    }


    if(!pad_alive) butt = 0;
    else
    {
        actparam.small_motor = 0;
        actparam.large_motor = 0;

        if(rumble1_on)
        {
            actparam.large_motor = 255;

            rumble1_on++;

            if(rumble1_on > 15) rumble1_on = 0;
        }

        if(rumble2_on)
        {
            actparam.small_motor = 1;

            rumble2_on++;

            if(rumble2_on > 10) rumble2_on = 0;
        }

        last_rumble = n;

        ioPadSetActDirect(n, &actparam);
    }

    temp_pad = butt;

    new_pad = temp_pad & (~old_pad); old_pad = temp_pad;

    return butt;
}
Пример #24
0
s32 main(s32 argc, const char* argv[])
{

    int count = 0;
    int n;
    padInfo padinfo;
	padData paddata;

    char *cur_device = "/ntfs0:";
    char path[1024];

    // map file functions to libc open, fopen, ...
    NTFS_init_system_io();

    tiny3d_Init(1024*1024);
    tiny3d_Project2D();

    u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global)    

    u32 * texture_pointer; // use to asign texture space without changes texture_mem

    if(!texture_mem) return 0; // fail!

    texture_pointer = texture_mem;

    ResetFont();
    texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font  , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL);

    initConsole();
    ioPadInit(7);

    DbgHeader("NTFS EXT2/3/4 Example");
    
   /*
    // Mount all NTFS volumes on all inserted block devices
    mountCount = ntfsMountAll(&mounts, NTFS_DEFAULT | NTFS_RECOVER);

   // mountCount = ntfsMountDevice (&__io_ntfs_usb000, &mounts, NTFS_DEFAULT | NTFS_RECOVER);
    
    if (mountCount == -1)
        DPrintf("Error whilst mounting devices (%i).\n", errno);
    else if (mountCount == 0)
        DPrintf("No NTFS volumes were found and/or mounted.\n");
    else
        DPrintf("%i NTFS volumes(s) mounted!\n\n", mountCount);
    */


    int i;

    count = 1;
    
    while(1) {
    if(count > 0) {
        count--;
        if(count == 0) {
            int k;
            initConsole();
            
            for(k = 0; k < 8; k++) {
                for (i = 0; i < mountCount[k]; i++)
                DPrintf("%i - %s:/ (%s) (from usb00%i)\n", i + 1, 
                (mounts[k]+i)->name, ntfsGetVolumeName((mounts[k] + i)->name), 
                    ((mounts[k] + i)->interface->ioType & 0xff) - '0');
            }

            
            int r;

            cur_device = NULL;
            r = NTFS_Test_Device("ext0"); DPrintf("\nTest ext0 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ext0:";

            r = NTFS_Test_Device("ext1"); DPrintf("Test ext1 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ext1:";

            r = NTFS_Test_Device("ext2"); DPrintf("Test ext2 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ext2:";

            r = NTFS_Test_Device("ext3"); DPrintf("Test ext3 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ext3:";

            r = NTFS_Test_Device("ntfs0"); DPrintf("Test ntfs0 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ntfs0:";

            r = NTFS_Test_Device("ntfs1"); DPrintf("Test ntfs1 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ntfs1:";

            r = NTFS_Test_Device("ntfs2"); DPrintf("Test ntfs2 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ntfs2:";

            r = NTFS_Test_Device("ntfs3"); DPrintf("Test ntfs3 %i\n" , r);
            if(r>=0 && !cur_device) cur_device = "/ntfs3:";

            if(!cur_device) cur_device = "/ntfs0:"; // by default
            
          

        }
    }

    DbgHeader("NTFS EXT2/3/4 Example");
    DbgMess("Press X to list device, O to test file and /\\ to exit");

    for(i = 0; i < 8 ; i++) {
        int r = NTFS_Event_Mount(i);

        if(r == 1) { // mount device
            
            NTFS_UnMount(i);

            mounts[i] = NULL;
            mountCount[i] = 0;

            mountCount[i] = ntfsMountDevice (disc_ntfs[i], &mounts[i], NTFS_DEFAULT | NTFS_RECOVER);
            
            if(mountCount[i]>0) {count = 1;} // update counter
        } else if(r == -1) { // unmount device
            NTFS_UnMount(i);
            count = 1;
        }
    }

    

  //  DbgMess();


    DbgDraw();
    tiny3d_Flip();
    ioPadGetInfo(&padinfo);

            for(n = 0; n < MAX_PADS; n++) {
                static u32 btn_flags = 0;
            
                if(padinfo.status[n]) {
                    
                    ioPadGetData(n, &paddata);
                   
                    if(paddata.BTN_CROSS) {
                        if((btn_flags & 1)==0){
                            btn_flags|=1;
                            max_list = 0;
                            initConsole();

                            count = 300;

                            DPrintf("Listing 10 entries from %s (5 seconds)\n", cur_device);
                            
                            sprintf(path, "%s", cur_device);

                            list(path, 0);
                           
                        }
        
                    } else btn_flags&=~1;

                    if(paddata.BTN_CIRCLE) {
                        if((btn_flags & 2)==0){
                            btn_flags|=2;
                            
                            DPrintf("\n\nWriting / Reading a file from %s\n", cur_device);
                            
                            sprintf(path, "%s/0text", cur_device);
                            
                            mkdir(path, 0777);

                            sprintf(path, "%s/0text/test.txt", cur_device);

                            FILE *fp;
                          
                            fp =fopen(path, "wb");
        
                            if(fp) {

                                int i;
 
                                i = fwrite(message, 1, strlen(message), fp);

                                if(i != strlen(message)) DPrintf("Error writing the file!\n");

                                fclose(fp);
                      

                            } else DPrintf("Error creating the file!\n");
           
                            memset(buffer, 0, 1024);

                            sprintf(path, "%s/0text/test.txt", cur_device);

                            fp = fopen(path, "rb");

             
                            if(fp) {

                                int i;

                 // NOTE: for files > 2GB you can use 64 bit method

                                #ifdef USE_64BIT_SEEK
    
                                struct _reent reent1;

                                DPrintf ("Using _lseek64_r for large files\n");

                                s64 size = _lseek64_r(&reent1, fp->_file, 0, SEEK_END);
                                
                                _lseek64_r(&reent1, fp->_file, 0, SEEK_SET);

                                DPrintf ("Size of file %i bytes\n", (int) size);

                                #else

                                fseek(fp, 0, SEEK_END);

                                int size = ftell(fp);

                                DPrintf ("Size of file %i bytes\n", size);

                                fseek(fp, 0, SEEK_SET);

                                #endif
                                
                                i = fread(buffer, 1, size, fp);

                                if(i != size) DPrintf("Error reading the file %i!\n", i);

                                fclose(fp);

                            } else DPrintf("Error Reading the file!\n");

                            DPrintf("Readed From file: %s\n\n", buffer);
                        }
 
                        
                    } else btn_flags&=~2;



                    if(paddata.BTN_TRIANGLE){
                       
                        goto out;				
        
                    }
                }
            }

    
           
    }

    out:;
    DPrintf("Umounting\n");
    DbgDraw();
    tiny3d_Flip();
 
    NTFS_UnMountAll();

	return 0;
}
Пример #25
0
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;
}
Пример #26
0
int main(s32 argc, char* argv[])
{
	atexit(_unload);

	// Initialize graphics
	GFX = new NoRSX();
	MsgDialog MSG(GFX);

	// Release message
	MSG.Dialog(MSG_OK, "This build of OpenPS3FTP has not been tested by the author. As such, you use this software at your own risk. Please report any issues found to the OpenPS3FTP GitHub repository or send a tweet to @jjolano. See README.txt for more details.");

	// Initialize required libraries: net, netctl, io
	netInitialize();
	netCtlInit();
	ioPadInit(7);

	// Verify connection state
	s32 state;
	netCtlGetState(&state);

	if(state != NET_CTL_STATE_IPObtained)
	{
		// not connected to network - terminate program
		MSG.Dialog(MSG_OK, "Could not verify connection status. OpenPS3FTP will now exit.");
		exit(EXIT_FAILURE);
	}

	// Set application running state
	GFX->AppStart();

	// Create thread for server
	sys_ppu_thread_t id;
	sysThreadCreate(&id, ftp_main, GFX, 1001, 0x1000, THREAD_JOINABLE, const_cast<char*>("opf_ftp_main"));

	// Set up graphics
	Font F1(LATIN2, GFX);
	Background BG(GFX);
	Bitmap BM(GFX);

	NoRSX_Bitmap PCL;
	BM.GenerateBitmap(&PCL);
	BG.MonoBitmap(COLOR_BLACK, &PCL);

	// Retrieve detailed connection information (ip address)
	net_ctl_info info;
	netCtlGetInfo(NET_CTL_INFO_IP_ADDRESS, &info);

	// Draw bitmap layer
	// Not sure how this will actually look.
	F1.PrintfToBitmap(50, 50, &PCL, COLOR_WHITE, "OpenPS3FTP version %s", OFTP_VERSION);
	F1.PrintfToBitmap(50, 100, &PCL, COLOR_WHITE, "Written by John Olano (twitter: @jjolano)");

	F1.PrintfToBitmap(50, 200, &PCL, COLOR_WHITE, "IP Address: %s (port 21)", info.ip_address);

	F1.PrintfToBitmap(50, 300, &PCL, COLOR_WHITE, "SELECT: Execute dev_blind");
	F1.PrintfToBitmap(50, 350, &PCL, COLOR_WHITE, "START: Exit OpenPS3FTP");

	// Pad IO variables
	padInfo padinfo;
	padData paddata;
	padData paddata_old[MAX_PADS];

	// Main thread loop
	while(GFX->GetAppStatus() != APP_EXIT)
	{
		// Get Pad Status
		ioPadGetInfo(&padinfo);

		for(unsigned int i = 0; i < MAX_PADS; i++)
		{
			if(padinfo.status[i])
			{
				// Get Pad Data
				ioPadGetData(i, &paddata);

				// Parse Pad Data
				if(Pad_onPress(paddata, paddata_old[i], BTN_SELECT))
				{
					// dev_blind stuff
					sysFSStat stat;
					s32 ret = sysFsStat("/dev_blind", &stat);

					if(ret == 0)
					{
						// dev_blind exists - ask to unmount
						MSG.Dialog(MSG_YESNO, "Do you want to unmount dev_blind?");

						if(MSG.GetResponse(MSG_DIALOG_BTN_YES) == 1)
						{
							// syscall unmount
							lv2syscall1(838, (u64)"/dev_blind");

							// display success
							MSG.Dialog(MSG_OK, "dev_blind was successfully unmounted.");
						}
					}
					else
					{
						// dev_blind does not exist - ask to mount
						MSG.Dialog(MSG_YESNO, "Do you want to mount dev_blind?");

						if(MSG.GetResponse(MSG_DIALOG_BTN_YES) == 1)
						{
							// syscall mount
							lv2syscall8(837, (u64)"CELL_FS_IOS:BUILTIN_FLSH1", (u64)"CELL_FS_FAT", (u64)"/dev_blind", 0, 0 /* readonly */, 0, 0, 0);

							// display success with info
							MSG.Dialog(MSG_OK, "dev_blind was successfully mounted. Please note that dev_blind will not automatically unmount upon exiting OpenPS3FTP.");
						}
					}
				}

				if(Pad_onPress(paddata, paddata_old[i], BTN_START))
				{
					// Exit application
					GFX->AppExit();
				}

				paddata_old[i] = paddata;
			}
		}

		// Draw bitmap->screenbuffer
		BM.DrawBitmap(&PCL);
		GFX->Flip();
	}

	BM.ClearBitmap(&PCL);

	// Wait for server thread to complete
	u64 retval;
	sysThreadJoin(id, &retval);

	// Parse thread return value if application is not exiting
	if(GFX->ExitSignalStatus() == NO_SIGNAL && retval != 0)
	{
		// Error - see ftp.cpp
		MSG.ErrorDialog((u32)retval);
		exit(EXIT_FAILURE);
	}

	return 0;
}
Пример #27
0
/* check controller for input */
inline int
padCheck ( padBtnData *pdata )
{
  static int i ;
  padInfo padinfo ;
  padData paddata ;

  pdata->btn = 0 ;

  ioPadGetInfo ( &padinfo ) ;
  for ( i = 0 ; i < MAX_PADS ; i++ )
  {
    if ( !padinfo.status[i] )
    {
      continue ;
    }
    else
    {
      ioPadGetData ( i, &paddata ) ;
      if ( paddata.BTN_TRIANGLE )
      {
        pdata->btn = PAD_TRIANGLE ;
      }
      else if ( paddata.BTN_CIRCLE )
      {
        pdata->btn = PAD_CIRCLE ;
      }
      else if ( paddata.BTN_CROSS )
      {
        pdata->btn = PAD_CROSS ;
      }
      else if ( paddata.BTN_SQUARE )
      {
        pdata->btn = PAD_SQUARE ;
      }
      else if ( paddata.BTN_SELECT )
      {
        pdata->btn = PAD_SELECT ;
      }
      else if ( paddata.BTN_START )
      {
        pdata->btn = PAD_START ;
      }
      else if ( paddata.BTN_UP )
      {
        pdata->btn = PAD_UP ;
      }
      else if ( paddata.BTN_RIGHT )
      {
        pdata->btn = PAD_RIGHT ;
      }
      else if ( paddata.BTN_DOWN )
      {
        pdata->btn = PAD_DOWN ;
      }
      else if ( paddata.BTN_LEFT )
      {
        pdata->btn = PAD_LEFT ;
      }
      else
      {
        pdata->btn = 0 ;
      }
    }
  }

  pdata->now = pdata->btn & ( ~pdata->last ) ;
  pdata->last = pdata->btn ;

  return pdata->now ;
}
Пример #28
0
s32 main(s32 argc, const char* argv[])
{
	printf("init_screen()\n");
	init_screen();

	PadInfo padinfo;
	PadData paddata;
	int i;
	
	printf("Initializing 6 SPUs... ");
	printf("%08x\n", lv2SpuInitialize(6, 5));

	printf("ioPadInit()\n");
	ioPadInit(7);
	printf("init_efb()\n");
	init_efb(1);

	long frame = 0; // To keep track of how many frames we have rendered.
	
	// Ok, everything is setup. Now for the main loop.
	while(1){
		u64 frameStart=sys_time_get_system_time();
		printf("frame\n");
		// 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;
				}
			}
			
		}

		u64 afterPad=sys_time_get_system_time();
		u64 afterWaitForBlit=sys_time_get_system_time();
		printf("waitFlip\n");
		waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer

		u64 afterWaitFlip=sys_time_get_system_time();
		printf("drawFrame\n");
		if(1)
		{
			//drawFrame(buffers[currentBuffer], frame); // Draw into the unused buffer6
			drawFrame((buffer*)offscreenBuffers[0], frame); // Draw into the unused buffer
		}
		else
		{
			for(int xy=0;xy<offWidth*offHeight;xy++)
			{
				if(currentBuffer)
					offscreenBuffers[0][xy]=xy*2;//%offWidth;
				else
					offscreenBuffers[0][xy]=xy*2;//%offWidth;
			}
		}
		u64 afterDraw=sys_time_get_system_time();
		printf("efbBlitToScreen\n");
		efbBlitToScreen(efbD, buffers[currentBuffer]->ptr,efbBuffers[0]);
		efbWaitForBlit(efbD);
		printf("flip\n");
		u64 afterBlit=sys_time_get_system_time();
		flip(currentBuffer); // Flip buffer onto screen
		printf("currentBuffer\n");
		u64 afterFlip=sys_time_get_system_time();
		currentBuffer = !currentBuffer; 
		frame++;
		//if(frame>4)
		//	break;

		u64 padTime=afterPad-frameStart;
		u64 blitFlipWaitTime=afterWaitForBlit-afterPad;
		u64 flipWaitTime=afterWaitFlip-afterWaitForBlit;
		u64 drawTime=afterDraw-afterWaitFlip;
		u64 blitTime=afterBlit-afterDraw;
		u64 flipTime=afterFlip-afterBlit;
		u64 totalTime=afterFlip-frameStart;

		printf("%9ld, %9ld, %9ld, %9ld, %9ld, %9ld, %9ld\n",padTime,blitFlipWaitTime,flipWaitTime,drawTime,blitTime,flipTime,totalTime);
		//break;
	}
	efbShutdown(efbD);
	return 0;
}
Пример #29
0
s32 main(s32 argc, const char* argv[])
{
	padInfo padinfo;
	padData paddata;
	ioPadInit(7);

	int Bx=0;
	int By=0;


	pngData *png = new pngData;
	
	NoRSX *GFX = new NoRSX(RESOLUTION_AUTO, RESOLUTION_1280x720); //set defined screen resolution You can change it to:
						    			  //RESOLUTION_720x480 | RESOLUTION_720x576 | RESOLUTION_1280x720 | RESOLUTION_1920x1080
	Image IMG(GFX);
	Background BG(GFX);
	Object OBJ(GFX);
	Bitmap BMap(GFX);
	MsgDialog Msg(GFX);

	NoRSX_Bitmap Precalculated_Layer;	
	
	BMap.GenerateBitmap(&Precalculated_Layer); //Initialize the Bitmap
	
	Font F1(Sans_ttf,Sans_ttf_size ,GFX);   //Loaded from Memory
	Font F2("/dev_flash/data/font/SCE-PS3-VR-R-LATIN2.TTF" ,GFX);  //Loaded from File!
	Font F3(JPN ,GFX);  //I'm Using PS3 Original Fonts! These are the available on the ps3: LATIN2 | JPN | KOR | CGB | KANA
	

	IMG.LoadPNG_Buf(NoRSX_Image_png,NoRSX_Image_png_size, png);

	png = IMG.ResizeImage(png, 500, 500); //pngData* IMG.ResizeImage(pngData*, new width, new height)

	u32 imgX =(GFX->width/2)-(png->width/2), imgY = (GFX->height/2)-(png->height/2);

	BG.MonoBitmap(0xb4e83a,&Precalculated_Layer); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX)

//	IMG.DrawIMGtoBitmap(imgX,imgY,png,&Precalculated_Layer);

	OBJ.CircleToBitmap(500,500,50,COLOR_YELLOW,&Precalculated_Layer);


	F1.PrintfToBitmap(150,200,&Precalculated_Layer,COLOR_RED,"Screen %d x %d",GFX->width,GFX->height);
	F1.PrintfToBitmap(150,250,&Precalculated_Layer,COLOR_BLUE, 35,"Press X to exit! (Start to skip Message Dialogs and exit)");
	F2.PrintfToBitmap(150,300,&Precalculated_Layer,COLOR_GREEN,60,"FreeType2 with TTF support :)");
	F3.PrintfToBitmap(150,500,&Precalculated_Layer,"Written by deroad");

	int frame=0;
	/*
	// Bitmap
	
	GFX->AppStart();
	while(GFX->GetAppStatus()){
		static time_t starttime = 0;
		double fps = 0;
		if (starttime == 0) starttime = time (NULL);
		else fps = frame / difftime (time (NULL), starttime);
		ioPadGetInfo(&padinfo);
		if(padinfo.status[0]){
			ioPadGetData(0, &paddata);
			if(paddata.BTN_CROSS){
				GFX->AppExit();
			}
			if(paddata.BTN_START){
				GFX->AppExit();
				goto end;
			}
		}
		BMap.DrawBitmap(&Precalculated_Layer);
		IMG.DrawIMG(imgX,imgY,png);
		F1.Printf(150,100,COLOR_RED,60,"FPS %f", fps);

		GFX->Flip();
		frame ++;
	}
	*/
	GFX->AppStart();
	while(GFX->GetAppStatus()){
		static time_t starttime = 0;
		double fps = 0;
		if (starttime == 0) starttime = time (NULL);
		else fps = frame / difftime (time (NULL), starttime);
		ioPadGetInfo(&padinfo);
		if(padinfo.status[0]){
			ioPadGetData(0, &paddata);
			if(paddata.BTN_TRIANGLE){
				GFX->AppExit();
			}
			if(paddata.BTN_START){
				GFX->AppExit();
				goto end;
			}
		}
		BG.Mono(0xb4e83a);
		F1.Printf(150,100,COLOR_RED,60,"FPS %f", fps);
		F1.Printf(150,200,COLOR_RED,"Screen %d x %d",GFX->width,GFX->height);
		F1.Printf(150,250,COLOR_BLUE, 35,"Press /\\ to exit! (Start to skip Message Dialogs and exit)");
		F2.Printf(150,300,COLOR_GREEN,60,"FreeType2 with TTF support :)");
		F3.Printf(150,500,"Written by deroad");
		IMG.DrawIMG(imgX,imgY,png);
		GFX->RescaleFlip();
		frame ++;
	}
	if(GFX->ExitSignalStatus()) goto end;

	//You need to clean the Bitmap before exit
	BMap.ClearBitmap(&Precalculated_Layer);

	Msg.TimerErrorDialog(0xdeadbeef, 5000.f);

	Msg.TimerDialog(MSG_OK, "Timer Dialog!", 5000.f);
	Msg.TimerErrorDialog(0xdeadbeef, 5000.f);


	GFX->AppStart();
	frame = 0;
	Msg.SingleProgressBarDialog("Single progress bar!!", "Deroad Bar text");
	while(GFX->GetAppStatus() && Bx<100){
		Msg.ProgressBarDialogFlip();
		frame ++;
		if(frame%55==0){
			Msg.SingleProgressBarDialogIncrease(10);
			Bx+=10;
		}
	}
	Msg.ProgressBarDialogAbort();


	GFX->AppStart();
	Msg.DoubleProgressBarDialog("Double progress bar!!", "Deroad Bar1 text", "Deroad Bar2 text");
	Bx=0;
	By=0;
	while(GFX->GetAppStatus() && By<=100){
		Msg.ProgressBarDialogFlip();
		frame ++;
		if(frame%55==0){
			Bx+=10;
			Msg.DoubleProgressBarDialogIncreaseFirstBar(10);
		 }

		if(Bx>100){
			Bx=0;
			Msg.DoubleProgressBarDialogResetFirstBar();
			Msg.DoubleProgressBarDialogIncreaseSecondBar(20);
			By+=20;
		}
	}
	Msg.ProgressBarDialogAbort();
end:
	GFX->NoRSX_Exit();
	ioPadEnd();
	return 0;
}
Пример #30
0
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;
}