Esempio n. 1
0
//**********************************************************************************
//	
//**********************************************************************************
void	CTexture::Upload()
{
//	Swizzle();

	sceGuStart( GU_DIRECT, CGfx::GetDrawList() );

	sceGuCopyImage( GU_PSM_8888, 0, 0, m_nWidth, m_nHeight, m_nCanvasWidth, m_pBuffer, 0, 0, m_nCanvasWidth, s_pVRAM );

	sceGuFinish();
	sceGuSync( 0, 0 );

	m_pVRAM = s_pVRAM;

	s_pVRAM += m_nCanvasWidth * m_nHeight * 4;
}
Esempio n. 2
0
static void psp_set_texture_frame(void *data, const void *frame, bool rgb32,
                               unsigned width, unsigned height, float alpha)
{
   psp1_video_t *psp = (psp1_video_t*)data;

   (void) rgb32;
   (void) alpha;

#ifdef DEBUG
   /* psp->menu.frame buffer size is (480 * 272)*2 Bytes */
   rarch_assert((width*height) < (480 * 272));
#endif

   psp_set_screen_coords(psp->menu.frame_coords, 0, 0,
         SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT, 0);
   psp_set_tex_coords(psp->menu.frame_coords, width, height);

   sceKernelDcacheWritebackRange(frame, width * height * 2);

   sceGuStart(GU_DIRECT, psp->main_dList);
   sceGuCopyImage(GU_PSM_4444, 0, 0, width, height, width,
         (void*)frame, 0, 0, width, psp->menu.frame);
   sceGuFinish();

   sceGuStart(GU_SEND, psp->menu.dList);
   sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuTexFilter(GU_LINEAR, GU_LINEAR);
   sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->menu.frame);
   sceGuEnable(GU_BLEND);

#if 0
   /* default blending */
   sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
#endif
   sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F);
;
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
         GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
         psp->menu.frame_coords);
   sceGuFinish();

}
Esempio n. 3
0
void retro_run(void)
{
   int i;
   bool updated = false;

   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
      check_variables();

   input_poll_cb();

   for (i=0; i < 130; i++)
      KBD_RES(i);

   for (i=0; i < sizeof(keymap)/sizeof(keymap_t); i++)
      if (input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0, keymap[i].retro))
         KBD_SET(keymap[i].fmsx);

   joystate = 0;

   for (i = 0; i < sizeof(joymap) / sizeof(keymap_t); i++)
   {
	   if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, joymap[i].retro))
	   {
		   if (i < joy_keyboard_begin)
			   JOY_SET(joymap[i].fmsx);
		   else
			   KBD_SET(joymap[i].fmsx);
	   }
   }

   RETRO_PERFORMANCE_INIT(core_retro_run);
   RETRO_PERFORMANCE_START(core_retro_run);

   RunZ80(&CPU);
   RenderAndPlayAudio(SND_RATE / 60);

   RETRO_PERFORMANCE_STOP(core_retro_run);

   fflush(stdout);

#ifdef PSP
   static unsigned int __attribute__((aligned(16))) d_list[32];
   void* const texture_vram_p = (void*) (0x44200000 - (640 * 480)); // max VRAM address - frame size

   sceKernelDcacheWritebackRange(XBuf, 256*240 );
   sceGuStart(GU_DIRECT, d_list);
   sceGuCopyImage(GU_PSM_5650, 0, 0, image_buffer_width, image_buffer_height, image_buffer_width, image_buffer, 0, 0, image_buffer_width, texture_vram_p);

   sceGuTexSync();
   sceGuTexImage(0, 512, 256, image_buffer_width, texture_vram_p);
   sceGuTexMode(GU_PSM_5650, 0, 0, GU_FALSE);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuDisable(GU_BLEND);
   sceGuFinish();

   video_cb(texture_vram_p, image_buffer_width, image_buffer_height, image_buffer_width * sizeof(uint16_t));
#else
   video_cb(image_buffer, image_buffer_width, image_buffer_height, image_buffer_width * sizeof(uint16_t));
