예제 #1
0
파일: main.c 프로젝트: GOMF/virtbit
int main(int argc, char *argv[]) {
	if (argc <= 0)
		return -1;
	
	printf("sizeof Computer: %d\n", sizeof(struct Computer));
	
	struct Computer *computer = createComputer();
	struct Screen *screen = createScreen(640, 480, 80, 60);
	
	computer->screen = screen;
	
	loadProgram(computer, argv[1]);
	saveDump(&computer->ram, "init_dump.bin");
		
	DBG_init();
	DBG_register(&computer->cpu);
		
	run(computer);
		
	saveDump(&computer->ram, "dump.bin");
	
	DBG_free();
	
	freeComputer(computer);
		
	return 0;
}
void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
{
	if (currentState == DOWNLOADING) {
		updateState(CANCELLING);
		return;
	}
	if (currentState == DONE) {
		// this means we are retrying - so we better clean out the partial
		// list of downloaded dives from the last attempt
		diveImportedModel->clearTable();
		clear_table(&downloadTable);
	}
	updateState(DOWNLOADING);

	// you cannot cancel the dialog, just the download
	ui.cancel->setEnabled(false);
	ui.downloadCancelRetryButton->setText(tr("Cancel download"));

	auto data = thread.data();
	data->setVendor(ui.vendor->currentText());
	data->setProduct(ui.product->currentText());
#if defined(BT_SUPPORT)
	data->setBluetoothMode(ui.bluetoothMode->isChecked());
	if (data->bluetoothMode()) {
		// Get the selected device address from dialog or from preferences
		if (btDeviceSelectionDialog != NULL) {
			data->setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress());
			data->setDevBluetoothName(btDeviceSelectionDialog->getSelectedDeviceName());
		} else {
			data->setDevName(qPrefDiveComputer::device());
			data->setDevBluetoothName(qPrefDiveComputer::device_name());
		}
	} else
		// this breaks an "else if" across lines... not happy...
#endif
	if (data->vendor() == "Uemis") {
		char *colon;
		char *devname = copy_qstring(ui.device->currentText());

		if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
			*(colon + 2) = '\0';
			fprintf(stderr, "shortened devname to \"%s\"", devname);
		}
		data->setDevName(devname);
	} else {
		data->setDevName(ui.device->currentText());
	}

	data->setForceDownload(ui.forceDownload->isChecked());
	data->setCreateNewTrip(ui.createNewTrip->isChecked());
	data->setSaveLog(ui.logToFile->isChecked());
	data->setSaveDump(ui.dumpToFile->isChecked());

	qPrefDiveComputer::set_vendor(data->vendor());
	qPrefDiveComputer::set_product(data->product());
	qPrefDiveComputer::set_device(data->devName());

#if defined(BT_SUPPORT)
	qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
#endif

	// before we start, remember where the dive_table ended
	previousLast = dive_table.nr;
	thread.start();

	// FIXME: We should get the _actual_ device info instead of whatever
	// the user entered in the dropdown.
	// You can enter "OSTC 3" and download just fine from a "OSTC Sport", but
	// this check will compair apples and oranges, firmware wise, then.
	QString product(ui.product->currentText());
	//
	// We shouldn't do this for memory dumps.
	if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" ||
	     product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") &&
	    !data->saveDump()) {
		ostcFirmwareCheck = new OstcFirmwareCheck(product);
	}
}