Ejemplo n.º 1
0
int main (int argc, char* argv[]){	
	
	if (argc != 3){
		printf("Incorrect arguments for comb. Please enter your circuit description file, followed by your input file.\n");
		return 0;
	}
	
	int i, j, numInput;
	block* var = malloc(26 * sizeof(block));
	block* tvar = malloc(26 * sizeof(block));
	instruct* instructions = malloc(100 * sizeof(instruct));
	
	for (i = 0; i < 26; i++)
	var[i].name = (char *) malloc (sizeof(char) * 11);
	for (i = 0; i < 26; i++)
	tvar[i].name = (char *) malloc (sizeof(char) * 11);
	for (i = 0; i < 100; i++){
		instructions[i].gate = (char *) malloc (sizeof(char) * 11);
		instructions[i].vari = malloc(100 * sizeof(char *));
		for (j = 0; j < 100; j++)
		instructions[i].vari[j] = malloc(100 * sizeof(char));
	}

	readInputs(argv[1], numInput, instructions, var, tvar);
	
	
	
	readStates(argv[2], var);

	
	
	printer(var, tvar, instructions);
	return 0;
}
Ejemplo n.º 2
0
void CGeneratorInput::readInputFile(const std::string& fileName, CPinPass::States& states)
{
	TiXmlDocument document;

	if(!base::loadXml(fileName, document))
	{
		base::lerr<<"Can't open input XML file \""<<fileName<<"\".";
		return;
	}

	TiXmlElement* root = document.FirstChildElement("EffectGeneratorParameters");

	if(!root)
	{
		base::lerr<<"Can't find root element in input XML file \""<<fileName<<"\".";
		return;
	}

	TiXmlElement* elem = root->FirstChildElement();

	while(elem != NULL)
	{
		std::string name = elem->Value();

		if(name == "constants")
			readConstants(elem);
		else
		if(name == "includes")
			readIncludes(elem);
		else
		if(name == "states")
			readStates(elem, states);
		else
		if(name == "pins")
			readPins(elem, states);
		else
		if(name == "inputs")
			readInputs(elem, states);
		else
			base::lwrn<<"Found element \""<<name<<"\" while parsing input file \""<<
						fileName<<"\". Nothing know about this type. Skipping...";

		elem = elem->NextSiblingElement();
	}
}
Ejemplo n.º 3
0
int loadGame(string filePrefix) {
	dout << "--- loadGame (started in: " << current_time << ")" << endl;
	dout << " loading game from '" << filePrefix << "'" << endl;
	resetGame();
	if(readStates(filePrefix)) return 1;
	if(readAllScripts(filePrefix)) return 1;
	if(readDialogs(filePrefix)) return 1;
	if(readGameState(filePrefix)) return 1;
	if(readInventory(filePrefix)) return 1;
	if(readHotspots(filePrefix)) return 1;
	if(readScenes(filePrefix)) return 1;
	if(readMainCharacter(filePrefix)) return 1;
	if(readMusic(filePrefix)) return 1;
	soundPlayer.resumeAll();

	dout << "--- End loadGame (ended in: " << current_time << ")" << endl << endl;
	return 0;
}
Ejemplo n.º 4
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key)
{
	if (debugOutput) {printf("Pressed key number: %i\n", key);}
	if ( key == ' ' )
	{
		if ( m_run )
		{
			m_run = false;
			ofxOscMessage m;
			m.setAddress("/stop");
			m.addIntArg(0);
			sender.sendMessage ( m );
			setOscDebugMessage(m);
		}
		else
		{
			m_run = true;
			ofxOscMessage m;
			m.setAddress("/start");
			m.addIntArg(1);
			sender.sendMessage ( m );
			setOscDebugMessage(m);
		}
	}
	else if (key == 'r' || key == 'R')
	{
		m_numSamples[m_currentSample] = 0;
		m_sampleVector[m_currentSample].clear();
	}
	else if (key == 'z')
	{
		if (m_numSamples[m_currentSample] > 0)
		{
			--m_numSamples[m_currentSample];
			m_sampleVectorPopped[m_currentSample].push_back(m_sampleVector[m_currentSample].back());
			m_sampleVector[m_currentSample].pop_back();
		}
	}
	else if (key == 'Z')
	{
		if (m_sampleVectorPopped[m_currentSample].size() > 0) {
			m_sampleVector[m_currentSample].push_back(m_sampleVectorPopped[m_currentSample].back());
			m_sampleVectorPopped[m_currentSample].pop_back();
			++m_numSamples[m_currentSample];
		}
	}
	else if ( key == 'c' )
	{
		// clear all samples
		for (int i = 0; i < MAX_SAMPLES; ++i) {
			m_numSamples[i] = 0;
			m_sampleVector[i].clear();
		}
	}
	else if ( key == 'C' )
	{
		clearAll();
	}
	else if ( key == 'F' )
	{
		isFullScreen = !isFullScreen;
		ofSetFullscreen(isFullScreen);
	}
	else if (key >= 48 && key <=57)
	{
		m_currentSample = key - 48;
		if (debugOutput) {printf("set sample: %i\n", m_currentSample);}
	}
	else if (key == 'd')
	{
		if (debugOutput) {printf("debug mode\n");}
		debugMode = !debugMode;
	}
	else if (key == 'f')
	{
		showColors = !showColors;
	}
	else if (key == 'g')
	{
		for (int i = 0; i < MAX_SAMPLES; ++i) {
			m_sampleColors[i].r = ofRandom(0, 255);
			m_sampleColors[i].g = ofRandom(0, 255);
			m_sampleColors[i].b = ofRandom(0, 255);
			m_sampleColors[i].a = 127;
		}
	}
	else if (key == 'h')
	{
		if (debugOutput) {printf("help mode\n");}
		helpMode = !helpMode;
		usageMode = false;
	}
	else if (key == 'm')
	{
		showOscDebugPosition = !showOscDebugPosition;
	}
	else if (key == OF_KEY_UP)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}

			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		++m_currentState;

		if (m_currentState > XMLstates.getNumTags("STATE"))
		{
			m_currentState = 0;
		}
		loadState(m_currentState);
		if (debugOutput) {printf("current state : %i\n", m_currentState);}

	}
	else if (key == OF_KEY_DOWN)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}

			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		--m_currentState;
		if (m_currentState < 0)
		{
			m_currentState =  XMLstates.getNumTags("STATE");
		}
		loadState(m_currentState);
		if (debugOutput) {printf("current state : %i\n", m_currentState);}
	}
	else if (key == OF_KEY_RETURN)
	{
		usageMode = !usageMode;
	}
	else if (key == 'w')
	{
		if (debugMode) {
			saveCurrentState();
			if (debugOutput) {printf("saved current state!\n");}
			buttonPushed = true;
		}
	}
	else if (key == 'e')
	{
		if (debugMode)
		{
			readStates();
		}
	}
	else if (key >= 257 && key <= 266)
	{
		if (m_currentState == 0) {
			nPtsBackup = nPts;
			for (int i = 0; i < MAX_N_PTS; ++i) {
				ptsBackup[i] = 0;
			}
			
			for (int i = 0; i < nPts; ++i) {
				ptsBackup[i] = pts[i];
			}
			for (int i = 0; i < MAX_SAMPLES; ++i) {
				m_sampleVectorBackup[i] = m_sampleVector[i];
				m_numSamplesBackup[i] = m_numSamples[i];
				m_playStatusesBackup[i] = m_playStatuses[i];
			}
		}
		
		m_currentState = (key - 256) + stateTen;
		printf("current state %i\n", m_currentState);
		printf("lastTagNumber: %i\n", lastTagNumber);
		if (m_currentState > XMLstates.getNumTags("STATE")) 
		{
			m_currentState = lastTagNumber;
		}
		loadState(m_currentState);
		stateTenMsg = "";
		if (debugOutput) {printf("current state : %i\n", m_currentState);}
	}
	else if (key == OF_KEY_F11)
	{
		printf("bla %i",(XMLstates.getNumTags("STATE")));
		if ((XMLstates.getNumTags("STATE") - stateTen) > 10 )
		{
			stateTen += 10;
			std::stringstream str;
			str << ", +";
			str << stateTen;
			str << "...";
			stateTenMsg = str.str();
		}
//		if (stateTen% <= XMLstates.getNumTags("STATE")) {
//			m_currentState += stateTen
//		}
//		m_currentState 
	}
	else if (key == OF_KEY_F12) 
	{
		if (stateTen != 0){
			stateTen -= 10;
			std::stringstream str;
			str << ", -";
			str << stateTen;
			str << "...";			
			stateTenMsg = str.str();
		}
	}
}