コード例 #1
0
ファイル: RingOfTrials.cpp プロジェクト: lev1976g/NoxicCore
bool RingOfTrials::HookHandleRepop(Player* plr)
{
	LocationVector dest;
	dest.ChangeCoords(4057.042725f, 2918.686523f, 13.051933f);
	plr->SafeTeleport(m_mapMgr->GetMapId(), m_mapMgr->GetInstanceID(), dest);
	return true;
}
コード例 #2
0
ファイル: MiscSpells.cpp プロジェクト: Antares84/arcemu
// 54640
bool SOTATeleporter( uint32 i, Spell *s ){
	Player *plr = s->GetPlayerTarget();
	if( plr == NULL )
		return true;

	LocationVector dest;
	uint32 closest_platform = 0;
	
	for(uint32 i = 0; i < 5; i++){
		float distance = plr->GetDistanceSq( sotaTransporterDestination[i][0], sotaTransporterDestination[i][1], sotaTransporterDestination[i][2]);
		
		if(distance < 75){
			closest_platform = i;
			break;
		}
	}
	
	dest.ChangeCoords(sotaTransporterDestination[closest_platform][0],
                      sotaTransporterDestination[closest_platform][1],
					  sotaTransporterDestination[closest_platform][2],
					  sotaTransporterDestination[closest_platform][3]);
	
	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
	return true;
}
コード例 #3
0
ファイル: EyeOfTheStorm.cpp プロジェクト: AegisEmu/AegisEmu
bool EyeOfTheStorm::HookHandleRepop(Player * plr)
{
	uint32 i;
	int32 sval;
	uint32 t = plr->GetTeam();
	float dist = 999999.0f;
	float distcur;
	LocationVector dest;

	if(plr->GetTeam() == 0)
		sval = 100;
	else
		sval = 0;

	dest.ChangeCoords( EOTSStartLocations[t][0], EOTSStartLocations[t][1], EOTSStartLocations[t][2], 0 );

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		if( m_CPStatus[i] == sval )
		{
			distcur = plr->GetPositionNC().Distance2DSq( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1] );
			if( distcur < dist )
			{
				dist = distcur;
				dest.ChangeCoords( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0 );
			}
		}
	}

	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
	return true;
}
コード例 #4
0
void StrandOfTheAncient::OnPlatformTeleport(Player *plr)
{
	LocationVector dest;
	uint32 closest_platform = 0;

	for (uint32 i = 0; i < GATE_COUNT; i++)
	{
		float distance = CalculateDistance(plr->GetPositionX(),
			plr->GetPositionY(), plr->GetPositionZ(),
			sotaTransporterDestination[i][0],
			sotaTransporterDestination[i][1],
			sotaTransporterDestination[i][2]);
		if (distance < 75)
		{
			closest_platform = i;
			break;
		}
	}
	dest.ChangeCoords(sotaTransporterDestination[closest_platform][0],
		sotaTransporterDestination[closest_platform][1],
		sotaTransporterDestination[closest_platform][2],
		sotaTransporterDestination[closest_platform][3]);

	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
}
コード例 #5
0
void StrandOfTheAncient::OnStart()
{
	sLog.outDebug("OnStart: SOTA Battleground\n");

	LocationVector dest;
	m_started = true;

	for(list<Player*>::iterator itr = sota_players.begin(); itr != sota_players.end(); ++itr)
	{
		Player *plr = *itr;
		dest.ChangeCoords(sotaStopBoatsPlayer[plr->GetTeam()][0], sotaStopBoatsPlayer[plr->GetTeam()][1],
			sotaStopBoatsPlayer[plr->GetTeam()][2], sotaStopBoatsPlayer[plr->GetTeam()][3]);

		plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
	}

	SetWorldState(WORLDSTATE_SOTA_CAPTURE_BAR_DISPLAY, (uint32)-1);
	SetWorldState(WORLDSTATE_SOTA_CAPTURE_BAR_VALUE, (uint32)-1);
	SetWorldState(WORLDSTATE_SOTA_BONUS_TIME, 1);
	SetWorldState(WORLDSTATE_SOTA_TIMER_1, 10); // 10 Minute Timer

	//SetTime(ROUND_LENGTH, 0);
	sEventMgr.AddEvent( this, &StrandOfTheAncient::TimeTick, EVENT_SOTA_TIMER, MSTIME_SECOND * 5, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT );

	UpdatePvPData();
}
コード例 #6
0
ファイル: EyeOfTheStorm.cpp プロジェクト: WowDevs/Sandshroud
bool EyeOfTheStorm::HookHandleRepop(Player* plr)
{
    uint32 i;
    uint32 t = plr->GetTeam();
    float dist = 999999.0f;
    float distcur;
    LocationVector dest;

    dest.ChangeCoords( EOTSStartLocations[t][0], EOTSStartLocations[t][1], EOTSStartLocations[t][2], 0 );

    for(i = 0; i < EOTS_TOWER_COUNT; i++)
    {
        if( m_CPBanner[i] && m_CPBanner[i]->GetEntry() == EOTS_BANNER_ALLIANCE && t == 0 ||
              m_CPBanner[i]->GetEntry() == EOTS_BANNER_HORDE && t == 1 ||
              m_CPBanner2[i] && m_CPBanner2[i]->GetEntry() == EOTS_BANNER_ALLIANCE && t == 0 ||
              m_CPBanner2[i]->GetEntry() == EOTS_BANNER_HORDE && t == 1 ||
              m_CPBanner3[i] && m_CPBanner3[i]->GetEntry() == EOTS_BANNER_ALLIANCE && t == 0 ||
              m_CPBanner3[i]->GetEntry() == EOTS_BANNER_HORDE && t == 1 )
        {
            distcur = plr->GetPositionNC().Distance2DSq( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1] );
            if( distcur < dist )
            {
                dist = distcur;
                dest.ChangeCoords( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0 );
            }
        }
    }

    plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
    return true;
}
コード例 #7
0
ファイル: CircleOfBlood.cpp プロジェクト: master312/AscEmu
bool CircleOfBlood::HookHandleRepop(Player* plr)
{
    LocationVector dest;
    dest.ChangeCoords(6241.171875f, 261.067322f, 0.891833f);
    plr->SafeTeleport(m_mapMgr->GetMapId(), m_mapMgr->GetInstanceID(), dest);
    return true;
}
コード例 #8
0
ファイル: DalaranSewers.cpp プロジェクト: lev1976g/AscEmu
bool DalaranSewers::HookHandleRepop(Player* plr)
{
    LocationVector dest;
    dest.ChangeCoords(1292.51f, 792.05f, 9.34f);
    plr->SafeTeleport(m_mapMgr->GetMapId(), m_mapMgr->GetInstanceID(), dest);
    return true;
}
コード例 #9
0
bool StrandOfTheAncient::HookHandleRepop(Player * plr)
{
	LocationVector dest;

	dest.ChangeCoords(sotaRepop[plr->GetTeam()][0], sotaRepop[plr->GetTeam()][1],
		sotaRepop[plr->GetTeam()][2], sotaRepop[plr->GetTeam()][3]);

	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
	return true;
}
コード例 #10
0
ファイル: WarsongGulch.cpp プロジェクト: AegisEmu/AegisEmu
bool WarsongGulch::HookHandleRepop(Player * plr)
{
    LocationVector dest;
	if(plr->GetTeam())
		dest.ChangeCoords(1032.644775f, 1388.316040f, 340.559937f, 0.043200f);
	else
		dest.ChangeCoords(1423.218872f, 1554.663574f, 342.833801f, 3.124139f);
	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
	return true;
}
コード例 #11
0
ファイル: MovementHandler.cpp プロジェクト: wow4all/wowtbc
void WorldSession::HandleTeleportCheatOpcode(WorldPacket & recv_data)
{
	float x,y,z,o;
	LocationVector vec;

	if(!HasGMPermissions())
	{
		SendNotification("You do not have permission to use this function.");
		return;
	}

	recv_data >> x >> y >> z >> o;
	vec.ChangeCoords(x,y,z,o);
	_player->SafeTeleport(_player->GetMapId(),_player->GetInstanceID(),vec);
}
コード例 #12
0
   void PSU1Rules::BuildGenericSignal(const GenericTupleVector& genericTupleVec)
   {
      std::cout << "BUILDING Generic Signals " << std::endl;

      for(uint16_t idx=0; idx<genericTupleVec.size(); ++idx)
      {
         // get all port.channel locations
         LocationVector lv = genericTupleVec[idx].get<0>();

         // iterate through all locations and assign signal
         for(uint16_t jdx=0; jdx<lv.size(); ++jdx)
         {
            ports_[ChIndex(lv,jdx)] = genericTupleVec[idx].get<1>();
         } 
      }
   }
