예제 #1
0
파일: player.c 프로젝트: cooper6581/dplay
void play_module(struct Player *p, 
                  struct Module *m, unsigned long count)
{
  // main play routine
  //p->ticks++;
  if(p->ticks >= p->speed) {
    // check for pattern break
    if (p->p_break) {
      p->order_index++;
      p->row = p->p_break_x * 10 + p->p_break_y;
      p->pos = &m->pattern_data[m->order[p->order_index] * m->channels * 64];
      p->p_break = 0;
      p->p_break_x = 0;
      p->p_break_y = 0;
    }
    update_row(p, m, count);
    p->ticks = 0;
    p->row++;
    if(p->row < 64)
      p->pos+=4;
    else {
      p->order_index++;
      p->row=0;
      p->pos = &m->pattern_data[m->order[p->order_index] * m->channels * 64];
    }
  }
  update_tick(p);
  p->ticks++;
}
예제 #2
0
int main(int argc, char** argv)
{
	SDL_Event event; 
	int quit = 0; 

	SDL_Init(SDL_INIT_VIDEO);

	SDL_Window *window;
	SDL_Renderer *renderer;

	window = SDL_CreateWindow("SDL Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_W, SCREEN_H, SDL_WINDOW_SHOWN);
	if (window == NULL) { printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); }

	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

	update_tick(ti);

	while (!quit)
	{
		while (SDL_PollEvent(&event))
		{
			if (event.type == SDL_QUIT) 
			{
				quit = 1;
			}
		}

		update();
		draw(renderer);
	}

	SDL_Quit();

	return 0;
}
예제 #3
0
파일: preempt_trace.c 프로젝트: Aand1/ROSCH
/**
 * trace preemption when a new job of the given task is started.
 * we must be aware of priority inversion by self-suspention.
 */
void preempt(resch_task_t *rt)
{
	unsigned long flags;
	int cpu = rt->cpu_id;
	resch_task_t *curr = lo[cpu].current_task;

	preempt_lock(cpu, &flags);
	update_tick(cpu);
	/* we must compare the priorities because a lower-priority task may
	   be executed ahead of a higher one due to its self-suspention. */
	if (curr && curr->prio < rt->prio) {
		if (task_has_reserve(curr)) {
			preempt_account(curr);
		}
		__preempt_current(rt);
	}	
	else if (!curr) {
		__preempt_idle(rt);
	}

	if(task_has_reserve(rt) && job_is_started(rt)) {
		resume_account(rt);
	}
	preempt_unlock(cpu, &flags);
}
예제 #4
0
파일: preempt_trace.c 프로젝트: Aand1/ROSCH
/**
 * trace preemption when a job of the given task is completed.
 * we must be aware of priority inversion by self-suspention.
 */
void preempt_self(resch_task_t *rt)
{
	unsigned long flags;
	int cpu = rt->cpu_id;
	resch_task_t *curr = rt->preemptee;

	preempt_lock(cpu, &flags);
	update_tick(cpu);

	if (task_has_reserve(rt)) {
		suspend_account(rt);
	}

	/* note that rt->preemptee will be not necessarily scheduled next, 
	   if some higher-priority tasks have released jobs. in that case, 
	   this task will be preempted again. */
	if (curr) {
		curr->preempter = NULL;
		if (task_has_reserve(curr)) {
			resume_account(curr);
		}
	}
	lo[cpu].current_task = curr;
	rt->preemptee = NULL;

	preempt_unlock(cpu, &flags);
}
예제 #5
0
void draw(SDL_Renderer *renderer)
{
	if (last_tick(ti) >= SCREEN_TICKS_PER_FRAME) {
		//printf("ltick %d, %d\n", last_tick(ti), SCREEN_TICKS_PER_FRAME);

		SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
		SDL_RenderClear(renderer);
		
		for (int i = 0; i < BOX_COUNT; i++)
			box[i].draw(renderer);

		SDL_RenderPresent(renderer);

		update_tick(ti);
	}
	else {
		SDL_Delay(1);
	}
}