Пример #1
0
int main() {
	PSX_Init();
	GsInit();
	GsSetList(prim_list);
	GsClearMem();
	GsSetVideoMode(320, 240, VMODE_PAL);
	GsLoadFont(768, 0, 768, 256);
	SetVBlankHandler(prog_vblank_handler);

	while(1) {
		if(display_is_old)	{
			dbuf=!dbuf;
			GsSetDispEnvSimple(0, dbuf ? 0 : 256);
			GsSetDrawEnvSimple(0, dbuf ? 256 : 0, 320, 240);

			GsSortCls(0,0,0);

			GsPrintFont(70, 120, "Hello World");
	
			GsDrawList();
			while(GsIsDrawing());

			display_is_old=0;
		}
	}

	return 0;
}
Пример #2
0
void game_init()
{
// Initialize the PSXSDK library
	PSX_Init();
	
// Initialize graphics
	GsInit();
	
// Clear video memory	
	GsClearMem();

// Set up drawing environment
	game_drawenv.dither = 0;
	game_drawenv.draw_on_display = 0;
	game_drawenv.x = 0;
	game_drawenv.y = 0;
	game_drawenv.w = 320;
	game_drawenv.h = 240;
	game_drawenv.ignore_mask = 0;
	game_drawenv.set_mask = 0;
	
	GsSetDrawEnv(&game_drawenv);
	
// Set up display environment
	game_dispenv.x = 0;
	game_dispenv.y = 256;
	
	GsSetDispEnv(&game_dispenv);
	
// Set drawing list
	GsSetList(game_draw_list);
	
// Initialize sound
	SsInit();
	
	
}
Пример #3
0
int main() {
	PSX_Init();
	GsInit();
	GsSetList(prim_list);
	GsClearMem();
	GsSetVideoMode(320, 240, COMPILE_VMODE);
	GsLoadFont(768, 0, 768, 256);
	SetVBlankHandler(prog_vblank_handler);
	volatile int player1_score = 0;
	volatile int player2_score = 0;
	volatile int weapon1 = 0;
	volatile int weapon2 = 0;
	volatile int pause = 0;
	volatile int newround = 0;
	
	while(1) {
		if(display_is_old)	{
			dbuf=!dbuf;
			GsSetDispEnvSimple(0, dbuf ? 0 : 256);
			GsSetDrawEnvSimple(0, dbuf ? 256 : 0, 320, 240);
			
			if(newround == 1)	{
				while((pause + 240) > time_counter)	{
				};
				newround = 0;
			};

			GsSortCls(0,0,255);	

			if(player1_score == 10)	{
				GsPrintFont(5, 100, " Player 1 wins. Take that, Player 2.");
				player1_score = 0;
				player2_score = 0;
				newround = 1;
			}
			else if(player2_score == 10)	{
				GsPrintFont(5, 100, " Player 2 wins. Hah, Player 1 fails.");
				player1_score = 0;
				player2_score = 0;
				newround = 1;
			}
			else	{
				GsPrintFont(5, 100, " Take 10 paces and draw your weapons!");
			};

			GsPrintFont(5, 15, "   Rock, Paper, Scissors by Moonlit");
			GsPrintFont(5, 22, "  ----------------------------------");
			GsPrintFont(5, 45, " Choose your weapon:          Scores: ");
			GsPrintFont(5, 52, "---------------------        ---------");
			GsPrintFont(5, 60, "   SQUARE = Rock              P1: %d", player1_score);
			GsPrintFont(5, 70, "   CROSS  = Paper             P2: %d", player2_score);
			GsPrintFont(5, 80, "   CIRCLE = Scissors ");
						
			PSX_ReadPad(&pad1, &pad2);

			if(pad1 & PAD_SQUARE)	{
				//P1 ROCK
				weapon1 = 1;
			}
			else if(pad1 & PAD_CROSS)	{
				//P1 PAPER
				weapon1 = 2;
			}
			else if(pad1 & PAD_CIRCLE)	{
				//P1 SCISSORS
				weapon1 = 3;
			};
						
			if(pad2 & PAD_SQUARE)	{
				//P2 ROCK
				weapon2 = 1;
			}
			else if(pad2 & PAD_CROSS)	{
				//P2 PAPER
				weapon2 = 2;
			}
			else if(pad2 & PAD_CIRCLE)	{
				//P2 SCISSORS
				weapon2 = 3;
			};
		
			pause = time_counter;
			
			if(weapon1 > 0 && weapon2 > 0)	{
				if(weapon1 == 1) GsPrintFont(5, 130, " Player 1 chose rock...");;
				if(weapon1 == 2) GsPrintFont(5, 130, " Player 1 chose paper...");;
				if(weapon1 == 3) GsPrintFont(5, 130, " Player 1 chose scissors...");;
				if(weapon2 == 1) GsPrintFont(5, 140, " Player 2 chose rock...");;
				if(weapon2 == 2) GsPrintFont(5, 140, " Player 2 chose paper...");;
				if(weapon2 == 3) GsPrintFont(5, 140, " Player 2 chose scissors...");;

				
				// It's a draw.
				if(weapon1 == 1 && weapon2 == 1)	{
					GsPrintFont(5, 170, " Thick as two bricks.");
					GsPrintFont(5, 180, " Surely there's mortar life..?");
				};
				if(weapon1 == 2 && weapon2 == 2)	{
					GsPrintFont(5, 170, " Two sheets to the wind.");
					GsPrintFont(5, 180, " It's blowing up in here.");
				};
				if(weapon1 == 3 && weapon2 == 3)	{
					GsPrintFont(5, 170, " Neither of you are the ");
					GsPrintFont(5, 180, " sharpest in the drawer, are you?");
				};
				
				// Player 1 wins.
				if(weapon1 == 1 && weapon2 == 3)	{
					GsPrintFont(5, 160, " Careful Player 2... ");
					GsPrintFont(5, 170, " You'll ruin those scissors.");
					GsPrintFont(5, 180, " That's a point for Player 1.");
					player1_score++;
				};
				if(weapon1 == 2 && weapon2 == 1)	{
					GsPrintFont(5, 160, " Aw, gift wrapped rocks.");
					GsPrintFont(5, 170, " Really, Player 2.");
					GsPrintFont(5, 180, " You shouldn't have.");
					player1_score++;
				};
				if(weapon1 == 3 && weapon2 == 2)	{
					GsPrintFont(5, 160, " Player 2 gets the chop.");
					GsPrintFont(5, 170, " A ticker tape parade for Player 1.");
					GsPrintFont(5, 180, " What other use for shredded paper?");
					player1_score++;
				};

				// Player 2 wins.
				if(weapon2 == 1 && weapon1 == 3)	{
					GsPrintFont(5, 160, " Stab in the back for Player 1.");
					GsPrintFont(5, 170, " At least those blades");
					GsPrintFont(5, 180, " are safer now.");
					player2_score++;
				};
				if(weapon2 == 2 && weapon1 == 1)	{
					GsPrintFont(5, 160, " +1 for Player 2.");
					GsPrintFont(5, 170, " Player 1 gets stoned.");
					GsPrintFont(5, 180, " Too wrapped up in the game.");
					player2_score++;
				};
				if(weapon2 == 3 && weapon1 == 2)	{
					GsPrintFont(5, 160, " Player 1's all cut up.");
					GsPrintFont(5, 170, " It's twice as nice when ");
					GsPrintFont(5, 180, " the paper's sliced.");
					player2_score++;
				};
				
				newround = 1;
				weapon1 = 0;
				weapon2 = 0;
			};
			
					
			GsDrawList();
			while(GsIsDrawing());

			display_is_old=1;
		}
	}

	return 0;
}
Пример #4
0
int main()
{
	GsDispEnv my_dispenv;
	GsDrawEnv my_drawenv;
	GsLine my_line;
	GsSprite my_sprite;
	GsRectangle colorbox;
	GsDot my_dot;
	unsigned short pad1;
	unsigned int WasL2=0, WasR2=0, WasL1=0, WasR1=0, WasSelect = 0;
	int x, y;

	PSX_InitEx(PSX_INIT_NOBIOS);
	GsInit();
	GsClearMem();
	SetVBlankHandler(my_vblank_handler);

	// This has to be interlaced	
	GsSetVideoModeEx(640, 480, EXAMPLES_VMODE, 0, 1, 0);
	
	my_dispenv.x = 0;
	my_dispenv.y = 0;
	
	GsSetDispEnv(&my_dispenv);
	
	my_drawenv.dither = 0;
	my_drawenv.draw_on_display = 1;
	my_drawenv.x = 0;
	my_drawenv.y = 0;
	my_drawenv.w = 640;
	my_drawenv.h = 512;
	my_drawenv.ignore_mask = 0;
	my_drawenv.set_mask = 0;
	
	GsSetDrawEnv(&my_drawenv);
	
	GsSetList(primitive_list);
	
	load_ui_graphics();
	while(GsIsDrawing());
	
	colorbox.x = 0;
	colorbox.y = 0;
	colorbox.w = 640;
	colorbox.h = 511;
	colorbox.r = 255;
	colorbox.g = 255;
	colorbox.b = 255;
	colorbox.attribute = 0;
	
	GsSortRectangle(&colorbox);
	
	sort_color_boxes();
	
	
	my_sprite.x = 0;
	my_sprite.y = 0;
	my_sprite.tpage = 10;
	my_sprite.u = 0;
	my_sprite.v = 0;
	my_sprite.attribute = 0;
	my_sprite.cx = 640;
	my_sprite.cy = 480;
	my_sprite.r = my_sprite.g = my_sprite.b = NORMAL_LUMINOSITY;
	my_sprite.scalex = my_sprite.scaley = 0;
	my_sprite.w = 16;
	my_sprite.h = 24;
		
	GsDrawList();	
	while(GsIsDrawing());
	
	// Backup 32x32 area
	MoveImage(cursor_x, cursor_y, 992, 0, 32, 32);
	
	my_dot.attribute = 0;
	
	while(1)
	{	
		while(speed_counter)
		{
			old_cursor_x = cursor_x;
			old_cursor_y = cursor_y;
	
			// Restore 32x32 area
			MoveImage(992, 0, old_cursor_x, old_cursor_y, 32, 32);
			while(GsIsDrawing());
			
			PSX_ReadPad(&pad1, NULL);
		
			if(pad1 & PAD_LEFT)
				cursor_x-=cursor_speed;
			
			if(pad1 & PAD_RIGHT)
				cursor_x+=cursor_speed;
			
			if(pad1 & PAD_UP)
				cursor_y-=cursor_speed;
		
			if(pad1 & PAD_DOWN)
				cursor_y+=cursor_speed;
			
			if(cursor_x <= 0)
				cursor_x = 0;
			
			if(pad1 & PAD_CROSS)
			{
				if(cursor_y >= 384)
				{
					y = (cursor_y - 384) >> 4;
					x = cursor_x >> 6;
					
					current_color[0] = paint_colors[(y * 10)+x][0];
					current_color[1] = paint_colors[(y * 10)+x][1];
					current_color[2] = paint_colors[(y * 10)+x][2];
				}
				else
				{
				
				switch(brush_type)
				{
					case 0:
						if(cursor_y >= 384)
						{
							break;
						}
					
						my_dot.r = current_color[0];
						my_dot.g = current_color[1];
						my_dot.b = current_color[2];
						my_dot.x = cursor_x;
						my_dot.y = cursor_y;
				
						GsSortDot(&my_dot);
					break;
					case 1:
						if(cursor_y >= 380)
						{
							break;
						}
					
						my_dot.r = current_color[0];
						my_dot.g = current_color[1];
						my_dot.b = current_color[2];
						my_dot.x = cursor_x + 1;
						my_dot.y = cursor_y;
				
						GsSortDot(&my_dot);
						
						my_dot.x++;
						
						GsSortDot(&my_dot);
						
						my_dot.y++;
						my_dot.x-=2;
						
						GsSortDot(&my_dot);
						
						my_dot.x++;
						
						GsSortDot(&my_dot);
						
						my_dot.x++;
						
						GsSortDot(&my_dot);
						
						my_dot.x++;
						
						GsSortDot(&my_dot);
						
						my_dot.y++;
						my_dot.x-=2;
						
						GsSortDot(&my_dot);
						
						my_dot.x++;
						
						GsSortDot(&my_dot);
					break;
				}
				
				}
				
				GsDrawList();
				while(GsIsDrawing());
			}
				
			if((pad1 & PAD_R2) && !WasR2)
			{
				cursor_speed++;
				WasR2 = 1;
			}
				
			if((pad1 & PAD_L2) && !WasL2)
			{
				cursor_speed--;
				WasL2 = 1;
			}
			
			if(!(pad1 & PAD_R2))
				WasR2 = 0;
				
			if(!(pad1 & PAD_L2))
				WasL2 = 0;
			
			if((pad1 & PAD_R1) && !WasR1)
			{
				brush_type++;
				WasR1 = 1;
			}
			
			if((pad1 & PAD_L1) && !WasL1)
			{
				brush_type--;
				WasL1 = 1;
			}
			
			if((pad1 & PAD_SELECT) && !WasSelect)
			{
				my_sprite.attribute ^= (ENABLE_TRANS | TRANS_MODE(0));
				my_dot.attribute ^= (ENABLE_TRANS | TRANS_MODE(0));
				WasSelect = 1;
			}
			
			if(!(pad1 & PAD_SELECT))
				WasSelect = 0;
			
			if(!(pad1 & PAD_R1))
				WasR1 = 0;
				
			if(!(pad1 & PAD_L1))
				WasL1 = 0;
				
			if(cursor_speed <= 0)
				cursor_speed = 1;
				
			if(cursor_speed >= 8)
				cursor_speed = 7;
				
			if(brush_type <= 0)
				brush_type = 0;
				
			if(brush_type > 1)
				brush_type = 1;	
	
			// Backup 32x32 area
				MoveImage(cursor_x, cursor_y, 992, 0, 32, 32);
				while(GsIsDrawing());
			
		//	if(cursor_x != old_cursor_x || cursor_y != old_cursor_y)
		//	{
			//	printf("cx = %d, cy = %d, cursor_speed = %d, brush_type = %d\n",
			//	cursor_x, cursor_y, cursor_speed, brush_type);
		

			

		
				my_sprite.x = cursor_x;
				my_sprite.y = cursor_y;
				GsSortSimpleSprite(&my_sprite);
		
				GsDrawList();
				while(GsIsDrawing());
		//	}
			
			speed_counter--;
		}