Beispiel #1
0
void hanoi(int from, int to, int via, int n)
{
	if (n > 0)
		hanoi(from, via, to, n-1);

	int from_ptr = --stackptr[from];
	int to_ptr = stackptr[to]++;
	int k = stacks[from][from_ptr];
	stacks[from][from_ptr] = 0;
	stacks[to][to_ptr] = k;

	update_screen();

	for (int k = 0; k < 10; k++)
	{
		draw_banner(banner_pos);

		if (++banner_pos == 96)
			banner_pos = 0;

		for (int i = 0; i < 100000; i++)
			asm volatile ("");
	}

	if (n > 0)
		hanoi(via, to, from, n-1);
}
void ms_tick(void)
{
	DrawScene();
	draw_banner();
	
	if (ms.state == MS_EXPANDING)
	{
		ms.expandframe++;
		
		if (ms.expandframe > EXPAND_LENGTH)
			ms.state = MS_DISPLAYED;
		else
			draw_expand();
	}
	
	if (ms.state == MS_DISPLAYED)
	{
		// scan down effect
		if (ms.current_row < map.ysize)
		{
			draw_row(ms.current_row++);
			
			if (ms.current_row < map.ysize)
				draw_row(ms.current_row++);
		}
		
		// draw map
		DrawRect(ms.x - 1, ms.y - 1, ms.x + ms.w, ms.y + ms.h, DK_BLUE);
		DrawSurface(ms.sfc, ms.x, ms.y);
		
		// you-are-here dot
		if (++ms.timer & 8)
			draw_sprite(ms.px, ms.py, SPR_MAP_PIXELS, 4);
		
		// dismissal
		if (ms.lastbuttondown)
		{
			if (!buttondown())
				ms.lastbuttondown = false;
		}
		else if (buttondown())
		{
			ms.state = MS_CONTRACTING;
		}
	}
	else if (ms.state == MS_CONTRACTING)
	{
		ms.expandframe--;
		
		if (ms.expandframe <= 0)
		{
			int param = (ms.return_gm == GM_INVENTORY) ? 1 : 0;
			game.setmode(ms.return_gm, param);
		}
		else
		{
			draw_expand();
		}
	}
}
Beispiel #3
0
int main()
{
	struct Timer fps;
	
	time_t current;
	struct tm *current_tm;
	struct Banner date_banner = {
		.string = date_string,
		.offset = 0
	};

	if (LCD_Init() != 0) {
		printf("Error initializing LCD\n");
		return 1;
	}

	LCD_SetBacklight(1);

	for (;;) {

		timer_start(&fps);

		current = time(NULL);
		current_tm = localtime(&current);
		string_print_date(date_string, current_tm);

		LCD_Clear();
		draw_clock_frame();
		draw_time(current_tm);
		update_banner(&date_banner);
		draw_banner(&date_banner, 0);
		draw_banner(&date_banner, 38);
		LCD_Display();

		if (timer_get_msecs(&fps) < 1000 / FRAMES_PER_SECOND) {
			usleep(1000 * ( 1000 / FRAMES_PER_SECOND ) - timer_get_msecs(&fps));
		}

	}

	return 0;
}
Beispiel #4
0
int draw_menu(int now, int old, int mode)
{
	int i;

	if (old == -1)
	{
		for (i = 0;i < 22;i++)
		{
			move(i, MENU_LEFT);
			if (MENU_TOP - 5 == i)
			{
				move(i, 1);
				prints("\033[36;1;40m¢~¢w¢w¢w¢w¢¡%s¡»¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w\033[37m NewsTitle \033[32;1m¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¡»%s", "\033[32;1;40m", ORG_BAR);
			}
			else if (i == MENU_TOP - 2)
				prints("\033[32;1;40m %s"ORG_BAR, main_menu[site]);
			else if (i == MENU_TOP - 4)
				prints("\033[36;1;40m¢x%2d₪כ%2d₪י¢x"ORG_BAR, ptime->tm_mon + 1, ptime->tm_mday);
			else if (i == MENU_TOP - 3)
				prints("\033[36;1;40m¢¢¢w¢w¢w¢w¢£"ORG_BAR);
			else if (i == MENU_TOP - 1)
				prints("\033[32;1mש�¡ד\033[37mMemu\033[32;40m¡דש�");
			else if (i == MENU_TOP + MAX_MENU)
				prints("\033[32;1;40mשד¡ד¡ד¡ד¡דשו"ORG_BAR);//,"\033[32;1;40m");
			else
			{
				move(i, MENU_LEFT + 2);
				if (i >= MENU_TOP && i < MENU_TOP + menu_count)
					prints("%s%6s%s", ORG_BAR, menu_list[i-MENU_TOP], ORG_BAR);
				else
					prints("%s%6s%s", ORG_BAR, " ", ORG_BAR);
			}
		}
		draw_banner(BANNER_TOP);
	}
	else
	{
		move(MENU_TOP + old, MENU_LEFT + 2);
		prints("%s%6s  %s", ORG_BAR, menu_list[old], ORG_BAR);
	}

	move(MENU_TOP + now, MENU_LEFT + 2);
	prints("%s%6s  %s", MENU_BAR, menu_list[now], ORG_BAR);
	return 0;
}
Beispiel #5
0
int fmain_menu()
{
	char c;
	int i, x, y;
	int now_main = site, old_main = 0;

	clear();
	draw_banner(MAIN_MENU_TOP - 6);

	move(MAIN_MENU_TOP - 2, MAIN_MENU_LEFT);
	prints("¢~שששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששש¢¡");
	for (i = 0;i < total_nall;i++)
	{
		x = i % MAX_MAIN_MENU ;
		y = i / MAX_MAIN_MENU ;
		if (y == 0)
		{
			move(MAIN_MENU_TOP + x, MAIN_MENU_LEFT);
			clrtohol();
		}
		move(MAIN_MENU_TOP + x, MAIN_MENU_LEFT + y*37);
		prints("%s%12s  %s", ORG_BAR, main_menu[i], ORG_BAR);
	}
	move(MAIN_MENU_TOP + MAX_MAIN_MENU + 1, MAIN_MENU_LEFT);
	prints("¢¢שששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששששש¢£");
	outz("\033[46;44m ¡i¾�§@»¡©ת¡j \033[47;31m  (¡פ¡ץ¡צ¡ק) \033[30m¿ן¾� \033[31m(Enter) \033[30m½T©w\033[31m (q)\033[30m ֲק¶}                          \033[m");
	draw_main_menu(site, site);

	do
	{
		old_main = now_main;
		c = vkey();
		switch (c)
		{
		case KEY_DOWN:
			now_main ++;
			if (now_main == total_nall)
				now_main = 0;
			draw_main_menu(now_main, old_main);
			break;
		case KEY_UP:
			now_main --;
			if (now_main < 0)
				now_main = total_nall - 1;
			draw_main_menu(now_main, old_main);
			break;
		case KEY_HOME:
		case '0':
			now_main = 0;
			draw_main_menu(now_main, old_main);
			break;
		case KEY_END:
		case '$':
			now_main = total_nall - 1;
			draw_main_menu(now_main, old_main);
			break;
		case Ctrl('U'):
						every_U();
			break;
		case KEY_RIGHT:
			now_main += MAX_MAIN_MENU ;
			if (now_main > total_nall - 1)
				now_main %= MAX_MAIN_MENU ;
			draw_main_menu(now_main, old_main);
			break ;
		case KEY_LEFT:
			if (now_main < MAX_MAIN_MENU)
	{
				if (now_main <= (total_nall - 1) % MAX_MAIN_MENU)
				{
					now_main += MAX_MAIN_MENU * ((total_nall - 1) / MAX_MAIN_MENU);
				}
				else
				{
					now_main = total_nall - 1;
				}
			}
			else
				now_main -= MAX_MAIN_MENU ;
			draw_main_menu(now_main, old_main);
			break;
		case '\n':
		case '\r':
			return now_main;
		}
	}
	while (c != 'q' && c != 'Q' && c != KEY_ESC);
	return -1;
}