示例#1
0
void gameoflife() {
	DEBUG_BYTE(0,0); // set debug bytes to zero
	DEBUG_BYTE(1,0);
	field_t pf1, pf2;
	field_t ldbuf[LOOP_DETECT_BUFFER_SIZE] = {{{0}}}; // loop detect buffer
	uint8_t ldbuf_idx = 0;
	uint16_t cycle;

#ifdef GLIDER_TEST
	/* initialize with glider */
	coord_t x,y;
	for(y = YSIZE; y--;) {
		for(x = XSIZE; x--;) {
			setcell(pf1, x, y, dead);
		}
	}
	insertglider(pf1);
#else
	/* initialize the field with random */
	pfinit(pf1);
#endif

	/* the main part */
	pfprint(pf1);
	for (cycle = 1; cycle < GOL_CYCLES; ++cycle) {
		DEBUG_BYTE(0, (uint8_t)(GOL_CYCLES-cycle) & 0xff); DEBUG_BYTE(1, SREG);
		wait(GOL_DELAY);
		pfcopy(pf2, pf1);
		nextiteration(pf1, pf2);
		pfprint(pf1);
		/* loop detection */
		if (!pfcmp(pf1, pf2)) {
			insertglider(pf1);
//			cycle = 1;
		}
		if (pfempty(pf1)) {
			/* kill game */
			return;
		}
		/* */
		uint8_t i;
		for (i = 0; i < LOOP_DETECT_BUFFER_SIZE; ++i) {
			if (!pfcmp(pf1, ldbuf[i])) {
				insertglider(pf1);
//				cycle = 1;
			}
		}
		pfcopy(ldbuf[ldbuf_idx], pf1);
		ldbuf_idx = (ldbuf_idx + 1u) % LOOP_DETECT_BUFFER_SIZE;
	}
}
示例#2
0
int
verify_other (const uint8_t *pw, int pw_len)
{
  const uint8_t *ks_pw1 = gpg_do_read_simple (NR_DO_KEYSTRING_PW1);
  int r;

  DEBUG_INFO ("verify_other\r\n");
  DEBUG_BYTE (pw_len);

  r = verify_user_0 (AC_OTHER_AUTHORIZED, pw, pw_len, pw_len, ks_pw1, 0);
  if (r > 0)
    auth_status |= AC_OTHER_AUTHORIZED;
  return r;
}
示例#3
0
static int
cir_getchar (uint32_t timeout)
{
  uint16_t cir_addr;
#if defined(DEBUG_CIR)
  uint16_t *p;
#endif

#if defined(DEBUG_CIR)
  cirinput_p = cirinput;
#endif

  cir_ll_init ();

  notification = 0;
  wait_usec = timeout;
  chopstx_usec_wait_var (&wait_usec);
  if (notification == 0)
    return -1;

  /* Sleep 200ms to avoid detecting chatter inputs.  */
  chopstx_usec_wait (200 * 1000);

#if defined(DEBUG_CIR)
  DEBUG_INFO ("****\r\n");
  DEBUG_SHORT (intr_ext);
  DEBUG_SHORT (intr_trg);
  DEBUG_SHORT (intr_ovf);
  DEBUG_INFO ("----\r\n");
  for (p = cirinput; p < cirinput_p; p++)
    {
      DEBUG_SHORT (*p);
    }
  DEBUG_INFO ("====\r\n");

  cirinput_p = cirinput;

  DEBUG_INFO ("**** CIR data:");
  DEBUG_WORD (cir_data);
  if (cir_seq > 48)
    {
      DEBUG_SHORT (cir_data_more);
    }
  DEBUG_BYTE (cir_seq);
#endif

  switch (cir_proto)
    {
    case CIR_PROTO_RC5:
      cir_data &= 0x003f;
      goto err;
    case CIR_PROTO_RC6:
      cir_addr = cir_data >> 8; /* in case of cir_seq == 16.  32??? */
      cir_data &= 0x00ff;
      return find_char_codetable (cir_data, cir_codetable_dell_mr425);
    case CIR_PROTO_NEC:
      cir_addr = cir_data&0xffff;
      if (cir_addr == CIR_ADDR_TOSHIBA_REGZA)
	{
	  cir_data = (cir_data >> 16) & 0x00ff;
	  return find_char_codetable (cir_data, cir_codetable_regza);
	}
      else
	goto err;