Пример #1
0
void _gInit()
{
  // Init & setup GU
  sceGuInit();
  sceGuStart(GU_DIRECT,list);

  sceGuDrawBuffer(GU_PSM_8888,(void*)FRAMEBUFFER_SIZE,PSP_LINE_SIZE);
  sceGuDispBuffer(G_SCR_W,G_SCR_H,(void*)0,PSP_LINE_SIZE);
  sceGuDepthBuffer((void*)(FRAMEBUFFER_SIZE*2),PSP_LINE_SIZE);
  sceGuOffset(2048-(G_SCR_W/2),2048-(G_SCR_H/2));
  sceGuViewport(2048,2048,G_SCR_W,G_SCR_H);

  gResetScissor();
  sceGuDepthRange(65535,0);
  sceGuClearDepth(65535);
  sceGuAlphaFunc(GU_GREATER,0,0xff);
  sceGuDepthFunc(GU_LEQUAL);
  sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
  sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA);
  sceGuTexFilter(GU_LINEAR,GU_LINEAR);
  sceGuShadeModel(GU_FLAT);

  sceGuDisable(GU_CULL_FACE);
  sceGuDisable(GU_CLIP_PLANES);
  sceGuDisable(GU_DITHER);
  sceGuEnable(GU_ALPHA_TEST);
  sceGuEnable(GU_SCISSOR_TEST);

  sceGuFinish();
  sceGuSync(0,0);
  sceDisplayWaitVblankStart();
  sceGuDisplay(GU_TRUE);

  init = G_TRUE;
}
Пример #2
0
void drawTorus( int val )
{
    // setup a light

    ScePspFVector3 dir = { 0, 0, 1 };
    sceGuLight(0,GU_DIRECTIONAL,GU_DIFFUSE,&dir);
    sceGuLightColor(0,GU_DIFFUSE,0x00ff4040 );
    sceGuLightAtt(0,1.0f,0.0f,0.0f);
    sceGuAmbient(0x00202020);

    // setup texture
    sceGuDisable(GU_TEXTURE_2D);
    sceGuEnable(GU_LIGHTING);
    sceGuEnable(GU_LIGHT0);

    // setup matrices for torus

    sceGumMatrixMode(GU_PROJECTION);
    sceGumLoadIdentity();
    sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

    sceGumMatrixMode(GU_VIEW);
    {
        ScePspFVector3 pos = {0.0f,0.0f,-2.5f};

        sceGumLoadIdentity();
        sceGumTranslate(&pos);
    }

    sceGumMatrixMode(GU_MODEL);
    {
        ScePspFVector3 rot = {val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f)};

        sceGumLoadIdentity();
        sceGumRotateXYZ(&rot);
    }

    // draw torus

    sceGuColor(0xffffff);
    sceGumDrawArray(GU_TRIANGLES,GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,sizeof(torus_indices)/sizeof(unsigned short),torus_indices,torus_vertices);


    // restore state

    sceGuDisable(GU_LIGHTING);
    sceGuDisable(GU_LIGHT0);
    sceGuEnable(GU_TEXTURE_2D);
}
Пример #3
0
void
psp_sdl_gu_init(void)
{
	sceGuStart(GU_DIRECT,list);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_5650, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuTexFilter(GU_LINEAR, GU_LINEAR);
	sceGuDisable(GU_BLEND);
  sceGuDisable(GU_DEPTH_TEST);
	sceGuFinish();
	sceGuSync(0, 0);

  sceDisplayWaitVblankStart();
}
		void SkyLight::Render()
		{
			sceGuEnable(GU_TEXTURE_2D);
			sceGuEnable(GU_BLEND);

			sceGuBlendFunc(GU_ADD, GU_FIX,GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF);

			sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, skyVertices);

			sceGuDisable(GU_TEXTURE_2D);
			sceGuDisable(GU_BLEND);

			//make default blend function
			sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
		}
