Example #1
0
BOOL System::Update(f32 dt)
{
	UNUSED(dt);

	sysUtilCheckCallback();

	return TRUE;
}
Example #2
0
void NoRSX::Flip(){
	waitFlip();
	memcpy(buffers[currentBuffer].ptr, buffer, buffer_size);
	flip(context, currentBuffer);
	currentBuffer = !currentBuffer;
	setRenderTarget(context, &buffers[currentBuffer]);
	sysUtilCheckCallback();
	return;
}
Example #3
0
void NoRSX::RescaleFlip(){
	waitFlip();
	ResizeBuffer();
	flip(context, currentBuffer);
	currentBuffer = !currentBuffer;
	setRenderTarget(context, &buffers[currentBuffer]);
	sysUtilCheckCallback();
	return;
}
Example #4
0
static void single_bar(char *caption) 
{
    progress_action = 0;

    msgDialogOpen2(mdialogprogress, caption, progress_callback, (void *) 0xadef0044, NULL);
    
    msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0);

    sysUtilCheckCallback();tiny3d_Flip(); 
}
Example #5
0
void showDialog(char* message) {
	appstate = 0;

	msgDialogOpen2(mt_ok, message, dialog_handler, NULL, NULL);

	while(appstate != 1) {
		sysUtilCheckCallback();
		flip();
	}
}
Example #6
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;
}
Example #7
0
void server_loop(void)
{
    int client_connected;
    msgType              dialog_type;
    char                 *message = (char *) malloc(512);

    // did the disc change?
    if (bd_contains_sacd_disc && bd_disc_changed)
    {
        bd_contains_sacd_disc = 0;
    }

    // by default we have no user controls
    dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON);

    if (!bd_contains_sacd_disc)
    {
    	union net_ctl_info info;

    	if(netCtlGetInfo(NET_CTL_INFO_IP_ADDRESS, &info) == 0)
    	{
       		sprintf(message, "              SACD Daemon %s\n\n"
       		                 "Status: Active\n"
       		                 "IP Address: %s (port 2002)\n"
       		                 "Client: %s\n"
       		                 "Disc: %s",
    			SACD_RIPPER_VERSION_STRING, info.ip_address,
    			(is_client_connected() ? "connected" : "none"),
    			(bd_disc_changed == -1 ? "empty" : "inserted"));
    	}
    	else
    	{
    		sprintf(message, "No active network connection was detected.\n\nPress OK to refresh.");
            dialog_type |= MSG_DIALOG_BTN_TYPE_OK;
    	}
    }

    msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL);

    dialog_action         = 0;
    bd_disc_changed       = 0;
    client_connected      = is_client_connected();
    while (!dialog_action && !user_requested_exit() && bd_disc_changed == 0 && client_connected == is_client_connected())
    {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();

    free(message);
}
Example #8
0
void show_version(void)
{
    msgType dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON);
    msgDialogOpen2(dialog_type, "SACD-Ripper, Version " SACD_RIPPER_VERSION_STRING, dialog_handler, NULL, NULL);
    msgDialogClose(5000.0f);

    dialog_action = 0;
    while (!dialog_action && !user_requested_exit())
    {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();
}
Example #9
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;
}
Example #10
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;
}
Example #11
0
int user_select_server_mode(void)
{
	msgType dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_YESNO | MSG_DIALOG_DISABLE_CANCEL_ON);
	msgDialogOpen2(dialog_type, "Would you like to run in server mode?", dialog_handler, NULL, NULL);
    msgDialogClose(5000.0f);

    dialog_action = 0;
    while (!dialog_action && !user_requested_exit())
    {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();

    return dialog_action != 2;
}
Example #12
0
void tiny3d_Flip()
{
    
    tiny3d_End();

    flip(Video_currentBuffer); // Flip buffer onto screen
    tiny3d_WaitRSX();
    Video_currentBuffer = !Video_currentBuffer;
    sysUtilCheckCallback();
    waitFlip();
    

    pos_rsx_vertex = 0;
    current_shader = -1;
    polygon = -1;
    off_head_vertex = off_start_vertex = 0;
    flag_vertex = VERTEX_LOCK;

}
Example #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;
}
Example #14
0
static int check_disc_space(sacd_reader_t *sacd_reader, scarletbook_handle_t *handle, int ripping_flags)
{
    uint64_t needed_sectors = 0;

    if (ripping_flags & RIP_ISO)
    {
        needed_sectors = sacd_get_total_sectors(sacd_reader);
    }
    else if (has_two_channel(handle) && ripping_flags & RIP_2CH)
    {
        needed_sectors = get_two_channel(handle)->track_end - get_two_channel(handle)->track_start;
    }
    else if (has_both_channels(handle) && ripping_flags & RIP_MCH)
    {
        needed_sectors = get_multi_channel(handle)->track_end - get_multi_channel(handle)->track_start;
    }

    if (needed_sectors > output_device_sectors)
    {
        msgType  dialog_type;
        char     *message   = (char *) malloc(512);

        LOG(lm_main, LOG_ERROR, ("no enough disc space on %s (%llu), needs: %llu", output_device, output_device_sectors, needed_sectors));

        snprintf(message, 512, "Ripping aborted.\nYou do not have enough disc space on [%s (%.2fGB available)].", output_device, output_device_space);
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        dialog_action = 0;
        msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL);
        while (!user_requested_exit() && !dialog_action)
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();
        free(message);

        return 0;
    }
    return 1;
}
Example #15
0
void EventHandler::CheckCallBack(){
	sysUtilCheckCallback();
}
Example #16
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;
}
Example #17
0
void
PSL1GHT_PumpEvents(_THIS)
{
    sysUtilCheckCallback();
}
Example #18
0
static void update_bar(u32 cpart)
{
    msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0, (u32) cpart);
    sysUtilCheckCallback();tiny3d_Flip();
}
Example #19
0
int install_modules(void)
{
    msgType dialogType;
    int     installed;

    if (has_all_modules_installed() != 0)
    {
        do
        {
            dialogType = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK);
            msgDialogOpen2(dialogType, "The SACD authentication and DST decoder modules need to be extracted.\n"
                           "Make sure you have the PS3 keys (app-pub-355, iso-iv-355, etc..) in the"
                           " root of an external USB/flash disc."
                           , dialog_handler, NULL, NULL);
            dialog_action = 0;
            while (!dialog_action && !user_requested_exit())
            {
                sysUtilCheckCallback();
                flip();
            }
            msgDialogAbort();

            if (user_requested_exit())
                return 1;

            if (dialog_action != 1)
                return -1;

            installed = (install_sac_module() == 0 && install_decoder_module() == 0);

            if (installed)
            {
                dialogType = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
                msgDialogOpen2(dialogType, "The modules were successfully extracted.", dialog_handler, NULL, NULL);
                dialog_action = 0;
                while (!dialog_action && !user_requested_exit())
                {
                    sysUtilCheckCallback();
                    flip();
                }
                msgDialogAbort();
            }
            else
            {
                dialogType = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK);
                msgDialogOpen2(dialogType, "ERROR: The keys were not found or the modules could not be extracted.\n"
                               "Please try again."
                               , dialog_handler, NULL, NULL);
                dialog_action = 0;
                while (!dialog_action && !user_requested_exit())
                {
                    sysUtilCheckCallback();
                    flip();
                }
                msgDialogAbort();

                if (dialog_action != 1)
                    return -1;
            }
        } while (!installed && !user_requested_exit());
    }

    return 0;
}
Example #20
0
int main(int argc, char *argv[])
{
    int     ret, server_mode;
    void    *host_addr = memalign(1024 * 1024, HOST_SIZE);
    msgType dialog_type;
	sys_ppu_thread_t id; // start server thread

    load_modules();

    init_logging();

	netInitialize();
	netCtlInit();

    // Initialize SPUs
    LOG(lm_main, LOG_DEBUG, ("Initializing SPUs\n"));
    ret = sysSpuInitialize(MAX_PHYSICAL_SPU, MAX_RAW_SPU);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sysSpuInitialize failed: %d\n", ret));
        goto quit;
    }

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

    ret = initialize_exit_handlers();
    if (ret != 0)
        goto quit;

    show_version();

    if (user_requested_exit())
        goto quit;

	u64 CEX=0x4345580000000000ULL;
	u64 DEX=0x4445580000000000ULL;
	u64 DEH=0x4445480000000000ULL;

	if(lv2peek(0x80000000002E79C8ULL)==DEX) {dex_mode=2; c_firmware=3.41f;}
	else
	if(lv2peek(0x80000000002CFF98ULL)==CEX) {dex_mode=0; c_firmware=3.41f;}
	else
	if(lv2peek(0x80000000002EFE20ULL)==DEX) {dex_mode=2; c_firmware=3.55f;}
	else
	if(lv2peek(0x80000000002D83D0ULL)==CEX) {dex_mode=0; c_firmware=3.55f;}
	else
	if(lv2peek(0x8000000000302D88ULL)==DEX) {dex_mode=2; c_firmware=4.21f;}
	else
	if(lv2peek(0x80000000002E8610ULL)==CEX) {dex_mode=0; c_firmware=4.21f;}
	else
	if(lv2peek(0x80000000002E9F08ULL)==CEX) {dex_mode=0; c_firmware=4.30f;}
	else
	if(lv2peek(0x8000000000304630ULL)==DEX) {dex_mode=2; c_firmware=4.30f;}
	else
	if(lv2peek(0x80000000002E9F18ULL)==CEX) {dex_mode=0; c_firmware=4.31f;}
	else
	if(lv2peek(0x80000000002EA488ULL)==CEX) {dex_mode=0; c_firmware=4.40f;}
	else
	if(lv2peek(0x80000000002EA498ULL)==CEX) {dex_mode=0; c_firmware=4.41f;}
	else
	if(lv2peek(0x8000000000304EF0ULL)==DEX) {dex_mode=2; c_firmware=4.41f;}
	else
	if(lv2peek(0x80000000002EA9B8ULL)==CEX) {dex_mode=0; c_firmware=4.46f;}
	else
	if(lv2peek(0x8000000000305410ULL)==DEX) {dex_mode=2; c_firmware=4.46f;}
	else
	if(lv2peek(0x80000000002E9BE0ULL)==CEX) {dex_mode=0; c_firmware=4.50f;}
	else
	if(lv2peek(0x8000000000309698ULL)==DEX) {dex_mode=2; c_firmware=4.50f;}
	else
	if(lv2peek(0x80000000002E9D70ULL)==CEX) {dex_mode=0; c_firmware=4.53f;}
	else
	if(lv2peek(0x80000000002EC5E0ULL)==CEX) {dex_mode=0; c_firmware=4.55f;}
	else
	if(lv2peek(0x80000000002ED850ULL)==CEX) {dex_mode=0; c_firmware=4.60f;}
	else
	if(lv2peek(0x80000000002ED860ULL)==CEX) {dex_mode=0; c_firmware=4.65f;}
	else
	if(lv2peek(0x800000000030F1A8ULL)==DEX) {dex_mode=2; c_firmware=4.65f;}
	else
	if(lv2peek(0x80000000002ED778ULL)==CEX) {dex_mode=0; c_firmware=4.70f;}
	else
	if(lv2peek(0x800000000030F240ULL)==DEX) {dex_mode=2; c_firmware=4.70f;}
	else
	if(lv2peek(0x80000000002ED818ULL)==CEX) {dex_mode=0; c_firmware=4.75f;}
	else
	if(lv2peek(0x800000000030F2D0ULL)==DEX) {dex_mode=2; c_firmware=4.75f;}
	else
	if(lv2peek(0x80000000002ED808ULL)==CEX) {dex_mode=0; c_firmware=4.80f;}
	else
	if(lv2peek(0x800000000030F3A0ULL)==DEX) {dex_mode=2; c_firmware=4.80f;}
	else
	if(lv2peek(0x800000000030F3B0ULL)==DEX) {dex_mode=2; c_firmware=4.81f;}
	else
	if(lv2peek(0x800000000032EB60ULL)==DEH) {deh_mode=2; c_firmware=4.81f;}
	else	
		c_firmware=0.00f;

	if(c_firmware==3.55f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_355D;
	}
	else
	if(c_firmware==3.55f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_355;
	}
	else
	if(c_firmware==4.21f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_421;
	}
	else
	if(c_firmware==4.30f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_430;
	}
	else
	if(c_firmware==4.30f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_430D;
	}
	else
	if(c_firmware==4.31f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_431;
	}
	else
	if(c_firmware==4.40f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_440;
	}
	else
	if(c_firmware==4.41f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_441;
	}
	else
	if(c_firmware==4.41f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_441D;
	}
	else
	if(c_firmware==4.46f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_446;
	}
	else
	if(c_firmware==4.50f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_450;
	}
	else
	if(c_firmware==4.53f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_453;
	}
	else
	if(c_firmware==4.55f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_455;
	}
	else
	if(c_firmware==4.60f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_460;
	}
	else
	if(c_firmware==4.65f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_465;
	}
	else
	if(c_firmware==4.65f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_465D;
	}
	else
	if(c_firmware==4.70f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_470;
	}
	else
	if(c_firmware==4.70f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_470D;
	}
	else
	if(c_firmware==4.75f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_475;
	}
	else
	if(c_firmware==4.80f && !dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_480;
	}
	else
	if(c_firmware==4.80f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_480D;
	}
	else
	if(c_firmware==4.75f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_475D;
	}
	else
	if(c_firmware==4.81f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_481D;
	}
	else
	if(c_firmware==4.46f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_446D;
	}
	else
	if(c_firmware==4.50f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_450D;
	}
	else
	if(c_firmware==4.21f && dex_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_421D;
	}
	else
	if(c_firmware==3.41f)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_341;
	}
	else
	if(c_firmware==4.81f && deh_mode)
	{
		SYSCALL_TABLE			= SYSCALL_TABLE_481H;
	}	
