Пример #1
0
AMBeamlineActionItem *VESPERSBeamline::createBeamChangeAction(VESPERS::Beam beam)
{
	// If we are already at the new beam position and the internal state of the beam is the same, then don't do anything.
	if (beam_ == beam && beamSelectionMotor_->withinTolerance(beamPositions_.value(beam)))
		return 0;

	// To change beams, it is either a two or three stage process.
	/*
		First: Turn off the ability to scan.  This ensures that the mono motor doesn't swing wildly around while switching between beams.
		Second: Move to the chosen beam.
		Third (if applicable): If the new beam is a monochromatic beam, turn on the ability to scan the energy.
	 */
	AMBeamlineParallelActionsList *changeBeamActionsList = new AMBeamlineParallelActionsList;
	AMBeamlineListAction *changeBeamAction = new AMBeamlineListAction(changeBeamActionsList);

	changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>());
	changeBeamActionsList->appendAction(0, mono()->createAllowScanningAction(false));

	changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>());
	AMBeamlineControlMoveAction *moveBeamAction = new AMBeamlineControlMoveAction(beamSelectionMotor());
	moveBeamAction->setSetpoint(beamPositions_.value(beam));
	changeBeamActionsList->appendAction(1, moveBeamAction);

	if (beam != VESPERS::Pink){

		changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>());
		changeBeamActionsList->appendAction(2, mono()->createAllowScanningAction(true));
	}

	return changeBeamAction;
}
Пример #2
0
jas_cmprof_t *jas_cmprof_createfromiccprof(jas_iccprof_t *iccprof)
{
	jas_cmprof_t *prof;
	jas_icchdr_t icchdr;
	jas_cmpxformseq_t *fwdpxformseq;
	jas_cmpxformseq_t *revpxformseq;

	if (!(prof = jas_cmprof_create()))
		goto error;
	jas_iccprof_gethdr(iccprof, &icchdr);
	if (!(prof->iccprof = jas_iccprof_copy(iccprof)))
		goto error;
	prof->clrspc = icctoclrspc(icchdr.colorspc, 0);
	prof->refclrspc = icctoclrspc(icchdr.refcolorspc, 1);
	prof->numchans = jas_clrspc_numchans(prof->clrspc);
	prof->numrefchans = jas_clrspc_numchans(prof->refclrspc);

	if (prof->numchans == 1) {
		if (mono(prof->iccprof, 0, &fwdpxformseq))
			goto error;
		if (mono(prof->iccprof, 1, &revpxformseq))
			goto error;
	} else if (prof->numchans == 3) {
		if (triclr(prof->iccprof, 0, &fwdpxformseq))
			goto error;
		if (triclr(prof->iccprof, 1, &revpxformseq))
			goto error;
	}
	prof->pxformseqs[SEQFWD(0)] = fwdpxformseq;
	prof->pxformseqs[SEQREV(0)] = revpxformseq;

#if 0
	if (prof->numchans > 1) {
		lut(prof->iccprof, 0, PER, &pxformseq);
		pxformseqs_set(prof, SEQFWD(PER), pxformseq);
		lut(prof->iccprof, 1, PER, &pxformseq);
		pxformseqs_set(prof, SEQREV(PER), pxformseq);
		lut(prof->iccprof, 0, CLR, &pxformseq);
		pxformseqs_set(prof, SEQREV(CLR), pxformseq);
		lut(prof->iccprof, 1, CLR, &pxformseq);
		pxformseqs_set(prof, SEQREV(CLR), pxformseq);
		lut(prof->iccprof, 0, SAT, &pxformseq);
		pxformseqs_set(prof, SEQREV(SAT), pxformseq);
		lut(prof->iccprof, 1, SAT, &pxformseq);
		pxformseqs_set(prof, SEQREV(SAT), pxformseq);
	}
#endif

	return prof;
error:
	return 0;
}
Пример #3
0
String AudioChannelSet::getDescription() const
{
    if (isDiscreteLayout())            return String ("Discrete #") + String (size());
    if (*this == disabled())           return "Disabled";
    if (*this == mono())               return "Mono";
    if (*this == stereo())             return "Stereo";
    if (*this == createLCR())          return "LCR";
    if (*this == createLRS())          return "LRS";
    if (*this == createLCRS())         return "LCRS";
    if (*this == quadraphonic())       return "Quadraphonic";
    if (*this == pentagonal())         return "Pentagonal";
    if (*this == hexagonal())          return "Hexagonal";
    if (*this == octagonal())          return "Octagonal";
    if (*this == ambisonic())          return "Ambisonic";
    if (*this == create5point0())      return "5.1 Surround";
    if (*this == create5point1())      return "5.1 Surround (+Lfe)";
    if (*this == create6point0())      return "6.1 Surround";
    if (*this == create6point0Music()) return "6.1 (Music) Surround";
    if (*this == create6point1())      return "6.1 Surround (+Lfe)";
    if (*this == create7point0())      return "7.1 Surround (Rear)";
    if (*this == create7point1())      return "7.1 Surround (Rear +Lfe)";
    if (*this == create7point1AC3())   return "7.1 AC3 Surround (Rear + Lfe)";
    if (*this == createFront7point0()) return "7.1 Surround (Front)";
    if (*this == createFront7point1()) return "7.1 Surround (Front +Lfe)";

    return "Unknown";
}
Пример #4
0
int CTalkChirno1::Thread(){

	chara = 0;
	face = 0;
	enemy_face = -1;
	font.CreateList("いるんだろ?\n出てこいよ。");
	Talk();

	for( int i = 0; i < 46; i++ ) {
		g_pBoss->Appear();
		SunEffectRect flame;
		flame.m_color = argb(127,0,0,0);
		SetRect(&flame.m_rect,GAME_LEFT+60,350,GAME_RIGHT-60,430);
		D3DCOLOR color = mono(128+127*(chara==0));
		int cx = - (chara != 0) * 20;
		int cy = (chara != 0) * 20;
		DrawMarisa(-200+cx,60+cy,face,manfu,color);
		flame.Draw();
		if( !GetInputState( INP_B6 ) )
			mt.Suspend();
	}

	chara = 1;
	enemy_face = 3;
	font.CreateList("な、なんで分かったのよ……");
	fntEnemy.CreateList("氷精 チルノ",16);
	Talk();

	chara = 0;
	face = 1;
	font.CreateList("妖精が現れるのには、前触れがあるんだぜ、\n知らないのか?");
	Talk();

	return 1;
}
Пример #5
0
void ReducerNoDedup<Q>::insert(ConstMonoRef multiple, const Poly& poly) {
  if (poly.isZero())
    return;
  mLeadTermKnown = false;

  const auto end = poly.end();
  for (auto it = poly.begin(); it != end; ++it) {
    NewTerm t = {it.coef(), mRing.monoid().alloc().release()};
    mRing.monoid().multiply(multiple, it.mono(), *t.mono);
    mQueue.push(t);
  }
}
Пример #6
0
bool ReducerHash<Q>::leadTerm(NewConstTerm& result) {
  while (!mQueue.empty()) {
    const auto top = mQueue.top();
    if (!mRing.coefficientIsZero(top->value())) {
      result.coef = top->value();
      result.mono = top->mono().ptr();
      return true;
    }
    mQueue.pop();
    mHashTable.remove(top);
  }
  return false;
}
Пример #7
0
void Connector::setupOutputBox() {
    
    QPalette p = output->palette() ;
    QFont mono("Inconsolata", 12) ;
    mono.setStyleStrategy(QFont::PreferAntialias);
    p.setColor(QPalette::Base, Qt::black) ;
    output->setReadOnly(true) ;
    output->setPalette(p) ;
    output->setTextColor(Qt::green) ;

    output->append("*******Connector Output*******") ;
    output->append("\n\n") ;
}
Пример #8
0
int main(int argc, char **argv)
{
    uint64_t start = mono();
    Node root;
    root.rect.w = 1280;
    root.rect.h = 720;

    const int count = std::max(1, (argc > 1 ? atoi(argv[1]) : 1));
    generate(&root, 10, 4);
    // root.dump();
    uint64_t elapsed = mono() - start;
    printf("Created %d nodes in %llums\n", nodeCount, elapsed);
    start = mono();
    uint64_t rendered = 0;
    for (int i=0; i<count; ++i) {
        rendered += root.render(root.rect);
    }
    elapsed = mono() - start;
    printf("Rendered %llu nodes in %llums (%d iteration%s)\n", rendered, elapsed, count, count > 1 ? "s" : "");

    return 0;
}
Пример #9
0
/*****************************************************************************
 * Convert
 *****************************************************************************/