Пример #5
0
void psp_init(void)
{
	SceUID thid;
	char buff[128], *r;

	/* fw 1.5 sometimes returns 8002032c, although getcwd works */
	r = getcwd(buff, sizeof(buff));
	if (r) sceIoChdir(buff);

	main_thread_id = sceKernelGetThreadId();

	lprintf("running on %08x kernel\n", sceKernelDevkitVersion()),
	lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id,
		sceKernelGetThreadCurrentPriority());

	thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL);
	if (thid >= 0)
	{
		sceKernelStartThread(thid, 0, 0);
	}

	/* video */
	sceDisplaySetMode(0, 480, 272);
	sceDisplaySetFrameBuf(VRAM_FB1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
	current_screen = 1;
	psp_screen = VRAM_FB0;

	/* gu */
	sceGuInit();

	sceGuStart(GU_DIRECT, guCmdList);
	sceGuDrawBuffer(GU_PSM_5650, (void *)VRAMOFFS_FB0, 512);
	sceGuDispBuffer(480, 272, (void *)VRAMOFFS_FB1, 512); // don't care
	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuDepthBuffer((void *)VRAMOFFS_DEPTH, 512);
	sceGuOffset(2048 - (480 / 2), 2048 - (272 / 2));
	sceGuViewport(2048, 2048, 480, 272);
	sceGuDepthRange(0xc350, 0x2710);
	sceGuScissor(0, 0, 480, 272);
	sceGuEnable(GU_SCISSOR_TEST);

	sceGuDepthMask(0xffff);
	sceGuDisable(GU_DEPTH_TEST);

	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuAmbientColor(0xffffffff);
	sceGuColor(0xffffffff);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);


	/* input */
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
Пример #6
0
void MasterGuRenderer::guInit() {
	DEBUG_ENTER_FUNC();

	sceGuInit();
	sceGuStart(0, _displayList);

	guProgramDisplayBufferSizes();

	sceGuOffset(2048 - (PSP_SCREEN_WIDTH / 2), 2048 - (PSP_SCREEN_HEIGHT / 2));
	sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuDepthRange(0xC350, 0x2710);
	sceGuDisable(GU_DEPTH_TEST);	// We'll use depth buffer area
	sceGuDepthMask(GU_TRUE);		// Prevent writes to depth buffer
	sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);

	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);
}
Пример #7
0
void draw() {
	startFrame();
	sceGuDisable(GU_TEXTURE);

	// Different formats - throughmode.
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_TRANSFORM_2D, 4, NULL, vertices_nofmt);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_8BIT | GU_TRANSFORM_2D, 4, NULL, vertices_s8);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 4, NULL, vertices_s16);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, NULL, vertices_f32);

	// Different formats - transform.
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_TRANSFORM_3D, 4, NULL, vertices_nofmt);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_8BIT | GU_TRANSFORM_3D, 4, NULL, vertices_s8x);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 4, NULL, vertices_s16x);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, NULL, vertices_f32x);

	// Wrong order (CCW.)
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, NULL, vertices_rev);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, NULL, vertices_revx);

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

	endFrame();
}
Пример #8
0
void testBlendFunc(const char *title, u32 prev, u32 c, int op, int src, int dst, u32 fixa, u32 fixb) {
	for (size_t i = 0; i < sizeof(copybuf) / 4; ++i) {
		copybuf[i] = prev;
	}
	sceKernelDcacheWritebackInvalidateAll();
	sceDmacMemcpy(sceGeEdramGetAddr(), copybuf, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();

	sceGuStart(GU_DIRECT, list);

	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(op, src, dst, fixa, fixb);

	sceGuEnable(GU_STENCIL_TEST);
	sceGuStencilFunc(GU_ALWAYS, 0xAA, 0xFF);
	sceGuStencilOp(GU_REPLACE, GU_REPLACE, GU_REPLACE);

	drawBoxCommands(c);

	sceGuFinish();
	sceGuSync(GU_SYNC_WAIT, GU_SYNC_WHAT_DONE);

	displayBuffer(title);

	sceGuDisable(GU_BLEND);
}
Пример #9
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));

}
Пример #10
0
void Red3dPrintf(const char *message, float font_size, int x, int y, u32 fg_color, u32 bg_color, ...)
{
	sceGuEnable(GU_TEXTURE_2D);
	sceGuEnable(GU_BLEND);
	char buffer[256];
	va_list ap;
	
	va_start(ap, message);
	vsnprintf(buffer, 256, message, ap);
	va_end(ap);
	buffer[255] = 0;
	
	intraFontSetStyle(ltn, font_size, fg_color, bg_color, 0);
	intraFontPrint(ltn, x, y, buffer);
	sceGuDisable(GU_BLEND);
	sceGuDisable(GU_TEXTURE_2D);
}
Пример #11
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;
}
Пример #12
0
void gEnd()
{
  if (!obj_begin || obj_list_size <= 0)
  {
    obj_begin = G_FALSE;
    return;
  }

  // Manage pspgu extensions
  if (obj_use_z)          sceGuEnable(GU_DEPTH_TEST);
  else                    sceGuDisable(GU_DEPTH_TEST);
  if (obj_use_blend)      sceGuEnable(GU_BLEND);
  else                    sceGuDisable(GU_BLEND);
  if (obj_use_vert_color) sceGuColor(WHITE);
  else                    sceGuColor(obj_list[0].color);
  if (!obj_use_tex)       sceGuDisable(GU_TEXTURE_2D);
  else
  {
    sceGuEnable(GU_TEXTURE_2D);
    if (obj_use_tex_linear) sceGuTexFilter(GU_LINEAR,GU_LINEAR);
    else                    sceGuTexFilter(GU_NEAREST,GU_NEAREST);
    if (obj_use_tex_repeat) sceGuTexWrap(GU_REPEAT,GU_REPEAT);
    else                    sceGuTexWrap(GU_CLAMP,GU_CLAMP);
    // Load texture
    sceGuTexMode(GU_PSM_8888,0,0,obj_tex->swizzled);
    sceGuTexImage(0,obj_tex->tw,obj_tex->th,obj_tex->tw,obj_tex->data);
  }

  switch (obj_type)
  {
    case RECTS: _gEndRects(); break;
    case LINES: _gEndLines(); break;
    case QUADS: _gEndQuads(); break;
  }

  sceGuColor(WHITE);
  sceGuEnable(GU_BLEND);

  obj_begin = G_FALSE;
  if (obj_use_z) zclear = G_TRUE;
}
Пример #13
0
void Light::disable(GLint glLightId_in)
{
	return;
	GLint lightId = (glLightId_in != -1)?glLightId_in:glLightId;

#ifdef ARCH_PSP
	sceGuDisable( lightId );	
#else
	glDisable(lightId);
	active_lights[lightId] = -1;
//	GLShader::setLightActivation(glLightId,0);
#endif
};
Пример #14
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));
    }
