Example #1
0
void writeDeclareVariable (ListObject *oIter, FILE * outFile, Object * tree) {
            Object * rType = findByNameInScope(tree,oIter->value->returnType,false);
            //compilerDebugPrintf("writing variable %s\n",oIter->value->name);
            if (!getFlag(oIter->value,FLAG_NO_CODEGEN)) {
                if (getFlag(rType, FLAG_PRIMITIVE)) {
                    if (oIter->value->genericType) {
                        Object * gType = findByNameInScope(tree,oIter->value->genericType,false);
                        if (getFlag(gType,FLAG_PRIMITIVE)) {
                            fprintf(outFile, "\t_$_%s_type_1(%s)  %s;\n", oIter->value->returnType, oIter->value->genericType,
                                    oIter->value->fullname);
                        } else {
                            fprintf(outFile, "\t_$_%s_type_0(" IDENT_MPTR ")  %s;\n", oIter->value->returnType,
                                    oIter->value->fullname);
                        }
                    } else {
                        fprintf(outFile, "\t%s %s;\n", oIter->value->returnType,
                                oIter->value->fullname);
                    }
                } else {
                    if (!strcmp(oIter->value->returnType, IDENT_MPTR)) {
                        fprintf(outFile, "\t_$_TEMP_OBJ(%s);\n", oIter->value->fullname);
                    } else if (!strcmp(oIter->value->returnType, IDENT_HEAP_MPTR)) {
                        fprintf(outFile, "\t_$_HEAP_VARIABLE(%s);\n", oIter->value->fullname);
                    }
                    else {
                        fprintf(outFile, "\t_$_VARIABLE(%s);\n", oIter->value->fullname);
                    }

                }
            }
}
Example #2
0
int multiply(int a,int b)
{
    int r=multiplyABS(abs(a),abs(b));
    if(getFlag(a)==getFlag(b))
        return r;
    return getNegative(r);
}
Example #3
0
/* see spec table 21 */
void s1(MsgHeader *header, MsgSync *sync, PtpClock *ptpClock)
{
  /* Current data set */
  ptpClock->steps_removed = sync->localStepsRemoved + 1;
  
  /* Parent data set */
  ptpClock->parent_communication_technology = header->sourceCommunicationTechnology;
  memcpy(ptpClock->parent_uuid,  header->sourceUuid, PTP_UUID_LENGTH);
  ptpClock->parent_port_id = header->sourcePortId;
  ptpClock->parent_last_sync_sequence_number = header->sequenceId;
  ptpClock->parent_followup_capable  = getFlag(header->flags, PTP_ASSIST);
  ptpClock->parent_external_timing = getFlag(header->flags, PTP_EXT_SYNC);
  ptpClock->parent_variance = sync->localClockVariance;
  ptpClock->grandmaster_communication_technology = sync->grandmasterCommunicationTechnology;
  memcpy(ptpClock->grandmaster_uuid_field, sync->grandmasterClockUuid, PTP_UUID_LENGTH);
  ptpClock->grandmaster_port_id_field = sync->grandmasterPortId;
  ptpClock->grandmaster_stratum = sync->grandmasterClockStratum;
  memcpy(ptpClock->grandmaster_identifier, sync->grandmasterClockIdentifier, PTP_CODE_STRING_LENGTH); 
  ptpClock->grandmaster_variance = sync->grandmasterClockVariance;
  ptpClock->grandmaster_preferred = sync->grandmasterPreferred;
  ptpClock->grandmaster_is_boundary_clock = sync->grandmasterIsBoundaryClock;
  ptpClock->grandmaster_sequence_number = sync->grandmasterSequenceId;
  
  /* Global time properties data set */
  ptpClock->current_utc_offset = sync->currentUTCOffset;
  ptpClock->leap_59 =  getFlag(header->flags, PTP_LI_59);
  ptpClock->leap_61 =  getFlag(header->flags, PTP_LI_61);
  ptpClock->epoch_number = sync->epochNumber;  
}
Example #4
0
//Add with carry
void adc(CPU *c, OP_CODE_INFO *o){
    int8_t carry = getFlag(c,C);
    int8_t accum = getRegByte(c,ACCUM);
    int8_t operand = o->operand;
    int16_t sum = (0x00FF&carry) + (0x00FF&accum) + (0x00FF&operand);
    int8_t sumByte = sum & 0x00FF;
    setZero(c,sumByte);
    if(getFlag(c,D)){ //in decimal mode
        //if lower 4 bits of operands plus
        //the carry in are larger than 9,
        //then we need to apply conversions
        //to remain in binary coded decimal format.
        if((accum & 0xF) + (operand & 0xF)
            + carry > 9){
            sum += 6;
        }
        setSign(c,sum&0xFF);
        setOverflow(c,accum,operand,sum&0xFF);
        //if the higher bits aren't in
        //BCD format we need to add 96 to convert.
        //Black magic from http://nesdev.com/6502.txt
        sum += sum > 0x99 ? 96 : 0;
        setCarryBCD(c, sum);
    } else {
        setSign(c,sumByte);
        setOverflow(c,accum,operand,sumByte);
        setCarry(c,sum);
    }
    setRegByte(c,ACCUM,sum&0xFF);
}
// *************************************************************************************************
// @fn          simpliciti_main_tx_only
// @brief       Get data through callback. Transfer data when external trigger is set.
// @param       none
// @return      none
// *************************************************************************************************
void simpliciti_main_tx_only(void)
{
    while (1)
    {
        // Get end device data from callback function
        simpliciti_get_ed_data_callback();

        // Send data when flag bit SIMPLICITI_TRIGGER_SEND_DATA is set
        if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA))
        {
            // Get radio ready. Wakes up in IDLE state.
            SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);

            // Acceleration / button events packets are 4 bytes long
            SMPL_SendOpt(sLinkID1, simpliciti_data, 4, SMPL_TXOPTION_NONE);

            // Put radio back to SLEEP state
            SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);

            clearFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA);
        }

        // Exit when flag bit SIMPLICITI_TRIGGER_STOP is set
        if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_STOP))
        {
            // Clean up SimpliciTI stack to enable restarting
            sInit_done = 0;
            break;
        }
    }
}
Example #6
0
long Light::update (void) {

	if (!getFlag(OBJECT_FLAG_DONE)) {
		//----------------------------------
		//-- Always force position altitude 'cause set every frame.
		position.z += ((LightTypePtr)getObjectType())->altitudeOffset;
		setPosition(position);
	
		if (getFlag(OBJECT_FLAG_JUSTCREATED)) {
			setFlag(OBJECT_FLAG_JUSTCREATED, false);
			setFlag(OBJECT_FLAG_TANGIBLE, false);
		}
	
#ifdef USE_LIGHT_APPEARANCE
		//-----------------------------------------
		// Light is NEVER Done.  Unless its done!
		bool inView = onScreen();
		lightAppearance->setInView(inView);
		long result = lightAppearance->update();
		if (!result && ((LightTypePtr)getObjectType())->oneShotFlag)
			setFlag(OBJECT_FLAG_DONE, true);
#endif
	}

	return (true);
}
Example #7
0
void writeTreeHelper(FILE * outc, FILE * outh, Object * tree, int indent)
{

    ListObject *oIter;
    ListString *sIter;

    if (tree == 0) {
        warningMsg("tree was null in writeTree. (ObjectTree.c)\n");
        return;
    }

    if (outc == 0 || outh == 0) {
        warningMsg("output file was null in writeTree. (ObjectTree.c)\n");
        return;
    }

    oIter = tree->definedSymbols;
    sIter = tree->paramTypes;

    //construct and print function header
    if (isVerb(tree) && !getFlag(tree, FLAG_EXTERNAL)) {
        compilerDebugPrintf("Writing function %s\n",tree->fullname);
        writeFunction(outh, tree, indent, false);
    } else if (tree->category == Type && !getFlag(tree, FLAG_EXTERNAL)) {
        writeClass(outc, outh, tree, indent);
    } else if (tree->category == Dummy) {
        //Dummy
    } else {
        writeOther(outc, outh, tree, indent);
    }

}
Example #8
0
void CTLCheck::check(Vars &v, Model &m, Formula &f, BitStore *bs,
										 bool printFormulas, bool showProgress)
{
#undef pt
#define pt(a) //pr(a)

	f_ = f;
	model_ = &m;
	vars_ = &v;

	sfAlias_.clear();
	stateFlags_.clear();
	sfOrder_.clear();
	pvWarn_.clear();

	showProgress_ = showProgress;

	if (bs)
		bs->clear();

	ASSERT(f_.isCTL());

	prepareModel();
	if (model().defined()) {

		// reduce formula to minimal set of connectives
		f_.reduce();
		pt(("CTLCheck, checking formula\n    %s\n==> %s\n",f.s(),f_.s()));
		extractSubformulas();

		for (int i = 0; i < sfOrder_.length(); i++)
			processFormula(sfOrder_[i]);

		if (printFormulas) {
			for (int i = 0; i < model().states(); i++) {
				int name = model().stateName(i);
				Cout << "State #" << name << ":\n";
				for (int j = 0; j < sfOrder_.length(); j++) {
					int form = sfOrder_[j];
					if (getFlag(i,form)) {
						Cout << "  ";
						f_.print(form,false);
						Cout << "\n";
					}
				}
				Cout << "\n";
			}
		}

		if (bs) {
			int satFormula = sfOrder_.last();

			for (int i = 0; i < model().states(); i++)
				if (getFlag(i,satFormula))
					bs->set(i);
			pt((" satisfying states: %s\n",bs->s() ));
		}
	}
}
void LeprechaunController::update(const GameTime& gameTime)
{
	LuckyLeprechauns& game = (LuckyLeprechauns&)getManager();
	beginFlags.reset();

	setFlag(LeprechaunFlag::throwPig, false);
	setFlag(LeprechaunFlag::pigRobbery, false);
	setFlag(LeprechaunFlag::explosionTrap, false);
	usedItem = false;
	collectedItem = false;

	for (unsigned i = 0; i < TimerType::count; ++i)
		timerFinished[i] = timers[i] > 0 && (timers[i] -= gameTime.elapsed) <= 0;

	if (timerFinished[TimerType::caneHit])
		setFlag(LeprechaunFlag::caneHit, false);

	if (timerFinished[TimerType::stoneHit])
		setFlag(LeprechaunFlag::stoneHit, false);

	if (timerFinished[TimerType::attackDouble])
		setFlag(LeprechaunFlag::attackDouble, false);

	if (timerFinished[TimerType::invisibility])
		setFlag(LeprechaunFlag::invisibility, false);

	if (timerFinished[TimerType::invulnerability])
		setFlag(LeprechaunFlag::invulnerability, false);

	if (timerFinished[TimerType::showInvisibility])
		setFlag(LeprechaunFlag::showInvisibility, false);

	if (timerFinished[TimerType::speedBoost])
		setFlag(LeprechaunFlag::speedBoost, false);

	if (timerFinished[TimerType::kick])
		setBeginFlag(LeprechaunFlag::kick, true);

	Matrix rotation = Matrix::createFromQuaternion(getRotation());

	if (timerFinished[TimerType::cane])
	{
		setBeginFlag(LeprechaunFlag::cane, true);

		cane->setPosition(Vector3::transform(cane->getStartOffset(), rotation) + getPosition());
		cane->setRotation(cane->getStartRotation() * getRotation());
	}

	if (timerFinished[TimerType::hat])
	{
		setBeginFlag(LeprechaunFlag::hat, true);

		hat->setPosition(Vector3::transform(hat->getStartOffset(), rotation) + getPosition());
		hat->setRotation(hat->getStartRotation() * getRotation());
	}

	hat->setEnabled(getFlag(LeprechaunFlag::hat));
	cane->setEnabled(getFlag(LeprechaunFlag::cane));
}
Example #10
0
int divide(int a,int b)
{
    if(b==0)
        throw "error";
    int r=divideABS(abs(a),abs(b));
    if(getFlag(a)==getFlag(b))
        return r;
    return getNegative(r);
}
Example #11
0
void
GlWindow::setFlag (int flag, bool enable)
{
	if (enable)
		d_flags |= flag;	// set flag
	else
		d_flags &= ~flag;	// clear flag

	md2_setStyle ((int) getFlag (F_GLCOMMANDS), (int) getFlag (F_INTERPOLATE));
}
Example #12
0
void Light::render (void) {

	if (g_gamePaused)
		onScreen();

	if (!getFlag(OBJECT_FLAG_JUSTCREATED) && (windowsVisible == turn) && !getFlag(OBJECT_FLAG_DONE)) {
#ifdef USE_LIGHT_APPEARANCE
		lightAppearance->render(LIGHT_DEPTH_FIXUP);
#endif
	}
}
Example #13
0
static char * EOR3() {
    CPU *c = getCPU();
    c->PC = 0xCFEE;
    setRegByte(c,ACCUM,0x8A);
    OP_CODE_INFO *o = getOP_CODE_INFO(0x92,0,modeImmediate);
    eor(c,o);
    mu_assert("EOR2 err, ACCUM != 0x18", (0xFF & getRegByte(c,ACCUM)) == 0x18);
    mu_assert("EOR2 err, SIGN != 0", getFlag(c, S) == 0);
    mu_assert("EOR2 err, ZERO != 0", getFlag(c, Z) == 0);
    freeOP_CODE_INFO(o);
    free(c);
    return 0;
}
Example #14
0
void s1(MsgHeader *header,   // Pointer to unpacked PTP version 1 header
        MsgSync   *sync,     // Pointer to unpacked PTP version 1 sync message data
        PtpClock  *ptpClock  // Pointer to main PTP data structure
       )
{
  DBGV("s1:\n");
  /* Current data set */
  ptpClock->steps_removed                    = sync->localStepsRemoved + 1;
  
  /* Parent data set */
  ptpClock->parent_communication_technology  = header->sourceCommunicationTechnology;
  memcpy(ptpClock->parent_uuid,
         header->sourceUuid,
         PTP_UUID_LENGTH
        );
  ptpClock->parent_port_id                   = header->sourcePortId;
  ptpClock->parent_last_sync_sequence_number = header->sequenceId;
  ptpClock->parent_followup_capable          = getFlag(header->flags, PTP_ASSIST);
  ptpClock->parent_external_timing           = getFlag(header->flags, PTP_EXT_SYNC);
  ptpClock->parent_v1_variance               = sync->localClockVariance;
  ptpClock->grandmaster_communication_technology = sync->grandmasterCommunicationTechnology;
  memcpy(ptpClock->grandmaster_uuid_field,
         sync->grandmasterClockUuid,
         PTP_UUID_LENGTH
        );
  ptpClock->grandmaster_port_id_field        = sync->grandmasterPortId;
  ptpClock->grandmaster_stratum              = sync->grandmasterClockStratum;
  memcpy(ptpClock->grandmaster_identifier,
         sync->grandmasterClockIdentifier,
         PTP_CODE_STRING_LENGTH
        ); 
  ptpClock->grandmaster_v1_variance          = sync->grandmasterClockVariance;
  ptpClock->grandmaster_preferred            = sync->grandmasterPreferred;
  ptpClock->grandmaster_is_boundary_clock    = sync->grandmasterIsBoundaryClock;
  ptpClock->grandmaster_sequence_number      = sync->grandmasterSequenceId;
  
  /* Global time properties data set */

  ptpClock->current_utc_offset               = sync->currentUTCOffset;
  ptpClock->leap_59                          = getFlag(header->flags, PTP_LI_59);
  ptpClock->leap_61                          = getFlag(header->flags, PTP_LI_61);
  ptpClock->epoch_number                     = sync->epochNumber;  

#ifdef PTPD_DBG
/* AKB: Debug Function to dump PTP V2 header and first timestamp from
 * raw buffer
 */
 /* debug_dump_data_set_info(ptpClock); */
#endif

}
Example #15
0
void AgiEngine::interpretCycle() {
	ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY];
	bool oldSound;
	byte oldScore;

	if (!_game.playerControl)
		setVar(VM_VAR_EGO_DIRECTION, screenObjEgo->direction);
	else
		screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION);

	checkAllMotions();

	oldScore = getVar(VM_VAR_SCORE);
	oldSound = getFlag(VM_FLAG_SOUND_ON);

	// Reset script heuristic here
	resetGetVarSecondsHeuristic();

	_game.exitAllLogics = false;
	while (runLogic(0) == 0 && !(shouldQuit() || _restartGame)) {
		setVar(VM_VAR_WORD_NOT_FOUND, 0);
		setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0);
		setVar(VM_VAR_BORDER_CODE, 0);
		oldScore = getVar(VM_VAR_SCORE);
		setFlag(VM_FLAG_ENTERED_CLI, false);
		_game.exitAllLogics = false;
		artificialDelay_CycleDone();
		resetControllers();
	}
	artificialDelay_CycleDone();
	resetControllers();

	screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION);

	if (getVar(VM_VAR_SCORE) != oldScore || getFlag(VM_FLAG_SOUND_ON) != oldSound)
		_game._vm->_text->statusDraw();

	setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0);
	setVar(VM_VAR_BORDER_CODE, 0);
	setFlag(VM_FLAG_NEW_ROOM_EXEC, false);
	setFlag(VM_FLAG_RESTART_GAME, false);
	setFlag(VM_FLAG_RESTORE_JUST_RAN, false);

	if (_game.gfxMode) {
		updateScreenObjTable();
	}
	_gfx->updateScreen();
	//_gfx->doUpdate();
}
Example #16
0
void writeDeclareClassVariable (ListObject *oIter, FILE * outFile, Object * tree) {
    Object * rType = findByNameInScope(tree,oIter->value->returnType,false);
    if (!getFlag(oIter->value,FLAG_NO_CODEGEN)) {
        if (getFlag(rType, FLAG_PRIMITIVE)) {
            fprintf(outFile, "\t%s %s;\n", oIter->value->returnType,
                    oIter->value->fullname);
        } else {
            if (strcmp(oIter->value->fullname, IDENT_SUPER "_")) {
                fprintf(outFile, "\t" IDENT_MPTR "* %s;\n", oIter->value->fullname);
            } else {
                fprintf(outFile, "\t%s * %s;\n", oIter->value->returnType, oIter->value->fullname);
            }
        }
    }
}
Example #17
0
bool MgEllipse::_setHandlePoint(int index, const Point2d& pt, float tol)
{
    int index2 = getFlag(kMgSquare) ? index + 4 : index;
    return (index < _getHandleCount() - 1
            ? MgBaseRect::_setHandlePoint(index2, pt, tol)
            : offset(pt - getCenter(), -1));
}
Example #18
0
//------------------------------------------------------------------------------
void Entity::setUpdatable(bool updatable, const std::string layerName)
{
	// TODO FIXME Set the flag!!
    if (getFlag(SN_EF_UPDATABLE) ^ updatable)
    {
        Scene * scene = getScene();
        if (scene)
        {
			setFlag(SN_EF_UPDATABLE, updatable);
            UpdateManager & manager = scene->getUpdateManager();
            if (updatable)
            {
                manager.addEntity(*this, layerName.empty() ? UpdateManager::DEFAULT_LAYER : layerName);
            }
            else
            {
                manager.removeEntity(*this, layerName);
            }
        }
        else
        {
            SN_ERROR("Entity::setUpdatable: scene not found from entity " << toString());
        }
    }
    else
    {
        SN_WARNING("Entity::setUpdatable: no change made (entity " << toString() << ")");
    }
}
Example #19
0
//------------------------------------------------------------------------------
Entity::~Entity()
{
    if (r_parent)
        r_parent->removeChild(this);
    destroyChildren();

    removeAllTags();

	// Unregister update callback
    if (getFlag(SN_EF_UPDATABLE))
    	setUpdatable(false);
    if (getFlag(SN_EF_SYSTEM_EVENT_LISTENER))
        listenToSystemEvents(false);

    //SN_LOG("Entity " << getName() << " destroyed");
}
Example #20
0
File: Flag.cpp Project: kniz/World
	bool NE_DLL NEDebugManager::Flag::operator==(const Flag& source) const
	{
		if(this == &source) return true;
		if(getFlag() != source.getFlag()) return false;

		return true;
	}