/*
	if(c_firmware>=4.20f && SYSCALL_TABLE)
	{
		// add and enable lv2 peek/poke + lv1 peek/poke
		lv2poke(0x800000000000171CULL,       0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +   8, 0x396000B644000022ULL);
		lv2poke(0x800000000000171CULL +  16, 0x7C832378E8010010ULL);
		lv2poke(0x800000000000171CULL +  24, 0x7C0803A64E800020ULL);
		lv2poke(0x800000000000171CULL +  32, 0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +  40, 0x396000B744000022ULL);
		lv2poke(0x800000000000171CULL +  48, 0x38600000E8010010ULL);
		lv2poke(0x800000000000171CULL +  56, 0x7C0803A64E800020ULL);
		lv2poke(0x800000000000171CULL +  64, 0x7C0802A6F8010010ULL);
		lv2poke(0x800000000000171CULL +  72, 0x7D4B537844000022ULL);
		lv2poke(0x800000000000171CULL +  80, 0xE80100107C0803A6ULL);
		lv2poke(0x800000000000171CULL +  88, 0x4E80002080000000ULL);
		lv2poke(0x800000000000171CULL +  96, 0x0000170C80000000ULL);
		lv2poke(0x800000000000171CULL + 104, 0x0000171480000000ULL);
		lv2poke(0x800000000000171CULL + 112, 0x0000171C80000000ULL);
		lv2poke(0x800000000000171CULL + 120, 0x0000173C80000000ULL);
		lv2poke(0x800000000000171CULL + 128, 0x0000175C00000000ULL);
		lv2poke(SYSCALL_PTR( 6), 0x8000000000001778ULL); //sc6
		lv2poke(SYSCALL_PTR( 7), 0x8000000000001780ULL); //sc7
		lv2poke(SYSCALL_PTR( 8), 0x8000000000001788ULL); //sc8
		lv2poke(SYSCALL_PTR( 9), 0x8000000000001790ULL); //sc9
		lv2poke(SYSCALL_PTR(10), 0x8000000000001798ULL); //sc10
	}*/
    // remove patch protection
	if(c_firmware==3.55f)
	    remove_protection();

	if(c_firmware==0.00f)
		ret = -1;
	else
	    ret = patch_lv1_ss_services();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "ERROR: Couldn't patch lv1 services, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    // patch syscall 864 to allow drive re-init
	if(c_firmware==0.0f)
		ret = -1;
	else
	    ret = patch_syscall_864();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "ERROR: Couldn't patch syscall 864, returning to the XMB.\nMake sure you are running a firmware which allows patching!", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    // install the necessary modules
    ret = install_modules();
    if (ret < 0)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "Installation was aborted, returning to the XMB.", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();

        goto quit;
    }

    if (user_requested_exit())
        goto quit;

    // reset & re-authenticate the BD drive
    sys_storage_reset_bd();
    sys_storage_authenticate_bd();

    // eject current disc
    {
        int fd;
        ret = sys_storage_open(BD_DEVICE, &fd);
        if (ret == 0)
        {
            ioctl_eject(fd);
            sys_storage_close(fd);
        }
    }

    ret = sysDiscRegisterDiscChangeCallback(&bd_eject_disc_callback, &bd_insert_disc_callback);

    // poll for an output_device
    poll_output_devices();

    server_mode = user_select_server_mode();

    if (user_requested_exit())
        goto quit;

    if (server_mode)
    {
#ifdef ENABLE_LOGGING
        if (output_device)
        {
            char file_path[100];
            sprintf(file_path, "%s/daemon_log.txt", output_device);
            set_log_file(file_path);
        }
#endif
    	sysThreadCreate(&id, listener_thread, NULL, 1500, 0x400, 0, "listener");

        while (1)
        {
            // server loop
            server_loop();

            // break out of the loop when requested
            if (user_requested_exit())
                break;
        }
    }
    else
    {
        while (1)
        {
            // main loop
            main_loop();

            // break out of the loop when requested
            if (user_requested_exit())
                break;
        }
    }

    ret = sysDiscUnregisterDiscChangeCallback();

 quit:

    unpatch_lv1_ss_services();

    destroy_logging();
	netDeinitialize();
    unload_modules();

    free(host_addr);

    return 0;
}
Example #21
0
int start_ripping_gui(int ripping_flags)
{
    char *albumdir, *musicfilename, *file_path = 0;
    sacd_reader_t   *sacd_reader;
    scarletbook_handle_t *handle;
    scarletbook_output_t *output;
    msgType          dialog_type;
    int              area_idx, i, ret;

    uint32_t prev_upper_progress = 0;
    uint32_t prev_lower_progress = 0;
    uint32_t delta;

    int prev_current_track = 0;
    uint32_t prev_stats_total_sectors_processed = 0;
    uint32_t prev_stats_current_file_sectors_processed = 0;
    uint64_t tb_start, tb_freq;
    uint64_t tmp_total_ripping_sectors = 0;

    char progress_message[64];

    sysAtomicSet(&stats_total_sectors, 0);
    sysAtomicSet(&stats_total_sectors_processed, 0);
    sysAtomicSet(&stats_current_file_total_sectors, 0);
    sysAtomicSet(&stats_current_file_sectors_processed, 0); 
    sysAtomicSet(&stats_current_track, 0);
    sysAtomicSet(&stats_total_tracks, 0);

    sacd_reader = sacd_open("/dev_bdvd");
    if (sacd_reader) 
    {
        handle = scarletbook_open(sacd_reader, 0);

        if (check_disc_space(sacd_reader, handle, ripping_flags))
        {
            ret = sacd_authenticate(sacd_reader);
            if (ret != 0)
            {
                LOG(lm_main, LOG_ERROR, ("authentication failed: %x", ret));
            }

            // select the channel area
            area_idx = ((has_multi_channel(handle) && ripping_flags & RIP_MCH) || !has_two_channel(handle)) ? handle->mulch_area_idx : handle->twoch_area_idx;

            albumdir = get_album_dir(handle);

            output = scarletbook_output_create(handle, handle_status_update_track_callback, handle_status_update_progress_callback, safe_fwprintf);

            if (ripping_flags & RIP_ISO)
            {
                #define FAT32_SECTOR_LIMIT 2090000
                uint32_t total_sectors = sacd_get_total_sectors(sacd_reader);
                uint32_t sector_size = FAT32_SECTOR_LIMIT;
                uint32_t sector_offset = 0;
                if (total_sectors > FAT32_SECTOR_LIMIT)
                 {
                    musicfilename = (char *) malloc(512);
                    file_path = make_filename(output_device, 0, albumdir, "iso");
                    for (i = 1; total_sectors != 0; i++)
                    {
                        sector_size = min(total_sectors, FAT32_SECTOR_LIMIT);
                        snprintf(musicfilename, 512, "%s.%03d", file_path, i);
                        scarletbook_output_enqueue_raw_sectors(output, sector_offset, sector_size, musicfilename, "iso");
                        sector_offset += sector_size;
                        total_sectors -= sector_size;
                    }
                    free(file_path);
                    free(musicfilename);
                }
                else
                {
                    file_path = make_filename(output_device, 0, albumdir, "iso");
                    scarletbook_output_enqueue_raw_sectors(output, 0, total_sectors, file_path, "iso");
                    free(file_path);
                }
                tmp_total_ripping_sectors = sacd_get_total_sectors(sacd_reader);
            }
            else 
            {
                // do not overwrite previous dump
                get_unique_dir(output_device, &albumdir);

                // fill the queue with items to rip
                for (i = 0; i < handle->area[area_idx].area_toc->track_count; i++) 
                {
                    musicfilename = get_music_filename(handle, area_idx, i, 0);
                    if (ripping_flags & RIP_DSF)
                    {
                        file_path = make_filename(output_device, albumdir, musicfilename, "dsf");
                        scarletbook_output_enqueue_track(output, area_idx, i, file_path, "dsf", 
                            1 /* always decode to DSD */);
                    }
                    else if (ripping_flags & RIP_DSDIFF)
                    {
                        file_path = make_filename(output_device, albumdir, musicfilename, "dff");
                        scarletbook_output_enqueue_track(output, area_idx, i, file_path, "dsdiff", 
                            ((ripping_flags & RIP_2CH_DST || ripping_flags & RIP_MCH_DST) ? 0 : 1));
                    }

                    tmp_total_ripping_sectors += handle->area[area_idx].area_tracklist_offset->track_length_lsn[i];

                    free(musicfilename);
                    free(file_path);
                }

                file_path = make_filename(output_device, albumdir, 0, 0);
                LOG(lm_main, LOG_NOTICE, ("setting output folder to: %s", file_path));
                recursive_mkdir(file_path, 0777);
                free(file_path);
            }

            scarletbook_output_start(output);

            tb_freq = sysGetTimebaseFrequency();
            tb_start = __gettime(); 

            {
                char *message = (char *) malloc(512);

                file_path = make_filename(output_device, albumdir, 0, 0);
                snprintf(message, 512, "Title: %s\nOutput: %s\nFormat: %s\nSize: %.2fGB\nArea: %s\nEncoding: %s", 
                        substr(albumdir, 0, 100), 
                        file_path, 
                        (ripping_flags & RIP_DSDIFF ? "DSDIFF" : (ripping_flags & RIP_DSF ? "DSF" : "ISO")),
                        ((double) ((tmp_total_ripping_sectors * SACD_LSN_SIZE) / 1073741824.00)),
                        (ripping_flags & RIP_2CH ? "2ch" : "mch"),
                        (ripping_flags & RIP_2CH_DST || ripping_flags & RIP_MCH_DST ? "DST" : (ripping_flags & RIP_ISO ? "DECRYPTED" : "DSD"))
                        );
                free(file_path);

                dialog_action = 0;
                dialog_type   = MSG_DIALOG_MUTE_ON | MSG_DIALOG_DOUBLE_PROGRESSBAR;
                msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL);
                while (!user_requested_exit() && dialog_action == 0 && scarletbook_output_is_busy(output))
                {
                    uint32_t tmp_stats_total_sectors_processed = sysAtomicRead(&stats_total_sectors_processed);
                    uint32_t tmp_stats_total_sectors = sysAtomicRead(&stats_total_sectors);
                    uint32_t tmp_stats_current_file_sectors_processed = sysAtomicRead(&stats_current_file_sectors_processed);
                    uint32_t tmp_stats_current_file_total_sectors = sysAtomicRead(&stats_current_file_total_sectors);
                    int tmp_current_track = sysAtomicRead(&stats_current_track);

                    if (tmp_current_track != 0 && tmp_current_track != prev_current_track)
                    {
                        memset(progress_message, 0, 64);
       
                        musicfilename = get_music_filename(handle, area_idx, tmp_current_track - 1, 0);
                        // HACK: substr is not thread safe, but it's only used in this thread..
                        snprintf(progress_message, 63, "Track (%d/%d): [%s...]", tmp_current_track, sysAtomicRead(&stats_total_tracks), substr(musicfilename, 0, 40));
                        free(musicfilename);

                        msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0);
                        msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1, progress_message);
                        prev_upper_progress = 0;
                        prev_stats_current_file_sectors_processed = 0;

                        prev_current_track = tmp_current_track;
                    }

                    if (tmp_stats_total_sectors != 0 && prev_stats_total_sectors_processed != tmp_stats_total_sectors_processed)
                    {
                        delta = (tmp_stats_current_file_sectors_processed + (tmp_stats_current_file_sectors_processed - prev_stats_current_file_sectors_processed)) * 100 / tmp_stats_current_file_total_sectors - prev_upper_progress;
                        prev_upper_progress += delta;
                        msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0, delta);

                        delta = (tmp_stats_total_sectors_processed + (tmp_stats_total_sectors_processed - prev_stats_total_sectors_processed)) * 100 / tmp_stats_total_sectors - prev_lower_progress;
                        prev_lower_progress += delta;
                        msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX1, delta);

                        snprintf(progress_message, 64, "Ripping %.1fMB/%.1fMB at %.2fMB/sec", 
                                ((float)(tmp_stats_current_file_sectors_processed * SACD_LSN_SIZE) / 1048576.00),
                                ((float)(tmp_stats_current_file_total_sectors * SACD_LSN_SIZE) / 1048576.00),
                                (float)((float) tmp_stats_total_sectors_processed * SACD_LSN_SIZE / 1048576.00) / (float)((__gettime() - tb_start) / (float)(tb_freq)));
                        
                        msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0, progress_message);
                        
                        prev_stats_total_sectors_processed = tmp_stats_total_sectors_processed;
                        prev_stats_current_file_sectors_processed = tmp_stats_current_file_sectors_processed;
                    }

                    sysUtilCheckCallback();
                    flip();
                }
                msgDialogAbort();
                free(message);
            }
            free(albumdir);

            scarletbook_output_destroy(output);
        }
        scarletbook_close(handle);
    }
    sacd_close(sacd_reader);

    if (user_requested_exit())
    {
        return 0;
    }
    else if (1)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
        msgDialogOpen2(dialog_type, "ripping process completed.", dialog_handler, NULL, NULL);

        dialog_action = 0;
        while (!dialog_action && !user_requested_exit())
        {
            sysUtilCheckCallback();
            flip();
        }
        msgDialogAbort();
    }

    return 0;
}
Example #22
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;
}
Example #23
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;
}
Example #24
0
void main_loop(void)
{
    msgType              dialog_type;
    char                 *message = (char *) malloc(512);
    sacd_reader_t        *sacd_reader;
    scarletbook_handle_t *sb_handle = 0;
    int idx = 0;

    if (output_device_changed && output_device)
    {
        char file_path[100];
        sprintf(file_path, "%s/sacd_log.txt", output_device);
        set_log_file(file_path);
        LOG(lm_main, LOG_NOTICE, ("SACD-Ripper Version " SACD_RIPPER_VERSION_STRING));
    }

    // did the disc change?
    if (bd_contains_sacd_disc && bd_disc_changed)
    {
        // open the BD device
        sacd_reader = sacd_open("/dev_bdvd");
        if (sacd_reader)
        {
            // read the scarletbook information
            sb_handle = scarletbook_open(sacd_reader, 0);
            if (sb_handle)
            {
                master_text_t *master_text = &sb_handle->master_text;
                master_toc_t *mtoc = sb_handle->master_toc;

                if (master_text->disc_title || master_text->disc_title_phonetic)
                {
                    idx += snprintf(message_info + idx, 60, "Title: %s\n", substr((master_text->disc_title ? master_text->disc_title : master_text->disc_title_phonetic), 0, 50));
                    LOG(lm_main, LOG_NOTICE, ("Album Title: %s", substr((master_text->disc_title ? master_text->disc_title : master_text->disc_title_phonetic), 0, 50)));
                }

                if (message_info[idx - 1] != '\n') { message_info[idx++] = '\n'; message_info[idx] = '\0'; }

                if (master_text->disc_artist || master_text->disc_artist_phonetic)
                {
                    idx += snprintf(message_info + idx, 60, "Artist: %s\n", substr((master_text->disc_artist ? master_text->disc_artist : master_text->disc_artist_phonetic), 0, 50));
                    LOG(lm_main, LOG_NOTICE, ("Album Artist: %s", substr((master_text->disc_artist ? master_text->disc_artist : master_text->disc_artist_phonetic), 0, 50)));
                }

                if (message_info[idx - 1] != '\n') { message_info[idx++] = '\n'; message_info[idx] = '\0'; }

                idx += snprintf(message_info + idx, 20, "Version: %02i.%02i\n", mtoc->version.major, mtoc->version.minor);
                LOG(lm_main, LOG_NOTICE, ("Disc Version: %02i.%02i\n", mtoc->version.major, mtoc->version.minor));
                idx += snprintf(message_info + idx, 25, "Created: %4i-%02i-%02i\n", mtoc->disc_date_year, mtoc->disc_date_month, mtoc->disc_date_day);

                idx += snprintf(message_info + idx, 15, "Area 0:\n");
                idx += snprintf(message_info + idx, 35, "   Speakers: %s\n", get_speaker_config_string(sb_handle->area[0].area_toc));
                idx += snprintf(message_info + idx, 35, "   Encoding: %s\n", get_frame_format_string(sb_handle->area[0].area_toc));
                idx += snprintf(message_info + idx, 25, "   Tracks: %d (%.2fGB)\n", sb_handle->area[0].area_toc->track_count, ((double) (sb_handle->area[0].area_toc->track_end - sb_handle->area[0].area_toc->track_start) * SACD_LSN_SIZE) / 1073741824.00);
                if (has_both_channels(sb_handle))
                {
                    idx += snprintf(message_info + idx, 2, "\n");
                    idx += snprintf(message_info + idx, 15, "Area 1:\n");
                    idx += snprintf(message_info + idx, 35, "   Speakers: %s\n", get_speaker_config_string(sb_handle->area[1].area_toc));
                    idx += snprintf(message_info + idx, 35, "   Encoding: %s\n", get_frame_format_string(sb_handle->area[1].area_toc));
                    idx += snprintf(message_info + idx, 25, "   Tracks: %d (%.2fGB)\n", sb_handle->area[1].area_toc->track_count, ((double) (sb_handle->area[1].area_toc->track_end - sb_handle->area[1].area_toc->track_start) * SACD_LSN_SIZE) / 1073741824.00);
                }

                idx += snprintf(message_info + idx, 50, "\nclick X to start ripping, O to change output");

                current_ripping_flags = 0;
                if (has_two_channel(sb_handle))
                {
                    current_ripping_flags |= RIP_2CH;
                    if (sb_handle->area[sb_handle->twoch_area_idx].area_toc->frame_format == FRAME_FORMAT_DST)
                    {
                        current_ripping_flags |= RIP_2CH_DST;
                    }
                }
                if (has_multi_channel(sb_handle))
                {
                    current_ripping_flags |= RIP_MCH;
                }

                // validate output format as the ripping flags have changed
                output_format_changed = 1;
                validate_output_format();

                scarletbook_close(sb_handle);
                sb_handle = 0;
            }
            else
            {
                bd_contains_sacd_disc = 0;
            }

            // close the input device asap
            sacd_close(sacd_reader);
            sacd_reader = 0;
        }
        else
        {
            bd_contains_sacd_disc = 0;
        }
    }

    if (output_device_changed || output_format_changed)
    {
        // output device
        if (output_device)
            idx = snprintf(message_output, 35, "Output: %s %.2fGB\n", output_device, output_device_space);
        else
            idx = snprintf(message_output, 35, "Output: NO DEVICE\n");

        // output format
        idx += snprintf(message_output + idx, 20, "Format: ");

        switch (output_format)
        {
        case 0:
            idx += snprintf(message_output + idx, 20, "2ch DSDIFF (DSD)\n");
            break;
        case 1:
            idx += snprintf(message_output + idx, 20, "2ch DSDIFF (DST)\n");
            break;
        case 2:
            idx += snprintf(message_output + idx, 20, "2ch DSF (DSD)\n");
            break;
        case 3:
            idx += snprintf(message_output + idx, 20, "mch DSDIFF (DSD)\n");
            break;
        case 4:
            idx += snprintf(message_output + idx, 20, "mch DSDIFF (DST)\n");
            break;
        case 5:
            idx += snprintf(message_output + idx, 20, "mch DSF (DSF)\n");
            break;
        case 6:
            idx += snprintf(message_output + idx, 20, "ISO\n");
            break;
        }
        idx += snprintf(message_output + idx, 2, "\n");
    }

    // by default we have no user controls
    dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON);

    if (bd_contains_sacd_disc)
    {
        snprintf(message, 512, "%s%s", message_output, message_info);
    }
    else
    {
        snprintf(message, 512, "The current disc is empty or not recognized as an SACD, please re-insert.\n\n%s"
                 , (output_device ? "" : "(Also make sure you connect an external fat32 formatted harddisk!)"));
    }

    // can we start ripping?
    if (bd_contains_sacd_disc)
    {
        dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK);
    }

    msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL);

    dialog_action         = 0;
    bd_disc_changed       = 0;
    output_device_changed = 0;
    output_format_changed = 0;
    while (!dialog_action && !user_requested_exit() && bd_disc_changed == 0 && output_device_changed == 0)
    {
        // poll for new output devices
        poll_output_devices();

        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();

    // did user request to start the ripping process?
    if (dialog_action == 1 && bd_contains_sacd_disc)
    {
        start_ripping_gui(output_format_options[output_format]);

        reset_output_devices();

        // action is handled
        dialog_action = 0;
    }
    else if (dialog_action == 2)
    {
#if 0
        output_format++;

        // max of 7 output options
        if (output_format > 6)
        {
            output_format = 0;
        }
#endif

        // is the current selection valid?
        validate_output_format();

        // action is handled
        output_format_changed = 1;
        dialog_action = 0;
    }

    free(message);
}