Exemple #1
0
main () {
    FILE *fin  = fopen ("transform.in", "r");
    FILE *fout = fopen ("transform.out", "w");
    int a, b;
    int i,j,k;
	char ln[10];
	
	fscanf (fin, "%d", &nt);
	for(i=0;i<nt;i++){
		fscanf(fin, "%s", ln);
		for(j=0;j<nt;j++)pbf[i][j]=ln[j];
	}
	for(i=0;i<nt;i++){
		fscanf(fin, "%s", ln);
		for(j=0;j<nt;j++)pt[i][j]=paf[i][j]=ln[j];
	}
	
	for(k=1;k<4;k++){
		cpy();
		rot90(k);
		if(ide()){
			fprintf (fout, "%d\n", k);exit(0);
		}
	}
	
	cpy();
	ref();
	if(ide()){
		fprintf (fout, "%d\n", 4);exit(0);
	}
	
	for(k=1;k<4;k++){
		cpy();
		ref();
		rot90(k);
		if(ide()){
			fprintf (fout, "%d\n", 5);exit(0);
		}
	}

	cpy();
	if(ide()){
		fprintf (fout, "%d\n", 6);exit(0);
	}
	
    fprintf (fout, "%d\n", 7);
    exit (0);
}
Exemple #2
0
void csplayh5_state::csplayh5(machine_config &config)
{
	/* basic machine hardware */
	TMP68301(config, m_maincpu, 16000000); /* TMP68301-16 */
	m_maincpu->set_addrmap(AS_PROGRAM, &csplayh5_state::csplayh5_map);
	m_maincpu->out_parallel_callback().set(FUNC(csplayh5_state::tmp68301_parallel_port_w));

	TIMER(config, "scantimer", 0).configure_scanline(timer_device::expired_delegate(FUNC(csplayh5_state::csplayh5_irq), this), "screen", 0, 1);

#if USE_H8
	h830002_device &subcpu(H83002(config, "subcpu", DVD_CLOCK/2));    /* unknown divider */
	subcpu.set_addrmap(AS_PROGRAM, &csplayh5_state::csplayh5_sub_map);
	subcpu.set_addrmap(AS_IO, &csplayh5_state::csplayh5_sub_io_map);

	ide_controller_device &ide(IDE_CONTROLLER(config, "ide").options(ata_devices, "hdd", nullptr, true)); // dvd
	ide.irq_handler().set(FUNC(csplayh5_state::ide_irq));
#endif

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	/* video hardware */
	v9958_device &v9958(V9958(config, "v9958", XTAL(21'477'272))); // typical 9958 clock, not verified
	v9958.set_screen_ntsc("screen");
	v9958.set_vram_size(0x20000);
	v9958.int_cb().set(FUNC(csplayh5_state::csplayh5_vdp0_interrupt));
	SCREEN(config, "screen", SCREEN_TYPE_RASTER);

	/* sound hardware */
	NICHISND(config, m_nichisnd, 0);
}
IDEWidget::IDEWidget(QWidget* parent, const EntityOpenRequest& request)
		: QWidget(parent), linkBrush(QColor(Qt::blue))
{
	ui.setupUi(this);

	File file(request.getAttribute("file").toString().toLocal8Bit().constData());
	QVariant lineVariant = request.getAttribute("line");
	int selectedLine = lineVariant.isNull() ? -1 : lineVariant.toInt();

	QString content;

	istream* stream = file.openInputStream();

	char buffer[4096];
	while (!stream->eof()) {
		stream->read(buffer, sizeof(buffer)-1);
		buffer[stream->gcount()] = '\0';
		content.append(buffer);
	}

	delete stream;


	// Apply some basic syntax highlighting
	QString richContent("<pre>");
	QStringList lines = content.split('\n');
	QStringList::iterator it;

	QString keywords[] = {
			"end", "objs", "tobj", "anim", "peds", "weap", "cars", "hier", "txdp", "2dfx", "path"
	};

	for (it = lines.begin() ; it != lines.end() ; it++) {
		QString line = *it;
		QString cline = line;

		int cmtIdx = line.indexOf('#');

		if (cmtIdx != -1) {
			line.insert(cmtIdx, "<font color=\"#AAAAAA\">");
			line.append("</font>");
			cline = line.left(cmtIdx);
		}

		for (unsigned int i = 0 ; i < sizeof(keywords)/sizeof(keywords[0]) ; i++) {
			QString kw = keywords[i];
			QRegExp regex(QString("^(\\s*)(%1)(\\s*)$").arg(kw));
			cline.replace(regex, "\\1<font color=\"blue\"><b>\\2</b></font>\\3");
		}

		cline.replace(",", "<font color=\"red\">,</font>");

		if (cmtIdx != -1) {
			line.replace(0, cmtIdx, cline);
		} else {
			line = cline;
		}

		richContent.append(line).append('\n');
	}

	richContent.append("</pre>");

	ui.textEdit->setHtml(richContent);


	// Some kind of bug in QtDesigner incorrectly sets the visibility property of the headers to a rather
	// random value.
	ui.staticObjectTable->horizontalHeader()->setVisible(true);
	ui.timedObjectTable->horizontalHeader()->setVisible(true);
	ui.animationTable->horizontalHeader()->setVisible(true);
	ui.pedTable->horizontalHeader()->setVisible(true);
	ui.weaponTable->horizontalHeader()->setVisible(true);

	IDEReader ide(file);

	IDEStatement* stmt;

	while ((stmt = ide.readStatement())  !=  NULL) {
		idetype_t type = stmt->getType();

		int line = ide.getLastReadLine();

		if (type == IDETypeStaticObject) {
			IDEStaticObject* sobj = (IDEStaticObject*) stmt;
			int rc = ui.staticObjectTable->rowCount();
			ui.staticObjectTable->setRowCount(rc+1);
			ui.staticObjectTable->setItem(rc, 0, createItem(QString("%1").arg(sobj->getID())));
			ui.staticObjectTable->setItem(rc, 1, createItem(sobj->getModelName().get(), true));
			ui.staticObjectTable->setItem(rc, 2, createItem(sobj->getTXDArchiveName().get(), true));
			ui.staticObjectTable->setItem(rc, 3, createItem(QString("%1")
					.arg(sobj->getNumSubObjects())));
			ui.staticObjectTable->setItem(rc, 5, createItem(QString("%1")
					.arg(sobj->getFlags())));

			QStringList ddists;

			for (int32_t i = 0 ; i < sobj->getNumSubObjects() ; i++) {
				ddists << QString("%1").arg(sobj->getDrawDistances()[i]);
			}

			ui.staticObjectTable->setItem(rc, 4, createItem(ddists.join(", ")));

			if (line == selectedLine) {
				ui.staticObjectTable->setCurrentCell(rc, 0);
				ui.tabWidget->setCurrentWidget(ui.staticObjectWidget);
			}
		} else if (type == IDETypeTimedObject) {
			IDETimedObject* tobj = (IDETimedObject*) stmt;
			int rc = ui.timedObjectTable->rowCount();
			ui.timedObjectTable->setRowCount(rc+1);
			ui.timedObjectTable->setItem(rc, 0, createItem(QString("%1").arg(tobj->getID())));
			ui.timedObjectTable->setItem(rc, 1, createItem(tobj->getModelName().get(), true));
			ui.timedObjectTable->setItem(rc, 2, createItem(tobj->getTXDArchiveName().get(), true));
			ui.timedObjectTable->setItem(rc, 3, createItem(QString("%1")
					.arg(tobj->getNumSubObjects())));
			ui.timedObjectTable->setItem(rc, 5, createItem(QString("%1")
					.arg(tobj->getFlags())));
			ui.timedObjectTable->setItem(rc, 6, createItem(QString("%1")
					.arg(tobj->getTimeOn())));
			ui.timedObjectTable->setItem(rc, 7, createItem(QString("%1")
					.arg(tobj->getTimeOff())));

			QStringList ddists;

			for (int32_t i = 0 ; i < tobj->getNumSubObjects() ; i++) {
				ddists << QString("%1").arg(tobj->getDrawDistances()[i]);
			}

			ui.timedObjectTable->setItem(rc, 4, createItem(ddists.join(", ")));

			if (line == selectedLine) {
				ui.timedObjectTable->setCurrentCell(rc, 0);
				ui.tabWidget->setCurrentWidget(ui.timedObjectWidget);
			}
		} else if (type == IDETypeAnimation) {
			IDEAnimation* anim = (IDEAnimation*) stmt;
			int rc = ui.animationTable->rowCount();
			ui.animationTable->setRowCount(rc+1);
			ui.animationTable->setItem(rc, 0, createItem(QString("%1").arg(anim->getID())));
			ui.animationTable->setItem(rc, 1, createItem(anim->getModelName().get(), true));
			ui.animationTable->setItem(rc, 2, createItem(anim->getTXDArchiveName().get(), true));
			ui.animationTable->setItem(rc, 3, createItem(anim->getAnimationName().get()));
			ui.animationTable->setItem(rc, 4, createItem(QString("%1")
					.arg(anim->getDrawDist())));
			ui.animationTable->setItem(rc, 5, createItem(QString("%1").arg(anim->getFlags())));

			if (line == selectedLine) {
				ui.animationTable->setCurrentCell(rc, 0);
				ui.tabWidget->setCurrentWidget(ui.animationWidget);
			}
		} else if (type == IDETypePedestrian) {
			IDEPedestrian* ped = (IDEPedestrian*) stmt;
			int rc = ui.pedTable->rowCount();
			ui.pedTable->setRowCount(rc+1);
			ui.pedTable->setItem(rc, 0, createItem(QString("%1").arg(ped->getID())));
			ui.pedTable->setItem(rc, 1, createItem(ped->getModelName().get(), true));
			ui.pedTable->setItem(rc, 2, createItem(ped->getTXDArchiveName().get(), true));
			ui.pedTable->setItem(rc, 3, createItem(ped->getDefaultPedType().get()));
			ui.pedTable->setItem(rc, 4, createItem(ped->getBehavior().get()));
			ui.pedTable->setItem(rc, 5, createItem(ped->getAnimationGroup().get()));
			ui.pedTable->setItem(rc, 6, createItem(QString("%1")
					.arg(ped->getDrivableCarClasses(), 0, 16)));
			ui.pedTable->setItem(rc, 7, createItem(QString("%1").arg(ped->getFlags())));
			ui.pedTable->setItem(rc, 8, createItem(ped->getSecondaryAnimationFile().get()));
			ui.pedTable->setItem(rc, 9, createItem(QString("%1")
					.arg(ped->getPreferredRadio1())));
			ui.pedTable->setItem(rc, 10, createItem(QString("%1")
					.arg(ped->getPreferredRadio2())));
			ui.pedTable->setItem(rc, 11, createItem(ped->getVoiceFile().get()));
			ui.pedTable->setItem(rc, 12, createItem(ped->getVoice1().get()));
			ui.pedTable->setItem(rc, 13, createItem(ped->getVoice2().get()));

			if (line == selectedLine) {
				ui.pedTable->setCurrentCell(rc, 0);
				ui.tabWidget->setCurrentWidget(ui.pedWidget);
			}
		} else if (type == IDETypeWeapon) {
			IDEWeapon* weap = (IDEWeapon*) stmt;
			int rc = ui.weaponTable->rowCount();
			ui.weaponTable->setRowCount(rc+1);
			ui.weaponTable->setItem(rc, 0, createItem(QString("%1").arg(weap->getID())));
			ui.weaponTable->setItem(rc, 1, createItem(weap->getModelName().get(), true));
			ui.weaponTable->setItem(rc, 2, createItem(weap->getTXDArchiveName().get(), true));
			ui.weaponTable->setItem(rc, 3, createItem(weap->getAnimationName().get()));
			ui.weaponTable->setItem(rc, 4, createItem(QString("%1")
					.arg(weap->getObjectCount())));
			ui.weaponTable->setItem(rc, 6, createItem(QString("%1").arg(weap->getFlags())));

			QStringList ddists;

			for (int32_t i = 0 ; i < weap->getObjectCount() ; i++) {
				ddists << QString("%1").arg(weap->getDrawDistances()[i]);
			}

			ui.weaponTable->setItem(rc, 5, createItem(ddists.join(", ")));

			if (line == selectedLine) {
				ui.weaponTable->setCurrentCell(rc, 0);
				ui.tabWidget->setCurrentWidget(ui.weaponWidget);
			}
		}

		delete stmt;
	}

	ErrorLog* log = ide.getErrorLog();

	if (log->getMessageCount() > 0) {
		System* sys = System::getInstance();
		char* elem;

		sys->log(LogEntry::error(tr("Parsing errors in IDE file %1:")
				.arg(file.getPath().getFileName().get())));

		while ((elem = log->nextMessage())  !=  NULL) {
			sys->log(LogEntry::error(QString("\t%1").arg(elem)));
			delete[] elem;
		}
	}

	ui.staticObjectTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
	ui.timedObjectTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
	ui.animationTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
	ui.pedTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
	ui.weaponTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);

	connect(ui.staticObjectTable, SIGNAL(cellDoubleClicked(int, int)), this,
			SLOT(staticObjectTableCellDoubleClicked(int, int)));
	connect(ui.timedObjectTable, SIGNAL(cellDoubleClicked(int, int)), this,
			SLOT(timedObjectTableCellDoubleClicked(int, int)));
	connect(ui.animationTable, SIGNAL(cellDoubleClicked(int, int)), this,
			SLOT(animationTableCellDoubleClicked(int, int)));
	connect(ui.pedTable, SIGNAL(cellDoubleClicked(int, int)), this,
			SLOT(pedTableCellDoubleClicked(int, int)));
	connect(ui.weaponTable, SIGNAL(cellDoubleClicked(int, int)), this,
			SLOT(weaponTableCellDoubleClicked(int, int)));
}