Exemple #1
0
ENTRYPOINT void 
init_stonerview (ModeInfo *mi)
{
  stonerview_configuration *bp;

  if (!bps) {
    bps = (stonerview_configuration *)
      calloc (MI_NUM_SCREENS(mi), sizeof (stonerview_configuration));
    if (!bps) {
      fprintf(stderr, "%s: out of memory\n", progname);
      exit(1);
    }

    bp = &bps[MI_SCREEN(mi)];
  }

  bp = &bps[MI_SCREEN(mi)];

  bp->glx_context = init_GL(mi);

  bp->trackball = gltrackball_init ();
  bp->st = init_view(MI_IS_WIREFRAME(mi));
  init_move(bp->st);

  reshape_stonerview (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
}
Exemple #2
0
int allocator_init(unsigned int sobjs) {
	unsigned int i;
	char* addr;

	if( (sobjs > MAX_SOBJS) )
		return INVALID_SOBJS_COUNT; 

	handled_sobjs = sobjs;

	for (i=0; i<sobjs; i++){
		addr = allocate_mdt();
		if (addr == NULL) goto bad_init;
		maps[i].base = addr;
		maps[i].active = 0;
		maps[i].size = MDT_ENTRIES;
		AUDIT
		printf("INIT: sobj %d - base address is %p - active are %d - MDT size is %d\n",i,maps[i].base, maps[i].active, maps[i].size);
	}
	
#ifdef HAVE_NUMA
	set_daemon_maps(maps, moves);
	init_move(sobjs);
#endif


#ifdef HAVE_NUMA
	setup_numa_nodes();
#endif

	return SUCCESS;

bad_init:
	return INIT_ERROR; 
}
Exemple #3
0
static void
init_arb_move(F_line *p, int type, int x, int y, int px, int py)
{
    constrained = MOVE_ARB;
    init_move(p, type, x, y, px, py);
    canvas_middlebut_proc = null_proc;
    set_mousefun("place object", "", "cancel", LOC_OBJ, LOC_OBJ, LOC_OBJ);
    draw_mousefun_canvas();
}
Exemple #4
0
/* Function returns 1 if opponent's king is checked
 * c = 1 (white) or -1 (black) */
int is_check(board * brd, int c) {
  move * t = malloc(sizeof(move));
  init_move(&t);
  generate_all_moves(c, brd, &t);
  move * t_ = t;
  while(t_->next != NULL) {
    if( t_->x * c == -6) {
      free_moves(&t);
      return 1;
    }
    t_=t_->next;
  }
  free_moves(&t);
  return 0;
}
Exemple #5
0
/* Returns 1 if player c has valid moves left.
 * c = 1 (white) or -1 (black)
 * If king is in check and no valid moves left, that implies checkmate */
int has_moves(board * brd, int c) {
  move * t = malloc(sizeof(move));
  init_move(&t);
  generate_all_moves(c, brd, &t);
  move * t_ = t;
  while(t_->next != NULL) {
    if(apply_move(brd, &t_, c)) {
      undo_move(brd, &t_);
      free_moves(&t);
      return 1;

    }
    t_ = t_->next;
  }
  free_moves(&t);
  return 0;
}