示例#1
0
int csys_midievent(unsigned char * cmd,   unsigned char * ndata, 
	           unsigned char * vdata, unsigned short * extchan,
		   float * fval)

{

  int i = csysi_tailmidi;

  *cmd = csysi_midiqueue[i].cmd;
  *ndata = csysi_midiqueue[i].ndata;
  *vdata = csysi_midiqueue[i].vdata;
  *extchan = csysi_midiqueue[i].extchan;
  *fval = csysi_midiqueue[i].fval;

  if (*cmd == CSYS_MIDI_ENDTIME)
    *fval = (*fval > EV(scorebeats) + 5.0F) ? *fval : EV(scorebeats) + 5.0F;

  csysi_midiready--;
  csysi_nummidi--;

  csysi_tailmidi = (csysi_tailmidi+1)&(CSYSI_MAXMIDI-1);
  if (csysi_tailmidi == csysi_headmidi)  /* empty */
    {
      csysi_headmidi = 0;
      csysi_tailmidi = -1;
    }

  if (csysi_midiready)
    return CSYS_MIDIEVENTS;
  else
    return CSYS_NONE;

}
示例#2
0
文件: delaunay.cpp 项目: omco/geode
// Prepare a list of points for Delaunay triangulation: randomly assign into logarithmic bins, sort within bins, and add sentinels.
// For details, see Amenta et al., Incremental Constructions con BRIO.
static Array<Perturbed2> partially_sorted_shuffle(RawArray<const EV> Xin) {
  const int n = Xin.size();
  Array<Perturbed2> X(n+3,uninit);

  // Randomly assign input points into bins.  Bin k has 2**k = 1,2,4,8,... and starts at index 2**k-1 = 0,1,3,7,...
  // We fill points into bins as sequentially as possible to maximize cache coherence.
  const int bins = integer_log(n);
  Array<int> bin_counts(bins);
  for (int i=0;i<n;i++) {
    int j = (int)random_permute(n,key,i);
    const int bin = min(integer_log(j+1),bins-1);
    j = (1<<bin)-1+bin_counts[bin]++;
    X[j] = Perturbed2(i,Xin[i]);
  }

  // Spatially sort each bin down to clusters of size 64.
  const int leaf_size = 64;
  for (int bin=0;bin<bins;bin++) {
    const int start = (1<<bin)-1,
              end = bin==bins-1?n:start+(1<<bin);
    assert(bin_counts[bin]==end-start);
    spatial_sort(X.slice(start,end),leaf_size,new_<Random>(key+bin));
  }

  // Add 3 sentinel points at infinity
  X[n+0] = Perturbed2(n+0,EV(-bound,-bound));
  X[n+1] = Perturbed2(n+1,EV( bound, 0)    );
  X[n+2] = Perturbed2(n+2,EV(-bound, bound));

  return X;
}
示例#3
0
文件: cidr.c 项目: Neg9/namedrop
void mktbl6data(void) {
#define TBIT	(((0ULL - 1) / 2) + 1)
#define EV(x)	((x) != 0 && (((x) + 1) % 2) == 0)
	uint64_t a=TBIT, b=0, *c=&a, f=0;
	for (;; f++) {
		printf("%s{0x%016llxULL, 0x%016llxULL},%c", EV(f) ? "" : "\t", a, b, EV(f) ? '\n' : ' ');
		*c=(*c >> 1) | TBIT;
		if (*c == (uint64_t)(0 - 1)) {
			if (c == &b) {
				printf("{0x%016llxULL, 0x%016llxULL}\n", a, b);
				break;
			}
			c=&b;
		}
	}
}
示例#4
0
void CodeGenFunction::EmitCharacterAssignment(const Expr *LHS, const Expr *RHS) {
  auto Dest = EmitCharacterExpr(LHS);
  CharacterExprEmitter EV(*this);
  EV.setDestination(Dest);
  auto Src = EV.EmitExpr(RHS);

  if(EV.hasDestination())
    EmitCharacterAssignment(Dest, Src);
}
示例#5
0
QDomElement & PokeTeam::toXml(QDomElement &el) const
{
    const_cast<PokeTeam*>(this)->sanityCheck();

    QDomDocument doc;

    el.setAttribute("Nickname", nickname());
    el.setAttribute("Num", num().pokenum);
    el.setAttribute("Item", item());
    el.setAttribute("Ability", ability());
    el.setAttribute("Nature", nature());
    el.setAttribute("Gender", gender());
    el.setAttribute("Shiny", shiny());
    el.setAttribute("Happiness", happiness());
    el.setAttribute("Forme", num().subnum);
    el.setAttribute("Lvl", level());
    el.setAttribute("Gen", gen().num);
    el.setAttribute("SubGen", gen().subnum);

    for(int i = 0; i < 4; i++)
    {
        QDomElement move = doc.createElement("Move");
        el.appendChild(move);

        QDomText name = doc.createTextNode(QString("%1").arg(this->move(i)));
        move.appendChild(name);
    }
    for(int i = 0; i < 6; i++)
    {
        QDomElement Dv = doc.createElement("DV");
        el.appendChild(Dv);

        QDomText Dvname = doc.createTextNode(QString("%1").arg(DV(i)));
        Dv.appendChild(Dvname);
    }
    for(int i = 0; i < 6; i++)
    {
        QDomElement Ev = doc.createElement("EV");
        el.appendChild(Ev);

        QDomText Evname = doc.createTextNode(QString("%1").arg(EV(i)));
        Ev.appendChild(Evname);
    }

    return el;
}
示例#6
0
int main()
{
	Obs o1 = Obs();
	Obs o2 = Obs();
	Obs o3 = Obs();

	EV e = EV();

	uint32_t eventIDs[2] = { 0, 1 };

	e.RegisterObserver(eventIDs[0], &o1);
	e.RegisterObserver(eventIDs[1], &o2);
	e.RegisterObserver(eventIDs[0], &o3);
	e.NotifyObservers(eventIDs[0]);
	e.NotifyObservers(eventIDs[1]);

	getchar();
}
示例#7
0
LValueTy CodeGenFunction::EmitLValue(const Expr *E) {
  LValueExprEmitter EV(*this);
  return EV.Visit(E);
}
示例#8
0
RValueTy CodeGenFunction::EmitAggregateExpr(const Expr *E) {
  AggregateExprEmitter EV(*this);
  return EV.EmitExpr(E);
}
示例#9
0
void csysi_sampleread(void)