void SocketClient::requestRoutine(FdTimer *timer)
{
	sleep(5);
	while ( getFlag() )
	{
		timer->waitTimerEvent();

		//logger->info( "[INFO] CLIENT Ready to Send");

		memset(sendBuff, '\0', sizeof(sendBuff));
		//REQUEST RQ# DATE TIME MINIMUM LIST OF PARTICIPANTS TOPIC|Room|
		//REQUEST|%d-%d|2015-11-12|20:00|2|127.0.0.1,192.168.0.1|COEN 456|H-634|

		header = REQUEST;
		//sprintf (sendBuff,"%d|%d|2015-11-12|20:00|2|127.0.0.1,192.168.10.51,192.168.10.52,192.168.10.53,192.168.10.54,192.168.10.55|COEN 456|H-634|", header, ++req_id );

		sprintf (sendBuff,"%d|%d|2015-12-14|20:00|1|127.0.0.1,192.168.10.55,|COEN 456|H-634|", header, ++req_id );


		//DEBUG TO DELETE
		//char tempBuff[sizeof(sendBuff)];
		//sprintf (tempBuff,"DEBUG::Client Sent Buffer Size:%d with buffer:%s", sizeof(sendBuff), sendBuff);
		//printf("Client Sent Buffer Size:%ld with buffer:%s\n",sizeof(sendBuff),sendBuff);
		//logger->info(tempBuff);
		//printf("Client Sent packet to %s:%d\n", inet_ntoa(server_addr.sin_addr), ntohs(server_addr.sin_port));

		//TEST print size
		//std::string test(sendBuff);
		//printf("%lu\n",test.size() );

		sendMsg(sendBuff);
		//sleep(30);

	}
}
Example #22
0
	virtual void main()
	{
		//init
		QString psname = getString("psname");
		if (psname=="") psname = getInfile("in");

		//load
		VariantList variants;
		variants.load(getInfile("in"));

		//annotate
		bool test = getFlag("test");
		QString mode = getEnum("mode");
		if(mode=="germline")
		{
			NGSD(test).annotate(variants, psname);
		}
		else if(mode=="somatic")
		{
			NGSD(test).annotateSomatic(variants, psname);
		}

		//store
		variants.store(getOutfile("out"));
	}
