Esempio n. 1
0
void nextBoxHasColor(int *x, int *y, HasColorMode mode)
{
	VertexColor *sendVertices = mode & HASCOLOR_RGBA_TRANSPARENT ? transparentColorVertices : colorVertices;

	sendVertices[0].x = *x;
	sendVertices[0].y = *y;
	sendVertices[1].x = *x + 40;
	sendVertices[1].y = *y + 20;
	*x += 47;
	if (*x >= 470) {
		*x = 10;
		*y += 26;
	}
	sceKernelDcacheWritebackRange(sendVertices, sizeof(colorVertices));

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, mode & HASCOLOR_RGB ? GU_TCC_RGB : GU_TCC_RGBA);
	sceGuTexImage(0, 4, 4, 16, imageData);

	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, sendVertices);
	sceGuFinish();
	sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE);
	sceGuSync(0, 0);
	sceGuStart(GU_DIRECT, list);
}
Esempio n. 2
0
//Dessine une tile de la texture sélectionnée. Eviter d'utiliser à l'extérieur.
void oslDrawTextTile(int u, int v, int x, int y, int tX, int tY)
{
	int color = oslBlendColor(osl_textColor);

	//If enabled, draw the background
	if (osl_textBkColor & 0xff000000)
		oslDrawTextTileBack(x, y, tX, tY);

	tX += osl_curFont->addedSpace;

	OSL_FAST_VERTEX_COLOR32 *vertices;
	vertices = (OSL_FAST_VERTEX_COLOR32*)sceGuGetMemory(2 * sizeof(OSL_FAST_VERTEX_COLOR32));

	vertices[0].u = u;
	vertices[0].v = v;
	vertices[0].color = color;
	vertices[0].x = x;
	vertices[0].y = y;
	vertices[0].z = 0;

	vertices[1].u = u+tX;
	vertices[1].v = v+tY;
	vertices[1].color = color;
	vertices[1].x = x+tX;
	vertices[1].y = y+tY;
	vertices[1].z = 0;

    int wasEnable = osl_textureEnabled;
	oslEnableTexturing();

	sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
	sceKernelDcacheWritebackRange(vertices, 2 * sizeof(OSL_FAST_VERTEX_COLOR32)); //SAKYA
    if (!wasEnable)
        oslDisableTexturing();
}
Esempio n. 3
0
void _gEndLines()
{
  // Define vertices properties
  int prim = GU_LINES,
      v_obj_nbr = 2,
      v_nbr = v_obj_nbr * (obj_list_size / 2),
      v_coord_size = 3,
      v_color_size = (obj_use_vert_color) ? 1 : 0,
      v_size = v_color_size * sizeof(gColor) +
               v_coord_size * sizeof(float),
      v_type = GU_VERTEX_32BITF | GU_TRANSFORM_2D,
      i;

  if (obj_use_vert_color) v_type |= GU_COLOR_8888;

  // Allocate vertex list memory
  void *v = sceGuGetMemory(v_nbr * v_size), *vi = v;

  // Build the vertex list
  for (i=0; i+1<obj_list_size; i+=2)
  {
    vi = _gSetVertex(vi,i  ,0.f,0.f);
    vi = _gSetVertex(vi,i+1,0.f,0.f);
  }

  // Then put it in the display list.
  sceGuDrawArray(prim,v_type,v_nbr,NULL,v);
}
Esempio n. 4
0
void _gEndQuads()
{
  // Define vertices properties
  int prim = GU_TRIANGLES,
      v_obj_nbr = 6,
      v_nbr = v_obj_nbr * (obj_list_size / 4),
      v_coord_size = 3,
      v_tex_size = (obj_use_tex) ? 2 : 0,
      v_color_size = (obj_use_vert_color) ? 1 : 0,
      v_size = v_tex_size * sizeof(short) +
               v_color_size * sizeof(gColor) +
               v_coord_size * sizeof(float),
      v_type = GU_VERTEX_32BITF | GU_TRANSFORM_2D,
      i;

  if (obj_use_tex)        v_type |= GU_TEXTURE_16BIT;
  if (obj_use_vert_color) v_type |= GU_COLOR_8888;

  // Allocate vertex list memory
  void *v = sceGuGetMemory(v_nbr * v_size), *vi = v;

  // Build the vertex list
  for (i=0; i+3<obj_list_size; i+=4)
  {
      vi = _gSetVertex(vi,i  ,0.f,0.f);
      vi = _gSetVertex(vi,i+1,1.f,0.f);
      vi = _gSetVertex(vi,i+3,0.f,1.f);
      vi = _gSetVertex(vi,i+3,0.f,1.f);
      vi = _gSetVertex(vi,i+1,1.f,0.f);
      vi = _gSetVertex(vi,i+2,1.f,1.f);
  }

  // Then put it in the display list.
  sceGuDrawArray(prim,v_type,v_nbr,NULL,v);
}
Esempio n. 5
0
static void LogoDrawTiles(OSL_IMAGE *img, float positions[TABH][TABW])
{
	OSL_FAST_VERTEX *vertices, *vptr;
	int nbVertices, x, y;
	oslSetTexture(img);

	for (y=0;y<HAUT/TILE;y++)			{
		vertices = (OSL_FAST_VERTEX*)sceGuGetMemory((LARG/TILE) * 2 * sizeof(OSL_FAST_VERTEX));
		vptr = vertices;
		nbVertices = 0;
		for (x=0;x<LARG/TILE;x++)			{
			vertices[nbVertices].u = x * TILE;
			vertices[nbVertices].v = y * TILE;
			vertices[nbVertices].x = x * TILE;
			vertices[nbVertices].y = positions[y][x];
			vertices[nbVertices].z = 0;
			nbVertices ++;
			vertices[nbVertices].u = x * TILE + TILE;
			vertices[nbVertices].v = y * TILE + TILE;
			vertices[nbVertices].x = x * TILE + TILE;
			vertices[nbVertices].y = positions[y][x] + TILE;
			vertices[nbVertices].z = 0;
			nbVertices ++;
		}
		//Dessine
		if (nbVertices > 0)
			sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, nbVertices, 0, vertices);
	}
}
Esempio n. 6
0
void vidgu_render_nostretch(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
{
	int start, end;

	sceGuStart(GU_DIRECT,list);
	sceGuTexMode(GU_PSM_5650,0,0,0); // 16-bit RGBA
	sceGuTexImage(0,512,512,512,g_pBlitBuff); // setup texture as a 256x256 texture
	//sceKernelDcacheWritebackAll();
	sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // don't get influenced by any vertex colors
	sceGuTexFilter(GU_NEAREST,GU_NEAREST); // point-filtered sampling
	for (start = sx, end = sx+sw; start < end; start += SLICE_SIZE, dx += SLICE_SIZE)
	{
		struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
		int width = (start + SLICE_SIZE) < end ? SLICE_SIZE : end-start;

		vertices[0].u = start; vertices[0].v = sy;
		vertices[0].color = 0;
		vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0;

		vertices[1].u = start + width; vertices[1].v = sy + sh;
		vertices[1].color = 0;
		vertices[1].x = dx + width; vertices[1].y = dy + sh; vertices[1].z = 0;

		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5650|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
	}
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuSwapBuffers();
	//sceGuSwapBuffers();
}
Esempio n. 7
0
void drawShadowCaster( Geometry* geom )
{
    sceGuSetMatrix(GU_MODEL,&geom->world);

    sceGuColor(0x00000000);
    sceGuDrawArray(GU_TRIANGLES,GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,geom->count,geom->indices,geom->vertices);
}
Esempio n. 8
0
int DrawBox(int x1,int y1,int x2,int y2,int color,int fillflag)
{
	GUINITCHECK;
	if(fillflag)
	{
		dxpGraphicsSetup2D(color);
		DXP_FVF_2D *vertex = (DXP_FVF_2D*)dxpGuGetMemory(sizeof(DXP_FVF_2D) * 2);
		if(!vertex)return -1;
		vertex[0].x = x1;
		vertex[0].y = y1;
		vertex[0].z = dxpGraphicsData.z_2d;
		vertex[1].x = x2;
		vertex[1].y = y2;
		vertex[1].z = dxpGraphicsData.z_2d;
		sceGuDrawArray(GU_SPRITES,DXP_VTYPE_2D | GU_TRANSFORM_2D,2,0,vertex);
		return 0;
	}else
	{
		int dres = 0;
		x1 += 1;
		y1 += 1;
		dres += DrawLine(x1,y1,x2,y1,color);
		dres += DrawLine(x1,y1,x1,y2,color);
		dres += DrawLine(x2,y1,x2,y2,color);
		dres += DrawLine(x1,y2,x2,y2,color);
		return dres ? -1 : 0;
	}
}
Esempio n. 9
0
void drawSprite(int sx, int sy, int width, int height, gwTextureS* source, int dx, int dy)
{
	//sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
	//sceGuTexMode(source->format, 0, 0, source->swizzled);
	//sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, source->data);
	
//	float u = 1.0f / ((float)source->textureWidth);
	//float v = 1.0f / ((float)source->textureHeight);
	//sceGuTexScale(u, v);
	
//	sceGuDisable(GU_DEPTH_TEST);
	int j = 0;
	while (j < width) {
		struct BlitVertex {
			unsigned short u,v;
			short x,y,z;
		} *vertices = (struct BlitVertex*) sceGuGetMemory(2 * sizeof(struct BlitVertex));
		int sliceWidth = 64;
		if (j + sliceWidth > width) sliceWidth = width - j;
		vertices[0].u = sx + j;
		vertices[0].v = sy;
		vertices[0].x = dx + j;
		vertices[0].y = dy;
		vertices[0].z = 1;
		vertices[1].u = sx + j + sliceWidth;
		vertices[1].v = sy + height;
		vertices[1].x = dx + j + sliceWidth;
		vertices[1].y = dy + height;
		vertices[1].z = 1;
		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
		j += sliceWidth;
	}
//	sceGuEnable(GU_DEPTH_TEST);
//	sceGuTexScale(1.0f, 1.0f);
}
Esempio n. 10
0
void oslDrawTextTileBack(int x, int y, int tX, int tY)		{
	int color = oslBlendColor(osl_textBkColor);

	OSL_LINE_VERTEX_COLOR32 *vertices;
	vertices = (OSL_LINE_VERTEX_COLOR32*)sceGuGetMemory(2 * sizeof(OSL_LINE_VERTEX_COLOR32));

//	x += osl_curFont->addedSpace;			//<-- STAS: tX seems to be more appropiate here :-)
	tX += osl_curFont->addedSpace;			//<-- STAS END -->

	vertices[0].color = color;
	vertices[0].x = x;
	vertices[0].y = y;
	vertices[0].z = 0;

	vertices[1].color = color;
	vertices[1].x = x+tX;
	vertices[1].y = y+tY;
	vertices[1].z = 0;

    int wasEnable = osl_textureEnabled;
    oslDisableTexturing();

    sceGuDrawArray(GU_SPRITES,GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
	sceKernelDcacheWritebackRange(vertices, 2 * sizeof(OSL_LINE_VERTEX_COLOR32)); //SAKYA
    if (wasEnable)
        oslEnableTexturing();
}
Esempio n. 11
0
void oslDrawImageSimple(OSL_IMAGE *img)				{
		OSL_UVFLOAT_VERTEX *vertices;
		int x = img->x, y = img->y;
		//Very little overhead to support the rotation center but anyway... this routine was meant to be very simple :p
//		int x = img->x - img->centerX, y = img->y - img->centerY;

		// do a striped blit (takes the page-cache into account)
		oslSetTexture(img);
		if (oslImageGetAutoStrip(img))			{
			if (oslVerifyStripBlit(img))
				return;
		}

		vertices = (OSL_UVFLOAT_VERTEX*)sceGuGetMemory(2 * sizeof(OSL_UVFLOAT_VERTEX));

		vertices[0].u = img->offsetX0;
		vertices[0].v = img->offsetY0;
		vertices[0].x = x;
		vertices[0].y = y;
		vertices[0].z = 0;

		vertices[1].u = img->offsetX1;
		vertices[1].v = img->offsetY1;
		vertices[1].x = x + img->stretchX;
		vertices[1].y = y + img->stretchY;
		vertices[1].z = 0;

		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
}
Esempio n. 12
0
void drawBoxCommands(u32 c) {
	vertices_f32[0] = makeVertex32(c, -1.0, -1.0, 0.0);
	vertices_f32[1] = makeVertex32(c, 1.0, 1.0, 0.0);

	// Clearing cache is fun.  Let's do it all the time.
	sceKernelDcacheWritebackInvalidateAll();
	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_f32);
}
Esempio n. 13
0
int xTextPrint(int x, int y, char* text)
{
    if (!x_current_font) return 0;
    if (!x_current_font->texture) return 0;
    
    float pos = (float)x;
	int len = strlen(text);
    int text_length = xTextLength(text, len);
    if (x_font_align == X_ALIGN_CENTER) pos -= 0.5f*text_length;
    else if (x_font_align == X_ALIGN_RIGHT) pos -= text_length;
    
    u16 char_width = x_current_font->texture->width/16;

    Text_Vert* vertices = (Text_Vert*)sceGuGetMemory(2*len*sizeof(Text_Vert));
    Text_Vert* vert_ptr = vertices;
    int i = 0;
    while (/* *text != '\0' && num >= 0 */ i < len)
    {
        int tx = (((u8)*text >> 0) & 0x0f) * char_width;
        int ty = (((u8)*text >> 4) & 0x0f) * char_width;

        vert_ptr->u = (s16)(tx);
        vert_ptr->v = (s16)(x_current_font->texture->height - ty);
		vert_ptr->color = x_font_color;
        vert_ptr->x = (int)(pos);
        vert_ptr->y = (int)(y);
        vert_ptr->z = 0.0f;
        
        vert_ptr += 1;
        pos += x_font_scale*x_current_font->widths[(u8)*text];

        vert_ptr->u = (s16)(tx + x_current_font->widths[(u8)*text]);
		vert_ptr->v = (s16)(x_current_font->texture->height - ty - char_width);
		vert_ptr->color = x_font_color;
        vert_ptr->x = (int)(pos);
        vert_ptr->y = (int)(y + x_font_scale*char_width);
        vert_ptr->z = 0.0f;
        
        vert_ptr += 1;
        text += 1;
        //num -= 1;
        i += 1;
    }

    xTexSetImage(x_current_font->texture);
    xGuSaveStates();
    sceGuEnable(GU_TEXTURE_2D);
    sceGuEnable(GU_BLEND);
    sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
    sceGuDisable(GU_DEPTH_TEST);
    sceGuDrawArray(GU_SPRITES, Text_Vert_vtype|GU_TRANSFORM_2D, 2*len, 0, vertices);
    xGuLoadStates();

    return (int)text_length;
}
Esempio n. 14
0
void drawBG()
{
	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0x550055);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGBA);
	sceGuTexImage(0, 4, 4, 16, bgData);

	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, bg);
}
Esempio n. 15
0
void drawShadowReceiver( Geometry* geom, ScePspFMatrix4 shadowProjMatrix )
{
    sceGuSetMatrix(GU_MODEL,&geom->world);

    // multiply shadowmap projection texture by geometry world matrix
    // since geometry coords are in object space

    gumMultMatrix(&shadowProjMatrix, &shadowProjMatrix, &geom->world );
    sceGuSetMatrix(GU_TEXTURE,&shadowProjMatrix);

    sceGuColor(geom->color);
    sceGuDrawArray(GU_TRIANGLES,GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,geom->count,geom->indices,geom->vertices);
}
Esempio n. 16
0
void vidgu_render(int sx, int sy, int sw,int sh,int dx, int dy, int dw,int dh)
{
	unsigned int j,cx,cy;
	struct Vertex* vertices;

	cx=(480-dw)/2;
	cy=(272-dh)/2;

	sceGuStart(GU_DIRECT,list);
	sceGuTexMode(GU_PSM_5650,0,0,0); // 16-bit RGBA
	sceGuTexImage(0,512,512,512,g_pBlitBuff); // setup texture as a 256x256 texture
	//sceKernelDcacheWritebackAll();
	sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA); // don't get influenced by any vertex colors
	sceGuTexFilter(GU_LINEAR,GU_LINEAR); // point-filtered sampling

	int		start, end;
	float	ustart = (float)sx;
	float	ustep = (float)sw / (float)(dw / SLICE_SIZE);

	// blit maximizing the use of the texture-cache

	for (start = sx, end = sx+dw; start < end; start += SLICE_SIZE, dx += SLICE_SIZE)
	{
		struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
		int width = (start + SLICE_SIZE) < end ? SLICE_SIZE : end-start;

		vertices[0].u = ustart; 
		vertices[0].v = (float)sy;
		vertices[0].color = 0;
		vertices[0].x = dx; 
		vertices[0].y = dy; 
		vertices[0].z = 0;

		vertices[1].u = ustart + ustep; 
		vertices[1].v = (float)(sy + sh);
		vertices[1].color = 0;
		vertices[1].x = dx + width; 
		vertices[1].y = dy + dh; 
		vertices[1].z = 0;

		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5650|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);

		ustart += ustep;
	}


	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuSwapBuffers(); 
}
Esempio n. 17
0
    void ya2d_drawFillRect(int x, int y, int w, int h, u32 color)
    {
		sceGuDisable(GU_TEXTURE_2D);
        ya2d_FastVertex *vertices = (ya2d_FastVertex *)sceGuGetMemory(4 * sizeof(ya2d_FastVertex));

        vertices[0] = (ya2d_FastVertex){color, x, y};
        vertices[1] = (ya2d_FastVertex){color, x, y+h};
        vertices[2] = (ya2d_FastVertex){color, x+w, y};
        vertices[3] = (ya2d_FastVertex){color, x+w, y+h};

        sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices);

        sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_FastVertex));
    }
