Example #1
0
BOOL System::Initialize()
{
	Log(TAG "Initializing...");
	iFrameRate = pConfiguration->GetFrameRate();

	sysUtilRegisterCallback(0, sysutil_exit_callback, this);

	Log(TAG "Initialization completed.");
	return TRUE;
}
Example #2
0
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;
}
Example #3
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 #4
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 #5
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 #6
0
/* init event handler */
void
eventInitialization ( eventData *edata )
{
  dbgprintf ( "initializing" ) ;

  /* initialize variables */
  edata->menu = 1 ;
  edata->exitapp = 1 ;
  edata->xmbopen = 0 ;

  /* initialize semaphore attributes */
  edata->sem_attr.key            = 0x03 ;
  edata->sem_attr.attr_protocol  = SYS_SEM_ATTR_PROTOCOL ;
  edata->sem_attr.attr_pshared   = SYS_SEM_ATTR_PSHARED ;

  /* initialize mutex attributes */
  edata->mutex_attr.key              = 0x03 ;
  edata->mutex_attr.attr_protocol    = SYS_MUTEX_PROTOCOL_FIFO ;
  edata->mutex_attr.attr_pshared     = SYS_MUTEX_ATTR_PSHARED ;
  edata->mutex_attr.attr_recursive   = SYS_MUTEX_ATTR_RECURSIVE ;
  edata->mutex_attr.attr_adaptive    = SYS_MUTEX_ATTR_ADAPTIVE ;

  /* initialize condition attributes */
  edata->cond_attr.key               = 0x03 ;
  edata->cond_attr.attr_pshared      = SYS_COND_ATTR_PSHARED ;

  /* create semaphore */
  sysSemCreate ( &edata->sem, &edata->sem_attr, 1, SEM_CONSUMERS ) ;

  /* create mutex */
  sysMutexCreate ( &edata->mutex, &edata->mutex_attr ) ;

  /* create cond */
  sysCondCreate ( &edata->cond, edata->mutex, &edata->cond_attr ) ;

  /* register eventHandler */
  sysUtilRegisterCallback ( SYSUTIL_EVENT_SLOT0, eventHandler, edata ) ;

  dbgprintf ( "initialized" ) ;
}
Example #7
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 #8
0
void EventHandler::RegisterCallBack(s32 SLOT){
	sysUtilRegisterCallback(SLOT , EvHandler, NULL);
}
Example #9
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 #10
0
void
PSL1GHT_InitSysEvent(_THIS)
{
    sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandle, _this);
}
Example #11
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;
}
Example #12
0
int tiny3d_Init(u32 vertex_buff_size)
{
    static int inited= 0;

    int n;
    
    int use_Z32 = 1;

    if(vertex_buff_size & TINY3D_Z16) use_Z32 = 0;

    vertex_buff_size &= 0x3fffffff;

    flag_vertex = VERTEX_LOCK;

    if(inited) return TINY3D_CANNOTINIT;

    inited = 1;

    if(vertex_buff_size <= 1024*1024) vertex_buff_size = 1024*1024;
    
    size_rsx_vertex = vertex_buff_size;

    init_screen(1024*1024*2, use_Z32);

    CtrlReg = gcmGetControlRegister();
    
    n = 0;

    while(fpshader_list[n]) {

        // install fragments shaders in rsx memory
        u32 *frag_mem = rsxMemalign(256, (((realityFragmentProgram_internal *) fpshader_list[n])->size * 4 + 255) & ~255);
    
        if(!frag_mem) return TINY3D_OUTMEMORY;

        internal_reality_InstallFragmentProgram(context, fpshader_list[n], frag_mem);
        
        n++;
    }

    // shaders datas
    for(n = 0; n < 12; n++) {
        data_shader[n].off_project  = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*)       vshader_text_normal_bin, "ProjMatrix");
        data_shader[n].off_modelv   = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*)       vshader_text_normal_bin, "WorldMatrix");
        data_shader[n].off_position = internal_reality_VertexProgramGetInputAttribute((internal_reality_VertexProgram*) vshader_text_normal_bin, "inputvertex.vertex");
        data_shader[n].off_texture  = internal_reality_VertexProgramGetInputAttribute((internal_reality_VertexProgram*) vshader_text_normal_bin, "inputvertex.texcoord");
        data_shader[n].off_texture2 = internal_reality_VertexProgramGetInputAttribute((internal_reality_VertexProgram*) vshader_text_normal_bin, "inputvertex.texcoord2");
        data_shader[n].off_color    = internal_reality_VertexProgramGetInputAttribute((internal_reality_VertexProgram*) vshader_text_normal_bin, "inputvertex.color");
        data_shader[n].off_normal   = internal_reality_VertexProgramGetInputAttribute((internal_reality_VertexProgram*) vshader_text_normal_bin, "inputvertex.normal");
        data_shader[n].vp           = (void *) vshader_text_normal_bin;
        data_shader[n].fp_alt[0]    = (void *) NULL;
        data_shader[n].fp_alt[1]    = (void *) NULL;
        data_shader[n].fp_yuv[0]    = (void *) NULL;
        data_shader[n].fp_yuv[1]    = (void *) NULL;

        data_shader[n].off_lightAmbient   = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "lightAmbient");
        data_shader[n].off_lightColor     = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "lightColor");
        data_shader[n].off_lightPosition  = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "lightPosition");
        data_shader[n].off_cameraPosition = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "CameraPosition");
        data_shader[n].off_emissive       = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "Memissive");
        data_shader[n].off_ambient        = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "Mambient");
        data_shader[n].off_diffuse        = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "Mdiffuse");
        data_shader[n].off_specular       = internal_reality_VertexProgramGetConstant((internal_reality_VertexProgram*) vshader_text_normal_bin, "Mspecular");

        data_shader[n].fixed_color = 0;
    }
    
    data_shader[0].off_texture  = -1; // colorf
    data_shader[0].off_texture2 = -1;
    data_shader[0].off_normal   = -1;
    data_shader[0].fp           = &nv30_fp_color;
    data_shader[0].size_vertex  = 16+16;

    data_shader[1].fixed_color  = 1; // colori
    data_shader[1].off_texture  = -1;
    data_shader[1].off_texture2 = -1;
    data_shader[1].off_normal   = -1;
    data_shader[1].fp           = &nv30_fp_color;
    data_shader[1].size_vertex  = 16+4;

    data_shader[2].off_texture2 = -1; // texture
    data_shader[2].off_color    = -1;
    data_shader[2].off_normal   = -1;
    data_shader[2].fp           = &nv30_fp_texture;
    data_shader[2].fp_yuv[0]    = &nv30_fp_yuv;
    data_shader[2].fp_yuv[1]    = &nv30_fp_yuv8;
    data_shader[2].size_vertex  = 16+8;

    data_shader[3].off_color    = -1; // texture + texture2
    data_shader[3].off_normal   = -1;
    data_shader[3].fp           = &nv30_fp_texture2;
    data_shader[3].fp_alt[0]    = &nv30_fp_texture2_alt;
    data_shader[3].fp_alt[1]    = &nv30_fp_texture2_alt2;
    data_shader[3].size_vertex  = 16+8+8;

    data_shader[4].off_texture2 = -1; // texture + colorf
    data_shader[4].off_normal   = -1;
    data_shader[4].fp           = &nv30_fp_texture_color;
    data_shader[4].fp_yuv[0]    = &nv30_fp_yuv_color;
    data_shader[4].fp_yuv[1]    = &nv30_fp_yuv_color8;
    data_shader[4].size_vertex  = 16+16+8;

    data_shader[5].off_normal   = -1; // texture + texture2 + colorf
    data_shader[5].fp           = &nv30_fp_texture_color2;
    data_shader[5].fp_alt[0]    = &nv30_fp_texture_color2_alt;
    data_shader[5].fp_alt[1]    = &nv30_fp_texture_color2_alt2;
    data_shader[5].size_vertex  = 16+16+8+8;
    
    data_shader[6].fixed_color  = 1; // texture + colori
    data_shader[6].off_texture2 = -1;
    data_shader[6].off_normal   = -1;
    data_shader[6].fp           = &nv30_fp_texture_color;
    data_shader[6].fp_yuv[0]    = &nv30_fp_yuv_color;
    data_shader[6].fp_yuv[1]    = &nv30_fp_yuv_color8;
    data_shader[6].size_vertex  = 16+4+8;
    
    data_shader[7].fixed_color  = 1; // texture + texture2 + colori
    data_shader[7].off_normal   = -1;
    data_shader[7].fp           = &nv30_fp_texture_color2;
    data_shader[7].fp_alt[0]    = &nv30_fp_texture_color2_alt;
    data_shader[7].fp_alt[1]    = &nv30_fp_texture_color2_alt2;
    data_shader[7].size_vertex  = 16+4+8+8;

    data_shader[8].off_texture  = -1; // normal
    data_shader[8].off_texture2 = -1;
    data_shader[8].off_color    = -1;
    data_shader[8].fp           = &nv30_fp_color;
    data_shader[8].size_vertex  = 16+12;

    data_shader[9].off_texture2 = -1; // normal + texture
    data_shader[9].off_color    = -1;
    data_shader[9].fp           = &nv30_fp_texture_color;
    data_shader[9].size_vertex  = 16+12+8;

    data_shader[10].off_color    = -1; // normal + texture + texture2
    data_shader[10].fp           = &nv30_fp_texture_color2;
    data_shader[10].fp_alt[0]    = &nv30_fp_texture_color2_alt;
    data_shader[10].fp_alt[1]    = &nv30_fp_texture_color2_alt2;
    data_shader[10].size_vertex  = 16+12+8+8;

    current_shader = -1;

    rsx_vertex = rsxMemalign(64, vertex_buff_size);

    pos_rsx_vertex = 0;

    polygon = -1;
    off_head_vertex = off_start_vertex = 0;

    sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT3);
    sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT3, tiny3d_callback, NULL);
    
    return TINY3D_OK;
}