Beispiel #1
0
int display_usertype(char *buf) {
	char *orig_buf=buf;
	uint32_t size = *((uint32_t*)buf);
	size = ntohl(size);
	buf+=4;
	if(strcmp(buf, "NetworkId")==0 || strcmp(buf, "IdentityId")==0 || strcmp(buf, "BufferId")==0 || strcmp(buf, "MsgId")==0) {
		printf("%s(", buf);
		buf+=strlen(buf)+1;
		buf+=display_int(buf, 0);
		printf(")");
	} else if(strcmp(buf, "Identity")==0) {
		buf+=strlen(buf)+1;
		buf+=display_map(buf);
	} else if(strcmp(buf, "BufferInfo")==0) {
		buf+=strlen(buf)+1;
		buf+=display_bufferinfo(buf);
	} else if(strcmp(buf, "Message")==0) {
		buf+=strlen(buf)+1;
		buf+=display_message(buf);
	} else if(strcmp(buf, "Network::Server")==0) {
		buf+=strlen(buf)+1;
		buf+=display_map(buf);
	} else {
		printf(" Usertype('%s') \n", buf);
		printf("Unsupported.\n");
		exit(0);
	}
	return buf-orig_buf;
}
Beispiel #2
0
int		exec_fct(SDL_Surface *screen, t_map *map)
{
  t_player	player;
  int		continuer;
  t_image	img;
  int		jump;
  t_npc		*monsters;

  SDL_EnableKeyRepeat(10, 10);
  continuer = 1;
  monsters = init_all(&img, &player, map);
  jump = 0;
  while (continuer > 0)
    {
      display_map(screen, map, &img);
      display_npcs(screen, monsters);
      display_player(screen, &player);
      display_life(screen, &player);
      SDL_Flip(screen);
      continuer = gravite(&player, map);
      if (continuer >= 0)
	player_act(&continuer, map, &player);
      if (continuer > 0)
	continuer = env_act(map, &player, monsters);
    }
  img_delete(&img);
  return (continuer);
}
Beispiel #3
0
void	display(char *map)
{
  int	start;
  int	nb_ply;
  int	nb_team;
  char	team_win;

  start = 0;
  while (42)
    {
      if ((nb_team = count_team(map)) == 1)
	team_win = get_last_team(map);
      nb_ply = count_player(map, 'a');
      start = (nb_ply >= NB_PLAY ? 1 : start);
      if (nb_ply < NB_PLAY && start == 0)
	wrt_str("-{ You have to put more player for start the game. }-\n");
      else
	wrt_str("-{ The Game is running ! }-\n");
      display_stat(map, nb_ply, nb_team);
      display_map(map);
      if (nb_ply == 1 && start == 1)
	{
	  printf("The team %d Win !!!!\n", team_win - '0');
	  break;
	}
    }
}
Beispiel #4
0
int main(void) {
    struct map map;
    int i;

    srand((unsigned int)time(NULL));
    printf("** zDemineur **\n\n");
    if(!load(&map))
        fill_map(&map);

    map_gen(&map);

    while(!iswon(&map)) {
#if defined (_WIN32) || defined (_WIN64)
        system("cls");
#else
        printf("________________________________________________________\n");
#endif
        display_map(&map);
        action(&map);
    }
    printf("\nYou won ! Here is the completely visible map :\n");
    display_map_debug(&map);

    for(i = 0; i < map.rows; ++i)
        free(map.Map[i]);

    free(map.Map);
    return 0;
}
Beispiel #5
0
int display_world (struct world *world)
{
	int ret; 
	struct position p;
	struct cell *cell;
	int team;

	if ((ret=display_map (world)) != 0) return ret;

	for (p.x=0;p.x<world->size_x;p.x++) {
		for (p.y=0;p.y<world->size_y;p.y++) {
			cell = cell_at (world, &p);

			if (cell->food > 0)
				v_set_food (&p, cell);	
			for (team=0; team<NUM_COLONIES; team++) {
				if (cell->markers[team] > 0) {
					v_set_marker (&p, cell->markers);
				}
			}
			if (cell->ant) {
				v_set_ant (cell->ant);
			}
		}
	}

	return v_redisplay_everything ();
}
Beispiel #6
0
int		main()
{
  int		**map;

  map = init_map();
  display_map(map);
  return (0);
}
Beispiel #7
0
int display_qvariant(char *buf) {
	char *orig_buf=buf;
	uint32_t type = *((uint32_t*)buf);
	type=ntohl(type);
	buf+=4;
	char null=*buf;
	buf++;
	if(null) {
		//Nothing to do
	}
	switch(type) {
		case 1:
			buf+=display_bool(buf);
			break;
		case 2:
		case 3:
			buf+=display_int(buf, type);
			break;
		case 7:
			//UTF16 byte
			buf+=display_short(buf);
			break;
		case 8:
			buf+=display_map(buf);
			break;
		case 9:
			buf+=display_list(buf);
			break;
		case 10:
			buf+=display_string(buf);
			break;
		case 11:
			buf+=display_stringlist(buf);
			break;
		case 12:
			buf+=display_bytearray(buf);
			break;
		case 15:
			buf+=display_time(buf);
			break;
		case 16:
			buf+=display_date(buf);
			break;
		case 127:
			//User type !
			buf+=display_usertype(buf);
			break;
		case 133:
			buf+=display_short(buf);
			break;
		default:
			printf("Unknown QVariant type: %d\n", type);
			exit(-1);
			break;
	};
	return buf-orig_buf;
}
Beispiel #8
0
void	display_live(t_map *map, int coord, t_x_y direct)
{
  map[coord].index = 6;
  system("clear");
  display_map(map, 0, 1, direct);
  printf("\n\n\n");
  map[coord].index = 1;
  usleep(50000);
}
Beispiel #9
0
void	image(t_env *e)
{
    if (e->img)
        mlx_destroy_image(e->mlx, e->img);
    e->img = mlx_new_image(e->mlx, e->size_x, e->size_y);
    e->img_addr = mlx_get_data_addr(e->img,
                                    &e->bits_pix, &e->size_line, &e->end);
    display_map(e);
    mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
}
Beispiel #10
0
void	perfect(char **argv, short int live, short int imparfait)
{
  t_map	*map;
  t_x_y	coord;

  x_y(&coord, argv);
  coord.live = live;
  map = create_map(coord.y, coord.x, coord);
  generator(map, coord.live, coord);
  if (imparfait)
    unperfect(map, coord.x * (coord.y / 2 + 1) + coord.y / 2, coord);
  if (coord.x < atoi(argv[1]))
    display_map(map, 1, coord.live, coord);
  else if (coord.x == atoi(argv[1]))
    display_map(map, 0, coord.live, coord);
  if (coord.x == atoi(argv[1]) && coord.y < atoi(argv[2]))
    x_one_of_two(coord.live, atoi(argv[1]), 1);
  else if (coord.y < atoi(argv[2]))
    x_one_of_two(coord.live, atoi(argv[1]), 0);
  free(map);
}
Beispiel #11
0
void main(void) 
{ 
 //   rst=0; 
    nop(); 
    nop(); 
    nop();         
//    rst=1;  
  textsize=graphicsize=size_lie/8*size_hang;// 
  textsize_l=textsize;// 
  textsize_h=textsize>>8;// 
    
  graphicsize_h=graphicsize>>8; 
  graphicsize_l=graphicsize; 
        
  text_startaddr=0x0000; 
  text_startaddr_h=text_startaddr>>8;// 
  text_startaddr_l=text_startaddr; 
    
  graphic_startaddr=text_startaddr+textsize;// 
  graphic_startaddr_h=graphic_startaddr>>8;// 
  graphic_startaddr_l=graphic_startaddr; 
 
    double_byte_parameter(text_startaddr_l,text_startaddr_h,0x40);//TEXT  
    double_byte_parameter((size_lie/8),0x00,0x41); 
    double_byte_parameter(graphic_startaddr_l,graphic_startaddr_h,0x42); 
    double_byte_parameter((size_lie/8),0x00,0x43); 
 
 
    no_parameter(0x80);//TEXT OR GRAPHIC  
    no_parameter(0xa3);// 
    CGRAM(); 
 
  while(1) 
     {         
  all_display(1,0x00); 
  no_parameter(0x98);//TEXT OFF ,GRAPHIC ON 
    display_map(&sch); 
  delay1s(); 
  display_8HO(&graphich8o); 
  delay1s(); 
      no_parameter(0x94);  //TEXT ON,GRAPHIC OFF 
  all_display(0,0x00); 
  displayHZ(); 
  delay1s(); 
  all_display(0,0x00); 
  display8hotext(); 
  delay1s(); 
    
     } 
} 
Beispiel #12
0
void	player_plays(t_rows **begin)
{
	int	matches;

	matches = ft_strlen((*begin)->line);
	display_map(begin);
	ft_putendl("It's your turn to play!");
	matches = get_players_play(matches, *begin);
	ft_screenclr();
	ft_putstr("You just removed ");
	ft_rec_putnbr(matches);
	if (matches > 1)
		ft_putendl(" matches");
	else
		ft_putendl(" matche");
}
Beispiel #13
0
/*
 * Display a "small-scale" map of the dungeon.
 *
 * Note that the "player" is always displayed on the map.
 */