Esempio n. 18
0
void drawTexFlush(int width, int height, int stride, int texfmt, const void *tex, const void *clut, int clutfmt, int blocks, const void *verts, int indexMask) {
	sceGuStart(GU_DIRECT, list);

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(texfmt, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
	sceGuTexImage(0, width, height, stride, tex);

	sceGuClutLoad(blocks, clut);
	sceGuClutMode(clutfmt, 0, indexMask, 0);
	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, verts);

	sceGuFinish();
	sceGuSync(0, 0);
}
Esempio n. 19
0
static void draw_bg_map_256(BGMAP_TEXT_t* map_data, unsigned character_base_block, unsigned offsetX, unsigned offsetY)
{
   return;
   psp1_sprite_t* tile_coords = sceGuGetMemory(32*32*sizeof(psp1_sprite_t));
   unsigned int i;

   sceGuClutLoad(32, palette_ram_8bit);
   sceGuClutMode(GU_PSM_5551,0,0xFF,0);

   sceGuTexImage(0, 128, 256, 128, GBA_VRAMTEXTURE_8bit + character_base_block * 16 * 1024);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);

   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 32 * 32 * 2, NULL,(void*)tile_coords);

}
Esempio n. 20
0
static void draw_bg_map_16(BGMAP_TEXT_t* map_data, unsigned character_base_block)
{

   unsigned int i;
   u16* tile_data = GBA_VRAMTEXTURE_4bit +  character_base_block * 32 * 1024 ;

   for (i = 0; i < 32*32; i++)
   {
      sceGuTexImage(0, 8, 8, 8,
                    tile_data + (map_data[i].tile_number << 6));

      sceGuClutMode(GU_PSM_5551,0,0x0F,map_data[i].palette_id);

      sceGuDrawArray(GU_SPRITES, GU_TEXTURE_8BIT | GU_VERTEX_16BIT |
                     GU_TRANSFORM_3D, 2, NULL,(void*)(screen_tiles + (map_data[i].flip_XY << 10) + i));

   }
}
Esempio n. 21
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. 22
0
void psp_renderSprite(int flags, int x, int y, int w, int h) {
	log("%d %d %d %d %d\n",flags,x,y,w,h);
	SpriteVertex *vertices = (SpriteVertex*)sceGuGetMemory(2*sizeof(SpriteVertex));
	vertices[0].u = 0;
	vertices[0].v = 0;
	vertices[0].x = x;
	vertices[0].y = y;
	vertices[0].z = 0;
	vertices[1].u = w;
	vertices[1].v = h;
	vertices[1].x = x+w;
	vertices[1].y = y+h;
	vertices[1].z = 0;
	if(flags & SPRITE_HFLIP) {
		vertices[0].u = w;
		vertices[1].u = 0;
	}
	sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
}
Esempio n. 23
0
int DrawExtendGraph(int x1,int y1,int x2,int y2,int gh,int trans)
{
	if((x2 < x1 || y2 < y1) && !(x2 < x1 && y2 < y1))return DrawModiGraph(x1,y1,x2,y1,x2,y2,x1,y2,gh,trans);//X方向反転画像がうまく動作しないので(GU_SPRITESを使ったのが原因と思われる)強引に回避
	DXPGRAPHICSHANDLE* gptr;
	GHANDLE2GPTR(gptr,gh)
	if(dxpGraphicsSetup2DTex(gptr->tex,trans) < 0)return -1;
	int sw = dxpPsm2SliceSize[gptr->tex->psm][0];
	int sh = dxpPsm2SliceSize[gptr->tex->psm][1];
	int u[2],v[2];
	int count = ((gptr->u1 - gptr->u0 + sw - 1) / sw) * ((gptr->v1 - gptr->v0 + sh - 1) / sh);
	DXP_FVF_2DTEX *vtxbuf = (DXP_FVF_2DTEX*)dxpGuGetMemory(sizeof(DXP_FVF_2DTEX) * 2 * count);
	float uscale = (float)(x2 - x1) / (float)(gptr->u1 - gptr->u0);
	float vscale = (float)(y2 - y1) / (float)(gptr->v1 - gptr->v0);
	u[0] = gptr->u0;
	while(u[0] < gptr->u1)
	{
		u[1] = MIN(u[0] + sw,gptr->u1);
		v[0] = gptr->v0;
		while(v[0] < gptr->v1)
		{
			v[1] = MIN(v[0] + sh,gptr->v1);
			vtxbuf->u = u[0];
			vtxbuf->v = v[0];
			vtxbuf->x = x1 + uscale * (u[0] - gptr->u0);
			vtxbuf->y = y1 + vscale * (v[0] - gptr->v0);
			vtxbuf->z = dxpGraphicsData.z_2d;
			++vtxbuf;
			vtxbuf->u = u[1];
			vtxbuf->v = v[1];
			vtxbuf->x = x1 + uscale * (u[1] - gptr->u0);
			vtxbuf->y = y1 + vscale * (v[1] - gptr->v0);
			vtxbuf->z = dxpGraphicsData.z_2d;
			++vtxbuf;
			v[0] += sh;
		}
		u[0] += sw;
	}
	vtxbuf -= count * 2;
	sceGuDrawArray(GU_SPRITES,DXP_VTYPE_2DTEX | GU_TRANSFORM_2D,2 * count,NULL,vtxbuf);
	return 0;
}
Esempio n. 24
0
static void gba_upload_vram (void)
{
   sceGuDisable(GU_SCISSOR_TEST);
   sceGuDisable(GU_DEPTH_TEST);

   sceGuEnable(GU_TEXTURE_2D);

   sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
   sceGuClutMode(GU_PSM_5551,0,0xFF,0);
   sceGuClutLoad(32, index_copy_clut);


   sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_8bit_GU, 128);
   sceGuTexImage(0, 128, 256, 128, vram);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256), 128);
   sceGuTexImage(0, 128, 256, 128, vram + (128*256));
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256*2), 128);
   sceGuTexImage(0, 128, 256, 128, vram + (128*256) * 2);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuTexMode(GU_PSM_T4, 0, 0, GU_FALSE);
   sceGuClutMode(GU_PSM_5551,0,0xFF,0);
   sceGuClutLoad(32, index_copy_clut);

   sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_4bit_GU, 256);
   sceGuTexImage(0, 256, 256, 256, vram);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) , 256);
   sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2));
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) * 2, 256);
   sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2)*2);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

}
Esempio n. 25
0
 virtual void draw() {
     sceGuEnable(GU_TEXTURE_2D);
     sceGuTexMode(GU_PSM_8888, 0, 0, GU_FALSE);
     sceGuEnable(GU_BLEND);
     sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
     sceGuTexImage(0, 256, 256, 256, data_.get().data());
     sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
     sceGuTexFilter(GU_LINEAR, GU_LINEAR);
     bright_texture_vertex * const vertex = static_cast<bright_texture_vertex *>(sceGuGetMemory(2 * sizeof(*vertex)));
     vertex[0].u = u_;
     vertex[0].v = v_;
     vertex[0].color = color_ | static_cast<boost::uint32_t>(alpha_) << 24;
     vertex[0].x = x_;
     vertex[0].y = y_;
     vertex[0].z = 0.f;
     vertex[1].u = u_ + u_size_;
     vertex[1].v = v_ + v_size_;
     vertex[1].color = color_ | static_cast<boost::uint32_t>(alpha_) << 24;
     vertex[1].x = x_ + width_;
     vertex[1].y = y_ + height_;
     vertex[1].z = 0.f;
     sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vertex);
 }
