示例#1
0
void schedule(){
	int i, running;
	struct task *t;

#ifdef TRACE  
	feed_wdt();
#endif
		
	for (i=0; i<num_tasks;){

#ifdef TRACE
		cur_task = 99;
#endif  
	
		handle_events();

#ifdef TRACE
		cur_task = i;
#endif
		
		t=&(task_list[i]);
		/* Run the next thread with its own thread structure as argument */
		if (t->state == RUN) {
			running = PT_SCHEDULE( t->thread(&(t->thread_pt)) );
			i++;
		} else {
			task_del(i);
			// do not increment i, we probably have a new task at this index
		}
  	};
};
示例#2
0
void 
popup(char *text, int time_out, int (*keypress_handler) (struct Screen *, int)){
	if 	( ! popup_active ){
		popup_active = 1;
		screen_visible(cur_screen, 0);
		popup_save();
		popup_win.flags |= WINFLG_VISIBLE;
		if (keypress_handler != NULL)
				popup_keypress_handler = keypress_handler;

		set_keypress_handler(popup_keypress_dispatch);

		if (time_out > 0){
			timer_add(&popup_tmr, time_out, 0);
			close_popup_task = task_add(&close_popup);
		} 
	} else {						// already a popup active
		if (time_out > 0){
			if (timed_popup)
				timer_set(&popup_tmr, time_out, 0);
			else {
				timer_add(&popup_tmr, time_out, 0);
				close_popup_task = task_add(close_popup);
			};
		} else {
			if (timed_popup) {
				task_del(close_popup_task);
				timer_del(&popup_tmr);
			};
		};
	};
	timed_popup = (time_out > 0);
	win_new_text(&popup_win, text);
	win_redraw(&popup_win);	
};
示例#3
0
// 080EDBE8
void intro_end(struct intro *in) {
	if (in->field4 == 0) {
		sub_08070424(0, 0, 0x400);
		in->field4 = 1;
	} else if (in->field4 == 1) {
		if (sub_080F682C() == 0) {
			task_del(in->tid);
			free(in);
			sub_08000B94(2);
			hblank_handler_set(0);
			set_callback2(&c2_intro_2);
		}
	}
}
示例#4
0
文件: multitask.c 项目: songtzu/study
void 
task_sleep(task_t* task)
{
  task_t* now_task;

  if (2 == task->flags) { /* the task in the wake state */
    now_task = task_now();
    task_del(task);
    if (task == now_task) {
      /* if task sleep, then need to switch task */
      task_switch_sub();
      now_task = task_now();
      farjump(0, now_task->sel);
    }
  }
}
示例#5
0
文件: task.c 项目: l-patpat/mcu-frame
void task_dispatch(s_TaskList *tasks)
{
	s_Task *task;

	for(task = tasks->First; task; task = task->Next)
	{
		if(task->Interval < 0)
		{
			task_del(tasks, (void*)task->Hook);
		}
		else if(task->Counter)
		{
			task->Counter--;
		}
	}
}
示例#6
0
// 08110F14
void game_continue(task_id c) {
	quest_logger_filter_disable();
	prev_quest_display_number = 0;

	for (uint i=0; i<4; i++)
		if (sav1i->questlog[i].active)
			prev_quest_display_number++;

	if (prev_quest_display_number > 0) {
		help_system_enabled = 0;
		flashback();
	} else
		set_callback2(&c2_8056938);

	task_del(c);
}
示例#7
0
void 
popup_end(){
	if (timed_popup) {
		task_del(close_popup_task);
		timer_del(&popup_tmr);	
	};

	popup_active = 0;
	set_keypress_handler(mainscreen_keypress);
	
	if (deferred_screen != NO_SCREEN)
		screen_enter(deferred_screen);
	else {
		popup_restore();
		screen_visible(cur_screen, 1);
		screen_redraw(cur_screen);
	};
};
示例#8
0
文件: multitask.c 项目: songtzu/study
void 
task_run(task_t* task, int level, int priority)
{
  if (level < 0)
    level = task->level;
  if (priority > 0)
    task->priority = priority;

  /* modify the task in activity */
  if (2 == task->flags && task->level != level) 
    task_del(task); /* task->flags will be 1 */

  if (2 != task->flags) {
    task->level = level;
    task_add(task);
  }

  g_taskctrl->change_lv = 1;  /* it will check level at next switch task */
}
void region_loop(u8 tid) {
    (void)tid;
    switch (pokedex_context->state) {
    case 0:
        bgid_send_tilemap(2);

        for (u8 i = 0; i < 7; ++i) {
            rboxid_clear_pixels(i, 0);
            rboxid_print(i, FONT_DEX_STD, region_text_x_offset[i], region_text_y_offset[i], &pdex_text_color, 0,
                         pdex_str_regions[i + 1]);
            rboxid_update_tilemap_and_tileset(i);
        }

        region_load_border();
        region_load_icon_palettes();
        for (u8 i = 0; i < 21; ++i)
            region_load_icon(i);

        palette_bg_faded_fill_black();
        pokedex_context->state++;
        break;
    case 1:
        gpu_sync_bg_show(0);
        gpu_sync_bg_hide(1);
        gpu_sync_bg_hide(3);

        gpu_sync_bg_show(2);
        fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 16, 0, 0x0000);
        pokedex_context->state++;
        break;
    case 2:
        if (!pal_fade_control.active)
            pokedex_context->state++;
        break;
    case 3:
        switch (super.buttons_new) {
        case KEY_RIGHT:
            if (pokedex_context->region_selected < 6) {
                pokedex_context->region_selected++;
                m4aSongNumStart(101);
            }
            break;
        case KEY_DOWN:
            if (pokedex_context->region_selected < 3) {
                pokedex_context->region_selected += 3;
                m4aSongNumStart(101);
            }
            break;
        case KEY_LEFT:
            if (pokedex_context->region_selected > 0) {
                pokedex_context->region_selected--;
                m4aSongNumStart(101);
            }
            break;
        case KEY_UP:
            if ((pokedex_context->region_selected > 2) && (pokedex_context->region_selected < 6)) {
                pokedex_context->region_selected -= 3;
                m4aSongNumStart(101);
            }
            break;
        case KEY_A:
            fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
            pokedex_context->state = 10;
            m4aSongNumStart(5);
            break;
        case KEY_B:
            fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
            pokedex_context->state = 11;
            m4aSongNumStart(601);
        default:
            break;
        }
        break;
    case 10:
        if (!pal_fade_control.active) {
            task_del(tid);
            pdex_vram_free_bgmaps();
            pokedex_context->cursor_position_top = region_to_dex[pokedex_context->region_selected];
            set_callback2(pdex_load);
        }
        break;
    case 11:
        if (!pal_fade_control.active) {
            task_del(tid);
            pdex_free_memory();
            set_callback2(c2_overworld_switch_start_menu);
            set_callback1(c1_overworld);
        }
        break;
    default:

        break;
    }
}
示例#10
0
void waitbutton_text(u8 task_id) {
	if (!remoid_a_pressed_maybe(0)) {
		superstate.multi_purpose_state_tracker = tasks[task_id].priv[0];
		task_del(task_id);
	}
}
示例#11
0
static void 
screen_exit(){
	task_del(auto_search_task);
	win_cursor_set(NULL, WIN_TXT_SIZE-1);
	screen_visible(SEARCH_SCREEN, 0);
};