{
  int sym, i, len;
  csysi_sampleunit * sidx, * newsamp;
  union { unsigned int l; float f ; } u;
  union { unsigned short us; signed short ss ; } s;

  sidx = (csysi_sampleunit *) malloc(sizeof(csysi_sampleunit));
  sidx->token = sym = csysi_readbit(16);
  sidx->len = len = csysi_readbit(24) + SAMP_DATABLOCK;
  sidx->p = (float *) malloc(len*sizeof(float));

  sidx->p[len - SAMP_LLMEM] = 0;
  if (csysi_readbit(1))  /* sampling rate */
    sidx->p[len - SAMP_SR] = csysi_readbit(17);
  else
    sidx->p[len - SAMP_SR] = EV(ARATE);

  if (csysi_readbit(1))  /* loop points */
    {
      sidx->p[len - SAMP_LOOPSTART] = csysi_readbit(24);
      sidx->p[len - SAMP_LOOPEND] = csysi_readbit(24);
    }
  else
    {
      sidx->p[len - SAMP_LOOPSTART] = -1;
      sidx->p[len - SAMP_LOOPEND] = -1;
    }

  if (csysi_readbit(1))  /* base frequency */
    {
      u.l = csysi_readbit(32);
      sidx->p[len - SAMP_BASEFREQ] = u.f;
    }
  else
    sidx->p[len - SAMP_BASEFREQ] = -1;

  i = 0;
  if (csysi_readbit(1))  /* float sample */
    {
      while (i < (len - SAMP_DATABLOCK))
	{
	  u.l = csysi_readbit(32);
	  sidx->p[i++] = u.f;
	}
    }
  else
    {      
      while (i < (len - SAMP_DATABLOCK))
	{
	  s.us = csysi_readbit(16);
	  sidx->p[i++] = s.ss*(1.0F/32767.0F);
	}
    }

  newsamp = sidx;

  if (!csysi_samples)
    {
      csysi_samples = newsamp;
      return;
    }

  if ((sidx = csysi_samples)->token > sym)
    {
      newsamp->next = csysi_samples;
      csysi_samples = newsamp;
      return;
    }

  while (sidx && (sidx->token <= sym))
    {

      if ((sidx->next == NULL) || 
	  (sidx->next->token > sym))
	break;

      if (sidx->token == sym)
	{
	  while (sidx->next && (sidx->next->token == sym))
	    sidx = sidx->next;
	  break;
	}
      sidx = sidx->next;
    }

  newsamp->next = sidx->next;
  sidx->next = newsamp;
  return;

}
示例#10
0
void csysi_openfile(void)