#endif



}
Esempio n. 4
0
void S9xSceGURenderTex (char *tex, int width, int height, int x, int y, int xscale, int yscale, int xres, int yres)
{
  // If you don't call this, Gu will run into cache problems with
  // reading pixel data...
  sceKernelDcacheWritebackAll ();

  unsigned int j;

  const int slice_scale = ((float)xscale / (float)width) * (float)SLICE_SIZE;
  const int tex_filter  = (PSP_Settings.bBilinearFilter ? GU_LINEAR :
                                                              GU_NEAREST);

  struct Vertex* vertices;
  struct Vertex* vtx_iter;


  // If the x/y scale matches the width/height, we can take a shortcut and
  // merely copy tex into the VRAM at the given (x,y) coordinate.
  //
  //  NOTE: This disables bilinear filtering, but that's not saying a whole
  //        lot, since the image will not require a min / mag filter.
  if ((xscale == width) && (yscale == height)) {
    sceGuStart (0, SceGU.list);
      sceGuCopyImage (SceGU.pixel_format, 0, 0, xres, yres, width, tex, x, y,
                        SceGU.line_size,
                          (void *)(0x04000000 + (uint32)SceGU.vram_offset));
    sceGuFinish ();
  }

  // If the scale doesn't match the width/height, we have to perform a
  // special blit to stretch the image.
  else {
#ifdef SCEGU_DIRECT_COPY
    sceGuStart (0, SceGU.list);

      sceGuCopyImage (SceGU.pixel_format, 0, 0, width, height, width, tex, 0, 0,
                        SceGU.line_size,
                          (void *)(0x04000000 + (uint32)SceGU.vram_offset));
#endif

      sceGuStart (0, SceGU.list);

      sceGuTexMode      (SceGU.texture_format, 0, 0, 0);
#ifndef SCEGU_DIRECT_COPY
      sceGuTexImage     (0, width, height, width, tex);
#else
      sceGuTexImage     (0, width, height, SceGU.line_size, (void *)(0x04000000 + (uint32)SceGU.vram_offset));
#endif
      sceGuTexFunc      (GU_TFX_REPLACE, 0);
      sceGuTexFilter    (tex_filter, tex_filter);
      sceGuTexScale     (1, 1);
      sceGuTexOffset    (0, 0);
      sceGuAmbientColor (0xffffffff);

      sceGuScissor      (x, y, xres, yres);

#ifdef DRAW_SINGLE_BATCH
      // Allocate (memory map) the "vertex array" beforehand
      const int num_verts = (width / SLICE_SIZE) * 2;
      const int vtx_alloc = num_verts * sizeof (struct Vertex);
                 vertices = (struct Vertex *)sceGuGetMemory (vtx_alloc);
                 vtx_iter = vertices;
#endif

      // Do a striped blit (takes the page-cache into account)
      for (j = 0; j < width; j += SLICE_SIZE, x += slice_scale)
      {
#ifndef DRAW_SINGLE_BATCH
        vtx_iter = (struct Vertex *)sceGuGetMemory (sizeof (struct Vertex) * 2);
#endif
        vtx_iter [0].u = j;                 vtx_iter [0].v = 0;
        vtx_iter [0].x = x;                 vtx_iter [0].y = y;            vtx_iter [0].z = 0;
        vtx_iter [1].u = (j + SLICE_SIZE);  vtx_iter [1].v = height;
        vtx_iter [1].x = (x + slice_scale); vtx_iter [1].y = (y + yscale); vtx_iter [1].z = 0;

        vtx_iter [0].color = vtx_iter [1].color = 0;

#ifndef DRAW_SINGLE_BATCH
			  sceGuDrawArray (GU_SPRITES, SceGU.tt | SceGU.ct | SceGU.mt | SceGU.dm, 2, 0, vtx_iter);
        vtx_iter += 2;
#endif
      }

#ifdef DRAW_SINGLE_BATCH
      sceGuDrawArray (GU_SPRITES, GE_SETREG_VTYPE (SceGU.tt,
                                                   SceGU.ct,
                                                   0,
                                                   SceGU.mt,
                                                   0, 0, 0, 0,
                                                   SceGU.dm),
                                            num_verts,
                                               0,
                                            vertices);
#endif
    sceGuFinish ();
  }

#ifdef SCEGU_DOUBLE_BUFFERED
  sceGuSync   (0, 0);

  if (PSP_Settings.bVSync)
    sceDisplayWaitVblankStart ();
#endif

#ifdef SCEGU_DOUBLE_BUFFERED
  S9xSceGUSwapBuffers ();
#endif
}