コード例 #1
0
ファイル: calc.c プロジェクト: alberthdev/wxwabbitemu
void check_bootfree_and_update(LPCALC lpCalc) {
	u_char *bootFreeString = lpCalc->mem_c.flash + (lpCalc->mem_c.flash_pages - 1) * PAGE_SIZE + 0x0F;
	if (*bootFreeString != '1') {
		//not using bootfree
		return;
	}
	if (bootFreeString[1] == '.') {
		//using normal bootpage
		return;
	}
	if (!strcmp((const char *) bootFreeString, BOOTFREE_VER)) {
		return;
	}
#ifdef WINVER
	TCHAR hexFile[MAX_PATH];
	ExtractBootFree(lpCalc->model, hexFile);
	FILE *file;
	_tfopen_s(&file, hexFile, _T("rb"));
	writeboot(file, &lpCalc->mem_c, -1);
	fclose(file);
	_tfopen_s(&file, lpCalc->rom_path, _T("wb"));
	if (file) {
		fclose(file);
		MFILE *mfile = ExportRom(lpCalc->rom_path, lpCalc);
		mclose(mfile);
	}
#endif
}
コード例 #2
0
/*
 * Class:     com_Revsoft_Wabbitemu_CalcInterface
 * Method:    CreateRom
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
 */
JNIEXPORT jint JNICALL Java_com_Revsoft_Wabbitemu_calc_CalcInterface_CreateRom
	(JNIEnv *env, jclass classObj, jstring jOsPath, jstring jBootPath,
			jstring jRomPath, jint model) {
	checkThread();
	const char *osPath = env->GetStringUTFChars(jOsPath, JNI_FALSE);
	const char *bootPath = env->GetStringUTFChars(jBootPath, JNI_FALSE);
	const char *romPath = env->GetStringUTFChars(jRomPath, JNI_FALSE);

	//Do not allow more than one calc currently
	if (lpCalc) {
		calc_slot_free(lpCalc);
	}

	lpCalc = calc_slot_new();
	calc_init_model(lpCalc, model, NULL);

	//slot stuff
	strcpy(lpCalc->rom_path, romPath);
	lpCalc->active = TRUE;
	lpCalc->model = (CalcModel) model;
	lpCalc->cpu.pio.model = model;
	FILE *file = fopen(bootPath, "rb");
	if (file == NULL) {
		calc_slot_free(lpCalc);
		lpCalc = NULL;
		return -1;
	}
	writeboot(file, &lpCalc->mem_c, -1);
	fclose(file);
	remove(bootPath);
	TIFILE_t *tifile = importvar(osPath, FALSE);
	if (tifile == NULL) {
		calc_slot_free(lpCalc);
		lpCalc = NULL;
		return -2;
	}
	int link_error = forceload_os(&lpCalc->cpu, tifile);
	if (link_error != LERR_SUCCESS) {
		calc_slot_free(lpCalc);
		lpCalc = NULL;
		return -2;
	}

	calc_erase_certificate(lpCalc->mem_c.flash,lpCalc->mem_c.flash_size);
	calc_reset(lpCalc);
	//write the output from file
	MFILE *romfile = ExportRom((char *) romPath, lpCalc);
	if (romfile != NULL) {
		mclose(romfile);
		calc_slot_free(lpCalc);
		lpCalc = NULL;
		return 0;
	}

	calc_slot_free(lpCalc);
	lpCalc = NULL;
	return -3;
}