Exemple #1
0
void console_main(void){
	
	//Init games
	num_games = 3;
	game_definitions = malloc(sizeof(struct game_definition)*num_games);
	game_definitions[0].main_entry = &line_racer_main;
	game_definitions[0].name = "Line Racer";
	game_definitions[0].name_len = 10;
	
	game_definitions[1].main_entry = &pong_main;
	game_definitions[1].name = "Pong";
	game_definitions[1].name_len = 4;
	
	game_definitions[2].main_entry = &_256_main;
	game_definitions[2].name = "256 Color Demo";
	game_definitions[2].name_len = 14;
	
	unsigned char selection = 0;
	while(1){
		vga_draw_string(20, 20, COLOR_WHITE, "Select Game", 11);
		int i = 0;
		for(i = 0; i < num_games; i++){
			if(selection == i){
				vga_draw_character(29, 30 + i*8, COLOR_RED, '>');
				vga_draw_string(35, 30 + i*8, COLOR_RED, game_definitions[i].name, game_definitions[i].name_len);
			}else{
				vga_draw_character(29, 30 + i*8, COLOR_BLACK, '>');
				vga_draw_string(35, 30 + i*8, COLOR_WHITE, game_definitions[i].name, game_definitions[i].name_len);
			}
			
		}
		
		if(controller_is_down(0, ps_start)){
			void (*game_entry) ();
			game_entry = game_definitions[selection].main_entry;
			game_entry();
			vga_clear_screen(COLOR_BLACK);
		}else if(controller_is_down(0, ps_dpad_down)){
			selection++;
			if(selection >= num_games)
				selection = 0;
			sleep_frames(25);
		}else if(controller_is_down(0, ps_dpad_up)){
			selection--;
			if(selection >= num_games)
				selection = num_games-1;
			sleep_frames(25);
		}
		
		sleep_frame();
	}
	
}
Exemple #2
0
////////////////////////////////////////////////////////////////////////////////
// Functions
////////////////////////////////////////////////////////////////////////////////
static void gui_draw_window(void *b, int x, int y, int width, int height)
{
	vga_filledrect(b, x, y, width - 1, 1, COLOR3);
	vga_filledrect(b, x + 1, y + 1, width - 3, 1, COLOR4);
	vga_filledrect(b, x, y + 1, 1, height - 2, COLOR3);
	vga_filledrect(b, x + 1, y + 2, 1, height - 4, COLOR4);
	vga_filledrect(b, x + width - 2, y + 1, 1, height - 3, COLOR2);
	vga_filledrect(b, x + width - 1, y, 1, height - 1, COLOR1);
	vga_filledrect(b, x + 1, y + height - 2, width - 2, 1, COLOR2);
	vga_filledrect(b, x, y + height - 1, width, 1, COLOR1);
	vga_filledrect(b, x+2, y+2, width-4, height-4, COLOR3);
	vga_filledrect(b, x+3, y+3, width-6, 18, SELECT);
	vga_draw_string(b, x+7, y+7, COLOR4, "Ticks %d", kinfo.ticks);
	vga_draw_string(b, x+7, y+27, COLOR4, "X %d Y %d", x+2, y+2);
}
Exemple #3
0
void gui_main(int argc, char **argv)
{
	extern unsigned long BootPageDirectory;
	paging_map(&BootPageDirectory, (void *)0xC0400000, (void *)0x400000, 1024*1024*8, 0x7);


	lx = x = GUI_WIDTH/2;
	ly = y = GUI_HEIGHT/2;
	x = y = 50;

	task_create(gui_daemon, 0, "moused", 0);
	
	unsigned long frames = 0;
	unsigned long tickstart = kinfo.ticks;
	while (1)
	{
		if (running == 0)
		{
			if (kinfo.gui == 1)
			{
				vga_set_mode(vgadev, GUI_WIDTH, GUI_HEIGHT, GUI_BPP);
				running = 1;
				tickstart = kinfo.ticks;
				frames = 0;
			}
			continue;
		}
		else if (kinfo.gui == 0)
		{
			vga_unset_mode(vgadev);
			running = 0;
			tty_scrolldown();
			continue;
		}
		
		frames++;
		
		// Clear
		vga_clear(vgadev, COLORBG);
		
		// Destop text
		vga_draw_string(vgadev, 0, 0, COLOR4, "EOS (Built %s %s)\n", __DATE__, __TIME__);
		vga_draw_string(vgadev, 0, 8, COLOR4, "Processor: %s", kinfo.cpuname);
		vga_draw_string(vgadev, 0, 16, COLOR4, "Memory: %dMB", kinfo.memory / 1024);
		vga_draw_string(vgadev, 0, 24, COLOR4, "Memory Used: %d", mm_used());

		vga_draw_string(vgadev, 0, 40, COLOR4, "mSPF %d", (kinfo.ticks-tickstart)/frames);
		if (kinfo.ticks - tickstart > 100)
			vga_draw_string(vgadev, 0, 48, COLOR4, "FPS %d", frames / ((kinfo.ticks-tickstart)/100));
		
		// Desktop icons
		//gui_draw_icon(vgadev, 8, 8);
		int winxnow, winynow;
		winxnow = winx;
		winynow = winy;
		gui_draw_window(vgadev, winxnow, winynow, 320, 240);
		gui_draw_icon(vgadev, winxnow+24, winynow+64);
		vga_draw_string(vgadev, winxnow+64, winynow+68, COLOR4, "Devices");
		gui_draw_icon(vgadev, winxnow+24, winynow+96);
		vga_draw_string(vgadev, winxnow+64, winynow+100, COLOR4, "Users");

		gui_draw_widget(vgadev, x, y);
		vga_flip(vgadev);
	}
}