コード例 #13
0
ファイル: Disassembler.cpp プロジェクト: bjackson/LC3Tools
bool Disassembler::DisassembleData(LocationVector &LocationStack, istream &InputStream, uint64 &Address)
{
	bool fRetVal = true;
	unsigned int TempChar;
	Data *pData;
	while(InputStream.good() && Address < EndAddress)
	{
		//Get a byte of data from the stream.
		TempChar = InputStream.get();
		if(TempChar == -1)	//EOF
			break;

		//Add the byte to the sequence
		if((*TheProg.Segments.rbegin())->Sequence.empty())
		{
			//Create a new byte element.
			pData = new Data(LocationStack, DATA1, Addressability, new IntegerNumber(LocationStack, TempChar));
			(*TheProg.Segments.rbegin())->Sequence.push_back(pData);
			pData->Address = Address;
		}
		else
		{
			//Add the byte to an existing array.
			pData = reinterpret_cast<Data *>(*(*TheProg.Segments.rbegin())->Sequence.rbegin());
			pData->vData.push_back(new IntegerNumber(LocationStack, TempChar));
			pData->Length++;
			pData->Size++;
		}

		Address++;
		LocationStack.rbegin()->second++;
	}
	return fRetVal;
}
コード例 #14
0
void IsleOfConquest::OnPlatformTeleport(Player* plr)
{
	LocationVector dest;
	uint32 closest_platform = 0;

	if(plr->GetTeam() == TEAM_ALLIANCE)
	{
		for (uint32 i = 0; i < 6; i++)
		{
			float distance = CalcDistance(plr->GetPositionX(),
				plr->GetPositionY(), plr->GetPositionZ(),
				iocTransporterDestination[i][0],
				iocTransporterDestination[i][1],
				iocTransporterDestination[i][2]);
			if (distance < 75 && distance > 10)
			{
				closest_platform = i;
				break;
			}
		}
		dest.ChangeCoords(iocTransporterDestination[closest_platform][0],
			iocTransporterDestination[closest_platform][1],
			iocTransporterDestination[closest_platform][2],
			iocTransporterDestination[closest_platform][3]);
	}
	else		// HORDE
	{
		for (uint32 i = 6; i < 12; i++)
		{
			float distance = CalcDistance(plr->GetPositionX(),
				plr->GetPositionY(), plr->GetPositionZ(),
				iocTransporterDestination[i][0],
				iocTransporterDestination[i][1],
				iocTransporterDestination[i][2]);
			if (distance < 75 && distance > 10)
			{
				closest_platform = i;
				break;
			}
		}
		dest.ChangeCoords(iocTransporterDestination[closest_platform][0],
			iocTransporterDestination[closest_platform][1],
			iocTransporterDestination[closest_platform][2],
			iocTransporterDestination[closest_platform][3]);
	}
	plr->SafeTeleport(plr->GetMapId(), plr->GetInstanceID(), dest);
}
コード例 #15
0
ファイル: main.cpp プロジェクト: bjackson/LC3Tools
int main(int argc, char* argv[])
{
	cout << "\n\t\tLC-3 Assembler Converter 1.0, Ashley Wise\n\n";

	if(!ProcessArgs(argc, argv))
	{
		PrintUsage();
		return 0;
	}

	char sMessageBuffer[65 + MAX_FILENAME_CHAR];
	LocationVector LocationStack;
	bool fRetVal = true;

	for(unsigned int i = 0; i < InputList.size(); i++)
	{
		ifstream AsmFile(InputList[i].c_str());
		if(!AsmFile.good())
		{
			sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
			AsmCallBack(Fatal, sMessageBuffer, LocationVector());
			fRetVal = false;
			continue;
		}

		string sAsm3FileName = InputList[i]+"3";
		ofstream Asm3File(sAsm3FileName.c_str());
		if(!Asm3File.good())
		{
			sprintf(sMessageBuffer, "Unable to open file %.255s", sAsm3FileName.c_str());
			AsmCallBack(Fatal, sMessageBuffer, LocationVector());
			fRetVal = false;
			continue;
		}

		LocationStack.push_back( LocationVector::value_type(i, 1) );
		cout << "Translating " << InputList[i].c_str() << endl;
		if(!AsmConvertLC3(AsmFile, Asm3File, LocationStack, AsmCallBack))
		{
			fRetVal = false;
			continue;
		}
	}
	cout << endl;

	return 0;
}
コード例 #16
0
ファイル: MessageTypes.cpp プロジェクト: TasteeWheat/mxoemu1
WhereAmIResponse::WhereAmIResponse( const LocationVector &currPos )
{
	byte whereamipacket[] =
	{
		0x81, 0x54, 0x00, 0xB4, 0xC3, 0x46, 0x00, 0x80, 0xFC, 0xC3, 0x00, 0xE2, 0x01, 0x47, 0x07, 0x01,	0x00
	} ;

	currPos.toFloatBuf(&whereamipacket[2],sizeof(whereamipacket)-2);
	m_buf.clear();
	m_buf.append(whereamipacket,sizeof(whereamipacket));
}
コード例 #17
0
void randomizeVector(LocationVector& V) {
	int n = V.size();
	int n2 = (int)(n/2);
	int rand_index = 0;
	for(int i = 0; i < n2;) {
		rand_index = rand() % n;
		if(!V[rand_index]) {
			V[rand_index] = true;
			i++;
		}
	}
}
コード例 #18
0
   void PSU1Rules::BuildTxaSignal(const TxaTupleVector& txaTupleVec, 
         const TrTupleVector& trTupleVec, const double txa, const double bauda)
   {
      std::cout << "BUILDING TXA Signal " << std::endl;

      LocationVector lv = txaTupleVec[0].get<0>();
      const uint16_t pre_baud = round(trTupleVec[0].get<1>()/bauda);
      const double txa_baud = round(txa/bauda);

      for(uint16_t idx=0; idx<lv.size(); ++idx)
      {
         const uint16_t ch_idx = ChIndex(lv,idx);
         ports_[ch_idx].resize(pre_baud + txa_baud);

         for(uint16_t jdx=0; jdx<txa_baud; ++jdx)
         {
            const uint16_t txa_offset = jdx + pre_baud;
            ports_[ch_idx].set(txa_offset,true);
         }
      }
   }