Example #23
0
void MgBaseRect::setRectWithAngle(const Point2d& pt1, const Point2d& pt2,
                                  float angle, const Point2d& basept)
{
    Box2d rect(pt1, pt2);
    
    if (getFlag(kMgSquare)) {
        if (basept == pt1 && isCurve()) {
            rect.set(basept, 2 * basept.distanceTo(pt2), 0);
        }
        else {
            float len = mgMax(fabsf(pt2.x - pt1.x), fabsf(pt2.y - pt1.y));
            if (basept == pt1 && !isCurve()) {
                rect.set(pt1, pt1 + Point2d(pt2.x > pt1.x ? len : -len,
                                            pt2.y > pt1.y ? len : -len));
            } else {
                rect.set(basept, basept == pt1 ? 2 * len : len, 0);
            }
        }
    }
    
    _points[0] = rect.leftTop();
    _points[1] = rect.rightTop();
    _points[2] = rect.rightBottom();
    _points[3] = rect.leftBottom();

    if (!mgIsZero(angle))
    {
        Matrix2d mat(Matrix2d::rotation(angle, basept));
        for (int i = 0; i < 4; i++)
            _points[i] *= mat;
    }
}
int SpdyStream::writev(IOVec &vector, int total)
{
    int size;
    int ret;
    if (getState() == HIOS_DISCONNECTED)
        return LS_FAIL;
    if (getFlag(HIO_FLAG_BUFF_FULL))
        return 0;
    size = getDataFrameSize(total);
    if (size <= 0)
        return 0;
    if (size < total)
    {
        //adjust vector
        IOVec iov(vector);
        total = iov.shrinkTo(size, 0);
        ret = sendData(&iov, size);
    }
    else
        ret = sendData(&vector, size);
    if (ret == -1)
        return LS_FAIL;
    return size;

}
Example #25
0
      ScopedTemporaryFlagsChanger(Flags toFlags) {
        count_ = new int[MAXNUM];
        if (! count_) return;

        for (int i = 0;; ++i) {
          count_[i] = 0;

          ModifierFlag flag = getFlag(i);
          if (flag == ModifierFlag::NONE) break;

          // ----------------------------------------
          // reset flag
          while (! makeFlags().isOn(flag)) {
            temporary_increase(flag);
            ++count_[i];
          }
          while (makeFlags().isOn(flag)) {
            temporary_decrease(flag);
            --count_[i];
          }

          // ----------------------------------------
          // set a flag
          if (toFlags.isOn(flag)) {
            temporary_increase(flag);
            ++count_[i];
          }
        }
      }
