Esempio n. 1
0
static int load_modules(void)
{
    int ret;

    ret = sysModuleLoad(SYSMODULE_FS);
    if (ret != 0)
        return ret;
    else
        loaded_modules |= 1;

    ret = sysModuleLoad(SYSMODULE_IO);
    if (ret != 0)
        return ret;
    else
        loaded_modules |= 2;

    ret = sysModuleLoad(SYSMODULE_GCM_SYS);
    if (ret != 0)
        return ret;
    else
        loaded_modules |= 4;

    return ret;
}
Esempio n. 2
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;
}
Esempio n. 3
0
int PS3_initialize(void)
{
	s32 ret,i;
	void *host_addr = memalign(1024*1024, HOST_SIZE);
	s32 pressedCounter = 0;
	Matrix4 rotX,rotY;
	
	sysModuleLoad(SYSMODULE_FS);
	ioPadInit(7);

	write_log("PS3_initialize...\n");
	int videoMode = getVideoMode();
	init_screen(host_addr, HOST_SIZE, videoMode);

	init_shader();
	
	//init_texture();
	//init_texture_ui();

	quad = createQuad(10.0f, 0.0f);
	quad_ui = createQuad(10.0f, 0.5f);

	rotX = Matrix4::rotationX(DEGTORAD(0.0f));
	rotY = Matrix4::rotationY(DEGTORAD(180.0f));
	modelMatrixBase = rotX * rotY;
	modelMatrixUi = rotX * rotY;
	modelMatrix = rotX * rotY;

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

	P = transpose(Matrix4::orthographic(-5.0f, 5.0f, -5.0f, 5.0f, -10.0f, 10.0f));

	// by default sretch video to 90% of the screen in X axis (compensate output to wide screens)
	scaler.setX(1.0f);
	scaler.setY(1.0f);
	scaler.setZ(1.0f);

	translator.setX(0.0f);
	translator.setY(0.0f);
	translator.setZ(0.0f);

	setRenderTarget(curr_fb);

	scanline.setX(200.0f);		//desnity
	scanline.setY(2.0f);		//contrast
	scanline.setZ(0.7f);		//brightnes
	scanline.setW(0.1f);		//scanline type -> horizontal lines

	scanlineUi.setX(0);			//no desnsity modifier
	scanlineUi.setY(0);			//no contrast modifier
	scanlineUi.setZ(1.0f);		//full brightnes
	scanlineUi.setW(0.0f);		//scanline type -> no scanlines

	running = 1;

	masterVolume = 32768.0f * 2.8f; // 80%
	volumeMuted = 0;

	return 0;
}
Esempio n. 4
0
s32 main(s32 argc, const char* argv[])
{
	padInfo padinfo;
	padData paddata;
	int i;
    int frame = 0;
	
	tiny3d_Init(1024*1024);

	ioPadInit(7);
    
    sysModuleLoad(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,
            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);


        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;
}