コード例 #19
0
   void PSU1Rules::BuildCodeSignal(const CodeTupleVector& codeTupleVec,
         const TrTupleVector& trTupleVec, const double bauda)
   {
      std::cout << "BUILDING CODE Signal " << std::endl;

      LocationVector lv = codeTupleVec[0].get<0>();
      const Pattern pattern = codeTupleVec[0].get<1>();
      const uint16_t pre_baud = round(trTupleVec[0].get<1>()/bauda);

      for(uint16_t idx=0; idx<lv.size(); ++idx)
      {
         const uint16_t ch_idx = ChIndex(lv,idx);
         ports_[ch_idx].resize(pre_baud+pattern.size());

         for(uint16_t jdx=0; jdx<pattern.size(); ++jdx) 
         {
            const uint16_t code_offset = pre_baud + jdx;
            ports_[ch_idx][code_offset] = pattern[jdx];
         }
      }
   }
コード例 #20
0
   void PSU1Rules::BuildTrSignal(const TrTupleVector& trTupleVec, const double txa, const double bauda)
   {
      std::cout << "BUILDING TR Signal " << std::endl;
      const uint16_t pre_baud = round(trTupleVec[0].get<1>()/bauda);
      const uint16_t post_baud = round(trTupleVec[0].get<2>()/bauda);
      const uint16_t txa_baud = round(txa/bauda);
      const uint16_t tr_baud = pre_baud + txa_baud + post_baud;

      LocationVector lv = trTupleVec[0].get<0>();

      for(uint16_t idx=0; idx<lv.size(); ++idx)
      {
         const uint16_t ch_idx = ChIndex(lv,idx);
         ports_[ch_idx].resize(tr_baud);

         for(uint16_t jdx=0; jdx<tr_baud; ++jdx)
         {
            ports_[ch_idx].set(jdx,true);
         }
      }

   }
