Exemplo n.º 1
0
void infogb_vram_blit()
{
   gp_uploadTexture(&thegp, NES_TEX, 256, 0, 0, 0x02, &g_BitmapData, 160, 144);
   gp_setTex(&thegp, NES_TEX, 256, 8, GS256, 0x02, 0, 0, 0, g_Filter);

   if ( g_Stretch == 2 ) {
      gp_texrect(&thegp, 0, 16, 0, 0, 320, (256-16), 160, 144, 2,
         GS_SET_RGBA(0x00, 0x00, 0x00, 0x80));
   } else if ( g_Stretch == 1 ) {
      gp_texrect(&thegp, 40, 20, 0, 0, (240+40), (216+20), 160, 144, 2,
         GS_SET_RGBA(0x00, 0x00, 0x00, 0x80));
   } else {
      gp_texrect(&thegp, 80, 56, 0, 0, (160+80), (144+56), 160, 144, 2,
         GS_SET_RGBA(0x00, 0x00, 0x00, 0x80));
   }

   if ( g_ShowFPS ) {
      char strInfo[32];
      sprintf(strInfo, "FPS Rate: %i", PS2_FPSMeasure());
      TextOut(15, 30, strInfo, 3);
   }

   UpdateDrawing();
}
Exemplo n.º 2
0
int main()
{
	int xpos=20;
	int ypos=20;
	int xdir=1;
	int ydir=1;


	gsFontTex* fontTex;


	// Create a gsDriver with default settings
	// (320x240 32bit, double-buffer, zbuffer allocated, alpha enabled)
	gsDriver myGsDriver(NTSC);

	// Change to hi-res so can fit more of our 16x16 font on screen
	myGsDriver.setDisplayMode(640, 480,
				  NTSC, FIELD,
				  GS_PSMCT32,
				  GS_ENABLE, GS_PSMZ32,
				  2);

	gsFont myFont;

	// Won't bother creating our own gsPipe, since we can use the one created by our gsDriver
	// gsPipe myGsPipe;

	// Assign a gsPipe to the font handler
	myFont.assignPipe(&myGsDriver.drawPipe);

	// Enable alpha blending
	myGsDriver.drawPipe.setAlphaEnable(GS_ENABLE);


	// Open the file
	int filehandle = fioOpen("host:arial.fnt",O_RDONLY);

	// Get the size of the file
	int filesize = fioLseek( filehandle, 0, SEEK_END);

	// allocate space to load the file into EE mem
	fontTex = (gsFontTex*)memalign(64,filesize);

	//seek back to the start of the file
	fioLseek(filehandle, 0, SEEK_SET);

	if (fioRead(filehandle,fontTex,filesize) <= 0)
	{
		printf("Could not load texfont.fnt\n");
		while(1);
	}

	fioClose(filehandle);

	// Upload into the beginning of texture mem (with texture-buffer width set to 256)
	myFont.uploadFont(fontTex, myGsDriver.getTextureBufferBase(), 
		fontTex->TexWidth, // Use the fontTex width as texbuffer width (can use diff width)
		0, 0 );

	while (1)
	{
        // Clear the screen (with ZBuffer Disabled)
		myGsDriver.drawPipe.setZTestEnable(GS_DISABLE);
		myGsDriver.drawPipe.RectFlat(0,0,640,480,0,GS_SET_RGBA(0x00,0x00,0x00,0x80));
		myGsDriver.drawPipe.setZTestEnable(GS_ENABLE);


		// WHY IS THIS FUBAR IF DRAWN OUT OF SEQUENCE ? (Z-Test should make it okay)

		// Draw a static, solid red rectangle in the background (z=1)
		myGsDriver.drawPipe.RectFlat(
			120, 60, 120+120, 60+80,
			1, GS_SET_RGBA(0xFF,0x00,0x00,0x7F));


		// Print some text behind the moving transparent rectangle, but in-front of the static solid one

		myFont.Print(20, 400, 40, 2, GS_SET_RGBA(0xFF,0xFF,0xFF,0x80), GSFONT_ALIGN_LEFT,
			"This is some left-aligned text on the first line,\n"
			"and this is some more text.\n"
			"Don't get too excited, this is just even more text to prove that line-wrap works properly.");

		myFont.Print(140, 500, 200, 2, GS_SET_RGBA(0x20,0x20,0xFF,0x80), GSFONT_ALIGN_CENTRE,
			"This is some blue centred text.\n"
			"You can do some nice \aunderlining\a if you want to!\n"
			"It's easy, just use \\a to turn it on or off");

		myFont.Print(20, 620, 360, 2, GS_SET_RGBA(0xFF,0x20,0x20,0x80), GSFONT_ALIGN_RIGHT,
			"This is some red right-aligned text.\n"
			"You can do some nice \bbold\b text too if you want!\n"
			"Just use \\b to turn bold text on or off");



		// Draw a moving, semi-transparent, rectangle (at z=3)
		myGsDriver.drawPipe.RectFlat(
			xpos, ypos, xpos+160, ypos+120,
			3, GS_SET_RGBA(0x00,0xFF,0x00,0x40));



		// Flush the pipe, to draw the prims
		myGsDriver.drawPipe.Flush();



		// Wait for VSync and then swap buffers
		myGsDriver.WaitForVSync();

		myGsDriver.swapBuffers();

		// move the green rectangle
		xpos+=xdir;
		ypos+=ydir;

		// change dir if it hits the limits
		if (xpos>((640-160)-1)) xdir=-1;
		if (xpos<1) xdir=1;

		if (ypos>((480-120)-1)) ydir=-1;
		if (ypos<1) ydir=1;

	}
}
Exemplo n.º 3
0
void CD_disco(int type)
{
	
	putScreen(0, 0, "");
	putScreen(0, 0, "");
	
	unsigned discColor = 0;
	char discName[256];
		
	if(type==4)
	{
		sprintf(discName, "%s", "USE SWAP");
		discColor = GS_SET_RGBA(0x5A,0xD2,0x43,0x80);
	}
	if(type==2)
	{
		sprintf(discName, "%s", "PS2 CD-ROM");
		discColor = GS_SET_RGBA(0x12,0x00,0xFF,0x80);
	}
	if(type==3)
	{
		sprintf(discName, "%s", "PS2 DVD-ROM");
		discColor = GS_SET_RGBA(0xE3,0xCD,0x3B,0x80);
	}
	if(type==1)
	{
		sprintf(discName, "%s", "PSX CD-ROM");
		discColor = GS_SET_RGBA(0x00,0x00,0x00,0x80);
	}
	
	putBackground(img_fondo);
	myGsDriver->drawPipe.RectFlat(0,0,tvmx,60,0,colorNegro);
	myGsDriver->drawPipe.RectGouraud(0,420,colorNegro,tvmx,tvmy,colorAzul,0);
	myFont.uploadFont(fontTex, myGsDriver->getTextureBufferBase(), fontTex->TexWidth, 0, 0 );
	myFont.Print(420, tvmx, 15, 1, colorBlanco, GSFONT_ALIGN_LEFT, txt_1);
	myFont.Print(420, tvmx, 30, 1, colorNaranja, GSFONT_ALIGN_LEFT, "http://ps2dev.siirlabs.com");
	myGsDriver->drawPipe.RectFlat(55,125,591,367,0,colorBlanco);
	myGsDriver->drawPipe.Line(0,59,tvmx,59,0,colorGris2);
	myGsDriver->drawPipe.Line(0,420,tvmx,420,0,colorGris2);
	
	myFont.Print(53, tvmx, 97, 1, colorBlanco, GSFONT_ALIGN_LEFT, "CogSwap Loader");
	
	if(type > 0)
	{
		fillCircle(175, 245, 100, discColor);
		fillCircle(175, 245, 20, GS_SET_RGBA(0xFF,0xFF,0xFF,0x80));
		myFont.Print(304, 640, 196, 1, GS_SET_RGBA(0x0E,0x23,0xA1,0x80), GSFONT_ALIGN_LEFT, "Formato del disco:");
		myFont.Print(304, 640, 216, 1, GS_SET_RGBA(0x00,0x00,0x00,0x80), GSFONT_ALIGN_LEFT, (char *)discName);
	}
	else
	{
		myFont.Print(230, 640, 216, 1, GS_SET_RGBA(0x00,0x00,0x00,0x80), GSFONT_ALIGN_LEFT, "No Hay Disco");
	}
	
	putImage(img_logo, 21, 18);
	myFont.uploadFont(fontTex, myGsDriver->getTextureBufferBase(), fontTex->TexWidth, 0, 0 );
	myFont.Print(15, tvmx-15, 435, 1, colorGris2, GSFONT_ALIGN_LEFT, txt_40);
	
	myGsDriver->drawPipe.Flush();
	myGsDriver->WaitForVSync();
	myGsDriver->swapBuffers();
}
Exemplo n.º 4
0
int main()
{
	int xpos=30;
	int ypos=30;
	int xdir=1;
	int ydir=1;

	// Create a gsDriver with custom settings
	// (640x480 32bit, double-buffer, zbuffer allocated, alpha enabled)
	gsDriver myGsDriver(NTSC);
	
	myGsDriver.setDisplayMode(640, 480,
				  NTSC, FIELD,
				  GS_PSMCT32,
				  GS_ENABLE, GS_PSMZ32,
				  2);

	myGsDriver.drawPipe.setAlphaEnable(GS_ENABLE);
	// Won't bother creating our own gsPipe, since we can use the one created by our gsDriver
	// gsPipe myGsPipe;

	while (1)
	{
        // Clear the screen (with ZBuffer Disabled)
		myGsDriver.drawPipe.setZTestEnable(GS_DISABLE);
		myGsDriver.drawPipe.RectFlat(0,0,640,480,0,GS_SET_RGBA(0,0,0,0x80));
		myGsDriver.drawPipe.setZTestEnable(GS_ENABLE);
	
		// Draw some shapes

		// This is at the back (z=1), so will be behind the moving object
		myGsDriver.drawPipe.RectFlat(80,60,80+120,60+80,1,GS_SET_RGBA(0xFF,0,0,0x80));

		// This is also at the back (z=1)
		myGsDriver.drawPipe.TriangleGouraud(
			400, 300, 1, GS_SET_RGBA(0xFF,0x00,0x00,0x80),
			550, 320, 1, GS_SET_RGBA(0x00,0xFF,0x00,0x80),
			380, 460, 1, GS_SET_RGBA(0x00,0x00,0xFF,0x80));

		// This is near the back too (z=2)
		myGsDriver.drawPipe.TriangleLine(
			20,  240, 2, GS_SET_RGBA(0xFF,0xFF,0x00,0x80),
			220, 240, 2, GS_SET_RGBA(0xFF,0xFF,0x00,0x80),
			120, 390, 2, GS_SET_RGBA(0xFF,0xFF,0x00,0x80));

		// This moving transparent (alpha=0x40) Rectangle is in front of most of the other objects (z=3)
		myGsDriver.drawPipe.RectFlat(
			xpos, ypos,
			xpos+160, ypos+120,
			3, GS_SET_RGBA(0,0xFF,0,0x40));

		// but behind this solid gouraud 4-sided poly (z=4)
		myGsDriver.drawPipe.TriStripGouraud(
			400, 50,  4, GS_SET_RGBA(0xFF,0x00,0x00,0x80),
			550, 50,  4, GS_SET_RGBA(0xFF,0x00,0xFF,0x80),
			450, 200, 4, GS_SET_RGBA(0xFF,0x00,0xFF,0x80),
			600, 200, 4, GS_SET_RGBA(0x00,0x00,0xFF,0x80));


		// Flush the pipe, to draw the prims
		myGsDriver.drawPipe.Flush();


		// Wait for VSync and then swap buffers
		myGsDriver.WaitForVSync();

		myGsDriver.swapBuffers();

		// move the green rectangle
		xpos+=xdir;
		ypos+=ydir;

		// change dir if it hits the limits
		if (xpos>((640-160)-1)) xdir=-1;
		if (xpos<1) xdir=1;

		if (ypos>((480-120)-1)) ydir=-1;
		if (ypos<1) ydir=1;

	}
}