void do_cmd_view_map(void)
{
	int cy, cx;
	byte w, h;
	const char *prompt = "Hit any key to continue";
	if (Term->view_map_hook) {
		(*(Term->view_map_hook))(Term);
		return;
	}
	/* Save screen */
	screen_save();

	/* Note */
	prt("Please wait...", 0, 0);

	/* Flush */
	Term_fresh();

	/* Clear the screen */
	Term_clear();

	/* store the tile multipliers */
	w = tile_width;
	h = tile_height;
	tile_width = 1;
	tile_height = 1;

	/* Display the map */
	display_map(&cy, &cx);

	/* Show the prompt */
	put_str(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2);

	/* Highlight the player */
	Term_gotoxy(cx, cy);

	/* Get any key */
	(void)anykey();

	/* Restore the tile multipliers */
	tile_width = w;
	tile_height = h;

	/* Load screen */
	screen_load();
}
Beispiel #14
0
int			display_sdl(t_graphic *c)
{
  if (SDL_FillRect(c->display.list[WINDOW], NULL, 0x000000) == -1)
    return (my_error(SDL_GetError(), FAILURE));
  if (c->map != NULL && (display_map(c) == FAILURE ||
			 display_items(c) == FAILURE ||
			 display_eggs(c) == FAILURE ||
			 display_player(c) == FAILURE ||
			 display_anims(c) == FAILURE ||
			 display_gui(c) == FAILURE))
    return (FAILURE);
  if (SDL_Flip(c->display.list[WINDOW]) == -1)
    return (my_error(SDL_GetError(), FAILURE));
  if (SDL_PollEvent(&c->display.event) == -1)
    return (my_error((SDL_GetError()), FAILURE));
  SDL_Delay(1000 * 7 / c->time / NB_SPRITES_ANIM);
  return (event(c));
}
Beispiel #15
0
/*
 * Initialize a flat 1:1 mapping
 * which is stored in global root_map
 */