コード例 #21
0
   void PSU1Rules::BuildSaSignal(const SaTupleVector& saTupleVec,
         const TrTupleVector& trTupleVec, const double bauda)
   {

      std::cout << "BUILDING SA (Receive Window) Signal " << std::endl;

      for(uint16_t idx =0; idx<saTupleVec.size(); ++idx)
      {
         // get all port.channel locations
         LocationVector lv = saTupleVec[idx].get<0>();
         bool isNeg = saTupleVec[idx].get<1>(); 

         // convert to baud
         const uint16_t h0_baud  = round(saTupleVec[idx].get<2>()/bauda);
         const uint16_t hf_baud  = round(saTupleVec[idx].get<3>()/bauda);
         const uint16_t pre_baud = round(trTupleVec[0].get<1>()/bauda);

         //window's point of reference is TXA and not t=0 since we
         //are using a TR window to protect the receivers (i.e. add pre offset)
         const uint16_t h0_offset = h0_baud + pre_baud;
         const uint16_t hf_offset = hf_baud + pre_baud;

         for(uint16_t jdx=0; jdx<lv.size(); ++jdx)
         {
            const uint16_t ch_jdx = ChIndex(lv,jdx);
            ports_[ch_jdx].resize(hf_offset);

            // enable signal for defined receive window 
            for(uint16_t kdx=h0_offset; kdx<hf_offset; ++kdx)
            { 
               ports_[ch_jdx][kdx]=true;
            }

            // invert signal if negate set
            if(isNeg) { ports_[ch_jdx].flip(); }
         } 
      }
   }
