コード例 #1
0
ファイル: conversion.c プロジェクト: Xxdzs/3Dengine
void	polar2carth(t_cmplx *v)
{
	const t_real		m = MODP(v);
	const t_real		a = ARGP(v);

	XP(v) = m * cos(a);
	YP(v) = m * sin(a);
	v->type = CARTHESIAN;
}
コード例 #2
0
ファイル: conversion.c プロジェクト: Xxdzs/3Dengine
void	carth2polar(t_cmplx *v)
{
	const t_real		x = XP(v);
	const t_real		y = YP(v);

	MODP(v) = sqrt(x * x + y * y);
	ARGP(v) = atan2(y, x);
	v->type = POLAR;
}
コード例 #3
0
// Block send moves, once CNN finish evaluation.
// If done is set, don't send anything.
BOOL ExLocalServerSendMove(void *ctx, MMove *move) {
  Exchanger *ex = (Exchanger *)ctx;
  if (move->seq == 0) return FALSE;
  while (! ex->done) {
    unsigned char flag = get_flag(ex);
    if (flag & (1 << SIG_RESTART)) break;
    if (PipeWrite(&ex->channels[PIPE_MOVE], ARGP(move)) == 0) {
      ex->move_sent ++;
      return TRUE;
    }
  }
  return FALSE;
}
コード例 #4
0
// Server side, three cases
//   1. Block on message with exit value = SIG_OK on newboard.
//   2. Return immediately with exit value = SIG_RESTART
//   3. Return immediately with exit value = SIG_HIGH_PR
// If num_attempt == 0, then try indefinitely, otherwise try num_attempt.
int ExLocalServerGetBoard(void *ctx, MBoard *mboard, int num_attempt) {
  Exchanger *ex = (Exchanger *)ctx;
  int count = 0;
  while (! ex->done && (num_attempt == 0 || count < num_attempt)) {
    // Check flag.
    unsigned char flag = get_flag(ex);
    if (flag & (1 << SIG_RESTART)) {
      return SIG_RESTART;
    }
    // Otherwise get the board, if succeed, return.
    if (PipeRead(&ex->channels[PIPE_BOARD], ARGP(mboard)) == 0) {
      ex->board_received ++;
      return SIG_OK;
    } else if (flag & (1 << SIG_FINISHSOON)) {
      // If there is no board to read and we want finish soon, return immediately.
      return SIG_NOPKG;
    }
    // Do I need to put some sleep here?
    count ++;
  }

  // queue_pop(&ex->q, board, sizeof(MBoard));
  return SIG_NOPKG;
}
コード例 #5
0
// Receive move (not blocked)
BOOL ExLocalClientGetMove(void *ctx, MMove *move) {
  Exchanger *ex = (Exchanger *)ctx;
  RET(PipeRead(&ex->channels[PIPE_MOVE], ARGP(move)));
}
コード例 #6
0
// Send board (not blocked)
BOOL ExLocalClientSendBoard(void *ctx, MBoard *board) {
  Exchanger *ex = (Exchanger *)ctx;
  RET(PipeWrite(&ex->channels[PIPE_BOARD], ARGP(board)));
}
コード例 #7
0
ファイル: MAIN.C プロジェクト: AnimatorPro/Animator-Pro
void main(int argc, char **argv)
{
Errcode err;
UBYTE oldconfig;
static Argparse_list apl[] = {
	ARGP(apl,0,"-flic",get_flic_arg),
	ARGP(apl,APLAST,"-poc",get_poco_arg),
};

	if((err = init_pj_startup(apl,get_rest_of_command_line,argc,argv,
							  "pj_help","aa.mu")) < Success)
	{
		goto error;
	}
	oldconfig = err;


	add_local_pdr(&fli_local_pdr);
	add_local_pdr(&pic_local_pdr);
	set_hotkey_func(do_pj_hotkey); /* set input hot key function */

	/* initialize pj resource files */

	if((err = init_pj_resources()) < Success)
		goto error;

	if((err = init_ptools()) < Success) /* initialize tools */
		goto error;
	if((err = init_inks()) < Success) /* load any loadable inks */
		goto error;

	if(cl_poco_name != NULL)
	{
		if ((err = compile_cl_poco(cl_poco_name)) < Success)
		{
			if (err == Err_in_err_file)
				po_file_to_stdout(poco_err_name);
			err = Err_reported;
			goto error;
		}
	}

	vs = default_vs; /* copy in default settings */


	if((err = open_pj_startup_screen(init_after_screen)) < Success)
		goto error;

#ifdef WIDGET
	widge_ask = TRUE;
#endif /* WIDGET */

	if(!oldconfig)
		soft_continu_box("newconfig");

	if (cl_flic_name != NULL)
		pj_delete(tflxname);	  /* Delete old tempflx */

	if((err = force_temp_files()) < Success)
		goto error;

	if (cl_flic_name != NULL)
		resize_load_fli(cl_flic_name);

	err = go_vpaint();

	for(;;)
	{
		switch(err)
		{
			case RESET_SCREEN_SIZE:
				err = resize_screen();
				break;
			case RESET_NEW_SIZE:
			case KILL_NEW_SIZE:
				scrub_cur_frame();	/* clean up act in case user aborts */
				flush_tflx();
				err = resize_pencel(FALSE,err == RESET_NEW_SIZE);
				break;
			case RESET_DEFAULT_FLX:
				push_close_toscreen();
				if((err = clear_vtemps(TRUE)) < 0)
					goto error;
				if((err = open_default_flx()) < 0)
					goto error;
			case RESTART_VPAINT:
				err = go_vpaint();
				break;
			case EXIT_SYSTEM:
				outofhere(TRUE); /* we've exited, don't need to break... */
			case QUIT_SYSTEM:
				outofhere(FALSE);
			default: /* not a good return */
				goto error;
		}
	}
error:
	cleanup_all(err);
	exit(err);
}