static void init_rootmap()
{
	u32 pgaddr = 0;
	int pg_idx = 0;
	int pgt_idx = 0;
	u32 tablesz;
	u32 *pgtable;
	u32 *pgdir;

	tablesz = phys_pgs / PGT_ENTRIES;
	if (phys_pgs % PGT_ENTRIES)
		tablesz++;

	root_map.m_pgdir =
	pgdir = get_pages(0, 0); /* just one page for pgdir */

	root_map.m_pgtable =
	pgtable = get_pages(0, log2(tablesz));


	/* Fill the page tables */
	while (pg_idx < phys_pgs)
		pgtable[pg_idx++] = PTE_DESC(pgaddr++, PTF_PRESENT | PTF_RW);

	/* Clear the remainder of the last page table */
	while (pg_idx % PGT_ENTRIES)
		pgtable[pg_idx++] = 0 | PTF_USER | PTF_RW;

	/* Add the filled page tables to the page directory */
	for (; pgt_idx < tablesz; pgt_idx++) {
		pgdir[pgt_idx] = (u32)(pgtable + pgt_idx * PGT_ENTRIES) | PTF_PRESENT | PTF_RW | PTF_GLOBAL;
	}

	while (pgt_idx < PGT_ENTRIES)
		pgdir[pgt_idx++] = 0 | PTF_USER | PTF_RW;
#ifdef DEBUG
	display_map(&root_map);
#endif
}
Beispiel #16
0
void	get_play(t_rows **begin, int i)
{
    int len;

    len = ft_strlen((*begin)->line);
    if (i % 2 == 0)
        player_plays(begin);
    else
    {
        display_map(begin);
        ft_putchar('\n');
        ft_putendl("Computer turn!");
        ia_plays(begin);
        len = len - ft_strlen((*begin)->line);
        ft_putstr("Computer just removed ");
        ft_rec_putnbr(len);
        if (len > 1)
            ft_putendl(" matches");
        else
            ft_putendl(" matche");
    }
}
Beispiel #17
0
int	game(t_allum *allum)
{
    int	key;

    start_game("Allum1");
    refresh();
    sleep(1);
    loading();
    clear();
    while (key != 32)
    {
        start_game("Allum1");
        display_map(allum);
        attron(COLOR_PAIR(7));
        mvprintw(LINES/2 - 6, COLS/2 - 4, "Your turn");
        mvprintw(LINES/2 + 6, COLS/2 - 15, "Press Enter to select | Arrow to move");
        key = getch();
        part_one(allum, key);
        if (part_two(allum) == 1)
            return (0);
    }
    return (1);
}
Beispiel #18
0
void handle_menu_choice(eMenu item_hit) {
	std::string dialogToShow;
	sf::Event dummyEvent = {sf::Event::KeyPressed};
	short i, choice;
	
	switch(item_hit) {
		case eMenu::NONE: break;
		case eMenu::FILE_OPEN:
			do_load();
			break;
		case eMenu::FILE_SAVE:
			do_save(0);
			break;
		case eMenu::FILE_SAVE_AS:
			do_save(1);
			break;
		case eMenu::FILE_NEW:
			if(overall_mode != MODE_STARTUP) {
				std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show();
				if(choice == "cancel")
					return;
				for(i = 0; i < 6; i++)
					univ.party[i].main_status = eMainStatus::ABSENT;
				party_in_memory = false;
				reload_startup();
				overall_mode = MODE_STARTUP;
				draw_startup(0);
			}
			start_new_game();
			draw_startup(0);
			menu_activate();
			break;
		case eMenu::FILE_ABORT:
			if(overall_mode != MODE_STARTUP) {
				std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show();
				if (choice=="cancel") return;
				reload_startup();
				overall_mode = MODE_STARTUP;
			}
			party_in_memory = false;
			draw_startup(0);
			menu_activate();
			break;
		case eMenu::PREFS:
			pick_preferences();
			break;
		case eMenu::QUIT:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN) {
				std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show();
				if(choice == "cancel")
					return;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save") {
					if(univ.file.empty()) {
						univ.file = nav_put_party();
						if(univ.file.empty()) break;
					}
					save_party(univ.file, univ);
				}
			}
			All_Done = true;
			break;
		case eMenu::OPTIONS_PC_GRAPHIC:
			choice = char_select_pc(1,"New graphic for who?");
			if(choice < 6)
				pick_pc_graphic(choice,1,nullptr);
			draw_terrain();
			break;
			
		case eMenu::OPTIONS_DELETE_PC:
			if(!prime_time()) {
				ASB("Finish what you're doing first.");
				print_buf();
			}
			else {
				choice = char_select_pc(1,"Delete who?");
				if(choice < 6) {
					std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show();
					if(confirm == "yes")
						kill_pc(univ.party[choice],eMainStatus::ABSENT);
				}
				draw_terrain();
			}
			break;
			
			
		case eMenu::OPTIONS_RENAME_PC:
			choice = char_select_pc(1,"Rename who?");
			if(choice < 6)
				pick_pc_name(choice,nullptr);
			put_pc_screen();
			put_item_screen(stat_window);
			break;
			
			
		case eMenu::OPTIONS_NEW_PC:
			if(!(is_town())) {
				add_string_to_buf("Add PC: Town mode only.");
				print_buf();
				break;
			}
			for(i = 0; i < 6; i++)
				if(univ.party[i].main_status == eMainStatus::ABSENT)
					i = 20;
			if(i == 6) {
				ASB("Add PC: You already have 6 PCs.");
				print_buf();
				break;
			}
			if(univ.town->has_tavern) {
				give_help(56,0);
				create_pc(6,nullptr);
			} else {
				add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2);
			}
			print_buf();
			put_pc_screen();
			put_item_screen(stat_window);
			break;
			
		case eMenu::OPTIONS_JOURNAL:
			journal();
			break;
		case eMenu::OPTIONS_TALK_NOTES:
			if(overall_mode == MODE_TALKING) {
				ASB("Talking notes: Can't read while talking.");
				print_buf();
				return;
			}
			talk_notes();
			break;
		case eMenu::OPTIONS_ENCOUNTER_NOTES:
			adventure_notes();
			break;
		case eMenu::OPTIONS_STATS:
			if(overall_mode != MODE_STARTUP)
				print_party_stats();
			break;
		case eMenu::HELP_OUT:
			dialogToShow = "help-outdoor";
			break;
		case eMenu::HELP_TOWN:
			dialogToShow = "help-town";
			break;
		case eMenu::HELP_COMBAT:
			dialogToShow = "help-combat";
			break;
		case eMenu::HELP_BARRIER:
			dialogToShow = "help-fields";
			break;
		case eMenu::HELP_HINTS:
			dialogToShow = "help-hints";
			break;
		case eMenu::HELP_SPELLS:
			dialogToShow = "help-magic";
			break;
		case eMenu::ABOUT:
			dialogToShow = "about-boe";
			break;
		case eMenu::LIBRARY_MAGE:
			display_spells(eSkill::MAGE_SPELLS,100,0);
			break;
		case eMenu::LIBRARY_PRIEST:
			display_spells(eSkill::PRIEST_SPELLS,100,0);
			break;
		case eMenu::LIBRARY_SKILLS:
			display_skills(eSkill::INVALID,0);
			break;
		case eMenu::LIBRARY_ALCHEMY:
			// TODO: Create a dedicated dialog for alchemy info
			display_alchemy();
			break;
		case eMenu::LIBRARY_TIPS:
			tip_of_day();
			break;
		case eMenu::LIBRARY_INTRO:
			dialogToShow = "welcome";
			break;
		case eMenu::ACTIONS_ALCHEMY:
			dummyEvent.key.code = sf::Keyboard::A;
			dummyEvent.key.shift = true;
			handle_keystroke(dummyEvent);
			break;
		case eMenu::ACTIONS_WAIT:
			dummyEvent.key.code = sf::Keyboard::W;
			handle_keystroke(dummyEvent);
			break;
		case eMenu::ACTIONS_AUTOMAP:
			if(!prime_time()) {
				ASB("Finish what you're doing first.");
				print_buf();
			}
			else {
				give_help(62,0);
				display_map();
			}
			make_cursor_sword();
			break;
		case eMenu::HELP_TOC:
			if(fs::is_directory(progDir/"doc"))
				launchURL("file://" + (progDir/"doc/game/Contents.html").string());
			else launchURL("https://blades.calref.net/doc/game/Contents.html");
			break;
		case eMenu::ABOUT_MAGE:
		case eMenu::ABOUT_PRIEST:
			give_help(209,0);
			break;
		case eMenu::ABOUT_MONSTERS:
			give_help(212,0);
			break;
	}
	if(!dialogToShow.empty()) {
		cChoiceDlog dlog(dialogToShow);
		dlog.show();
	}
}
Beispiel #19
0
int gameloop(void)
{

	int viewx, viewy, ex = 0, option, redraw = 1, nx, ny, mb;

	viewx = men.x - (WIN_X-1)/2 /*10*/;
	if( viewx < 0 ) viewx = 0;
	if( viewx > DIM_X-WIN_X+1/*40*/ ) viewx = DIM_X-WIN_X+1/*40*/;

	viewy = men.y - (WIN_Y-1)/2 /*5*/;
	if( viewy < 0 ) viewy = 0;
	if( viewy > DIM_Y-WIN_Y+1/*20*/ ) viewy = DIM_Y-WIN_Y+1/*20*/;

	while(ex==0)
	{

		if(redraw > 0)
		{
			display_map( viewx, viewy );
			redraw = 0;
		}

		displaymen( viewx, viewy );

		processing( viewx, viewy );

		clearmen( viewx, viewy);

		mb = m_button();

		if(mb==1)
		{

			if(m_ypos() < 180)
			{
				nx = ((men.x - viewx)*16) - m_xpos();
				ny = ((men.y - viewy)*16) - m_ypos();

				if( (nx > 0) & (checkmap( men.x-1, men.y ) > 0) ) men.x--;
				if( (nx < -16) & (checkmap( men.x+1, men.y ) > 0) ) men.x++;
				if( (ny > 0) & (checkmap( men.x, men.y-1 ) > 0) ) men.y--;
				if( (ny < -16) & (checkmap( men.x, men.y+1 ) > 0) ) men.y++;

				redraw=1;
			}
			else
			{
				nx = m_xpos();
				if( nx > 220 & nx < 240 ) fenceit( viewx, viewy );
				if( nx > 240 & nx < 260 ) homeit(viewx, viewy );
				if( nx > 260 & nx < 280 )
				{
					displayall();
					redraw = 2;
				}
				if( nx > 280 & nx < 300 ) ex=1;
			}

			delay(250);
		}

		if(bioskey(1)!=0)
		{
			option = bioskey(0);
		}
		else
		{
			option = 0;
		}

		switch(option)
		{
		case 283:
			ex = 1;
			break;

		case 19712:

			if( (men.x < DIM_X-1/*59*/) & (checkmap( men.x + 1 , men.y ) > 0) )
				men.x++;
			redraw = 1;
			break;

		case 19200:

			if( (men.x > 0) & (checkmap( men.x - 1 , men.y ) > 0) )
				men.x--;
			redraw = 1;
			break;

		case 20480:

			if( (men.y < DIM_Y/*30*/) & (checkmap( men.x , men.y + 1 ) > 0) )
				men.y++;
			redraw = 1;
			break;

		case 18432:

			if( (men.y > 0) & (checkmap( men.x , men.y - 1 ) > 0) )
				men.y--;
			redraw = 1;
			break;

		case 18688:

			displayall();
			redraw = 2;
			break;

		case 20992:

			fenceit( viewx, viewy );
			break;

		case 18176:

			homeit( viewx, viewy );
			break;

		default:

			break;

		}

		check_greble( viewx, viewy );

		if( redraw == 1 )
		{
			redraw = 0;

			if( ( men.x - 2 ) < viewx )
			{
				viewx = men.x - (WIN_X-1)/2 /*10*/;
				if( viewx < 0 ) viewx = 0;
				redraw = 1;
			}

			if( ( men.x + 2 ) > ( viewx + WIN_X-1/*20*/ ) )
			{
				viewx = men.x - (WIN_X-1)/2 /*10*/;
				if( viewx > DIM_X-WIN_X+1/*40*/ ) viewx = DIM_X-WIN_X+1/*40*/;
				redraw = 1;
			}

			if( ( men.y - 2 ) < viewy )
			{
				viewy = men.y - (WIN_Y-1)/2 /*5*/;
				if( viewy < 0 ) viewy = 0;
				redraw = 1;
			}

			if( ( men.y + 2 ) > ( viewy + WIN_Y-1/*10*/ ) )
			{
				viewy = men.y - (WIN_Y-1)/2 /*5*/;
				if( viewy > DIM_Y-WIN_Y+1 /*20*/ ) viewy = DIM_Y-WIN_Y+1 /*20*/;
				redraw = 1;
			}
		}
	}
}
Beispiel #20
0
Boolean handle_menu (short item, HMENU)
{
    short choice,i;
    POINT x = {1001,0},pass_point;
    Boolean to_return = false;

    switch (item) {
    case 1:  // File Menu
        if (in_startup_mode == true) startup_load();
        else do_load();
        break;
    case 2:
        do_save(0);
        break;
    case 3:
        if (in_startup_mode == true) save_file(1);
        else do_save(1);
        break;
    case 4:
        if (in_startup_mode == false)
        {
            choice = FCD(1091,0);
            if (choice == 1) return false;
            for (i = 0; i < 6; i++)
                adven[i].main_status = MAIN_STATUS_ABSENT;
            party_in_memory = false;
            reload_startup();
            in_startup_mode = true;
            draw_startup(0);
        }
        start_new_game();
        draw_startup(0);
        break;
    case 6:
        pick_preferences();
        break;
    case 7:
        pick_compatibility();
        break;
    case 8:  // Quit
        if (in_startup_mode == true) {
            to_return = All_Done = true;
            break;
        }
        if (overall_mode > MODE_TOWN) {
            choice = FCD(1067,0);
            if (choice == 1) return All_Done;
        }
        else {
            choice = FCD(1066,0);
            if (choice == 3)
                break;
            if (choice == 1)
                save_file(0);
        }
        to_return = All_Done = true;
        break;

    // Options menu
    case 21:
        choice = char_select_pc(0,0,"New graphic for who?");
        if (choice < 6)
            pick_pc_graphic(choice,1,0);
        initiate_redraw();
        break;

    case 22:
        choice = select_pc(0,0);
        if (choice < 6)
            pick_pc_name(choice,0);
        put_pc_screen();
        put_item_screen(stat_window,0);
        break;


    case 23:
        if (!(is_town())) {
            add_string_to_buf("Add PC: Town mode only.");
            print_buf();
            break;
        }
        for (i = 0; i < NUM_OF_PCS; i++)
            if (adven[i].main_status == MAIN_STATUS_ABSENT)
                i = 20;
        if (i == INVALID_PC) {
            ASB("Add PC: You already have 6 PCs.");
            print_buf();
        }
        if (c_town.town_num == scenario.which_town_start) {
            give_help(56,0,0);
            create_pc(6,0);
        }
        else {
            add_string_to_buf("Add PC: You can only make new");
            add_string_to_buf("  characters in the town you ");
            add_string_to_buf("  started in.");
        }
        print_buf();
        put_pc_screen();
        put_item_screen(stat_window,0);
        break;

    case 24:
        if (prime_time() == false) {
            ASB("Finish what you're doing first.");
            print_buf();
        }
        else {
            choice = char_select_pc(0,0,"Delete who?");
            if (choice < 6) {
                if ((i = FCD(1053,0)) == 2)
                    adven[choice].kill(0);
            }
            initiate_redraw();
        }
        break;

    case 27:
        if (overall_mode == MODE_TALKING) {
            ASB("Talking notes: Can't read while talking.");
            print_buf();
            return to_return;
        }
        talk_notes();
        break;
    case 28:
        adventure_notes();
        break;
    case 29:
        if (in_startup_mode == false) print_party_stats();
        break;

    // Help menu
    case 41:
        FCD(1079,0);
        break;
    case 42:
        FCD(1080,0);
        break;
    case 43:
        FCD(1081,0);
        break;
    case 44:
        FCD(1072,0);
        break; // magic barriers
    case 46:
        FCD(1084,0);
        break;
    case 47:
        FCD(1088,0);
        break;

    // Library
    case 61:
        display_spells(0,100,0);
        break;
    case 62:
        display_spells(1,100,0);
        break;
    case 63:
        display_skills(100,0);
        break;
    case 64:
        display_help(0,0);
        break;
    case 65:
        tip_of_day();
        break;
    case 67:
        FCD(986,0);
        break;

    // Actions
    case 81:
        if (overall_mode != MODE_TOWN) {
            ASB("Alchemy: In town mode only.");
            print_buf();
            break;
        }
        pass_point.x = 1000;
        pass_point.y = 405;
        to_return = handle_action(pass_point,(WPARAM) 0,(LPARAM)-1);
        break;
    case 82:
        to_return = handle_action(x,(WPARAM) 0,(LPARAM)-1);
        break;
    case 84:
        if (prime_time() == false) {
            ASB("Finish what you're doing first.");
            print_buf();
        }
        else {
            give_help(62,0,0);
            display_map();
        }
        SetCursor(sword_curs);
        break;

    // Mage is 399
    case 399:
        give_help(209,0,0);
        party.help_received[9] = false;
        break;

    // Priest is 499
    case 499:
        give_help(209,0,0);
        party.help_received[9] = false;
        break;

    // Monsters is 599
    case 599:
        give_help(212,0,0);
        break;

    case 100: // Index
        WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L);
        break;

    case 200: // About
        FCD(1062,0);
        break;

    default:
        if ((item >= 400) && (item < 500))  { // mage spell
            if (prime_time() == false) {
                ASB("Finish what you're doing first.");
                print_buf();
            }
            else handle_menu_spell(item - 400,0);
            break;
        }
        if ((item >= 500) && (item < 600))  { // priest spell
            if (prime_time() == false) {
                ASB("Finish what you're doing first.");
                print_buf();
            }
            else handle_menu_spell(item - 500,1);
            break;
        }
        if ((item >= 600) && (item < 700))  { // monster spell
            display_monst(item - 600,(creature_data_type *) NULL,1);
            break;
        }
        break;
    }
    if (in_startup_mode == true)
        menu_activate(0);
    else menu_activate(1);
    return to_return;
}
void create_node_map(int n_shader, int n_mem, int size, int use_map) 
{
   node_map = (int*)malloc((size)*sizeof(int));   
   if (use_map) {
      switch (size) {
      case 16 :
         { // good for 8 shaders and 8 memory cores
            int newmap[]  = {  
               0, 2, 5, 7,
               8,10,13,15,
               1, 3, 4, 6, //memory nodes
               9,11,12,14   //memory nodes
            }; 
            memcpy (node_map, newmap,16*sizeof(int));
            break;
         }
      case 64:
         { // good for 56 shaders and 8 memory cores
            int newmap[]  = {  
               0,  1,  2,  4,  5,  6,  7,  8,
               9, 10, 11, 12, 13, 14, 16, 18,
               19, 20, 21, 22, 23, 24, 25, 26,
               27, 28, 30, 31, 32, 33, 34, 35,
               37, 38, 39, 40, 41, 42, 43, 44,                    
               45, 46, 48, 50, 51, 52, 53, 54,
               55, 56, 57, 58, 59, 60, 62, 63, 
               3, 15, 17, 29, 36, 47, 49, 61  //memory nodes are in this line
            }; 
            memcpy (node_map, newmap,64*sizeof(int));
            break;
         }
      case 121:
         { // good for 110 shaders and 11 memory cores
            int newmap[]  = {  
               0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10,
               11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
               24, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
               37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
               48, 49, 50, 51, 52, 53, 54, 55, 56, 58, 59,
               61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72,
               73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
               84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 96,
               97, 98, 99,101,102,103,104,105,106,107,109,
               110,111,112,113,114,115,116,117,118,119,120,  
               12, 20, 25, 28, 57, 60, 63, 92, 95,100,108 //memory nodes are in this line
            }; 
            memcpy (node_map, newmap,121*sizeof(int));
            break;
         }
      case 36:
         {
            int memnodes[8]={3,7,10,12,23,25,28,32};
            map_gen(6/*dim*/,8/*memcount*/,memnodes);
            break;
         }
      default: 
         {
            cout<<"WARNING !!! NO MAPPING IMPLEMENTED YET FOR THIS CONFIG"<<endl;
            for (int i=0;i<size;i++) {
               node_map[i]=i;
            }
         }
      }
   } else { // !use_map
      for (int i=0;i<size;i++) {
         node_map[i]=i;
      }
   }
   reverse_map = (int*)malloc((size)*sizeof(int));   
   for (int i = 0; i < size ; i++) {
      for (int j = 0; j<size ; j++) {
         if (node_map[j]==i) {
            reverse_map[i]=j;
            break;
         }
      }
   }
   printf("GPGPU-Sim uArch: interconnect nodemap\n");
   display_map((int) sqrt(size),size);

}
Beispiel #22
0
int main()
{
	cout<<"Enter the name of a file to load: ";
	string fname = "hits.txt";
	cout<<fname<<endl; //cin>>fname;
	
	cout<<"Loading "<<fname<<"...\n\n";

	imap rmap;

	try
	{
		rmap = CreateMap(LinearizeFile(fname));
	}
	catch(string error)
	{
		cout<<error<<endl;
		return 1;
	}
	cout<<endl;

	int i=0;
	string s="";

	do
	{
		cout<<"Please select a menu option: "<<endl;
		cout<<"1)Link Information in date range"<<endl;
		cout<<"2)Information about all links"<<endl;
		cout<<"3)Link barchart for last 12 months"<<endl;
		cout<<"4)Display contents of imap"<<endl;
		cout<<"5)Quit the program"<<endl;
		cout<<"Option (1,2,3,4,5): ";

		cin>>s;
		i = atoi(s.c_str());
		cout<<endl;

		switch(i)
		{
		case 1:
			link_info_in_date_range(rmap);
			cout<<endl;
			break;
		case 2:
			info_about_all_links(rmap);
			cout<<endl;
			break;
		case 3:
			link_barchart(rmap);
			cout<<endl;
			break;
		case 4:
			display_map(rmap);
			cout<<endl;
			break;
		}
	}
	while(i!=5);

	return 0;
}
void
map_test (void)
{
  // Map of size 3.
  LAZY_MAP map (3);
  int i = 0;

  // Insert a few entries.
  for (i = 0; i < 3; ++i)
    map.bind (i, i);

  display_map (map);

  // Remove middle one.
  map.unbind (1);

  display_map (map);

  // Remove the entry on one end.
  map.unbind (0);

  display_map (map);

  // Remove the entry on the other end.
  map.unbind (2);

  display_map (map);

  // If we have lazy map managers, we can delete entries while
  // iterating over the map.

#if defined (ACE_HAS_LAZY_MAP_MANAGER)

  // Insert a few entries.
  for (i = 0; i < 3; ++i)
    map.bind (i, i);

  display_map (map);

  // Remove middle one.
  {
    // Deletion while iterating.
    for (LAZY_MAP::iterator iter = map.begin ();
         iter != map.end ();
         ++iter)
    {
      LAZY_MAP::ENTRY &entry = *iter;
      if (entry.int_id_ == 1)
        map.unbind (1);
    }

    display_map (map);
  }

  // Remove the entry on one end.
  {
    // Deletion while iterating.
    for (LAZY_MAP::iterator iter = map.begin ();
         iter != map.end ();
         ++iter)
      {
        LAZY_MAP::ENTRY &entry = *iter;
        if (entry.int_id_ == 0)
          map.unbind (0);
      }

    display_map (map);
  }

  // Remove the entry on the other end.
  {
    // Deletion while iterating.
    for (LAZY_MAP::iterator iter = map.begin ();
         iter != map.end ();
         ++iter)
      {
        LAZY_MAP::ENTRY &entry = *iter;
        if (entry.int_id_ == 2)
          map.unbind (2);
      }

    display_map (map);
  }

#endif /* ACE_HAS_LAZY_MAP_MANAGER */

  // Insert a few entries.  This will force an increase in map size.
  for (i = 0; i < 4; ++i)
    map.bind (i, i);

  display_map (map);

  // Remove a few entries (in reverse order).
  for (i = 3; i >= 0; --i)
    map.unbind (i);

  display_map (map);
}
Beispiel #24
0
void display_map_debug() {
	display_map(MAP_WIDTH,MAP_HEIGHT,_map);
}