コード例 #22
0
ファイル: RingOfValor.cpp プロジェクト: RAlexis/ArcEmu_MoP
bool RingOfValor::HookHandleRepop( Player *plr ){
	LocationVector dest;
	dest.ChangeCoords(762.91f, -284.28f, 28.28f);
	plr->SafeTeleport(m_mapMgr->GetMapId(), m_mapMgr->GetInstanceID(), dest);
	return true;
}
コード例 #23
0
ファイル: AsmUI.cpp プロジェクト: bjackson/LC3Tools
bool AsmCallBack(MessageEnum MessageType, const string &sMessage, const LocationVector &LocationStack)
{
	unsigned int i, j, Length, PreLength, OrigPreLength, CutOff, Temp, StackLength = 0, StackNumber = LocationStack.size()-1;
	ostrstream sMsg;
	const char *Buffer;
	char DBuffer[MAX_CONSOLE_WIDTH+1];
	char Space[MAX_CONSOLE_WIDTH/2+1];
	memset(Space, ' ', ConsoleWidth/2);
	//store the last locationstack so that we don't reprint a possibly long "From included file" list
	//when the current error happens in the same file as the one we just printed.
	static LocationVector LastLocation;


	if(!LocationStack.empty())
	{
		for(i = 0; i < StackNumber; i++)
		{
			if(LastLocation.size() > i+1 && LocationStack[i] == LastLocation[i])
				continue;
			else
				LastLocation.clear();
			sMsg << InputList[LocationStack[i].first].c_str() << "(" << LocationStack[i].second <<"):    Info:   From included file:\n";
		}
		LastLocation = LocationStack;
		StackLength = sMsg.pcount();
	}

	switch(MessageType)
	{
	case Info:
		if(!LocationStack.empty())
			sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "):    Info:   ";
		break;
	case Warning:
		Warnings++;
		if(LocationStack.empty())
			throw "Empty location stack for Warning!";
		sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "): Warning:   ";
		break;
	case Error:
		Errors++;
		if(LocationStack.empty())
			throw "Empty location stack for Error!";
		sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "):   Error:   ";
		break;
	case Fatal:
		Errors++;
		if(!LocationStack.empty())
			sMsg << InputList[LocationStack[StackNumber].first].c_str() << "(" << LocationStack[StackNumber].second << "):   ";
		sMsg << "Fatal:   ";
		break;
	}

	//Print the pre-message
	if(LocationStack.empty())
		OrigPreLength = PreLength = 0;
	else
		OrigPreLength = PreLength = sMsg.pcount() - StackLength;

	//If the pre-message is longer than half the width of the console,
	//add a newline and spaces so that it looks like the pre-message
	//ended at half-width.
	if(PreLength > ConsoleWidth/2)
	{
		sMsg << "\n";
		Space[ConsoleWidth/2] = 0;
		PreLength = ConsoleWidth/2;
		sMsg << Space;
	}
	else
		Space[PreLength] = 0;

	Length = sMessage.size();
	Buffer = sMessage.c_str();

	//Check for tabs, which increases the effective length of the string
	for(i = 0; Buffer[i]; i++)
		if(Buffer[i] == '\t')
			PreLength += CONSOLE_TAB_SIZE - 1;

	//Print lines of the message
	while(true)
	{
		//Determine where to partition this message so that it fits in the console
		//The -1 is there so that there is room for the newline character.
		Temp = CutOff = MIN(Length, ConsoleWidth-PreLength-1);
		if(Temp != Length)
		{	//Adjust the cutoff so that it doesn't break words
			while(Buffer[Temp] != ' ' && Buffer[Temp] != '\n' && Buffer[Temp] != '\t' && Buffer[Temp] != '\r' && Temp > 0)
				Temp--;
			if(Temp > 0)
				CutOff = Temp;
		}
		for(i = 0, j = 0; i < CutOff; i++)
		{
			if(Buffer[i] != '\n')
			{
				if(Buffer[i] == '\t')
					PreLength -= CONSOLE_TAB_SIZE - 1;
				DBuffer[j++] = Buffer[i];
			}
		}
		DBuffer[j] = 0;
		while(CutOff != Length && (Buffer[CutOff] == ' ' || Buffer[CutOff] == '\n' || Buffer[CutOff] == '\t' || Buffer[CutOff] == '\r'))
			CutOff++;
		Buffer = &Buffer[CutOff];
		Length -= CutOff;
		sMsg << DBuffer << '\n';

		//While there is still message left, print spaces to line it up
		if(Length > 0)
		{
			if(OrigPreLength == 0)
			{
				OrigPreLength = PreLength = MIN(8, ConsoleWidth/2) + PreLength;
				Space[0] = ' ';
				Space[MIN(8, ConsoleWidth/2)] = 0;
			}
			sMsg << Space;
		}
		else
			break;
	}

	sMsg << ends;
	cout << sMsg.str();

	cout.flush();

	return true;
}
コード例 #24
0
ファイル: AsmUI.cpp プロジェクト: bjackson/LC3Tools
bool AssemblerUI(vector<Program *> &AsmPrograms, RamVector &MemoryImage)
{
	bool fRetVal = true;
	char sMessageBuffer[65 + MAX_FILENAME_CHAR];
	unsigned int i;
	ofstream VHDLFile;

	AsmCallBack(Info, "", LocationVector());
	sprintf(sMessageBuffer, "\t\tLC-3b Assembler %.15s, Ashley Wise", ASM_VER);
	AsmCallBack(Info, sMessageBuffer, LocationVector());
	AsmCallBack(Info, "", LocationVector());

#ifdef BIG_ENDIAN_BUILD
	if(EndianCheck())
	{
		AsmCallBack(Fatal, "Platform is little endian; assembler built for big endian! Aborting...", LocationVector());
		return false;
	}
#else
	if(!EndianCheck())
	{
		AsmCallBack(Fatal, "Platform is big endian; assembler built for little endian! Aborting...", LocationVector());
		return false;
	}
#endif

	//Initialize program list
	for(i = 0; i < InputList.size(); i++)
	{
		LocationVector LocationStack;
		LocationStack.push_back( LocationVector::value_type(i, 0) );
		AsmPrograms.push_back(new Program(LocationStack, InputList[i], LC3bISA::Addressability));
	}

	//*** Perform Compilation ***

	//Lex, parse, and optimize each input asm file
	AsmCallBack(Info, "Compiling...", LocationVector());
	for(i = 0; i < AsmPrograms.size(); i++)
	{
		//Open the assembly file
		if(ToLower(AsmPrograms[i]->sFileName.Ext) == "obj" || ToLower(AsmPrograms[i]->sFileName.Ext) == "bin")
		{
			ifstream AsmFile(InputList[i].c_str(), ios::in | ios::binary);
			if(!AsmFile.good())
			{
				sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
				AsmCallBack(Fatal, sMessageBuffer, LocationVector());
				fRetVal = false;
				continue;
			}
			if(!Assemble<LC3bISA>::Disassemble(AsmFile, *AsmPrograms[i], AsmCallBack))
				fRetVal = false;
		}
		else
		{
			ifstream AsmFile(InputList[i].c_str());
			if(!AsmFile.good())
			{
				sprintf(sMessageBuffer, "Unable to open file %.255s", InputList[i].c_str());
				AsmCallBack(Fatal, sMessageBuffer, LocationVector());
				fRetVal = false;
				continue;
			}
			if(!Assemble<LC3bISA>::Compile(AsmFile, *AsmPrograms[i], AsmCallBack))
				fRetVal = false;
		}
	}
	if(!fRetVal)
		goto CleanUp;

	//*** Perform Linking ***

	//Convert the symbolic assembly program into a memory image
	AsmCallBack(Info, "Linking...", LocationVector());
	fRetVal = Assemble<LC3bISA>::Link(AsmPrograms, MemoryImage, AsmCallBack);
	if(!fRetVal)
		goto CleanUp;

	if(Flags.fOutputVHDL)
	{
		//Create output file name. If none is specified, the filename will be the same as
		//the first input file except the extention is replaced with ".vhd"
		if(sOutputFileName == "")
			sOutputFileName = AsmPrograms[0]->sFileName.Path + AsmPrograms[0]->sFileName.Bare + ".vhd";
		//Open the output file.
		VHDLFile.open(sOutputFileName.c_str());
		if(!VHDLFile.good())
		{
			sprintf(sMessageBuffer, "Unable to create file %.255s...", sOutputFileName.c_str());
			AsmCallBack(Fatal, sMessageBuffer, LocationVector());
			goto CleanUp;
		}
		//write the memory image into a VHDL Ram vectors file
		sprintf(sMessageBuffer, "Writing VHDL to %.255s...", sOutputFileName.c_str());
		AsmCallBack(Info, sMessageBuffer, LocationVector());
		Assemble<LC3bISA>::VHDLWrite(VHDLFile, MemoryImage, AsmCallBack);
	}
	else
		sOutputFileName = AsmPrograms[0]->sFileName.Path + AsmPrograms[0]->sFileName.Bare;
	//Print VHDL to stdout
	if(Flags.fStdout)
	{
		cout << endl;
		Assemble<LC3bISA>::VHDLWrite(cout, MemoryImage, AsmCallBack);
		cout << endl;
	}

CleanUp:
	AsmCallBack(Info, "", LocationVector());
	sprintf(sMessageBuffer, "%.255s:   %u Error%.1s, %u Warning%.1s", sOutputFileName.c_str(), Errors, (Errors != 1 ? "s" : ""), Warnings, (Warnings != 1 ? "s" : ""));
	AsmCallBack(Info, sMessageBuffer, LocationVector());
	AsmCallBack(Info, "", LocationVector());

	return fRetVal;
}
コード例 #25
0
   bool PSU1Rules::Verify()
   {
      //store all locations and compare to 
      //ensure unique assignments
      LocationVector globalLocations;

      //contains tuple<LocationVector, Pattern, double>
      //single entry
      const CodeTupleVector& codeTupleVec = codeKey.GetTupleRef();

      //contains tuple<LocationVector, double, double>
      //single entry
      const TrTupleVector& trTupleVec = trKey.GetTupleRef();

      //contains tuple<LocationVector, double>
      //single entry
      const TxaTupleVector& txaTupleVec = txaKey.GetTupleRef();

      //contains tuple<LocationVector, bool, double, double>
      //multiple entries
      const SaTupleVector& saTupleVec = saKey.GetTupleRef();

      //contains simple Parameter
      //multiple entries
      const ParameterVector& t1Tuple = t1Key.GetTupleRef();

      //contains tuple<LocationVector, dynamic_bitset<> >
      //optional with multiple entries
      GenericTupleVector genericTupleVec; 

      if(gKey.Set())
      {
         genericTupleVec = gKey.GetTupleRef();
      }

      //contains simple Parameter
      //single entry
      //const ParameterVector& t2Tuple   = t2Key.GetTupleRef();

      const double txa = txaTupleVec[0].get<1>();
      const double rfclk    = any_cast<double>(param::FindParameter(t1Tuple, "refclock").value);
      const double baudb    = any_cast<double>(param::FindParameter(t1Tuple, "baudb").value);
      const double ippa     = any_cast<double>(param::FindParameter(t1Tuple, "ippa").value);
      const double bauda    = any_cast<double>(param::FindParameter(t1Tuple, "bauda").value);
      const uint32_t txa_baud = round(txa/bauda);

      iif_.clkDivA = round(rfclk*bauda/2.0);
      iif_.clkDivB = round(rfclk*baudb/2.0);

      std::cout << "txa      = " << txa << std::endl;
      std::cout << "txa_baud = " << txa_baud << std::endl;
      std::cout << "rfclk    = " << rfclk << std::endl;
      std::cout << "baudb    = " << baudb << std::endl;
      std::cout << "bauda    = " << bauda << std::endl;
      std::cout << "ippa     = " << ippa << std::endl;
      std::cout << "diva     = " << iif_.clkDivA << std::endl;
      std::cout << "divb     = " << iif_.clkDivB << std::endl;

      //const double ipp_b   = rfclk/ipp;
      const double duty_cycle = txa/ippa;
      const uint32_t code_l  = codeTupleVec[0].get<2>();

      std::cout << "code length = " << code_l << std::endl;
      std::cout << "txa  length = " << txa_baud << std::endl;

      //verify that code width matches the transmitted pulse width
      if(txa_baud != code_l)
      {
         cerr << "TXA Pulse Width != CODE Pulse Width => " << txa_baud << " != " << code_l << endl;
         throw std::runtime_error("PSU1Rules: TXA length != CODE length");
      }

      //verify that code width matches the transmitted pulse width
      if( duty_cycle > MAX_DUTY_CYCLE ) 
      {
         throw std::runtime_error("PSU1Rules - DUTY CYCLE " + 
               lexical_cast<string>(duty_cycle) + " > " + 
               lexical_cast<string>(MAX_DUTY_CYCLE));
      }

      //push sa locations 
      for(uint16_t idx=0; idx<saTupleVec.size(); ++idx)
      {
         LocationVector lv = saTupleVec[idx].get<0>();
         globalLocations.insert(globalLocations.end(), lv.begin(), lv.end());
      }

      //push generic location
      for(uint16_t idx=0; idx<genericTupleVec.size(); ++idx)
      {
         LocationVector lv = genericTupleVec[idx].get<0>();
         globalLocations.insert(globalLocations.end(), lv.begin(), lv.end());
      }

      //push all other locations
      LocationVector t = txaTupleVec[0].get<0>();
      globalLocations.insert(globalLocations.end(), t.begin(), t.end() );
      t = trTupleVec[0].get<0>();
      globalLocations.insert(globalLocations.end(), t.begin(), t.end() );
      t = codeTupleVec[0].get<0>();
      globalLocations.insert(globalLocations.end(), t.begin(), t.end() );


      //lazy way to check for duplicate signal assignments
      for(uint16_t idx=0; idx<globalLocations.size(); ++idx)
      {
         for(uint16_t jdx=idx+1; jdx<globalLocations.size(); ++jdx)
         {
            if(globalLocations[idx].channel == globalLocations[jdx].channel)
            {
               if(globalLocations[idx].port == globalLocations[jdx].port)
               {
                  cout << globalLocations[idx].port << "." << globalLocations[idx].channel << " ";
                  throw std::runtime_error("SIGNALS are assigned to the same port.channel");
               }
            }
         }
      }

      return true;
   }