static block_t *Convert( filter_t *p_filter, block_t *p_block )
{
    block_t *p_out;
    int i_out_size;

    if( !p_block || !p_block->i_nb_samples )
    {
        if( p_block )
            block_Release( p_block );
        return NULL;
    }

    i_out_size = p_block->i_nb_samples * p_filter->p_sys->i_bitspersample/8 *
                 aout_FormatNbChannels( &(p_filter->fmt_out.audio) );

    p_out = block_Alloc( i_out_size );
    if( !p_out )
    {
        msg_Warn( p_filter, "can't get output buffer" );
        block_Release( p_block );
        return NULL;
    }
    p_out->i_nb_samples =
                  (p_block->i_nb_samples / p_filter->p_sys->i_nb_channels) *
                       aout_FormatNbChannels( &(p_filter->fmt_out.audio) );

#if 0
    unsigned int i_in_size = in_buf.i_nb_samples  * (p_filter->p_sys->i_bitspersample/8) *
                             aout_FormatNbChannels( &(p_filter->fmt_in.audio) );
    if( (in_buf.i_buffer != i_in_size) && ((i_in_size % 32) != 0) ) /* is it word aligned?? */
    {
        msg_Err( p_filter, "input buffer is not word aligned" );
        /* Fix output buffer to be word aligned */
    }
#endif

    memset( p_out->p_buffer, 0, i_out_size );
    if( p_filter->p_sys->b_downmix )
    {
        stereo2mono_downmix( p_filter, p_block, p_out );
        mono( p_filter, p_out, p_block );
    }
    else
    {
        stereo_to_mono( p_filter, p_out, p_block );
    }

    block_Release( p_block );
    return p_out;
}
Пример #10
0
void ReducerNoDedup<Q>::insertTail(NewConstTerm multiple, const Poly& poly) {
  if (poly.termCount() <= 1)
    return;
  mLeadTermKnown = false;

  auto it = poly.begin();
  const auto end = poly.end();
  for (++it; it != end; ++it) {
    NewTerm t;
    t.mono = mRing.allocMonomial();
    mRing.monoid().multiply(*multiple.mono, it.mono(), *t.mono);
    mRing.coefficientMult(multiple.coef, it.coef(), t.coef);
    mQueue.push(t);
  }
}
Пример #11
0
void CTalkChen1::DrawEnemy(){
	if( enemy_face < 0 )
		return;
	D3DCOLOR c = mono(128+127*(chara==1));
	RECT rect;
	SetRect(&rect,0,0,320,512);
	g_pStage5->imgTalk.DrawRectClip(360+(chara != 1)*20,100+(chara != 1)*20,rect,c);

	switch( enemy_face ) {
	case 1:
		SetRect(&rect,512-96,0,512,64);
		g_pStage5->imgTalk.DrawRectClip(360+64+(chara != 1)*20,100+64+(chara != 1)*20,rect,c);
		break;
	}
}
Пример #12
0
void ImageEffect::applyEffect(QImage &i, int effect) {
    switch(effect)
    {
        case ImageEffect::Effect_None:
            break;
        case ImageEffect::Effect_Grey:
            grey(i); break;
        case ImageEffect::Effect_Invert:
            invert(i); break;
        case ImageEffect::Effect_Mono:
            mono(i); break;
        case ImageEffect::Effect_Smurf:
            smurf(i); break;
    }
}
Пример #13
0
SapData SetDataValue(SapBuffer* Buffers, DWORD *pPrmIndex)
{
	if(IsMonoBuffer(Buffers) == TRUE)
	{
		SapDataMono mono(128);
		return mono;
	}
	else
	{
		SapDataRGB rgb;
		//SapDataRGB rgb(m_pInfoList->GetValueAt(*pPrmIndex), m_pInfoList->GetValueAt(*pPrmIndex+1), m_pInfoList->GetValueAt(*pPrmIndex+2));
		*pPrmIndex = *pPrmIndex+3;
		return rgb;
	}
}
Пример #14
0
void CTalkWriggle1::DrawEnemy(){
	D3DCOLOR c = mono(128+127*(chara==1));
	RECT rect;
	switch( enemy_face ) {
	case 0:
		g_pStage2->imgCutin.DrawClip(360+(chara != 1)*20,100+(chara != 1)*20,c);
		break;
	case 1:
		SetRect(&rect,0,0,256,438);
		g_pStage2->imgTalk.DrawRectClip(360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	case 2:
		SetRect(&rect,256,0,512,438);
		g_pStage2->imgTalk.DrawRectClip(360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	}
}
Пример #15
0
void cipherGen(int type[])
{
	switch(type[0])
	{
		case 1:
			rot13();
			break;
		case 2:
			mono();
			break;
		case 3:
			caesar();
			break;
		default:
			printf("Invalid cipher type");
	}	
}
Пример #16
0
int CTalkMystia1::Thread(){
	chara = 0;
	face = 0;
	enemy_face = -1;
	font.CreateList("あー何だろな、この場所は");
	Talk();

	for( int i = 0; i < 46; i++ ) {
		g_pBoss->Appear();
		SunEffectRect flame;
		flame.m_color = argb(127,0,0,0);
		SetRect(&flame.m_rect,GAME_LEFT+60,350,GAME_RIGHT-60,430);
		D3DCOLOR color = mono(128+127*(chara==0));
		int cx = - (chara != 0) * 20;
		int cy = (chara != 0) * 20;
		DrawMarisa(-200+cx,60+cy,face,manfu,color);
		flame.Draw();
		if( !GetInputState( INP_B6 ) )
			mt.Suspend();
	}

	chara = 1;
	enemy_face = 2;
	font.CreateList("ある〜晴れ〜た日〜の事〜♪");
	fntEnemy.CreateList("みみずくの夜 ミスティア",16);
	Talk();

	chara = 0;
	face = 4;
	font.CreateList("なんだ、夜雀の巣か");
	Talk();

	chara = 1;
	enemy_face = 2;
	font.CreateList("魔砲以上の〜愉快な〜♪");
	Talk();

	chara = 0;
	face = 3;
	manfu = 3;
	font.CreateList("歌うな!");
	Talk();

	return 1;
}
Пример #17
0
void CTalk::Talk(){
	if( g_pTitle->talk ) {
		SunEffectRect flame;
		flame.m_color = argb(127,0,0,0);
		SetRect(&flame.m_rect,GAME_LEFT+60,350,GAME_RIGHT-60,430);
		do{
			mt.Suspend();
			int mae = (chara != 0 && chara != 2);
			D3DCOLOR color = mono(128+127*(!mae));
			int cx = - mae * 20;
			int cy = mae * 20;
			DrawMarisa(-200+cx,60+cy,face,manfu,color);
			RECT rect;
			switch( manfu ) {
			case 0://驚
				SetRect(&rect,0,0,48,64);
				break;
			case 1://困
				SetRect(&rect,48,0,128,64);
				break;
			case 2://汗
				SetRect(&rect,128,0,160,64);
				break;
			case 3://怒
				SetRect(&rect,160,0,208,64);
				break;
			default:
				break;
			}
			if( manfu != -1 )
				g_pMaterial->imgManfu.DrawRectClip(40+cx,90+cy,rect,color);
			if( g_pTitle->otaku )
				DrawEnemy();
			flame.Draw();

			D3DCOLOR c1 = (chara==1) ? ENEMY_TALK_COLOR : MARISA_TALK_COLOR;
			D3DCOLOR c2 = ENEMY_TALK_COLOR;
			font.DrawFormat(100,370,c1);
			font2.DrawFormat(100,400,c2);
			fntEnemy.DrawFormat(500-16*fntEnemy.m_str.size()/2,340,ENEMY_NAME_COLOR);
		}while( !Next() );
	}
}
Пример #18
0
void CTalkMystia1::DrawEnemy(){
	if( enemy_face < 0 )
		return;
	D3DCOLOR c = mono(128+127*(chara==1));
	RECT rect;
	SetRect(&rect,0,0,256+32,512);
	g_pStage4->imgTalk.DrawRectClip(360+(chara != 1)*20,100+(chara != 1)*20,rect,c);

	switch( enemy_face ) {
	case 1:
		SetRect(&rect,512-128,0,512,128);
		g_pStage4->imgTalk.DrawRectClip(32+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	case 2:
		SetRect(&rect,512-128,128,512,256);
		g_pStage4->imgTalk.DrawRectClip(32+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	case 3:
		SetRect(&rect,512-128,256,512,384);
		g_pStage4->imgTalk.DrawRectClip(32+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	}
}
Пример #19
0
void CTalkChirno4::DrawEnemy(){
	if( enemy_face < 0 )
		return;
	D3DCOLOR c = mono(128+127*(chara==1));
	RECT rect;
	SetRect(&rect,0,0,300,512);
	g_pChirno2->imgTalk.DrawRectClip(360+(chara != 1)*20,100+(chara != 1)*20,rect,c);

	switch( enemy_face ) {
	case 1:
		SetRect(&rect,512-128,0,512,128);
		g_pChirno2->imgTalk.DrawRectClip(64+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	case 2:
		SetRect(&rect,512-128,128,512,256);
		g_pChirno2->imgTalk.DrawRectClip(64+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	case 3:
		SetRect(&rect,512-128,256,512,256+128);
		g_pChirno2->imgTalk.DrawRectClip(64+360+(chara != 1)*20,100+(chara != 1)*20,rect,c);
		break;
	}
}
Пример #20
0
void CTalkLety1::DrawEnemy(){
	if( enemy_face < 0 )
		return;
	int mae = (chara != 1 && chara != 2);
	D3DCOLOR c = mono(128+127*(!mae));
	RECT rect;
	SetRect(&rect,0,0,256,512);
	g_pStage6->imgTalk.DrawRectClip(360+mae*20,100+mae*20,rect,c);

	switch( enemy_face ) {
	case 1:
		SetRect(&rect,512-128,0,512,96);
		g_pStage6->imgTalk.DrawRectClip(64+360+mae*20,64+100+mae*20,rect,c);
		break;
	case 2:
		SetRect(&rect,512-128,96,512,96*2);
		g_pStage6->imgTalk.DrawRectClip(64+360+mae*20,64+100+mae*20,rect,c);
		break;
	case 3:
		SetRect(&rect,512-128,96*2,512,96*3);
		g_pStage6->imgTalk.DrawRectClip(64+360+mae*20,64+100+mae*20,rect,c);
		break;
	}
}
Пример #21
0
int mybls (double *time, double *flux, double *weight, long ndata,
	   float pmin, float pmax, float kmin, float kmax, 
	   float sampling, double *period, double *statistic, 
	   double *dc, double *duration, double *epoch, double *depth, 
	   long *np) {
  
  double *wflux = (double *) NULL; /* To hold weighted flux */
  double med; /* Median flux */
  double phwc; /* Constant to convert period & duration to min. star radius */
  long nhw, nep, nper; /* Number of trial half-widths, epochs and periods */
  double hwmin, hwmin2, hwmax, hwmax2, dhw, hw; /* Trial half-widths */
  double trange, trangexp, dep; /* Trial epochs */
  double dfreq, freqmin, freqmax, lfreqmin, lfreqmax, freq, per; /* Trial periods */
  long idata, ihw, ip_dep, ipmin, ipmax, ip,
    nfp, ifp, iarg, ie; /* Indices */
  double *wsum = (double *) NULL, *ywsum = (double *) NULL, sumw, sumyw,
    *sumw_ = (double *) NULL, *sumyw_ = (double *) NULL; /* Mono sums */
  double stat, stat_p, depth_p, epoch_p; /* Epoch search */

  /* Compute light curve median, weighted data arrays and initial chi2 */
  wflux = (double *) malloc( sizeof(double) * ndata );
  for (idata = 0; idata < ndata; idata++) {
    wflux[idata] = flux[idata]; 
  }
  sort1double(wflux, ndata);
  med = wflux[(ndata+1)/2];
  for (idata = 0; idata < ndata; idata++) {
    wflux[idata] = (flux[idata] - med) * weight[idata];
  }

  /* Set the half-width sampling */
  phwc = pow(4 / PI_CONST / G_CONST / MSUN_CONST, 1.0 / 3.0) * 
    RSUN_CONST * pow(DAY_TO_SEC, -2.0 / 3.0);
  nhw = (long) (((double) DEFAULT_NHW) * sampling);
  hwmax = pow(pmax, 1.0 / 3.0) * kmax * phwc / 2.;
  hwmax2 = pow(pmin, 1.0 / 3.0) * kmax * phwc / 2.;  
  hwmin = pow(pmin, 1.0 / 3.0) * kmin * phwc / 2.;
  hwmin2 = pow(pmax, 1.0 / 3.0) * kmin * phwc / 2.;
  dhw = MIN((hwmax - hwmin2), (hwmax2-hwmin)) / ((double) (nhw-1));
  nhw = MAX((long) ((hwmax - hwmin) / dhw) + 1, 1);

  /* Set epoch sampling */
  dep = (double) (hwmin * pmin / sampling / 2.0); 
  trange = time[ndata-1] - time[0];
  trangexp = trange + 2 * (hwmax + dep);
  nep = (long) (trangexp / dep) + 1;

  /* Set period sampling and initialise arrays to hold periodogram */
  dfreq = (double) (hwmin / trange / sampling);
  freqmin = (double) (1.0 / pmax);
  freqmax = (double) (1.0 / pmin);
  nper = (long) ((freqmax - freqmin) / dfreq) + 1;
  if (nper > *np) {
    printf("mybls/mybls.c: Error: too many trial periods.\n");
  }
  *np = nper;
  for(ip = 0; ip < nper; ip++) {
    freq = freqmin +  ((double) ip) * dfreq;
    period[ip] = 1.0 / freq;
    statistic[ip] = 0.0;
    duration[ip] = 0.0;
    depth[ip] = 0.0;
    epoch[ip] = 0.0;
    dc[ip] = med;
  }

  /* Allocate arrays to hold single epoch search output */  
  wsum = (double *) malloc(sizeof(double) * nep);
  ywsum = (double *) malloc(sizeof(double) * nep);
  ip_dep = (long) (pmax / dep) + 1;
  sumw_ = (double *) malloc(sizeof(double) * ip_dep);
  sumyw_ = (double *) malloc(sizeof(double) * ip_dep);

  /* Loop over trial half-widths */
  for(ihw = 0; ihw < nhw; ihw++) {
    hw = hwmin + ((double) ihw) * dhw;

    /* Work out the range of periods that give a value of k in the
       desired range */
    lfreqmax = (double) (pow(2 * hw / kmax / phwc, -3.0));
    lfreqmin = (double) (pow(2 * hw / kmin / phwc, -3.0));
    ipmin = MAX(0, (long) ((lfreqmin - freqmin) / dfreq));
    ipmax = MIN(nper-1, (long) ((lfreqmax - freqmin) / dfreq));

    /* Reset dep to appropriate value */
    dep = (double) (hw * pmin / sampling / 2.0);
 
    /* Single event search */
    mono(time, wflux, weight, ndata, hw, dep, nep, wsum, ywsum);

    /* Loop over the trial trial periods */
    for(ip = ipmin; ip < ipmax; ip++) {
      per = period[ip];
      ip_dep = (long) (per / dep) + 1; /* period in dep units */ 
      nfp = (long) (trangexp / per); /* number of integer periods in LC */

      /* Find best epoch */
      stat_p = 0.;
      epoch_p = 0;
      depth_p = 0;
      for (ie = 0; ie < ip_dep; ie++) {
	sumw = 0.;
	sumyw = 0.;
	for(ifp = 0; ifp <= nfp; ifp++) {
	  iarg = (long) ((((double) ifp) * per + ((double) ie) * dep) / dep);
	  if (iarg >= nep) continue;
	  sumw += wsum[iarg];
	  sumyw += ywsum[iarg];
	}
	if(((sumw) > EPS) && ((sumyw) > EPS)) {
	  stat = sumyw / sqrt(sumw);
	} else {
	  stat = 0.0;
	}
	if(stat > stat_p) { /* Best epoch so far? */
	  stat_p = stat;
	  depth_p = sumyw / sumw;
	  epoch_p = ie * dep - hw;
	}
      }
      if (stat_p > statistic[ip]) { /* Best at this period so far? */
	statistic[ip] = stat_p;
	depth[ip] = depth_p;
	epoch[ip] = epoch_p + time[0] - hw;
	duration[ip] = 2 * hw;
      }
    } /* End period loop */
  } /* End half-width loop */

  /* Free memory */
  if (wflux) free((void *) wflux);
  if (wsum) free((void *) wsum);
  if (ywsum) free((void *) ywsum);
  if (sumw_) free((void *) sumw_);
  if (sumyw_) free((void *) sumyw_);

  return(0);
 
}
Пример #22
0
void CTalkRumia2::DrawEnemy(){
	D3DCOLOR c = mono(128+127*(chara==1));
	g_pStage1->imgCutin.DrawClip(270+(chara != 1)*20,120+(chara != 1)*20,c);
}
Пример #23
0
void CTalkWriggle2::DrawEnemy(){
	D3DCOLOR c = mono(128+127*(chara==1));
	g_pStage2->imgCutin.DrawClip(360+(chara != 1)*20,100+(chara != 1)*20,c);
}
Пример #24
0
int CEnding::Thread(){
	PlayBGM("tbm_end");

//	g_pSystem->continue_dirty = 1;
	if( g_pSystem->continue_dirty == 0 ) {
		imgBack.LoadTexture("img/ending01.png");

		serif[0].font.Create("博麗神社。");
		Talk();
		serif[1].font.Create("一時は幻想郷中を埋め尽くさんとしていた吹雪が止み、");
		Talk();
		serif[2].font.Create("延期されていた忘年会も無事終わって、");
		Talk();
		serif[3].font.Create("何事も無かったかのように正月を迎えてようとしていた。");
		Talk();
		Init();
		serif[0].font.Create("霊夢「どういう桶の吹き回しかしら、それ?」");
		Talk();
		Init();

		imgBack.LoadTexture("img/ending02.png");

		serif[0].font.Create("魔理沙「目が悪いって言われたんでな、");
		Talk();
		serif[1].font.Create("      途中で香霖堂に寄って借りてきた。");
		Talk();
		serif[2].font.Create("      私が死ぬまでの間な。");
		Talk();
		serif[3].font.Create("      あいつは私より長く生きるだろうし」");
		Talk();
		Init();
		serif[0].font.Create("霊夢「あんたの場合、");
		Talk();
		serif[1].font.Create("      飽きるか壊すかするほうが早そうだけどね」");
		Talk();
		Init();

		serif[0].font.Create("霊夢「で、こいつは?」");
		Talk();

		imgBack.LoadTexture("img/ending03.png");
		
		serif[1].font.Create("魔理沙「今回の黒幕だぜ」");
		Talk();
		serif[2].font.Create("霊夢「黒幕って……何かあったの?」");
		Talk();
		serif[3].font.Create("レティ「何もないわ」");
		Talk();
		Init();

		serif[0].font.Create("魔理沙「ま、そういうことだ。");
		Talk();
		serif[1].font.Create("      っと、そろそろ時間だな」");
		Talk();
		serif[3].font.Create("『新年あけましておめでとう!』");
		Talk();
		Init();

		serif[0].font.Create("幻想郷の冬は厳しい。");
		Talk();
		serif[1].font.Create("幻想郷に棲む少女達は適度に運動をしなければ");
		Talk();
		serif[2].font.Create("体も凍り付いてしまうのかもしれない。");
		Talk();
		if( GetDifficult() != DIFF_LUNATIC )
			serif[3].font.Create("Good End                  クリアーおめでとう!");
		else
			serif[3].font.Create("Good End                  あんたはすごい!");
		Talk();
		Init();
	}else{
		imgBack.LoadTexture("img/ending10.png");
		serif[0].font.Create("魔法の森にて。");
		Talk();
		serif[1].font.Create("魔理沙「あーあ、疲れたぜ。");
		Talk();
		serif[2].font.Create("      大体なんだ、この寒さは?");
		Talk();
		serif[3].font.Create("      まるで真冬のようじゃないか」");
		Talk();
		Init();

		serif[0].font.Create("はっきり言って真冬である。");
		Talk();
		serif[1].font.Create("幻想郷の冬は厳しいのだ。");
		Talk();

		serif[3].font.Create("Bad End          コンティニューせずにクリアを目指そう!");
		Talk();
		Init();
	}
	imgBack.LoadTexture("img/thend.png");
	if( g_pTitle->talk ) {
		for(int i = 0; i < 255; i++ ){
			mt.Suspend();
			imgBack.Draw(0,0,mono(i));
		}
	}
	Talk();
	if( g_pGame->mode == 0 || g_pGame->mode == 2 )
		g_pSystem->SaveReplay();
	else {
		g_pTitle->Resume();
		return 0;
	}
	return 1;
}
Пример #25
0
int CTalkLety2::Thread(){
	chara = 0;
	face = 0;
	enemy_face = -1;
	font.CreateList("さあ、そろそろ黒幕においで願おうか");
	Talk();

	for( int i = 0; i < 46; i++ ) {
		g_pBoss->Appear();
		SunEffectRect flame;
		flame.m_color = argb(127,0,0,0);
		SetRect(&flame.m_rect,GAME_LEFT+60,350,GAME_RIGHT-60,430);
		D3DCOLOR color = mono(128+127*(chara==0));
		int cx = - (chara != 0) * 20;
		int cy = (chara != 0) * 20;
		DrawMarisa(-200+cx,60+cy,face,manfu,color);
		flame.Draw();
		if( !GetInputState( INP_B6 ) )
			mt.Suspend();
	}

	chara = 1;
	enemy_face = 0;
	font.CreateList("あら、あなたはこの美しく輝くオーロラが\n黒く見えるの?");
	fntEnemy.CreateList("冬の落とし子 レティ",16);
	Talk();

	chara = 0;
	face = 1;
	font.CreateList("黒くたって輝けるんだぜ。\n知らないのか?");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("輝くのはあなたじゃなくて、\nあなたの魔法でしょう?");
	Talk();

	chara = 0;
	face = 0;
	font.CreateList("つれないなあ。\nそんなだからこんな寒い冬にしちまうんだぜ?");
	Talk();

	chara = 1;
	enemy_face = 0;
	font.CreateList("私はいつも通り冬を運んだだけ。\n巫女が出てこないのが何よりの証拠よ");
	Talk();

	chara = 0;
	face = 1;
	font.CreateList("私は魔法使いだぜ、\n寒さをしのぐ魔法なんて夕飯前だ");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("あなた達人間は、少しばかり近視眼になっている。\n少しは妖怪を見習ったらどう?");
	Talk();

	chara = 0;
	face = 0;
	font.CreateList("妖怪は退治するものだぜ");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("妖怪は自然を司る……");
	Talk();

	chara = 1;
	enemy_face = 0;
	font.CreateList("自然に依存する人間は、\n自然のしっぺ返しを食らうことになる");
	Talk();

	chara = 2;
	enemy_face = 1;
	face = 1;
	font.CreateList("黒の魔法を食らわせてやろう、冬の妖怪");
	font2.CreateList("白き冬を味わわせてあげるわ、魔法使い");
	Talk();

	PlayBGM("tbm_lety");
	return 1;
}
Пример #26
0
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
    wxPaintDC dc( this );
    PrepareDC( dc );

    dc.DrawText( wxT("Loaded image"), 30, 10 );
    if (my_square.Ok())
        dc.DrawBitmap( my_square, 30, 30 );

    dc.DrawText( wxT("Drawn directly"), 150, 10 );
    dc.SetBrush( wxBrush( wxT("orange"), wxSOLID ) );
    dc.SetPen( *wxBLACK_PEN );
    dc.DrawRectangle( 150, 30, 100, 100 );
    dc.SetBrush( *wxWHITE_BRUSH );
    dc.DrawRectangle( 170, 50, 60, 60 );

    if (my_anti.Ok())
        dc.DrawBitmap( my_anti, 280, 30 );

    dc.DrawText( wxT("PNG handler"), 30, 135 );
    if (my_horse_png.Ok())
    {
        dc.DrawBitmap( my_horse_png, 30, 150 );
        wxRect rect(0,0,100,100);
        wxBitmap sub( my_horse_png.GetSubBitmap(rect) );
        dc.DrawText( wxT("GetSubBitmap()"), 280, 175 );
        dc.DrawBitmap( sub, 280, 195 );
    }

    dc.DrawText( wxT("JPEG handler"), 30, 365 );
    if (my_horse_jpeg.Ok())
        dc.DrawBitmap( my_horse_jpeg, 30, 380 );

    dc.DrawText( wxT("Green rotated to red"), 280, 365 );
    if (colorized_horse_jpeg.Ok())
        dc.DrawBitmap( colorized_horse_jpeg, 280, 380 );

    dc.DrawText( wxT("CMYK JPEG image"), 530, 365 );
    if (my_cmyk_jpeg.Ok())
        dc.DrawBitmap( my_cmyk_jpeg, 530, 380 );

    dc.DrawText( wxT("GIF handler"), 30, 595 );
    if (my_horse_gif.Ok())
        dc.DrawBitmap( my_horse_gif, 30, 610 );

    dc.DrawText( wxT("PCX handler"), 30, 825 );
    if (my_horse_pcx.Ok())
        dc.DrawBitmap( my_horse_pcx, 30, 840 );

    dc.DrawText( wxT("BMP handler"), 30, 1055 );
    if (my_horse_bmp.Ok())
        dc.DrawBitmap( my_horse_bmp, 30, 1070 );

    dc.DrawText( wxT("BMP read from memory"), 280, 1055 );
    if (my_horse_bmp2.Ok())
        dc.DrawBitmap( my_horse_bmp2, 280, 1070 );

    dc.DrawText( wxT("PNM handler"), 30, 1285 );
    if (my_horse_pnm.Ok())
        dc.DrawBitmap( my_horse_pnm, 30, 1300 );

    dc.DrawText( wxT("PNM handler (ascii grey)"), 280, 1285 );
    if (my_horse_asciigrey_pnm.Ok())
        dc.DrawBitmap( my_horse_asciigrey_pnm, 280, 1300 );

    dc.DrawText( wxT("PNM handler (raw grey)"), 530, 1285 );
    if (my_horse_rawgrey_pnm.Ok())
        dc.DrawBitmap( my_horse_rawgrey_pnm, 530, 1300 );

    dc.DrawText( wxT("TIFF handler"), 30, 1515 );
    if (my_horse_tiff.Ok())
        dc.DrawBitmap( my_horse_tiff, 30, 1530 );

    dc.DrawText( wxT("TGA handler"), 30, 1745 );
    if (my_horse_tga.Ok())
        dc.DrawBitmap( my_horse_tga, 30, 1760 );

    dc.DrawText( wxT("XPM handler"), 30, 1975 );
    if (my_horse_xpm.Ok())
        dc.DrawBitmap( my_horse_xpm, 30, 2000 );

    // toucans
    {
        int x = 750, y = 10, yy = 170;

        dc.DrawText(wxT("Original toucan"), x+50, y);
        dc.DrawBitmap(my_toucan, x, y+15, true);
        y += yy;
        dc.DrawText(wxT("Flipped horizontally"), x+50, y);
        dc.DrawBitmap(my_toucan_flipped_horiz, x, y+15, true);
        y += yy;
        dc.DrawText(wxT("Flipped vertically"), x+50, y);
        dc.DrawBitmap(my_toucan_flipped_vert, x, y+15, true);
        y += yy;
        dc.DrawText(wxT("Flipped both h&v"), x+50, y);
        dc.DrawBitmap(my_toucan_flipped_both, x, y+15, true);

        y += yy;
        dc.DrawText(wxT("In greyscale"), x+50, y);
        dc.DrawBitmap(my_toucan_grey, x, y+15, true);

        y += yy;
        dc.DrawText(wxT("Toucan's head"), x+50, y);
        dc.DrawBitmap(my_toucan_head, x, y+15, true);

        y += yy;
        dc.DrawText(wxT("Scaled with normal quality"), x+50, y);
        dc.DrawBitmap(my_toucan_scaled_normal, x, y+15, true);

        y += yy;
        dc.DrawText(wxT("Scaled with high quality"), x+50, y);
        dc.DrawBitmap(my_toucan_scaled_high, x, y+15, true);

        y += yy;
        dc.DrawText(wxT("Blured"), x+50, y);
        dc.DrawBitmap(my_toucan_blur, x, y+15, true);
    }

    if (my_smile_xbm.Ok())
    {
        int x = 300, y = 1800;

        dc.DrawText( wxT("XBM bitmap"), x, y );
        dc.DrawText( wxT("(green on red)"), x, y + 15 );
        dc.SetTextForeground( wxT("GREEN") );
        dc.SetTextBackground( wxT("RED") );
        dc.DrawBitmap( my_smile_xbm, x, y + 30 );

        dc.SetTextForeground( *wxBLACK );
        dc.DrawText( wxT("After wxImage conversion"), x + 120, y );
        dc.DrawText( wxT("(red on white)"), x + 120, y + 15 );
        dc.SetTextForeground( wxT("RED") );
        wxImage i = my_smile_xbm.ConvertToImage();
        i.SetMaskColour( 255, 255, 255 );
        i.Replace( 0, 0, 0,
            wxRED_PEN->GetColour().Red(),
            wxRED_PEN->GetColour().Green(),
            wxRED_PEN->GetColour().Blue() );
        dc.DrawBitmap( wxBitmap(i), x + 120, y + 30, true );
        dc.SetTextForeground( *wxBLACK );
    }


    wxBitmap mono( 60,50,1 );
    wxMemoryDC memdc;
    memdc.SelectObject( mono );
    memdc.SetPen( *wxBLACK_PEN );
    memdc.SetBrush( *wxWHITE_BRUSH );
    memdc.DrawRectangle( 0,0,60,50 );
    memdc.SetTextForeground( *wxBLACK );
#ifndef __WXGTK20__
    // I cannot convince GTK2 to draw into mono bitmaps
    memdc.DrawText( wxT("Hi!"), 5, 5 );
#endif
    memdc.SetBrush( *wxBLACK_BRUSH );
    memdc.DrawRectangle( 33,5,20,20 );
    memdc.SetPen( *wxRED_PEN );
    memdc.DrawLine( 5, 42, 50, 42 );
    memdc.SelectObject( wxNullBitmap );

    if (mono.Ok())
    {
        int x = 300, y = 1900;

        dc.DrawText( wxT("Mono bitmap"), x, y );
        dc.DrawText( wxT("(red on green)"), x, y + 15 );
        dc.SetTextForeground( wxT("RED") );
        dc.SetTextBackground( wxT("GREEN") );
        dc.DrawBitmap( mono, x, y + 30 );

        dc.SetTextForeground( *wxBLACK );
        dc.DrawText( wxT("After wxImage conversion"), x + 120, y );
        dc.DrawText( wxT("(red on white)"), x + 120, y + 15 );
        dc.SetTextForeground( wxT("RED") );
        wxImage i = mono.ConvertToImage();
        i.SetMaskColour( 255,255,255 );
        i.Replace( 0,0,0,
            wxRED_PEN->GetColour().Red(),
            wxRED_PEN->GetColour().Green(),
            wxRED_PEN->GetColour().Blue() );
        dc.DrawBitmap( wxBitmap(i), x + 120, y + 30, true );
        dc.SetTextForeground( *wxBLACK );
    }

    // For testing transparency
    dc.SetBrush( *wxRED_BRUSH );
    dc.DrawRectangle( 20, 2220, 560, 68 );

    dc.DrawText(wxT("XPM bitmap"), 30, 2230 );
    if ( m_bmpSmileXpm.Ok() )
        dc.DrawBitmap(m_bmpSmileXpm, 30, 2250, true);

    dc.DrawText(wxT("XPM icon"), 110, 2230 );
    if ( m_iconSmileXpm.Ok() )
        dc.DrawIcon(m_iconSmileXpm, 110, 2250);

    // testing icon -> bitmap conversion
    wxBitmap to_blit( m_iconSmileXpm );
    if (to_blit.Ok())
    {
        dc.DrawText( wxT("SubBitmap"), 170, 2230 );
        wxBitmap sub = to_blit.GetSubBitmap( wxRect(0,0,15,15) );
        if (sub.Ok())
            dc.DrawBitmap( sub, 170, 2250, true );

        dc.DrawText( wxT("Enlarged"), 250, 2230 );
        dc.SetUserScale( 1.5, 1.5 );
        dc.DrawBitmap( to_blit, (int)(250/1.5), (int)(2250/1.5), true );
        dc.SetUserScale( 2, 2 );
        dc.DrawBitmap( to_blit, (int)(300/2), (int)(2250/2), true );
        dc.SetUserScale( 1.0, 1.0 );

        dc.DrawText( wxT("Blit"), 400, 2230);
        wxMemoryDC blit_dc;
        blit_dc.SelectObject( to_blit );
        dc.Blit( 400, 2250, to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
        dc.SetUserScale( 1.5, 1.5 );
        dc.Blit( (int)(450/1.5), (int)(2250/1.5), to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
        dc.SetUserScale( 2, 2 );
        dc.Blit( (int)(500/2), (int)(2250/2), to_blit.GetWidth(), to_blit.GetHeight(), &blit_dc, 0, 0, wxCOPY, true );
        dc.SetUserScale( 1.0, 1.0 );
    }

    dc.DrawText( wxT("ICO handler (1st image)"), 30, 2290 );
    if (my_horse_ico32.Ok())
        dc.DrawBitmap( my_horse_ico32, 30, 2330, true );

    dc.DrawText( wxT("ICO handler (2nd image)"), 230, 2290 );
    if (my_horse_ico16.Ok())
        dc.DrawBitmap( my_horse_ico16, 230, 2330, true );

    dc.DrawText( wxT("ICO handler (best image)"), 430, 2290 );
    if (my_horse_ico.Ok())
        dc.DrawBitmap( my_horse_ico, 430, 2330, true );

    dc.DrawText( wxT("CUR handler"), 30, 2390 );
    if (my_horse_cur.Ok())
    {
        dc.DrawBitmap( my_horse_cur, 30, 2420, true );
        dc.SetPen (*wxRED_PEN);
        dc.DrawLine (xH-10,yH,xH+10,yH);
        dc.DrawLine (xH,yH-10,xH,yH+10);
    }

    dc.DrawText( wxT("ANI handler"), 230, 2390 );
    for ( int i=0; i < m_ani_images; i++ )
    {
        if (my_horse_ani[i].Ok())
        {
            dc.DrawBitmap( my_horse_ani[i], 230 + i * 2 * my_horse_ani[i].GetWidth() , 2420, true );
        }
    }
}
Пример #27
0
// Takes centroide values and deisotopes them 
void Deisotoper::go(
                    CentroidData& pCentroidData) // Data objects containing centroid values 
{
  int cnt,charge;
  double alpha;
  bool matched;
  list<CentroidPeak> centroidPeaks;
  list<CentroidPeak>::iterator start,end,pi;
  list<list<CentroidPeak>::iterator> matchedPeaks;
  
  pCentroidData.get(centroidPeaks);
  
  fMinPeakGroupSize = 2;
  
  if (CentroidData::sfMinIntensity<CentroidData::sfIntensityFloor) {
    pCentroidData.setNoise(30.0); // set noise level at 30 prcentile
    fTheta = pCentroidData.getNoise();
  } else {
    fTheta = CentroidData::sfMinIntensity;
  }
  
  pCentroidData.resetPeakGroupIter();
  while (pCentroidData.getNextPeakGroup(start,end)) { // isotopic patterns are withing the same peak group
    for (cnt=0,pi=start;pi!=end;++pi,++cnt);
    
    if (cnt>=fMinPeakGroupSize) { // Discard peak groups with only one peak
      for (pi=start;pi!=end;++pi,--cnt) {
        if (pi->getIntensity()<fTheta || cnt<fMinPeakGroupSize) continue; // skip small peaks

        if( CentroidData::MonoIsoDebugging ){
          if( ( CentroidData::DebugMonoIsoMassMin <= pi->getMass()) && ( CentroidData::DebugMonoIsoMassMax >= pi->getMass()) ){
            cout<<"To deisotope: "<<pi->getMass()<<" "<<pi->getIntensity()<<endl;
          }
        }
        
        for (charge=Deisotoper::sfMaxCharge;charge>=Deisotoper::sfMinCharge;--charge) {
                  
          matched = IsotopicDist::getMatchingPeaks(pi,end,charge,alpha,fTheta,matchedPeaks); // get peak that match isotopic pattern of charge
          if (matched && pi->getIntensity()>=fTheta) { // subtract isotopic match from peaks if match is significant
            
            if( CentroidData::MonoIsoDebugging ){
              if( ( CentroidData::DebugMonoIsoMassMin <= pi->getMass()) && ( CentroidData::DebugMonoIsoMassMax >= pi->getMass()) ){
                cout<<"matched to +"<<charge<<endl;
              }
            }
            
            DeconvPeak mono(pi->getMass(),0.0,charge,0,0.0,0.0);
            if( !pi->getExtraPeakInfo().empty() ){
              mono.setExtraPeakInfo(pi->getExtraPeakInfo());
            }
            
            if( CentroidData::MonoIsoDebugging ){
              if( ( CentroidData::DebugMonoIsoMassMin <= pi->getMass()) && ( CentroidData::DebugMonoIsoMassMax >= pi->getMass()) ){
                mono.show_info();
              }
            }
            
            
            IsotopicDist::subtractMatchingPeaks(matchedPeaks,charge,alpha,mono);
            fDeconvPeaks.push_back(mono);
                        
            if( CentroidData::MonoIsoDebugging ){
              if( ( CentroidData::DebugMonoIsoMassMin <= pi->getMass()) && ( CentroidData::DebugMonoIsoMassMax >= pi->getMass()) ){
                mono.show_info();
              }
            }
            
          }
          matchedPeaks.clear();
        }
      }
    }	
  }
}
Пример #28
0
void LogKlog::sniffTime(log_time& now, const char*& buf, ssize_t len,
                        bool reverse) {
    if (len <= 0) return;

    const char* cp = nullptr;
    if ((len > 10) && (*buf == '[')) {
        cp = now.strptime(buf, "[ %s.%q]");  // can index beyond buffer bounds
        if (cp && (cp > &buf[len - 1])) cp = nullptr;
    }
    if (cp) {
        len -= cp - buf;
        if ((len > 0) && isspace(*cp)) {
            ++cp;
            --len;
        }
        buf = cp;

        if (isMonotonic()) return;

        const char* b;
        if (((b = android::strnstr(cp, len, suspendStr))) &&
            (((b += strlen(suspendStr)) - cp) < len)) {
            len -= b - cp;
            calculateCorrection(now, b, len);
        } else if (((b = android::strnstr(cp, len, resumeStr))) &&
                   (((b += strlen(resumeStr)) - cp) < len)) {
            len -= b - cp;
            calculateCorrection(now, b, len);
        } else if (((b = android::strnstr(cp, len, healthdStr))) &&
                   (((b += strlen(healthdStr)) - cp) < len) &&
                   ((b = android::strnstr(b, len -= b - cp, batteryStr))) &&
                   (((b += strlen(batteryStr)) - cp) < len)) {
            // NB: healthd is roughly 150us late, so we use it instead to
            //     trigger a check for ntp-induced or hardware clock drift.
            log_time real(CLOCK_REALTIME);
            log_time mono(CLOCK_MONOTONIC);
            correction = (real < mono) ? log_time::EPOCH : (real - mono);
        } else if (((b = android::strnstr(cp, len, suspendedStr))) &&
                   (((b += strlen(suspendStr)) - cp) < len)) {
            len -= b - cp;
            log_time real;
            char* endp;
            real.tv_sec = strtol(b, &endp, 10);
            if ((*endp == '.') && ((endp - b) < len)) {
                unsigned long multiplier = NS_PER_SEC;
                real.tv_nsec = 0;
                len -= endp - b;
                while (--len && isdigit(*++endp) && (multiplier /= 10)) {
                    real.tv_nsec += (*endp - '0') * multiplier;
                }
                if (reverse) {
                    if (real > correction) {
                        correction = log_time::EPOCH;
                    } else {
                        correction -= real;
                    }
                } else {
                    correction += real;
                }
            }
        }

        convertMonotonicToReal(now);
    } else {
        if (isMonotonic()) {
            now = log_time(CLOCK_MONOTONIC);
        } else {
            now = log_time(CLOCK_REALTIME);
        }
    }
}
Пример #29
0
void LogKlog::sniffTime(log_time &now,
                        const char **buf, size_t len,
                        bool reverse) {
    const char *cp = now.strptime(*buf, "[ %s.%q]");
    if (cp && (cp >= &(*buf)[len])) {
        cp = NULL;
    }
    if (cp) {
        static const char healthd[] = "healthd";
        static const char battery[] = ": battery ";

        len -= cp - *buf;
        if (len && isspace(*cp)) {
            ++cp;
            --len;
        }
        *buf = cp;

        if (isMonotonic()) {
            return;
        }

        const char *b;
        if (((b = strnstr(cp, len, suspendStr)))
                && ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
            len -= b - cp;
            calculateCorrection(now, b, len);
        } else if (((b = strnstr(cp, len, resumeStr)))
                && ((size_t)((b += sizeof(resumeStr) - 1) - cp) < len)) {
            len -= b - cp;
            calculateCorrection(now, b, len);
        } else if (((b = strnstr(cp, len, healthd)))
                && ((size_t)((b += sizeof(healthd) - 1) - cp) < len)
                && ((b = strnstr(b, len -= b - cp, battery)))
                && ((size_t)((b += sizeof(battery) - 1) - cp) < len)) {
            // NB: healthd is roughly 150us late, so we use it instead to
            //     trigger a check for ntp-induced or hardware clock drift.
            log_time real(CLOCK_REALTIME);
            log_time mono(CLOCK_MONOTONIC);
            correction = (real < mono) ? log_time::EPOCH : (real - mono);
        } else if (((b = strnstr(cp, len, suspendedStr)))
                && ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
            len -= b - cp;
            log_time real;
            char *endp;
            real.tv_sec = strtol(b, &endp, 10);
            if ((*endp == '.') && ((size_t)(endp - b) < len)) {
                unsigned long multiplier = NS_PER_SEC;
                real.tv_nsec = 0;
                len -= endp - b;
                while (--len && isdigit(*++endp) && (multiplier /= 10)) {
                    real.tv_nsec += (*endp - '0') * multiplier;
                }
                if (reverse) {
                    if (real > correction) {
                        correction = log_time::EPOCH;
                    } else {
                        correction -= real;
                    }
                } else {
                    correction += real;
                }
            }
        }

        convertMonotonicToReal(now);
    } else {
        if (isMonotonic()) {
            now = log_time(CLOCK_MONOTONIC);
        } else {
            now = log_time(CLOCK_REALTIME);
        }
    }
}
Пример #30
0
int CTalkChirno2::Thread(){

	chara = 0;
	face = 3;
	enemy_face = -1;
	font.CreateList("む、誰だ!");
	Talk();

	for( int i = 0; i < 46; i++ ) {
		g_pBoss->Appear();
		SunEffectRect flame;
		flame.m_color = argb(127,0,0,0);
		SetRect(&flame.m_rect,GAME_LEFT+60,350,GAME_RIGHT-60,430);
		D3DCOLOR color = mono(128+127*(chara==0));
		int cx = - (chara != 0) * 20;
		int cy = (chara != 0) * 20;
		DrawMarisa(-200+cx,60+cy,face,manfu,color);
		flame.Draw();
		if( !GetInputState( INP_B6 ) )
			mt.Suspend();
	}

	chara = 1;
	enemy_face = 2;
	font.CreateList("さっき遭ったじゃない!");
	fntEnemy.CreateList("氷精 チルノ",16);
	Talk();

	chara = 0;
	face = 1;
	font.CreateList("そうだったか?");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("ふん、\nこの寒さで頭がおかしくなったんじゃない?");
	Talk();

	chara = 0;
	face = 0;
	font.CreateList("ところでこの寒さは……");
	Talk();

	chara = 1;
	enemy_face = 0;
	font.CreateList("ふっふっふ");
	Talk();

	chara = 0;
	face = 1;
	font.CreateList("お前以外の誰の仕業だ?");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("むっ");
	Talk();

	chara = 0;
	face = 2;
	font.CreateList("って、知らなさそうだな\nそもそもおまえは夏以外出没禁止なんだが");
	Talk();

	chara = 1;
	enemy_face = 2;
	font.CreateList("大ガマが冬眠している今こそ、\n私が活躍するチャンスなのよ!");
	Talk();

	chara = 0;
	face = 0;
	font.CreateList("まぁいいや。");
	Talk();
	face = 1;
	font.CreateList("3×3は?");
	Talk();

	chara = 1;
	enemy_face = 1;
	font.CreateList("�H!");
	Talk();

	StopBGM();
	PlayBGM("tbm_otenba");
	g_lEffect3.Add( new CEffectFont("♪バカとバカの境界",bgmFontColor,380,420) );

	return 1;
}