示例#1
0
void Key_task(void)
{
	key_scan();
	
	if(keycode != KEY_NULL)
	{
		if(scn_mode == GPS_MAIN_SCN)
		{
			switch(keycode)
			{
				case KEY_UP:
				case KEY_DOWN:
					switch_scn_flag(0);
					set_screen(GPS_MAIN_SCN);
					break;
				case KEY_LEFT:
					save_position();
					break;	
				case KEY_OK:
				case KEY_CANCEL:
					menu_start();
					break;
				default:
					break;
			}
		}
	}
}
示例#2
0
void get_ready(void)
{
	menu_init();
#if DEBUG	
	uart_puts_p(PSTR("menu_init() Completed! \n"));
#endif

	LED_on(LED_0);
	LED_on(LED_1);
	LED_on(LED_2);
	LED_on(LED_3);
	
	set_screen(SPLASH_SCN);
	_delay_ms(2000);
	
	gps_set_arg();
	
	LED_off(LED_0);
	LED_off(LED_1);
	LED_off(LED_2);
	LED_off(LED_3);
	
	set_screen(READY_SCN);
	menu_start();	
}
示例#3
0
文件: ex_cmd.c 项目: jollywho/nav
void start_ex_cmd(char symbol, int state)
{
  log_msg("EXCMD", "start");
  ex.ex_state = state;
  ex.state_symbol = symbol;
  window_refresh();

  pos_T max = layout_size();
  ex.curpos = 0;
  ex.curofs = 0;
  ex.maxpos = max.col - 2;
  ex.state = 0;
  ex.col_text = opt_color(COMPL_TEXT);
  ex.col_symb = opt_color(BUF_TEXT);

  switch (state) {
    case EX_CMD_STATE:
      menu_start(ex.menu);
      break;
    case EX_REG_STATE:
      ex.lm = window_get_focus()->matches;
      regex_mk_pivot(ex.lm);
      break;
    case EX_FIL_STATE:
      ex.fil = window_get_focus()->filter;
      //swap exline with filter string
      break;
  }
  ex.line = calloc(max.col, sizeof(char*));
  ex.cmd.cmds = NULL;
  ex.cmd.line = NULL;
  hist_push(state);
  cmdline_build(&ex.cmd, ex.line);
}
示例#4
0
int main(int argc, char *argv[])
{
	//>>>>>>>>>>  carregament da codepage  <<<<<<<<<<
	load_char_table(codepage);
	
	
	//>>>>>>>>>>  init kbc  <<<<<<<<<
	Bool mouse_detected = kbc_init(0);
	
	
	//>>>>>>>>>>  init kbd  <<<<<<<<<<
	kbd_init();
	
	
	//>>>>>>>>>>  init mouse  <<<<<<<<<<
	if (mouse_detected == true)
		mouse_init((int) 0);
	
	
	//>>>>>>>>>>  init rtc  <<<<<<<<<<
	rtc_init();
	drawDate();
	drawTime();
	drawCounter();
	
	
	//>>>>>>>>>>  init timer  <<<<<<<<<<
	timer0_init();
	timer_init(TIMER_2, LSBMSB | MODE3);

	
//#################
	menu_start();
//#################		
	
	
	
	//>>>>>>>>>>  restore kbd isr <<<<<<<<<<
	restore_keyboard_isr();
	
	
	//>>>>>>>>>>  restore mouse isr <<<<<<<<<<
	if (mouse_detected == true)
		restore_mouse_isr();
	
	
	//>>>>>>>>>>  restore rtc isr <<<<<<<<<<
	restore_rtc_isr();
	
	//>>>>>>>>>>  init timer isr <<<<<<<<<<
	restore_timer0();
	
	
	return 0;
}
示例#5
0
文件: main.c 项目: prophile/dim3
int main(int argc,char *argv[])
{
	app_init();
	
	menu_start();
    open_model_xml();
	
	doloop();

	app_shutdown();
    
    return(0);
}
示例#6
0
文件: main.c 项目: odrevet/GE
game_status state_in_game(SDL_Surface *screen, game* p_game)
{
  int i=0;
  bool done=false;

  game_status ret_code = GAME_OVER;
  SDL_Rect srcrect = {0,0,160,144};
  dstrect = set_rect(0,0,SCREEN_HEIGHT,SCREEN_WIDTH);

#ifdef USE_LUA
  lua_State *L;
  L = lua_open();
  luaopen_base(L);
  luaL_openlibs(L);
  luaopen_globals(L);
  luaopen_game(L);
  luaopen_unit(L);
  luaopen_sprite(L);
  luaopen_var(L);
  luaopen_map(L);

  //register lua functions
  lua_register(L ,"say", script_lua_unit_say);
  lua_register(L ,"unit_get_x", script_lua_unit_get_x);
  lua_register(L ,"unit_get_y", script_lua_unit_get_y);
  lua_register(L ,"unit_set_index_x", script_lua_unit_set_index_x);
  lua_register(L ,"unit_set_index_y", script_lua_unit_set_index_y);
  lua_register(L ,"event_text", script_lua_event_exec_text);
  lua_register(L ,"event_teleport", script_lua_event_exec_teleport);
  lua_register(L ,"unit_set_life", script_lua_unit_set_life);
  lua_register(L ,"unit_set_speed", script_lua_unit_set_speed);

  p_game->L = L;
  g_game = p_game;
#endif


  long timelastcall=SDL_GetTicks();

  if(map_get_current(p_game->p_map, p_game->cur_map)->music != NULL){
    char* music = strdup(map_get_current(p_game->p_map, p_game->cur_map)->music);
    Mix_Music* ingame_music = music_load(music);
    music_play(ingame_music);
  }

  message_box* p_menu = NULL;
  p_menu = menu_ingame_create(p_game);
  bool action;

  while (!done)
    {
      action = false;
      SDL_Event event;
      SDL_JoystickUpdate();
      while (SDL_PollEvent(&event)){
	switch ( event.type ){
	case SDL_QUIT:
	  ret_code = QUIT;
	  done = true;
	  break;
	case SDL_KEYUP:
	  switch ( event.key.keysym.sym ){
	  case SDLK_RETURN:
	    switch(menu_start(get_backbuffer_surface(), p_game)){
	    case 0:
	      menu_status(get_backbuffer_surface(), p_game);
	      break;
	    case 1:
	      menu_save(get_backbuffer_surface(), p_game);
	      break;
	    case 2:
	      ret_code = LOAD;
	      done=true;
	      break;
	    }
	    break;
	  default:break;
	  }
	  break;
	case SDL_JOYBUTTONDOWN:
	  switch(event.jbutton.button){
	  case 0:
	    switch(menu_start(get_backbuffer_surface(), p_game)){
	    case 0:
	      menu_status(get_backbuffer_surface(), p_game);
	      break;
	    case 1:
	      menu_save(get_backbuffer_surface(), p_game);
	      break;
	    case 2:
	      ret_code = LOAD;
	      done=true;
	      break;
	    }
	    break;
	  case 2:
	    action = true;
	    break;
	  }
	  break;
	default:break;
	}

	unit_handle_key(p_game->p_unit, &event, p_game);
      }

      int joystate = SDL_JoystickGetHat(p_game->p_unit->joystick, 0);
      switch (joystate){
      case SDL_HAT_DOWN:
	unit_set_vel_y(p_game->p_unit, p_game->p_unit->speed);
	unit_set_vel_x(p_game->p_unit, 0);
	p_game->p_unit->p_sprite->animation_current = DOWN;
	p_game->p_unit->dir = DOWN;
	p_game->p_unit->current_action = NOTHING;

	break;
      case SDL_HAT_UP:
	unit_set_vel_y(p_game->p_unit, -p_game->p_unit->speed);
	unit_set_vel_x(p_game->p_unit, 0);
	p_game->p_unit->p_sprite->animation_current = UP;
	p_game->p_unit->dir = UP;
	p_game->p_unit->current_action = NOTHING;
	break;
      case SDL_HAT_RIGHT:
	unit_set_vel_x(p_game->p_unit, p_game->p_unit->speed);
	unit_set_vel_y(p_game->p_unit, 0);
	p_game->p_unit->p_sprite->animation_current = RIGHT;
	p_game->p_unit->dir = RIGHT;
	p_game->p_unit->current_action = NOTHING;
	break;
      case SDL_HAT_LEFT:
	unit_set_vel_x(p_game->p_unit, -p_game->p_unit->speed);
	unit_set_vel_y(p_game->p_unit, 0);
	p_game->p_unit->p_sprite->animation_current = LEFT;
	p_game->p_unit->dir = LEFT;
	p_game->p_unit->current_action = NOTHING;
	break;
      default:
	break;
      }

      //drawing
      SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
      map_draw(map_get_current(p_game->p_map, p_game->cur_map), backbuffer);

      if(p_game->p_unit->current_action == FIGHT){
	anim_sprite_draw(p_game->p_unit->weapon, get_backbuffer_surface());
      }

      anim_sprite_draw(p_game->p_unit->p_sprite, backbuffer);

      for(i=0;i<p_game->NPC_nb;i++){
	NPC_update(p_game->p_NPC+i, map_get_current(p_game->p_map, p_game->cur_map), p_game->p_unit);
	anim_sprite_draw(p_game->p_NPC[i].p_sprite, backbuffer);
      }

      for(i=0;i<p_game->ennemie_nb;i++){
	ennemie_update(p_game->p_ennemie+i, map_get_current(p_game->p_map, p_game->cur_map), p_game->p_unit);
	anim_sprite_draw(p_game->p_ennemie[i].p_sprite, backbuffer);
      }

      Uint8* key = SDL_GetKeyState(NULL);
      if(key[p_game->p_unit->key_b] || action){
	for(i=0;i<p_game->NPC_nb;i++){

	  if(sprite_intersect((sprite*)p_game->p_unit->p_sprite, (sprite*)p_game->p_NPC[i].p_sprite)){
	    struct t_event* p_event = malloc(sizeof(struct t_event));
	    p_event->is_auto = true;
	    p_event->p_next = NULL;
	    p_event->type = EVENT_SCRIPT;

	    event_script* p_event_script = malloc(sizeof(event_script));
	    p_event_script->language = strdup("lua");
	    p_event_script->script = strdup(p_game->p_NPC[i].script);
	    p_event_script->version = strdup("1.0");

	    p_event->data = p_event_script;
	    event_exec_script(p_event, p_game);

	    event_free(p_event);
	  }
	}
      }


      //logic
      sprite_calc_bounding_box((sprite*)p_game->p_unit->p_sprite, true);



      //events when entering a tile
      point* p_point_enter = unit_check_on_tile_enter(p_game->p_unit, map_get_current(p_game->p_map, p_game->cur_map));
      if( p_point_enter != NULL &&
	  map_get_current(p_game->p_map, p_game->cur_map)->pp_tile[p_point_enter->y][p_point_enter->x].p_event != NULL &&
	  map_get_current(p_game->p_map, p_game->cur_map)->pp_tile[p_point_enter->y][p_point_enter->x].p_event->is_auto){

	p_game->p_unit->p_sprite->v_anim[p_game->p_unit->p_sprite->animation_current].frame_current = 1;
	event_dispatch(map_get_current(p_game->p_map, p_game->cur_map)->pp_tile[p_point_enter->y][p_point_enter->x].p_event, p_game);
	free(p_point_enter);

      }

      map* p_cur_map = map_get_current(p_game->p_map, p_game->cur_map);

      if(SDL_GetTicks() - timelastcall>1000/40) {

	unit_update(p_game->p_unit, p_cur_map);

	for(i=0;i<p_game->ennemie_nb;i++){

	  //Check weapon / ennemie collides
	  if(p_game->p_unit->current_action == FIGHT){
	    if(sprite_intersect((sprite*)p_game->p_unit->weapon, (sprite*)p_game->p_ennemie[i].p_sprite)){
	      p_game->p_ennemie[i].HP--;
	      if(p_game->p_ennemie[i].HP <= 0){                       //ennemie dead
		//sound dead
		//animation dead
		p_game->p_unit->XP += p_game->p_ennemie[i].XP;      //increase unit status
		p_game->p_unit->gold += p_game->p_ennemie[i].gold;

		ennemie_remove(p_game->p_ennemie, i, &p_game->ennemie_nb);      //remove ennemie
		break;
	      }
	    }
	  }

	  //Check unit / ennemie collides
	  if(p_game->p_unit->invincible_time <= 0 && sprite_intersect((sprite*)p_game->p_unit->p_sprite, (sprite*)p_game->p_ennemie[i].p_sprite)){
	    //sample_play(unit_hitted);
	    p_game->p_unit->invincible_time = 40;
	    unit_hitted(p_game->p_unit, p_game->p_ennemie+i, p_cur_map);
	    if(p_game->p_unit->HP <= 0){
	      //sound dead
	      //animation dead
	      //message game over
	      ret_code = GAME_OVER;
	      done = true;
	      break;
	    }
	  }
	}

	//Game events
	menu_ingame_update(get_backbuffer_surface(), p_menu, p_game);

	//update timer
	timelastcall=SDL_GetTicks();
      }

#if RENDER == 3 && !GEKKO
      SDL_GL_SwapBuffers();
#else
      SDL_SoftStretch(backbuffer, &srcrect, screen, &dstrect);
      SDL_Flip(screen);
#endif

    }

  game_free(p_game);
  return ret_code;
}
示例#7
0
void benchmark(void)
{
    unsigned long i;
    int row, col;

    menu_settings_t* mset   = &_menu_settings;
    menu_items_t   * mitems = &_menu_items;
    int menu_selected;

    /* Init timer stuff. */
    sc_tmr_start();

    menu_reset_settings(mset);
    menu_reset_items(mitems);
    menu_set_title(mset, "Saturn Memory Benchmark");

    menu_set_item(mitems, 0/*id*/, "Start Benchmarking    ", 0/*tag*/);
    menu_set_item(mitems, 1/*id*/, "Init DRAM             ", 1/*tag*/);
    menu_set_item(mitems, 2/*id*/, "Select test pattern   ", 2/*tag*/);
    menu_set_item(mitems, 3/*id*/, "Hexedit on error      ", 3/*tag*/);

    menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 7/*h*/, 1/*cols*/);
    menu_set_erase_on_exit(mset, 0);
    menu_set_callback_redraw(mset, display_bench_settings);

    menu_selected = 0;
    do
    {
        menu_selected = menu_start(mitems, mset, menu_selected/*selected_tag*/);
        if(mset->exit_code == MENU_EXIT_CANCEL)
        {
            return;
        }

        switch(menu_selected)
        {
        default:
        case(0):
            break;

        case(1):
            menu_clear_display(mset);
            my_RB_CartRAM_init(0/*CS0*/);
            bench_display_clear();
            break;

        case(2):
            test_pattern = (test_pattern+1)%PATTERN_CNT;
            break;

        case(3):
            hexedit_on_error = hexedit_on_error ? 0 : 1;
            break;
        }
    } while(menu_selected != 0);

    /* User requested benchmark start, so clear settings menu. */
    menu_clear_display(mset);


    /* Execute benchmarks. */
    bench_display_clear();
    row = 5, col = 2;
    for(i = 0; i < nBenches; i++)
    {
        unsigned short color;

        conio_printf(2, 4, COLOR_GREEN, "[%3d%%]Benchmarking \"%s\" ...", (100*i)/nBenches, benches[i].name);

        /* Perform bench. */
        benches[i].function(benches + i);

        /* Display some data in order to keep user waiting ... */
        display_bench_result(i);

        color = benches[i].status ? COLOR_YELLOW : COLOR_RED;
        conio_printf(col+ 0, row, color, "%s", benches[i].name);
        if(col==2)
        {
            col = 9;
        }
        else if(col==9)
        {
            col = 16;
        }
        else if(col==16)
        {
            col = 23;
        }
        else if(col==23)
        {
            col = 30;
        }
        else
        {
            col = 2;
            row++;
        }

        if(row >= BENCH_RESULT_STARTROW)
        {
            bench_display_clear();
            row = 5;
            col = 2;
        }
    }

prompt_start();//TMP?
    /* Display benchmark results. */
    bench_display_clear();

    menu_reset_settings(mset);
    menu_reset_items(mitems);
    menu_set_title(mset, "Benchmark Results");

    menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 12/*h*/, 1/*cols*/);
    menu_set_erase_on_exit(mset, 1);

    menu_set_features(mset, MENU_FEATURES_TEXTCENTER);
    menu_set_callback_getstr(mset, get_bench_name);
    menu_set_callback_redraw(mset, display_bench_result);

    menu_selected = 0;
    menu_selected = menu_list_start(NULL/*Items Array*/, nBenches, mset, menu_selected, NULL/*selection*/);
}