コード例 #26
0
ファイル: Disassembler.cpp プロジェクト: bjackson/LC3Tools
bool Disassembler::Disassemble(LocationVector &LocationStack, istream &InputStream, SymbolList &Symbols)
{
	bool fRetVal = true;
	unsigned int i, TempChar;
	JMT::ByteData ByteData;

	if(fRunOnce)
		throw "Disassembler called twice on the same program!";
	fRunOnce = true;

	//First read starting address.
	for(i = 0; i < sizeof(uint64); i++)
	{
		TempChar = InputStream.get();
		if(TempChar == -1)	//EOF
			break;
		//The address in the file is always little endian
#ifdef BIG_ENDIAN_BUILD
		ByteData.Bytes[sizeof(uint64) - i - 1] = TempChar;
#else
		ByteData.Bytes[i] = TempChar;
#endif
		LocationStack.rbegin()->second++;
	}
	if(i < sizeof(uint64))
	{
		CallBack(Fatal, "Unexpected end of file.", LocationStack);
		return false;
	}
	StartAddress = ByteData.UI64;

	//Then read ending address
	for(i = 0; i < sizeof(uint64); i++)
	{
		TempChar = InputStream.get();
		if(TempChar == -1)	//EOF
			break;
		//The address in the file is always little endian
#ifdef BIG_ENDIAN_BUILD
		ByteData.Bytes[sizeof(uint64) - i - 1] = TempChar;
#else
		ByteData.Bytes[i] = TempChar;
#endif
		LocationStack.rbegin()->second++;
	}
	if(i < sizeof(uint64))
	{
		CallBack(Fatal, "Unexpected end of file.", LocationStack);
		return false;
	}
	EndAddress = StartAddress + ByteData.UI64;

	//Check addresses
	if(EndAddress < StartAddress)
	{
		CallBack(Fatal, "Program end address is less than start address.", LocationStack);
		return false;
	}

	//Create program origin
	TheProg.fDynamicAddress = false;
	TheProg.Address = StartAddress;

	//Create program segment
	TheProg.Segments.push_back(new Segment(LocationStack, Addressability, 0));

	//Add the pre-existing symbols
	for(SymbolList::iterator SymbolIter = Symbols.begin(); SymbolIter != Symbols.end(); SymbolIter++)
		DisassembleSymbol(SymbolIter->first, SymbolIter->second, SymbolIter->third);

	//Try to disassemble instructions. Instructions have highest priority.
	uint64 Address = StartAddress;
	if(ToLower(TheProg.sFileName.Ext) == "obj")
	{
		if(!DisassembleInstructions(LocationStack, InputStream, Address))
			return false;
	}
	else	//"bin"
	{
		if(!DisassembleData(LocationStack, InputStream, Address))
			return false;
	}

	if(Address < EndAddress)
	{
		CallBack(Error, "Unexpected end of file.", LocationStack);
		return false;
	}

	//Create labels
	list<Element *>::iterator ElemIter = (*TheProg.Segments.begin())->Sequence.begin();
	for(LabelMap::iterator LabelIter = Labels.begin(); LabelIter != Labels.end(); LabelIter++)
	{
		//Find the element this label points to
		while(ElemIter != (*TheProg.Segments.begin())->Sequence.end() && (*ElemIter)->Address < LabelIter->first)
			ElemIter++;

		if(ElemIter == (*TheProg.Segments.begin())->Sequence.end())
		{
			ElemIter--;
			if((*ElemIter)->Address + (*ElemIter)->Size != LabelIter->first)
				throw "Disassembler: Ran out of elements while adding labels!";
			//Label points to end of program
			ElemIter++;
		}
		else if((*ElemIter)->Address != LabelIter->first)
			throw "Disassembler: Label points to inside an instruction!";

		//Add the label to the sequence
		Label *pLabel = new Label(LocationStack, LabelIter->second->sSymbol, *TheProg.Segments.begin());
		(*TheProg.Segments.begin())->Sequence.insert(ElemIter, pLabel);
		LabelIter->second->pLabel = pLabel;
		if(ElemIter != (*TheProg.Segments.begin())->Sequence.end())
		{
			if(!TheProg.TheSymbolTable.ResolveSymbol((*ElemIter)->LocationStack, LabelIter->second->sSymbol, CallBack, SymLabel))
				throw "ResolveSymbol in Disassembler failed!";
			pLabel->pElement = *ElemIter;
		}
		else
			if(!TheProg.TheSymbolTable.ResolveSymbol((*(*TheProg.Segments.begin())->Sequence.rbegin())->LocationStack, LabelIter->second->sSymbol, CallBack, SymLabel))
				throw "ResolveSymbol in Disassembler failed!";
	}

	return fRetVal;
}