{
  int i;
  char * name;

  /* first search ./sa file command line for .mp4 file */

  for (i=1;i<EV(csys_argc); i++)
    if (!strcmp(EV(csys_argv[i]),"-csys_fstr_file"))
      {
	i++;
	if (i == EV(csys_argc))
	  csys_terminate(".mp4 file not specified");
	if (!(csysi_bitfile = fopen(EV(csys_argv[i]),"rb")))
	  {
	    name = (char *) calloc(strlen(EV(csys_argv[i]))+5, sizeof(char));
	    sprintf(name,"%s.mp4",EV(csys_argv[i]));
	    if (!(csysi_bitfile = fopen(name,"rb")))
	      csys_terminate(".mp4 file not found");
	  }
	break;
      }

  /* then look though sfront command line for -bitc */

  if (!csysi_bitfile)
    {
      for (i=1;i<csys_sfront_argc; i++)
	if (!strcmp(csys_sfront_argv[i],"-bitc"))
	  {
	    i++;
	    if (i == csys_sfront_argc)
	      csys_terminate("-bitc file.mp4 unspecified");
	    if (!(csysi_bitfile = fopen(csys_sfront_argv[i],"rb")))
	      {
		name = (char *) calloc(strlen(csys_sfront_argv[i])+5,
				       sizeof(char));
		sprintf(name,"%s.mp4",csys_sfront_argv[i]);
		if (!(csysi_bitfile = fopen(name,"rb")))
		  csys_terminate("-bitc file.mp4 not found");
	      }
	    break;
	  }
    }

  if (!csysi_bitfile)
    csys_terminate(
	"Syntax: ./sa -csys_fstr_file file.mp4, or sfront -bitc file.mp4");

  /* if an explicit SASL endtime not give, invalidate computed endtime */

  if (!(CSYS_GIVENENDTIME))
    {
      csysi_compendtime = EV(endtime);
      if (!csysi_setendtime(CSYSI_MAXENDTIME))
	csys_terminate("problem setting init endtime");
    }

  /* skip to access_units, fill up queues */

  csysi_flushconfig();
  csysi_fillqueues();

}
示例#11
0
int csys_saslevent(unsigned char * cmd, unsigned char * priority,
		   unsigned short * id, unsigned short * label,
		   float * fval, unsigned int * pnum, float ** p)

{
  int i, done, j, scofound;
  csysi_sevent * cq;


  done = 1;
  if (csysi_scoready)
    {
      cq = &(csysi_scoqueue[csysi_tailsco]);
      scofound = 1;
    }
  else
    {
      if (csysi_absready)
	{
	  cq = &(csysi_absqueue[csysi_tailabs]);
	  scofound = 0;
	}
      else
	csys_terminate("saslevent() queue error");
    }

  *priority = cq->priority;
  *id = cq->id;
  *label = cq->label;
  *fval = cq->fval;
  *pnum = cq->pnum;
  *p = cq->p;

  switch (*cmd = cq->cmd) {
  case CSYS_SASL_ENDTIME :  
    *fval = EV(scorebeats);
    break;
  case CSYS_SASL_NOOP :
  case CSYS_SASL_TEMPO : 
  case CSYS_SASL_TABLE :
  case CSYS_SASL_INSTR :
    break;
  case CSYS_SASL_CONTROL :
    if ((*id) == CSYS_SASL_NOINSTR)
      break;
    if (csysi_targetvar == -1)
      {
	csysi_targetvar=0;
	while (csysi_targetvar < CSYS_TARGETNUM)
	  {
	    if (csys_target[csysi_targetvar].token == (*pnum))
	      break;
	    csysi_targetvar++;
	  }
	if (csysi_targetvar == CSYS_TARGETNUM) 
	  {
	    /* specified variable not imported -- abort command */
	    *cmd = CSYS_SASL_NOOP;
	    csysi_targetvar = -1;
	    break;
	  }
	csysi_targetcount = 0;
      }
    *id = csys_target[csysi_targetvar].instrindex[csysi_targetcount];
    *pnum = csys_target[csysi_targetvar].varindex[csysi_targetcount];
    if ((++csysi_targetcount) < csys_target[csysi_targetvar].numinstr)
      done = 0;
    else
      csysi_targetvar = -1;
    break;
  }

  if (done)
    {
      if (scofound)
	{
	  csysi_scoready--;
	  csysi_numscotime--;
	  csysi_tailsco = (csysi_tailsco+1)&(CSYSI_MAXSASL-1);
	  if (csysi_tailsco == csysi_headsco)  /* empty */
	    {
	      csysi_headsco = 0;
	      csysi_tailsco = -1;
	    }
	}
      else
	{
	  csysi_absready--;
	  csysi_numabstime--;
	  csysi_tailabs = (csysi_tailabs+1)&(CSYSI_MAXSASL-1);
	  if (csysi_tailabs == csysi_headabs)  /* empty */
	    {
	      csysi_headabs = 0;
	      csysi_tailabs = -1;
	    }
	}
    }

  if (csysi_scoready || csysi_absready)
    return CSYS_SASLEVENTS;
  else
    return CSYS_NONE;

}
示例#12
0
CharacterValueTy CodeGenFunction::EmitCharacterExpr(const Expr *E) {
  CharacterExprEmitter EV(*this);
  return EV.EmitExpr(E);
}
示例#13
0
int csys_newdata(void)
     