Пример #15
0
void Sprite::Draw()
{
    sceGumPushMatrix();

    ScePspFVector3 loc = {posX,posY,0.0f};
    sceGumTranslate(&loc);

    sceGuEnable(GU_TEXTURE_2D);
    TextureManager::Instance()->SetTexture(imageName,GU_NEAREST,GU_NEAREST);

    sceGumDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices);

    sceGuDisable(GU_TEXTURE_2D);
    sceGumPopMatrix();
}
Пример #16
0
void draw() {
	startFrame();
	sceGuDisable(GU_TEXTURE);

	sceGuDrawArray(GU_POINTS, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices1);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices1 + 1);
	sceGuDrawArray(GU_POINTS, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices1x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices1x + 1);

	sceGuDrawArray(GU_LINES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices2);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices2 + 1);
	sceGuDrawArray(GU_LINES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices2x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices2x + 1);

	sceGuDrawArray(GU_LINE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices3);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices3 + 1);
	sceGuDrawArray(GU_LINE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices3x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices3x + 1);

	sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices4);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices4 + 1);
	sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices4x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices4x + 1);

	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices5);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices5 + 1);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices5x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices5x + 1);

	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices6);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices6 + 1);
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices6x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices6x + 1);

	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices7);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices7 + 1);
	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices7x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices7x + 1);

	// Verify that it also works when auto-increasing the vertex pointer.
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices8);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, NULL);
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices8x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, NULL);

	endFrame();
}
Пример #17
0
void drawCube( Texture* texture, int val )
{
    // setup matrices for cube

    sceGumMatrixMode(GU_PROJECTION);
    sceGumLoadIdentity();
    sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

    sceGumMatrixMode(GU_VIEW);
    {
        ScePspFVector3 pos = {0.0f,0.0f,-2.5f};

        sceGumLoadIdentity();
        sceGumTranslate(&pos);
    }

    sceGumMatrixMode(GU_MODEL);
    {
        ScePspFVector3 rot = {val * 0.263f * (GU_PI/180.0f), val * 0.32f * (GU_PI/180.0f), val * 0.44f * (GU_PI/180.0f)};

        sceGumLoadIdentity();
        sceGumRotateXYZ(&rot);
    }

    // setup texture

    sceGuTexMode(texture->format,0,0,0);
    sceGuTexImage(texture->mipmap,texture->width,texture->height,texture->stride,texture->data);
    sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB);
    sceGuTexFilter(GU_LINEAR,GU_LINEAR);
    sceGuTexScale(1.0f,1.0f);
    sceGuTexOffset(0.0f,0.0f);
    sceGuAmbientColor(0xffffffff);

    sceGuEnable(GU_TEXTURE_2D);

    // draw cube

    sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,cube_vertices);

    sceGuDisable(GU_TEXTURE_2D);
}
Пример #18
0
void init() { 
	sceGuInit();
	sceGuStart(GU_DIRECT, list);
	sceGuDrawBuffer(GU_PSM_8888, fbp0, 512);
	sceGuDispBuffer(480, 272, fbp0, 512);
	sceGuDepthBuffer(dbp0, 512);
	sceGuOffset(2048 - (240 / 2), 2048 - (136 / 2));
	sceGuViewport(2048, 2048, 240, 136);
	sceGuDepthRange(65535, 0);
	sceGuDepthMask(0);
	sceGuScissor(0, 0, 480, 272);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuDisable(GU_TEXTURE_2D);

	ScePspFMatrix4 ones = {
		{1, 0, 0, 0},
		{0, 1, 0, 0},
		{0, 0, 1, 0},
		{0, 0, 0, 1},
	};

	sceGuSetMatrix(GU_MODEL, &ones);
	sceGuSetMatrix(GU_VIEW, &ones);
	sceGuSetMatrix(GU_PROJECTION, &ones);

	sceGuFinish();
	sceGuSync(0, 0);
 
	sceDisplayWaitVblankStart();
	sceGuDisplay(1);

	memset(copybuf, 0x44, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();
	sceDmacMemcpy(sceGeEdramGetAddr(), copybuf, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();

	displayBuffer("Initial");
}
Пример #19
0
int MFRenderer_CreateDisplay()
{
	gDisplay.width = SCR_WIDTH;
	gDisplay.height = SCR_HEIGHT;
	gDisplay.wide = true;

	gCurrentViewport.x = 0.0f;
	gCurrentViewport.y = 0.0f;
	gCurrentViewport.width = SCR_WIDTH;
	gCurrentViewport.height = SCR_HEIGHT;

	sceGuInit();

	sceGuStart(GU_DIRECT, displayList);
	sceGuDrawBuffer(GU_PSM_8888, (void*)0, BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)FRAME_SIZE, BUF_WIDTH);
	sceGuDepthBuffer((void*)(FRAME_SIZE*2), BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
	sceGuDepthRange(0x0, 0xFFFF);
	sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuDepthFunc(GU_LEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CCW); // NOTE: not CCW
	sceGuShadeModel(GU_SMOOTH);
	sceGuDisable(GU_CULL_FACE);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	return 0;
}
Пример #20
0
int main(int argc, char* argv[])
{
	pspDebugScreenInit();

	setupCallbacks();

	// setup GU

	void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
	void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

	sceGuInit();

	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
	sceGuDepthBuffer(zbp,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(65535,0);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	int val = 0;

	gettimeofday(&base_time,0);

	while(running())
	{
		struct Vertex* vertices;
		struct timeval tv;

		sceGuStart(GU_DIRECT,list);

		// clear screen

		sceGuClearColor(0);
		sceGuClearDepth(0);
		sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

		// draw triangle 1 (normal)

		sceGuColor(0xffffffff);

		vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex));
		vertices[0].x = (SCR_WIDTH/2) + cosf(val * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].y = (SCR_HEIGHT/2) + sinf(val * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].z = 0;
		vertices[1].x = (SCR_WIDTH/2) + cosf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].y = (SCR_HEIGHT/2) + sinf((val+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].z = 0;
		vertices[2].x = (SCR_WIDTH/2) + cosf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].y = (SCR_HEIGHT/2) + sinf((val+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].z = 0;
		sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices);

		// draw triangle 2 (affected by logic op)

		sceGuEnable(GU_COLOR_LOGIC_OP);
		sceGuLogicalOp(curr_state);

		sceGuColor(0xffff00ff);

		vertices = (struct Vertex*)sceGuGetMemory(3*sizeof(struct Vertex));
		vertices[0].x = (SCR_WIDTH/2) + cosf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].y = (SCR_HEIGHT/2) + sinf((val*1.1f) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[0].z = 0;
		vertices[1].x = (SCR_WIDTH/2) + cosf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].y = (SCR_HEIGHT/2) + sinf((val*1.1f+120) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[1].z = 0;
		vertices[2].x = (SCR_WIDTH/2) + cosf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].y = (SCR_HEIGHT/2) + sinf((val*1.1f+240) * (GU_PI/180)) * (SCR_HEIGHT/2);
		vertices[2].z = 0;
		sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_2D,3,0,vertices);

		sceGuDisable(GU_COLOR_LOGIC_OP);

		sceGuFinish();
		sceGuSync(0,0);

		gettimeofday(&tv,0);
		if ((tv.tv_sec-base_time.tv_sec) > TIME_SLICE)
		{
			curr_state = (curr_state + 1) & 15;
			base_time = tv;
		}

		sceDisplayWaitVblankStart();
		sceGuSwapBuffers();
		pspDebugScreenSetXY(0,0);
		pspDebugScreenPrintf("%s",names[curr_state]);

		val++;
	}

	sceGuTerm();

	sceKernelExitGame();
	return 0;
}
Пример #21
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;
}
Пример #22
0
bool8 S9xSceGUInit2 (void)
{
  SceGU.line_size        = 512;
  SceGU.max_texture_size = 512;

  if (SceGU.max_texture_size >= 512)
  {
      SceGU.texture_size = 512;
//        SceGU.num_textures = 2; // See note in 3d.h
      SceGU.num_textures = 1;
  }
  else
  {
      SceGU.texture_size = SceGU.max_texture_size;
      SceGU.num_textures = 1;
  }

  // TODO
  ///////Settings.SceGUEnable = TRUE;


  // 2nd texture may be reserved for transparency in the future.
#if 0
  if (SceGU.num_textures == 2)
  {
  }
#endif

  // Use a 16-bit pixel format 5-bits for RGB and 1-bit for Alpha (unused)
  SceGU.texture_format = GU_PSM_5551;
  SceGU.pixel_format   = GU_PSM_5551;
  SceGU.ct             = GU_COLOR_5551;
  SceGU.tt             = GU_TEXTURE_16BIT;
  SceGU.mt             = GU_VERTEX_16BIT;
  SceGU.dm             = GU_TRANSFORM_2D;

  sceGuStart (0, SceGU.list);

    sceGuDrawBufferList (SceGU.pixel_format, (void *)0,        SceGU.line_size);
    sceGuDispBuffer     (480, 272,           (void *)0x88000,  SceGU.line_size);
    sceGuDepthBuffer    (                    (void *)0x110000, SceGU.line_size);
    sceGuOffset         (0, 0);
    sceGuViewport       ((480 / 2), (272 / 2), 480, 272);
    sceGuDepthRange     (0xc350, 0x2710);
    sceGuScissor        (0, 0, 480, 272);
    sceGuEnable         (GU_SCISSOR_TEST);
    sceGuDisable        (GU_ALPHA_TEST);
    sceGuDisable        (GU_DEPTH_TEST);
    sceGuEnable         (GU_CULL_FACE);
    sceGuDisable        (GU_LIGHTING);
    sceGuFrontFace      (GU_CW);
    sceGuEnable         (GU_TEXTURE_2D);
    sceGuClear          (GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);

#if 0
    sceGuTexWrap        (GE_WRAP_REPEAT, GE_WRAP_REPEAT);
    sceGuTexFunc        (GU_TFX_MODULATE, /*GE_TCC_RGBA*/ GE_TCC_RGB);
#endif
  sceGuFinish ();

  sceGuSync   (0, 0);

  S9xSceGUSwapBuffers ();

  return (TRUE);
}
Пример #23
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



}
Пример #24
0
void app() {
    setupCallbacks();

    #ifdef DEBUG
    pspDebugScreenInit();
    #endif

    sceGuInit();

    void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
    void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
    void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

    sceGuStart(GU_DIRECT, list);

    sceGuDrawBuffer(GU_PSM_8888, fbp0, BUF_WIDTH);
    sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, fbp1, BUF_WIDTH);
    sceGuDepthBuffer(zbp, BUF_WIDTH);

    sceGuOffset(2048 - (SCR_WIDTH / 2), 2048 - (SCR_HEIGHT / 2));
    sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);

    sceGuDepthRange(65535, 0);
    sceGuClearDepth(65535);
    sceGuDepthFunc(GU_LEQUAL);

    sceGuAlphaFunc(GU_GREATER, 0, 255);
    sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
    sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
    sceGuTexFilter(GU_LINEAR, GU_LINEAR);
    sceGuShadeModel(GU_SMOOTH);

    sceGuEnable(GU_DEPTH_TEST);
    sceGuEnable(GU_ALPHA_TEST);
    sceGuEnable(GU_SCISSOR_TEST);
    sceGuEnable(GU_BLEND);

    sceGuDisable(GU_CULL_FACE);
    sceGuDisable(GU_CLIP_PLANES);
    sceGuDisable(GU_DITHER);

    sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);

    sceGuFinish();
    sceGuSync(0, 0);

    sceDisplayWaitVblankStart();
    sceGuDisplay(GU_TRUE);


    //g2dInit();

    /*tileset_tex = g2dTexLoad((char *) "resources/tilemap.png", G2D_SWIZZLE);
    outline_tex = g2dTexLoad((char *) "resources/tilemap2.png", G2D_SWIZZLE);
    text_tex = g2dTexLoad((char *) "resources/ui-font.png", G2D_SWIZZLE);
    frame_tex = g2dTexLoad((char *) "resources/frame.png", G2D_SWIZZLE);*/

    while (running()) {
        sceGuStart(GU_DIRECT,list);

        // Clear screen
        sceGuClearColor(0xff554433); // TODO change to black when everything works
        sceGuClearDepth(0);
        sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);

        // Process and draw a frame
        //menu.update();
        //background.draw();
        //menu.draw();
        
        sceGuFinish();
        sceGuSync(0,0);

        // Swap buffers and wait for VSYNC
        sceDisplayWaitVblankStart();
        sceGuSwapBuffers();
    }

    sceGuDisplay(GU_FALSE);
    sceGuTerm();

    sceKernelExitGame();
}
Пример #25
0
void DrawTilePSP (uint32 Tile, uint32 Offset, uint32 StartLine,
      uint32 LineCount)
{
    TILE_PREAMBLE

    float x = Offset % GFX.Pitch;
    float y = Offset / GFX.Pitch;

#define X 0
#define Y 1

#define U 0
#define V 1

    float pos [3][4];
    float tex [2][4];

    static bool8 init = FALSE;

    if (init == FALSE) {
    sceGuStart(0,list);
    sceGuDrawBufferList(GE_PSM_5551,(void*)0,512);
    sceGuDispBuffer(480,272,(void*)0x88000,512);
    sceGuDepthBuffer((void*)0x110000,512);
    sceGuOffset(0,0);
    sceGuViewport(480/2,272/2,480,272);
    sceGuDepthRange(0xc350,0x2710);
    sceGuScissor(0,0,480,272);
    sceGuEnable(GU_STATE_SCISSOR);
    sceGuDisable(GU_STATE_ATE);
    sceGuDisable(GU_STATE_ZTE);
    sceGuEnable(GU_STATE_CULL);
    sceGuDisable(GU_STATE_ALPHA);
    sceGuDisable(GU_STATE_LIGHTING);
    sceGuFrontFace(GE_FACE_CW);
    sceGuEnable(GU_STATE_TEXTURE);
    sceGuClear(GE_CLEAR_COLOR|GE_CLEAR_DEPTH);
    sceGuFinish();
    sceGuSync(0,0);

    init = TRUE;
    }

    pos [0][X] = 0 + x * 1;
    pos [0][Y] = 0 + y * 1;
    pos [1][X] = 0 + (x + 8.0f) * 1;
    pos [1][Y] = 0 + y * 1;
    pos [2][X] = 0 + (x + 8.0f) * 1;
    pos [2][Y] = 0 + (y + LineCount) * 1;
    pos [3][X] = 0 + x * 1;
    pos [4][Y] = 0 + (y + LineCount) * 1;

    if (!(Tile & (V_FLIP | H_FLIP)))
    {
  // Normal
  tex [0][U] = 0.0f;
  tex [0][V] = StartLine;
  tex [1][U] = 8.0f;
  tex [1][V] = StartLine;
  tex [2][U] = 8.0f;
  tex [2][V] = StartLine + LineCount;
  tex [3][U] = 0.0f;
  tex [3][V] = StartLine + LineCount;
    }
    else
    if (!(Tile & V_FLIP))
    {
  // Flipped
  tex [0][U] = 8.0f;
  tex [0][V] = StartLine;
  tex [1][U] = 0.0f;
  tex [1][V] = StartLine;
  tex [2][U] = 0.0f;
  tex [2][V] = StartLine + LineCount;
  tex [3][U] = 8.0f;
  tex [3][V] = StartLine + LineCount;

    }
    else
    if (Tile & H_FLIP)
    {
  // Horizontal and vertical flip
  tex [0][U] = 8.0f;
  tex [0][V] = StartLine + LineCount;
  tex [1][U] = 0.0f;
  tex [1][V] = StartLine + LineCount;
  tex [2][U] = 0.0f;
  tex [2][V] = StartLine;
  tex [3][U] = 8.0f;
  tex [3][V] = StartLine;

    }
    else
    {
  // Vertical flip only
  tex [0][U] = 0.0f;
  tex [0][V] = StartLine + LineCount;
  tex [1][U] = 8.0f;
  tex [1][V] = StartLine + LineCount;
  tex [2][U] = 8.0f;
  tex [2][V] = StartLine;
  tex [3][U] = 0.0f;
  tex [3][V] = StartLine;

    }

    sceGuStart(0,list);

    sceGuTexMode(GU_PSM_5551,0,0,0);
    sceGuTexFunc(GU_TFX_REPLACE,0);
    sceGuTexOffset(0,0);
    sceGuAmbientColor(0xffffffff);


    sceGuTexImage (0, 8, 8, 8, (void *)pCache);
    sceGuTexScale (1.0/8.0f, 1.0f/8.0f);

    struct Vertex *vertices;
    vertices = (struct Vertex *)sceGuGetMemory (4 * sizeof (struct Vertex));

    vertices[0].u = tex[0][U]; vertices[0].v = tex[0][V];
    vertices[0].x = pos[0][X]; vertices[0].y = pos[0][Y]; vertices[0].z = 0.0f;
    vertices[1].u = tex[1][U]; vertices[1].v = tex[1][V];
    vertices[1].x = pos[1][X]; vertices[1].y = pos[1][Y]; vertices[1].z = 0.0f;
    vertices[2].u = tex[2][U]; vertices[2].v = tex[2][V];
    vertices[2].x = pos[2][X]; vertices[2].y = pos[2][Y]; vertices[2].z = 0.0f;
    vertices[3].u = tex[3][U]; vertices[3].v = tex[3][V];
    vertices[3].x = pos[3][X]; vertices[3].y = pos[3][Y]; vertices[3].z = 0.0f;

    sceGuDrawArray (GU_PRIM_TRIANGLES,GE_SETREG_VTYPE(GE_TT_16BIT,GE_CT_5551,0,GE_MT_16BIT,0,0,0,0,GE_BM_2D),4,0,vertices);

    sceGuFinish ();
}
Пример #26
0
void StateOptions::Draw(StateManager* sManager)
{
    //start rendering
    mRender->StartFrame(1,1,1);

    switch(menuState)
    {
    case 0:
    {
        sceGuDisable(GU_DEPTH_TEST);
        sceGuEnable(GU_BLEND);
        sceGuColor(GU_COLOR(1,1,1,1.0f));

        for(int x = 0; x < 8; x++)
        {
            for(int y = 0; y < 5; y++)
            {
                backSprite->SetPosition(x*64,y*64);
                backSprite->Draw();
            }
        }


        //Controls
        buttonSprite->SetPosition(240,120);
        buttonSprite->Draw();

        //sensity - analog stick
        buttonSprite->SetPosition(240,160);
        buttonSprite->Draw();

        //back
        buttonSprite->SetPosition(240,200);
        buttonSprite->Draw();


        //selected button
        sbuttonSprite->SetPosition(240,(selectPos * 40) + 120);
        sbuttonSprite->Draw();

        sceGuDisable(GU_BLEND);
        sceGuEnable(GU_DEPTH_TEST);

        //draw subtitles on buttons

        selectPos == 0 ? DrawText(240,129,GU_COLOR(1,1,0,1) ,default_size,"Controls") : DrawText(240,129,GU_COLOR(1,1,1,1) ,default_size,"Controls");
        selectPos == 1 ? DrawText(240,169,GU_COLOR(1,1,0,1) ,default_size,"Analog stick") : DrawText(240,169,GU_COLOR(1,1,1,1) ,default_size,"Analog stick");
        selectPos == 2 ? DrawText(240,209,GU_COLOR(1,1,0,1) ,default_size,"Back") : DrawText(240,209,GU_COLOR(1,1,1,1) ,default_size,"Back");

        DrawText(240,29,GU_COLOR(1,1,1,1) ,default_size,"Options");
    }
    break;
    case 1://controls
    {
        sceGuDisable(GU_DEPTH_TEST);
        sceGuEnable(GU_BLEND);
        sceGuColor(GU_COLOR(1,1,1,1.0f));

        for(int x = 0; x < 8; x++)
        {
            for(int y = 0; y < 5; y++)
            {
                backSprite->SetPosition(x*64,y*64);
                backSprite->Draw();
            }
        }


        int starty = 60;
        //something
        for(int i = controlStart; i < controlEnd; i++)
        {
            if(controlPos == i)
            {
                halfsbuttonSprite->SetPosition(160,starty + (i * 30) - (controlStart * 30));
                halfsbuttonSprite->Draw();
            } else
            {
                halfbuttonSprite->SetPosition(160,starty + (i * 30) - (controlStart * 30));
                halfbuttonSprite->Draw();
            }
        }

        //back
        if(controlPos == 16)
        {
            sbuttonSprite->SetPosition(240,260);
            sbuttonSprite->Draw();
        } else
        {
            buttonSprite->SetPosition(240,260);
            buttonSprite->Draw();
        }

        sceGuDisable(GU_BLEND);
        sceGuEnable(GU_DEPTH_TEST);

        //write action names
        starty = 67;
        mRender->SetFontStyle(default_size,0xFFFFFFFF,0,0x00000000);
        for(int i = controlStart; i < controlEnd; i++)
        {
            //action
            mRender->DebugPrint(250,starty + (i * 30) - (controlStart * 30)+4,InputHelper::Instance()->getActionName(i).c_str());
        }

        mRender->SetFontStyle(default_big_size,0xFFFFFFFF,0,0x00000200);
        starty = 65;
        for(int i = controlStart; i < controlEnd; i++)
        {
            //button assigned to this action
            if(controlPos == i && chooseKeyState == true)
                mRender->DebugPrint(160,starty + (i * 30) - (controlStart * 30)+4,"...");
            else
                mRender->DebugPrint(160,starty + (i * 30) - (controlStart * 30)+4,InputHelper::Instance()->getButtonName(InputHelper::Instance()->getConnection(i).button).c_str());
        }

        DrawText(240,269,GU_COLOR(1,1,0,1) ,default_size,"Back");
        DrawText(240,29,GU_COLOR(1,1,1,1) ,default_size,"Controls");
    }
    break;
    case 2://analog stick
    {
        sceGuDisable(GU_DEPTH_TEST);
        sceGuEnable(GU_BLEND);
        sceGuColor(GU_COLOR(1,1,1,1.0f));

        for(int x = 0; x < 8; x++)
        {
            for(int y = 0; y < 5; y++)
            {
                backSprite->SetPosition(x*64,y*64);
                backSprite->Draw();
            }
        }

        //something
        nbuttonSprite->SetPosition(240,100);
        nbuttonSprite->Draw();

        nbuttonSprite->SetPosition(240,130);
        nbuttonSprite->Draw();

        nbuttonSprite->SetPosition(240,160);
        nbuttonSprite->Draw();

        nbuttonSprite->SetPosition(240,190);
        nbuttonSprite->Draw();

        //back
        buttonSprite->SetPosition(240,260);
        buttonSprite->Draw();

        if(currentAnalogPos < 4)
        {
            sbuttonSprite->SetPosition(240,100 + (currentAnalogPos * 30));
            sbuttonSprite->Draw();
        } else
        {
            sbuttonSprite->SetPosition(240,260);
            sbuttonSprite->Draw();
        }

        moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogYup) * 10) * 20),100);
        moverSprite->Draw();

        moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogYdown) * 10) * 20),130);
        moverSprite->Draw();

        moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogXleft) * 10) * 20),160);
        moverSprite->Draw();

        moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogXright) * 10) * 20),190);
        moverSprite->Draw();

        sceGuDisable(GU_BLEND);
        sceGuEnable(GU_DEPTH_TEST);

        mRender->SetFontStyle(default_size,0xFFFFFFFF,0,0x00000200);

        mRender->DebugPrint(240,109,"Analog up : %d%%",(int)(fabs(InputHelper::Instance()->analogYup) * 100.0f));
        mRender->DebugPrint(240,139,"Analog down : %d%%",(int)(fabs(InputHelper::Instance()->analogYdown) * 100.0f));
        mRender->DebugPrint(240,169,"Analog left : %d%%",(int)(fabs(InputHelper::Instance()->analogXleft) * 100.0f));
        mRender->DebugPrint(240,199,"Analog right : %d%%",(int)(fabs(InputHelper::Instance()->analogXright) * 100.0f));

        mRender->DebugPrint(240,269,"Back");
        DrawText(240,29,GU_COLOR(1,1,1,1) ,default_size,"Analog stick");
    }
    break;
    }

    //end frame
    mRender->EndFrame();
}
Пример #27
0
void StartUpDisplay()
{
	//ScePspFVector3	vec;

	_rotationSpeed = 1.0f;
	_rotation.x = 0.0f;
	_rotation.y = 0.0f;
	_rotation.z = 0.0f;
	_bgColour = 0;
	_frame = 0;
	_viewMode = 0;
	sceGuInit();
	sceGuStart(SCEGU_IMMEDIATE, (void *)disp_list, sizeof(disp_list));

	sceGuDrawBuffer(SCEGU_PF5551, SCEGU_VRAM_BP_0, SCEGU_VRAM_WIDTH);
	sceGuDispBuffer(SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT, SCEGU_VRAM_BP_1,
		SCEGU_VRAM_WIDTH);
	sceGuDepthBuffer(SCEGU_VRAM_BP_2, SCEGU_VRAM_WIDTH);

	sceGuOffset(SCEGU_SCR_OFFSETX, SCEGU_SCR_OFFSETY);
	sceGuViewport(2048, 2048, SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT);
	sceGuDepthRange(50000, 10000);

	sceGuDisable(SCEGU_BLEND);

	sceGuScissor(0, 0, SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT);
	sceGuEnable(SCEGU_SCISSOR_TEST);

	sceGuDepthFunc(SCEGU_GEQUAL);
	sceGuEnable(SCEGU_DEPTH_TEST);

	sceGuFrontFace(SCEGU_CW);

	sceGuDisable(SCEGU_TEXTURE);
	sceGuShadeModel(SCEGU_SMOOTH);

	sceGuEnable(SCEGU_DITHER);

	//vec.x = 0.0f;
	//vec.y = 0.0f;
	//vec.z = 1.0f;
	//sceGuLightColor(0, SCEGU_DIFFUSE, 0xffffffff);
	//sceGuLight(0, SCEGU_LIGHT_DIRECTION, SCEGU_DIFFUSE, &vec);
	//vec.x = 1.0f;
	//vec.y = 0.0f;
	//vec.z = 0.0f;
	//sceGuLightColor(1, SCEGU_DIFFUSE, 0xff00ffff);
	//sceGuLight(1, SCEGU_LIGHT_DIRECTION, SCEGU_DIFFUSE, &vec);
	//vec.x = -1.0f;
	//vec.y = 0.0f;
	//vec.z = 0.0f;
	//sceGuLightColor(2, SCEGU_DIFFUSE, 0xffff00ff);
	//sceGuLight(2, SCEGU_LIGHT_DIRECTION, SCEGU_DIFFUSE, &vec);
	//sceGuEnable(SCEGU_LIGHT0);
	//sceGuEnable(SCEGU_LIGHT1);
	//sceGuEnable(SCEGU_LIGHT2);
	//sceGuEnable(SCEGU_LIGHTING);

	//sceGuFog(14.50, 25.0, 0x007f00ff);

	//sceGuAmbient(0xcc004cb2);
	sceGuAmbient(0xffffffff);
	sceGuColor(0xff0000ff);

	//sceGuTexMode(SCEGU_PF5551, 1, SCEGU_SINGLE_CLUT, SCEGU_TEXBUF_NORMAL);
	//sceGuTexFilter(SCEGU_LINEAR_MIPMAP_NEAREST, SCEGU_LINEAR);
	//sceGuTexFunc(SCEGU_TEX_MODULATE, SCEGU_RGB);
	//sceGuTexWrap(SCEGU_REPEAT, SCEGU_REPEAT);

	sceGumSetMatrixStack(matrix_stack, 1, 1, 2, 0);
	sceGumMatrixMode(SCEGU_MATRIX_PROJECTION);
	sceGumLoadIdentity();
	sceGumPerspective(SCEGU_RAD(45.0f), SCEGU_SCR_ASPECT,
		1.000000f, 100.000000f);

	sceGumMatrixMode(SCEGU_MATRIX_WORLD);

	sceGuClearDepth(0);
	sceGuClearStencil(0);

	sceGuFinish();
	sceGuSync(SCEGU_SYNC_FINISH, SCEGU_SYNC_WAIT);

	sceGuDisplay(SCEGU_DISPLAY_ON);
}
Пример #28
0
//--------------------------------------------------------------------
// Función:    CFade::Update
// Creador:    Nacho (AMD)
// Fecha:      Thursday  14/06/2007  11:56:53
//--------------------------------------------------------------------
void CFade::Update(float dt)
{
	if (m_fFadeTime > 0.0f)
	{
		m_fFadeState += dt;	

		if (m_fFadeState >= m_fFadeTime)
		{
			m_bFadeActive = false;
		}

		float alpha = 0.0f;

		///--- fade in
		if (m_bFadeIn)
		{
			alpha = 255.0f - ((m_fFadeState * 255.0f) / m_fFadeTime);
		}
		///--- fade out
		else
		{
			alpha = ((m_fFadeState * 255.0f) / m_fFadeTime);
		}

		alpha = MAT_Clampf(alpha, 0.0f, m_fTarget);		

		if (alpha > 0.0f)
		{		
			VERT* v = (VERT*)sceGuGetMemory(sizeof(VERT) * 2);
			
			VERT* v0 = &v[0];
			VERT* v1 = &v[1];

			int alpha_integer = (((int)alpha) & 0xFF) << 24;

			v0->x = -1.0f;
			v0->y = -1.0f;
			v0->z = 0.0f;
			
			v1->x = 481.0f;
			v1->y = 273.0f;
			v1->z = 0.0f;	

			sceGuColor((m_iColor & 0x00ffffff) | alpha_integer);

			sceGuDisable(GU_TEXTURE_2D);

			sceGuDisable(GU_DEPTH_TEST);		

			sceGuEnable(GU_BLEND);
			sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
			
			sceGumDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, v);		

			sceGuEnable(GU_DEPTH_TEST);
			
			sceGuDisable(GU_BLEND);

			sceGuEnable(GU_TEXTURE_2D);
			sceGuColor(0xffffffff);
		}
	}
}
Пример #29
0
void StateOptions::Draw(StateManager* sManager)
{
	//start rendering
	mRender->StartFrame();

	switch(menuState)
	{
		case 0:
		{
			sceGuDisable(GU_DEPTH_TEST);
			sceGuEnable(GU_BLEND);
			sceGuColor(GU_COLOR(1,1,1,1.0f));

			for(int x = 0;x < 16;x++)
			{
				for(int y = 0;y < 9;y++)
				{
					backSprite->SetPosition(x*32,y*32);
					backSprite->Draw();
				}
			}

			logoSprite->Draw();

			//Controls
			buttonSprite->SetPosition(240,120);
			buttonSprite->Draw();

			//sensity - analog stick
			buttonSprite->SetPosition(240,150);
			buttonSprite->Draw();

			//texture pack
			buttonSprite->SetPosition(240,180);
			buttonSprite->Draw();

			//back
			buttonSprite->SetPosition(240,210);
			buttonSprite->Draw();


			//selected button
			sbuttonSprite->SetPosition(240,(selectPos * 30) + 120);
			sbuttonSprite->Draw();

			sceGuDisable(GU_BLEND);
			sceGuEnable(GU_DEPTH_TEST);

			//draw subtitles on buttons

			mRender->DebugPrint(240,125,"Controls");
			mRender->DebugPrint(240,155,"Analog stick");
			mRender->DebugPrint(240,185,"Texture pack");
			mRender->DebugPrint(240,215,"Back");
		}
		break;
		case 1://controls
		{
			sceGuDisable(GU_DEPTH_TEST);
			sceGuEnable(GU_BLEND);
			sceGuColor(GU_COLOR(1,1,1,1.0f));

			for(int x = 0;x < 16;x++)
			{
				for(int y = 0;y < 9;y++)
				{
					backSprite->SetPosition(x*32,y*32);
					backSprite->Draw();
				}
			}

			int starty = 60;
			//something
			for(int i = controlStart;i < controlEnd;i++)
			{
				if(controlPos == i)
				{
					halfsbuttonSprite->SetPosition(160,starty + (i * 30) - (controlStart * 30));
					halfsbuttonSprite->Draw();
				}else
				{
					halfbuttonSprite->SetPosition(160,starty + (i * 30) - (controlStart * 30));
					halfbuttonSprite->Draw();
				}
			}

			//back
			if(controlPos == 16)
			{
				sbuttonSprite->SetPosition(240,260);
				sbuttonSprite->Draw();
			}else
			{
				buttonSprite->SetPosition(240,260);
				buttonSprite->Draw();
			}

			sceGuDisable(GU_BLEND);
			sceGuEnable(GU_DEPTH_TEST);

			//write action names
			starty = 67;
			mRender->SetFontStyle(0.7f,0xFFFFFFFF,0xFF000000,0x00000000);
			for(int i = controlStart;i < controlEnd;i++)
			{
				//action
				mRender->DebugPrint(250,starty + (i * 30) - (controlStart * 30),InputHelper::Instance()->getActionName(i).c_str());
			}

			mRender->SetFontStyle(0.6f,0xFFFFFFFF,0xFF000000,0x00000200);
			starty = 65;
			for(int i = controlStart;i < controlEnd;i++)
			{
				//button assigned to this action
				if(controlPos == i && chooseKeyState == true)
					mRender->DebugPrint(160,starty + (i * 30) - (controlStart * 30),"...");
				else
					mRender->DebugPrint(160,starty + (i * 30) - (controlStart * 30),InputHelper::Instance()->getButtonName(InputHelper::Instance()->getConnection(i).button).c_str());
			}

			mRender->SetFontStyle(0.5f,0xFFFFFFFF,0xFF000000,0x00000200);
			mRender->DebugPrint(240,265,"Back");
			mRender->DebugPrint(240,20,"CONTROLS");
		}
		break;
		case 2://analog stick
		{
			sceGuDisable(GU_DEPTH_TEST);
			sceGuEnable(GU_BLEND);
			sceGuColor(GU_COLOR(1,1,1,1.0f));

			for(int x = 0;x < 16;x++)
			{
				for(int y = 0;y < 9;y++)
				{
					backSprite->SetPosition(x*32,y*32);
					backSprite->Draw();
				}
			}

			logoSprite->Draw();

			//something
			buttonSprite->SetPosition(240,100);
			buttonSprite->Draw();

			buttonSprite->SetPosition(240,130);
			buttonSprite->Draw();

			buttonSprite->SetPosition(240,160);
			buttonSprite->Draw();

			buttonSprite->SetPosition(240,190);
			buttonSprite->Draw();

			//back
			buttonSprite->SetPosition(240,260);
			buttonSprite->Draw();

			if(currentAnalogPos < 4)
			{
				sbuttonSprite->SetPosition(240,100 + (currentAnalogPos * 30));
				sbuttonSprite->Draw();
			}else
			{
				sbuttonSprite->SetPosition(240,260);
				sbuttonSprite->Draw();
			}

			moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogYup) * 10) * 20),100);
			moverSprite->Draw();

			moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogYdown) * 10) * 20),130);
			moverSprite->Draw();

			moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogXleft) * 10) * 20),160);
			moverSprite->Draw();

			moverSprite->SetPosition(144 +((fabs(InputHelper::Instance()->analogXright) * 10) * 20),190);
			moverSprite->Draw();

			sceGuDisable(GU_BLEND);
			sceGuEnable(GU_DEPTH_TEST);

			mRender->DebugPrint(240,105,"Analog up : %d%%",(int)(fabs(InputHelper::Instance()->analogYup) * 100.0f));
			mRender->DebugPrint(240,135,"Analog down : %d%%",(int)(fabs(InputHelper::Instance()->analogYdown) * 100.0f));
			mRender->DebugPrint(240,165,"Analog left : %d%%",(int)(fabs(InputHelper::Instance()->analogXleft) * 100.0f));
			mRender->DebugPrint(240,195,"Analog right : %d%%",(int)(fabs(InputHelper::Instance()->analogXright) * 100.0f));

			mRender->DebugPrint(240,265,"Back");
		}
		break;
		case 3:
		{
			sceGuDisable(GU_DEPTH_TEST);
			sceGuEnable(GU_BLEND);
			sceGuColor(GU_COLOR(1,1,1,1.0f));

			for(int x = 0;x < 16;x++)
			{
				for(int y = 0;y < 9;y++)
				{
					backSprite->SetPosition(x*32,y*32);
					backSprite->Draw();
				}
			}

			//select sprite
			if(TextureHelper::Instance()->packFiles.size() > 0)
			{
				selectSaveSprite->SetPosition(240,50 + (loadSavePos * 40) - (loadSaveStart * 40));
				selectSaveSprite->Draw();
			}

			//tp files
			for(int i = loadSaveStart;i <loadSaveMax;i++)
			{
				if(loadSavePos == i)
				{
					mRender->SetFontStyle(1.0f,0xFF000000,0xFFFFFFFF,0x00000000);
					mRender->DebugPrint(30,50 + (i * 40) - (loadSaveStart * 40),"%s",TextureHelper::Instance()->packFiles[i].c_str());
				}else
				{
					mRender->SetFontStyle(0.8f,0xFFFFFFFF,0xFF000000,0x00000000);
					mRender->DebugPrint(30,50 + (i * 40) - (loadSaveStart * 40),"%s",TextureHelper::Instance()->packFiles[i].c_str());
				}
			}

			//load
			buttonSprite->SetPosition(240,235);
			buttonSprite->Draw();

			//back
			buttonSprite->SetPosition(240,260);
			buttonSprite->Draw();

			//selected button
			sbuttonSprite->SetPosition(240,(loadSelectPos * 25) + 235);
			sbuttonSprite->Draw();

			sceGuDisable(GU_BLEND);
			sceGuEnable(GU_DEPTH_TEST);

			mRender->SetFontStyle(0.5f,0xFFFFFFFF,0xFF000000,0x00000200);
			mRender->DebugPrint(240,20,"Load Texture Pack");

			mRender->DebugPrint(240,240,"Load");
			mRender->DebugPrint(240,265,"Back");
		}
		break;
	}

	//end frame
	mRender->EndFrame();
}
Пример #30
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->main_dList         = memalign(16, 256); // make sure to allocate more space if bigger display lists are needed.
    psp->frame_dList        = memalign(16, 256);
    psp->rgui.dList         = memalign(16, 256);
    psp->rgui.frame         = memalign(16,  2 * 480 * 272);
    psp->frame_coords       = memalign(64,  1 * sizeof(psp1_sprite_t));
    psp->rgui.frame_coords  = memalign(64, 16 * sizeof(psp1_sprite_t));

    memset(psp->frame_coords      , 0,  1 * sizeof(psp1_sprite_t));
    memset(psp->rgui.frame_coords , 0, 16 * sizeof(psp1_sprite_t));
    sceKernelDcacheWritebackInvalidateAll();
    psp->frame_coords       = TO_UNCACHED_PTR(psp->frame_coords);
    psp->rgui.frame_coords  = TO_UNCACHED_PTR(psp->rgui.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 = 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;

    }

    sceDisplayWaitVblankStart();   // TODO : check if necessary
    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(GU_LINEAR, GU_LINEAR);  // TODO , move this to display list
    sceGuTexWrap (GU_CLAMP, GU_CLAMP);
    sceGuEnable(GU_TEXTURE_2D);
    sceGuDisable(GU_DEPTH_TEST);
    sceGuCallMode(GU_FALSE);

    sceGuFinish();
    sceGuSync(0, 0);

    sceDisplayWaitVblankStart();   // TODO : check if necessary
    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);

    sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x0000FF00, 0xFFFFFFFF); // green only
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords));
    sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF); // restore

    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_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords));

    sceGuClutMode(pixel_format, 0, color_mask, 0);
    sceGuClutLoad(lut_block_count, LUT_b);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords));

    sceGuFinish();

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

    return psp;
error:
    RARCH_ERR("PSP1 video could not be initialized.\n");
    return (void*)-1;
}