Example #26
0
uint16 CMobSkill::getMsgForAction()
{
    uint16 id = getID();
    uint16 messageid = 256 + id;
    uint8 flag = getFlag();
    if (flag == SKILLFLAG_WS)
    {
        switch (id)
        {
        case 190:  //dimensional death
            messageid = 255;
            break;
        case 246:  //shackled fists
        case 247:  //foxfire
        case 248:  //grim halo
        case 249:  //netherspikes
        case 250:  //carnal nightmare
            messageid = id;
            break;
        case 251:  //dancing chains
        case 252:  //barbed crescent
            messageid = id+1;
            break;
        case 253:  //aegis schism
            messageid = 251;
            break;
        default:
            break;
        }
    }
    return messageid;
}
Example #27
0
void SdlEngine::endRenderFrame()
{
  if( getFlag( Engine::debugInfo ) )
  {
    std::string debugText = StringHelper::format( 0xff, "fps:%d call:%d", _d->lastFps, _d->drawCall );
    _d->fpsText->fill( 0, Rect() );
    _d->debugFont.draw( *_d->fpsText, debugText, Point( 0, 0 ) );
    draw( *_d->fpsText, Point( _d->screen.width() / 2, 2 ) );
  }

  //Refresh the screen
  //SDL_SetRenderTarget( _d->renderer, NULL );

  //SDL_RenderCopyEx(_d->renderer, _d->screen.texture(), 0, 0, 0, 0, SDL_FLIP_HORIZONTAL );
  SDL_RenderPresent(_d->renderer);

  _d->fps++;

  if( DateTime::elapsedTime() - _d->lastUpdateFps > 1000 )
  {
    _d->lastUpdateFps = DateTime::elapsedTime();
    _d->lastFps = _d->fps;
    _d->fps = 0;
  }

  _d->drawCall = 0;

  //Logger::warning( "dt=%d  dtb=%d", drawTime, drawTimeBatch );
}
Example #28
0
	virtual void main()
	{
		//init
		StatisticsReads stats;
		FastqEntry entry;
		QStringList infiles;
		QStringList in1 = getInfileList("in1");
		QStringList in2 = getInfileList("in2");
		if (in2.count()!=0 && in1.count()!=in2.count())
		{
			THROW(CommandLineParsingException, "Input file lists 'in1' and 'in2' differ in counts!");
		}

		//process
		for (int i=0; i<in1.count(); ++i)
		{
			//forward
			FastqFileStream stream(in1[i]);
			while(!stream.atEnd())
			{
				stream.readEntry(entry);
				stats.update(entry, StatisticsReads::FORWARD);
			}
			infiles << in1[i];

			//reverse (optional)
			if (i<in2.count())
			{
				FastqFileStream stream2(in2[i]);
				while(!stream2.atEnd())
				{
					 stream2.readEntry(entry);
					 stats.update(entry, StatisticsReads::REVERSE);
				}

				//check read counts matches
				if (stream.index()!=stream2.index())
				{
					THROW(ArgumentException, "Differing number of reads in file '" + in1[i] + "' and '" + in2[i] + "'!");
				}

				infiles << in2[i];
			}
		}

		//store output
		QCCollection metrics = stats.getResult();
		if (getFlag("txt"))
		{
			QStringList output;
			metrics.appendToStringList(output);
			Helper::storeTextFile(Helper::openFileForWriting(getOutfile("out"), true), output);
		}
		else
		{
			metrics.storeToQCML(getOutfile("out"), infiles, "");
		}
	}