{
  int i, found;

  csysi_absready = 0; 
  csysi_scoready = 0; 
  csysi_midiready = 0; 

  csysi_fillqueues();

  /* see if an event is ready */

  i = csysi_tailsco;
  found = ((i = csysi_tailsco) < 0);
  while (csysi_numscotime && !found)
    {
      if (csysi_scoqueue[i].stime <= EV(scorebeats))
	csysi_scoready++;
      else
	found = 1;
      i = (i+1)&(CSYSI_MAXSASL-1);
      if (i == csysi_headsco)
	found = 1;
    }
  
  i = csysi_tailabs;
  found = ((i = csysi_tailabs) < 0);
  while (csysi_numabstime && !found)
    {
      if (csysi_absqueue[i].atime < EV(absolutetime))
	csysi_absready++;
      else
	found = 1;
      i = (i+1)&(CSYSI_MAXSASL-1);
      if (i == csysi_headabs)
	found = 1;
    }
  
  i = csysi_tailmidi;
  found = ((i = csysi_tailmidi) < 0);
  while (csysi_nummidi && !found)
    {
      if (csysi_midiqueue[i].atime < EV(absolutetime))
	csysi_midiready++;
      else
	found = 1;
      i = (i+1)&(CSYSI_MAXMIDI-1);
      if (i == csysi_headmidi)
	found = 1;
    }

  if (csysi_midiready)
    {
      if ((csysi_absready || csysi_scoready))
	return CSYS_EVENTS;
      else
	return CSYS_MIDIEVENTS;
    }
  else
    {
      if ((csysi_absready || csysi_scoready))
	return CSYS_SASLEVENTS;
      else
	return CSYS_NONE;
    }

}
示例#14
0
ComplexValueTy CodeGenFunction::EmitComplexExpr(const Expr *E) {
  ComplexExprEmitter EV(*this);
  return EV.EmitExpr(E);
}
示例#15
0
void PokePersonal::runCheck()
{
    if (!PokemonInfo::Exists(num(), gen())) {
        reset();
        return;
    }

    if (!PokemonInfo::AFormesShown(num())) {
        num() = num().original();
    }

    if (gen() <= 2) {
        ability() = 0;
        nature() = 0;
    } else {
        AbilityGroup ab = PokemonInfo::Abilities(num(), gen());

        if (ability() == 0 || (ability() != ab.ab(2) && ability() != ab.ab(1)))
            ability() = ab.ab(0);
    }

    if (gen().num == 2)
        controlGender();

    if (!ItemInfo::Exists(item(), gen())) {
        item() = 0;
    }

    for (int i = 0; i < 6; i++)
        controlEVs(i);

    if (gen() <= 2) {
        for (int i = 0; i < 6; i++) {
            if (DV(i) >= 15)
                setDV(i, 15);
        }
    }

    if (gen().num == 2) {
        setEV(SpDefense, EV(SpAttack));
        setDV(SpDefense, DV(SpAttack));
    }

    int avail = PokemonInfo::Gender(num());

    if (avail != Pokemon::MaleAndFemaleAvail) {
        gender() = avail;
    } else if (gender() == Pokemon::Neutral){
        gender() = Pokemon::Male;
    }

    int minLevel = PokemonInfo::AbsoluteMinLevel(num(), gen());

    if (MoveSetChecker::enforceMinLevels && level() < minLevel) {
        level() = minLevel;
    }

    QSet<int> invalidMoves;

    MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves);

    while (invalidMoves.size() > 0) {
        for (int i = 0; i < 4; i++) {
            if (invalidMoves.contains(move(i))) {
                setMove(0, i, false);
            }
        }
        invalidMoves.clear();

        MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves);
    }

    if (num().pokenum == Pokemon::Keldeo) {
        if (move(0) == Move::SecretSword || move(1) == Move::SecretSword || move(2) == Move::SecretSword || move(3) == Move::SecretSword) {
            num() = Pokemon::Keldeo_R;
        } else {
            num() = num().original();
        }
    }
}
示例#16
0
int PokeTeam::stat(int statno) const
{
    return PokemonInfo::FullStat(num(), gen(), nature(), statno, level(),DV(statno),EV(statno));
}
示例#17
0
int PokePersonal::EVSum() const
{
    return EV(Hp) + EV(Attack) + EV(Defense) + EV(Speed) + EV(SpAttack) + EV(SpDefense);
}