Esempio n. 26
0
void nextBox(int *x, int *y)
{
	vertices[0].x = *x;
	vertices[0].y = *y;
	vertices[1].x = *x + 40;
	vertices[1].y = *y + 20;
	*x += 47;
	if (*x >= 470) {
		*x = 10;
		*y += 26;
	}
	sceKernelDcacheWritebackRange(vertices, sizeof(vertices));

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGBA);
	sceGuTexImage(0, 4, 4, 16, imageData);

	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices);
	sceGuFinish();
	sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE);
	sceGuSync(0, 0);
	sceGuStart(GU_DIRECT, list);
}
Esempio n. 27
0
void draw() {
    startFrame();
    setSimpleTexture();

    // Different formats - throughmode.
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices_nofmt);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_8BIT | GU_TRANSFORM_2D, 2, NULL, vertices_s8);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices_s16);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_f32);

    // Different formats - transform.
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_TRANSFORM_3D, 2, NULL, vertices_nofmt);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_8BIT | GU_TRANSFORM_3D, 2, NULL, vertices_s8x);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 2, NULL, vertices_s16x);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_f32x);

    // Rotated (not TL - BR.)
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_trbl);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_brtl);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_trblx);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_brtlx);

    // Incomplete (only one prim.)
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 1, NULL, vertices_incomp);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 1, NULL, vertices_incompx);

    endFrame();
}
Esempio n. 28
0
static bool psp_frame(void *data, const void *frame,
      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
   static char fps_txt[128], fps_text_buf[128];
   psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
   static uint64_t currentTick,lastTick;
   static float fps=0.0;
   static int frames;
#endif

   if (!width || !height)
      return false;

   if (((uint32_t)frame&0x04000000) || (frame == RETRO_HW_FRAME_BUFFER_VALID))
      psp->hw_render = true;
   else if (frame)
      psp->hw_render = false;

   if (!psp->hw_render)
      sceGuSync(0, 0); /* let the core decide when to sync when HW_RENDER */

   pspDebugScreenSetBase(psp->draw_buffer);

   pspDebugScreenSetXY(0,0);

   video_monitor_get_fps(fps_txt, sizeof(fps_txt),
         g_settings.fps_show ? fps_text_buf : NULL,
         g_settings.fps_show ? sizeof(fps_text_buf) : 0);

   if(g_settings.fps_show)
   {
      pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
      pspDebugScreenPuts(fps_text_buf);
      pspDebugScreenSetXY(0,1);
   }

   if (msg)
      pspDebugScreenPuts(msg);

   if ((psp->vsync)&&(psp->vblank_not_reached))
      sceDisplayWaitVblankStart();

   psp->vblank_not_reached = true;

#ifdef DISPLAY_FPS
   frames++;
   sceRtcGetCurrentTick(&currentTick);
   uint32_t diff = currentTick - lastTick;
   if(diff > 1000000)
   {
      fps = (float)frames * 1000000.0 / diff;
      lastTick = currentTick;
      frames = 0;
   }

   pspDebugScreenSetXY(0,0);
   pspDebugScreenPrintf("%f", fps);
#endif

   psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
   g_extern.frame_count++;


   RARCH_PERFORMANCE_INIT(psp_frame_run);
   RARCH_PERFORMANCE_START(psp_frame_run);

   if (psp->should_resize)
      psp_update_viewport(psp);

   psp_set_tex_coords(psp->frame_coords, width, height);

   sceGuStart(GU_DIRECT, psp->main_dList);

   sceGuTexFilter(psp->tex_filter, psp->tex_filter);
   sceGuClear(GU_COLOR_BUFFER_BIT);

   /* frame in VRAM ? texture/palette was 
    * set in core so draw directly */
   if (psp->hw_render) 
      sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
            GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
            (void*)(psp->frame_coords));
   else
   {
      if (frame)
      {
         sceKernelDcacheWritebackRange(frame,pitch * height);
         sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2,
               0, width, height, pitch >> psp->bpp_log2,
               (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
      }
      sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
      sceGuCallList(psp->frame_dList);
   }

   sceGuFinish();

   RARCH_PERFORMANCE_STOP(psp_frame_run);

   if(psp->menu.active)
   {
      sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage));
      sceGuSync(0, 0);
   }

   return true;
}
Esempio n. 29
0
static void *psp_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   /* to-do : add ASSERT() checks or use main RAM if 
    * VRAM is too low for desired video->input_scale. */
   void *pspinput;
   int pixel_format, lut_pixel_format, lut_block_count;
   unsigned int red_shift, color_mask;
   void *displayBuffer, *LUT_r, *LUT_b;
   psp1_video_t *psp  = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));

   if (!psp)
      return NULL;

   sceGuInit();

   psp->vp.x           = 0;
   psp->vp.y           = 0;
   psp->vp.width       = SCEGU_SCR_WIDTH;
   psp->vp.height      = SCEGU_SCR_HEIGHT;
   psp->vp.full_width  = SCEGU_SCR_WIDTH;
   psp->vp.full_height = SCEGU_SCR_HEIGHT;

   /* Make sure anything using uncached pointers reserves 
    * whole cachelines (memory address and size need to be a multiple of 64)
    * so it isn't overwritten by an unlucky cache writeback.
    *
    * This includes display lists since the Gu library uses 
    * uncached pointers to write to them. */

   /* Allocate more space if bigger display lists are needed. */
   psp->main_dList         = memalign(64, 256);

   psp->frame_dList        = memalign(64, 256);
   psp->menu.dList         = memalign(64, 256);
   psp->menu.frame         = memalign(16,  2 * 480 * 272);
   psp->frame_coords       = memalign(64,
         (((PSP_FRAME_SLICE_COUNT * sizeof(psp1_sprite_t)) + 63) & ~63));
   psp->menu.frame_coords  = memalign(64,
         (((PSP_FRAME_SLICE_COUNT * sizeof(psp1_sprite_t)) + 63) & ~63));

   memset(psp->frame_coords, 0,
         PSP_FRAME_SLICE_COUNT * sizeof(psp1_sprite_t));
   memset(psp->menu.frame_coords, 0,
         PSP_FRAME_SLICE_COUNT * sizeof(psp1_sprite_t));

   sceKernelDcacheWritebackInvalidateAll();
   psp->frame_coords       = TO_UNCACHED_PTR(psp->frame_coords);
   psp->menu.frame_coords  = TO_UNCACHED_PTR(psp->menu.frame_coords);

   psp->frame_coords->v0.x = 60;
   psp->frame_coords->v0.y = 0;
   psp->frame_coords->v0.u = 0;
   psp->frame_coords->v0.v = 0;

   psp->frame_coords->v1.x = 420;
   psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT;
   psp->frame_coords->v1.u = 256;
   psp->frame_coords->v1.v = 240;

   psp->vsync = video->vsync;
   psp->rgb32 = video->rgb32;

   if(psp->rgb32)
   {
      uint32_t* LUT_r_local = (uint32_t*)(SCEGU_VRAM_BP32_2);
      uint32_t* LUT_b_local = (uint32_t*)(SCEGU_VRAM_BP32_2) + (1 << 8);

      red_shift = 8 + 8;
      color_mask = 0xFF;
      lut_block_count = (1 << 8) / 8;

      psp->texture = (void*)(LUT_b_local + (1 << 8));
      psp->draw_buffer = SCEGU_VRAM_BP32_0;
      psp->bpp_log2 = 2;

      pixel_format = GU_PSM_8888;
      lut_pixel_format = GU_PSM_T32;

      displayBuffer = SCEGU_VRAM_BP32_1;

      for (u32 i=0; i < (1 << 8); i++){
         LUT_r_local[i]= i;
         LUT_b_local[i]= i << (8 + 8);
      }

      LUT_r = (void*)LUT_r_local;
      LUT_b = (void*)LUT_b_local;

   }
   else
   {
      uint16_t* LUT_r_local = (uint16_t*)(SCEGU_VRAM_BP_2);
      uint16_t* LUT_b_local = (uint16_t*)(SCEGU_VRAM_BP_2) + (1 << 5);

      red_shift = 6 + 5;
      color_mask = 0x1F;
      lut_block_count = (1 << 5) / 8;

      psp->texture = (void*)(LUT_b_local + (1 << 5));
      psp->draw_buffer = SCEGU_VRAM_BP_0;
      psp->bpp_log2 = 1;

      pixel_format = 
         (g_extern.system.pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555) 
         ? GU_PSM_5551 : GU_PSM_5650 ;

      lut_pixel_format = GU_PSM_T16;

      displayBuffer = SCEGU_VRAM_BP_1;

      for (u16 i = 0; i < (1 << 5); i++)
      {
         LUT_r_local[i]= i;
         LUT_b_local[i]= i << (5 + 6);
      }

      LUT_r = (void*)LUT_r_local;
      LUT_b = (void*)LUT_b_local;

   }

   psp->tex_filter = video->smooth? GU_LINEAR : GU_NEAREST;

   /* TODO: check if necessary. */
   sceDisplayWaitVblankStart();

   sceGuDisplay(GU_FALSE);

   sceGuStart(GU_DIRECT, psp->main_dList);

   sceGuDrawBuffer(pixel_format, TO_GU_POINTER(psp->draw_buffer),
         SCEGU_VRAM_WIDTH);
   sceGuDispBuffer(SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT,
         TO_GU_POINTER(displayBuffer), SCEGU_VRAM_WIDTH);
   sceGuClearColor(0);
   sceGuScissor(0, 0, SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT);
   sceGuEnable(GU_SCISSOR_TEST);
   sceGuTexFilter(psp->tex_filter, psp->tex_filter);
   sceGuTexWrap (GU_CLAMP, GU_CLAMP);
   sceGuEnable(GU_TEXTURE_2D);
   sceGuDisable(GU_DEPTH_TEST);
   sceGuCallMode(GU_FALSE);

   sceGuFinish();
   sceGuSync(0, 0);
 
   /* TODO : check if necessary */
   sceDisplayWaitVblankStart();
   sceGuDisplay(GU_TRUE);

   pspDebugScreenSetColorMode(pixel_format);
   pspDebugScreenSetBase(psp->draw_buffer);

   /* fill frame_dList : */
   sceGuStart(GU_CALL, psp->frame_dList);

   sceGuTexMode(pixel_format, 0, 0, GU_FALSE);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuEnable(GU_BLEND);

   /* green only */
   sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x0000FF00, 0xFFFFFFFF);

   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
         GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
         (void*)(psp->frame_coords));
   
   /* restore */
   sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF);

   sceGuTexMode(lut_pixel_format, 0, 0, GU_FALSE);

   sceGuClutMode(pixel_format, red_shift, color_mask, 0);
   sceGuClutLoad(lut_block_count, LUT_r);

   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF |
         GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
         (void*)(psp->frame_coords));

   sceGuClutMode(pixel_format, 0, color_mask, 0);
   sceGuClutLoad(lut_block_count, LUT_b);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
         GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
         (void*)(psp->frame_coords));

   sceGuFinish();

   if (input && input_data)
   {
      pspinput = input_psp.init();
      *input = pspinput ? &input_psp : NULL;
      *input_data = pspinput;
   }

   psp->vblank_not_reached = true;
   sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, psp);
   sceKernelEnableSubIntr(PSP_VBLANK_INT, 0);

   psp->keep_aspect = true;
   psp->should_resize = true;
   psp->hw_render = false;

   return psp;