Example #29
0
	virtual void main()
	{
		//init
		bool v = getFlag("v");

		//load ids and lengths
		QHash<QByteArray, int> ids;
		QSharedPointer<QFile> file = Helper::openFileForReading(getInfile("ids"));
		while (!file->atEnd())
		{
			QByteArray line = file->readLine().trimmed();
			if (line.isEmpty() || line[0]=='#') continue;
			QList<QByteArray> parts = line.split('\t');
			int length = -1;
			if (parts.count()>1)
			{
				length = Helper::toInt(parts[1], "length value");
			}
			ids.insert(parts[0], length);
		}

		//open output stream
		FastqOutfileStream outfile(getOutfile("out"), false);

		//parse input and write output
		FastqFileStream stream(getInfile("in"));
		FastqEntry entry;
		while (!stream.atEnd())
		{
			stream.readEntry(entry);

			QByteArray id = entry.header.trimmed();
			id = id.mid(1);
			int comment_start = id.indexOf(' ');
			if (comment_start!=-1) id = id.left(comment_start);
			int length = ids.value(id, -2);
			if (length==-2) //id not in list
			{
				if (!v) continue;

				outfile.write(entry);
			}
			else if (length==-1) //id is in list, but no length given
			{
				if (v) continue;

				outfile.write(entry);
			}
			else if (length>=1) //id is in list and length given
			{
				if (v) continue;

				entry.bases.resize(length);
				entry.qualities.resize(length);
				outfile.write(entry);
			}
		}
	}
Example #30
0
static char * SEC1() {
    CPU *c = getCPU();
    OP_CODE_INFO *o = getOP_CODE_INFO(0,0,modeImmediate);
    sec(c,o);
    mu_assert("SEC1 err, Carry flag != 1", getFlag(c,C) == 1);
    freeOP_CODE_INFO(o);
    free(c);
    return 0;
}