예제 #1
0
파일: video.c 프로젝트: an0nym0u5/PSL1GHT
void
videoFinish ( videoData *vdata )
{
  dbgprintf ( "video finishing" ) ;

  static s32 i ;
  /* make sure no flip is in progress */
  gcmSetWaitFlip ( vdata->context ) ;

  /* free rsx buffers */
  for ( i = 0 ; i < MAX_BUFFERS ; i++ )
  {
    rsxFree ( vdata->rsx_buffers[i].ptr ) ;
  }

  /* finish rsx context */
  rsxFinish ( vdata->context, 1 ) ;

  /* free host_addr memory */
  free ( vdata->host_addr ) ;

  /* destroy semaphore */
  sysSemDestroy ( vdata->sem ) ;

  /* destroy cond */
  sysCondDestroy ( vdata->cond ) ;

  /* destroy mutex */
  sysMutexDestroy ( vdata->mutex ) ;
}
예제 #2
0
파일: main.cpp 프로젝트: Estwald/PSDK3v2
void program_exit_callback()
{
    gcmSetWaitFlip(context);
    rsxFinish(context,1);

    shutdown_spu();
}
예제 #3
0
파일: rsxutil.c 프로젝트: Estwald/PSDK3v2
int
initScreen (void *host_addr, u32 size)
{
  // gcmContextData *context = NULL; /* Context to keep track of the RSX
  // buffer. */
  videoState state;
  videoConfiguration vconfig;
  videoResolution res;		/* Screen Resolution */

  /* Initilise Reality, which sets up the command buffer and shared IO memory */
  context = rsxInit (CB_SIZE, size, host_addr);
  if (context == NULL)
    goto error;

  /* Get the state of the display */
  if (videoGetState (0, 0, &state) != 0)
    goto error;

  /* Make sure display is enabled */
  if (state.state != 0)
    goto error;

  /* Get the current resolution */
  if (videoGetResolution (state.displayMode.resolution, &res) != 0)
    goto error;

  /* Configure the buffer format to xRGB */
  memset (&vconfig, 0, sizeof (videoConfiguration));
  vconfig.resolution = state.displayMode.resolution;
  vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
  vconfig.pitch = res.width * sizeof (u32);
  vconfig.aspect = state.displayMode.aspect;

  waitRSXIdle (context);

  if (videoConfigure (0, &vconfig, NULL, 0) != 0)
    goto error;

  if (videoGetState (0, 0, &state) != 0)
    goto error;

  gcmSetFlipMode (GCM_FLIP_VSYNC);	// Wait for VSYNC to flip

  depth_pitch = res.width * sizeof (u32);
  depth_buffer = (u32 *) rsxMemalign (64, (res.height * depth_pitch) * 2);
  rsxAddressToOffset (depth_buffer, &depth_offset);

  gcmResetFlipStatus ();

  return 0;

  error:
  if (context)
    rsxFinish (context, 0);

  if (host_addr)
    free (host_addr);

  return 1;
}
예제 #4
0
파일: main.c 프로젝트: Noltari/BDEMUPatcher
int main() {
	sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, sysutil_callback, NULL);

	void *host_addr = memalign(1024*1024, HOST_SIZE);
	init_screen(host_addr, HOST_SIZE);

	setRenderTarget(curr_fb);

	int payload = payload_status();
	/*
	char dlgmsg[256];
	sprintf(dlgmsg, "Payload: %d", payload);
	showDialog(dlgmsg);
	*/
	if(payload == ZERO_PAYLOAD) {
		s32 fd = 0;
		int bdemu = bdemu_version(&fd);

		if(bdemu == 0) {
			//Wrong or inexistent file.
			lv2buzzer(0x1004, 0xa, 0x1b6);
			showDialog("Couldn't find correct \"BDEMU.BIN\".");
		}
		else {
			int fw_version = get_version();

			if(fw_version == FW_355_VALUE) {
				if(bdemu == 2) {
					payload_sky(fd);
				}
				else {
					payload_dean(fd);
				}
			}
			else if(fw_version == FW_341_VALUE && bdemu == 2) {
				payload_hermes(fd);
			}
			else {
				lv2buzzer(0x1004, 0xa, 0x1b6);
				showDialog("BDEMU.BIN doesn't suppoort your firmware.");
			}
		}
	}

	msgDialogAbort();

	gcmSetWaitFlip(context);
	rsxFinish(context, 1);

	//Launch Application on exit.
	sysProcessExitSpawn2(APP_LAUNCH, NULL, NULL, NULL, 0, 1001, SYS_PROCESS_SPAWN_STACK_SIZE_1M);

	return 0;
}
예제 #5
0
파일: NoRSX.cpp 프로젝트: wargio/NoRSX
void NoRSX::NoRSX_Exit(){
	gcmSetWaitFlip(context);
	for (int i=0;i<2;i++)
		rsxFree (buffers[i].ptr);
	rsxFree(buffer);
	rsxFinish (context, 1);
	free (host_addr);
	UnregisterCallBack(EVENT_SLOT0);
	already_done=1;
	return;
}
예제 #6
0
void
endScreen ()
{
  int i;

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

  rsxFinish (context, 1);
  free (host_addr);
}
예제 #7
0
파일: main.cpp 프로젝트: Estwald/PSDK3v2
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
파일: main.c 프로젝트: an0nym0u5/PSL1GHT
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;
}
예제 #9
0
파일: main.c 프로젝트: Noltari/PS3Samples
int main(s32 argc, const char* argv[]) {
	//Mutex.
	sys_mutex_attr_t attr;
	memset(&attr, 0, sizeof(attr));
	attr.attr_protocol = SYS_MUTEX_PROTOCOL_FIFO;
	attr.attr_recursive = SYS_MUTEX_ATTR_NOT_RECURSIVE;
	attr.attr_pshared = SYS_MUTEX_ATTR_PSHARED;
	attr.attr_adaptive = SYS_MUTEX_ATTR_NOT_ADAPTIVE;
	strcpy(attr.name, "mutex");
	sysMutexCreate(&thread_mutex, &attr);

	//Threads.
	THREADS_RUNNING = 2;
	sys_ppu_thread_t pad_id, program_id;
	sysThreadCreate(&pad_id, pad_thread, (void*) &GLOBAL_EXIT, 1500, 0x400, 0, "pad");
	sysThreadCreate(&program_id, program_thread, (void*) &GLOBAL_EXIT, 1337, 0x400, 0, "program");

	//Create buffers.
	gcmContextData *context;
	void *host_addr = NULL;
	rsxBuffer buffers[MAX_BUFFERS];
	int currentBuffer = 0;

	//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);

	//Get resolution.
	u16 width, height;
	getResolution(&width, &height);

	//Create buffers.
	int i;
	for(i = 0; i < MAX_BUFFERS; i++) {
		makeBuffer(&buffers[i], width, height, i);
	}
	flip(context, MAX_BUFFERS - 1);

	//Main loop.
	while(THREADS_RUNNING > 0) {
		//Prepare buffer.
		setRenderTarget(context, &buffers[currentBuffer]);
		waitFlip();

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

		//Change buffer.
		currentBuffer++;
		if(currentBuffer >= MAX_BUFFERS) {
			currentBuffer = 0;
		}
	}

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

	//Mutex destroy.
	sysMutexDestroy(thread_mutex);

	return 0;
}
예제 #10
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;
}