error:
   RARCH_ERR("PSP1 video could not be initialized.\n");
   return (void*)-1;
}
Esempio n. 30
0
void oslDrawMap(OSL_MAP *m)
{
	int x, y, v, sX, sY, mX, mY, dX, bY, dsX, dsY, xTile, yTile, i;
	u32 tilesPerLine = m->img->sizeX / m->tileX, tilesPerLineOpt = 0;
	u32 firstTileOpaque = !(m->flags & OSL_MF_TILE1_TRANSPARENT);
	u16 *map = (u16*)m->map;
	OSL_FAST_VERTEX *vertices, *vptr;
	int nbVertices;

	oslSetTexture(m->img);
	if (m->drawSizeX < 0 || m->drawSizeY < 0)			{
		dsX = osl_curBuf->sizeX/m->tileX+1;
		if (osl_curBuf->sizeX%m->tileX)		dsX++;
		dsY = osl_curBuf->sizeY/m->tileY+1;
		if (osl_curBuf->sizeY%m->tileY)		dsY++;
	}
	else
		dsX = m->drawSizeX, dsY = m->drawSizeY;

	//Try to optimize for shifting. From 1 to 256 tiles per line, should be a wide enough range.
	for (i=1;i<=8;i++)			{
		if (tilesPerLine >= 1<<i)
			tilesPerLineOpt = i;
	}

	sX = m->scrollX%m->tileX;
	sY = m->scrollY%m->tileY;
	//Pour parer au modulo négatif
	if (sX < 0)		sX += m->tileX;
	if (sY < 0)		sY += m->tileY;
	dX = (((m->scrollX)<0?(m->scrollX-m->tileX+1):(m->scrollX))/m->tileX)%m->mapSizeX;
	mY = (((m->scrollY)<0?(m->scrollY-m->tileY+1):(m->scrollY))/m->tileY)%m->mapSizeY;
	//Pour parer au modulo négatif
	if (dX < 0)		dX += m->mapSizeX;
	if (mY < 0)		mY += m->mapSizeY;

	yTile = -sY;

	switch (m->format)			{
		case OSL_MF_U16:
			for (y=0;y<dsY;y++)			{
				bY = m->mapSizeX * mY;
				mX = dX;
				xTile = -sX;
				vertices = (OSL_FAST_VERTEX*)sceGuGetMemory(dsX * 2 * sizeof(OSL_FAST_VERTEX));
				vptr = vertices;
				nbVertices = 0;
				if (tilesPerLineOpt)			{
					for (x=0;x<dsX;x++)			{
						v = map[bY+mX];
						//Plus compréhensible
						if (v || firstTileOpaque)			{
							//Optimized with shift & and. Multiplication doesn't need to be optimized as it requires 12 cycles (2 cycles + 10 overlap). Division requires 75 cycles instead. DDIV is 135, and DMULT is 2 + 18.
							vertices[nbVertices].u = (v & ((1 << tilesPerLineOpt) - 1)) * m->tileX;
							vertices[nbVertices].v = (v >> tilesPerLineOpt) * m->tileY;
							vertices[nbVertices].x = xTile;
							vertices[nbVertices].y = yTile;
							vertices[nbVertices].z = 0;
							vertices[nbVertices+1].u = vertices[nbVertices].u + m->tileX;
							vertices[nbVertices+1].v = vertices[nbVertices].v + m->tileY;
							vertices[nbVertices+1].x = vertices[nbVertices].x + m->tileX;
							vertices[nbVertices+1].y = vertices[nbVertices].y + m->tileY;
							vertices[nbVertices+1].z = 0;
							nbVertices += 2;
						}
						xTile += m->tileX;
						mX++;
						if (mX >= m->mapSizeX)
							mX -= m->mapSizeX;
					}
				}
				else	{
					for (x=0;x<dsX;x++)			{
						v = map[bY+mX];
						//Plus compréhensible
						if (v || firstTileOpaque)			{
							//Unoptimized method
							vertices[nbVertices].u = (v % tilesPerLine) * m->tileX;
							vertices[nbVertices].v = (v / tilesPerLine) * m->tileY;
							vertices[nbVertices].x = xTile;
							vertices[nbVertices].y = yTile;
							vertices[nbVertices].z = 0;
							vertices[nbVertices+1].u = vertices[nbVertices].u + m->tileX;
							vertices[nbVertices+1].v = vertices[nbVertices].v + m->tileY;
							vertices[nbVertices+1].x = vertices[nbVertices].x + m->tileX;
							vertices[nbVertices+1].y = vertices[nbVertices].y + m->tileY;
							vertices[nbVertices+1].z = 0;
							nbVertices += 2;
						}
						xTile += m->tileX;
						mX++;
						if (mX >= m->mapSizeX)
							mX -= m->mapSizeX;
					}
				}
				//Dessine
				if (nbVertices > 0)
					sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, nbVertices, 0, vertices);
				mY++;
				if (mY >= m->mapSizeY)
					mY -= m->mapSizeY;
				yTile += m->tileY;
			}