Esempio n. 1
0
gint display_import_romversion_dbox(void)
{
    const gchar *filename;
	char *dstname;
	int err;
    
    // get filename
	filename = create_fsel(inst_paths.base_dir, NULL, "*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE);
	if (!filename)
		return 0;

    if(ti68k_is_a_rom_file(filename))
	{
		err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname);
		handle_error();
		g_free(dstname);
	}
	else if(ti68k_is_a_tib_file(filename))
	{
		// fake rom
		err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname);
		handle_error();
		g_free(dstname);
	}

    return 0;
}
Esempio n. 2
0
gint display_import_romversion_dbox(void)
{
    const gchar *filename;
	char *dstname;
	int err;
    
    // get filename
	filename = create_fsel(inst_paths.base_dir, NULL, "*.rom;*.89u;*.9xu;*.v2u;*.tib", FALSE);
	if (!filename)
		return 0;

    if(ti68k_is_a_rom_file(filename))
	{
		err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname);
		handle_error();
		g_free(dstname);
	}
	else if(ti68k_is_a_tib_file(filename))
	{
		IMG_INFO infos = { 0 };
		int err = ti68k_get_tib_infos(filename, &infos, 0);
		int hw_type = HW2;

		if(infos.calc_type == TI92p || infos.calc_type == TI89)
		{
			int ret = msg_box3(_("HW type"), 
				_("The FLASH upgrade can be imported as HW1 or HW2. Please choose..."), 
				"HW1", "HW2", "Default");
			if(ret == BUTTON1)
				hw_type = HW1;
			else if(ret == BUTTON2)
				hw_type = HW2;
		}

		// fake rom
		err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type);
		handle_error();
		g_free(dstname);
	}

    return 0;
}
Esempio n. 3
0
gint display_set_tib_dbox(void)
{
    const gchar *filename;
	gchar *path, *name;
	int err;

    // get filename
	filename = create_fsel(inst_paths.base_dir, NULL, (char *)"*.89u;*.9xu;*.v2u;*.tib", FALSE);
	if (!filename)
		return 0;

	if(!ti68k_is_a_tib_file(filename))
	{
		msg_box1(_("Error"), _("Does not seem to be an upgrade."));
		return -1;
	}

	path = g_path_get_dirname(filename);
	name = g_path_get_basename(filename);

	// set tib file
	g_free(params.tib_file);
	params.tib_file = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
	g_free(path); g_free(name);

	err = ti68k_load_upgrade(params.tib_file);
	handle_error();
	if(err)
	{
		msg_box1(_("Error"), _("Cannot load the upgrade."));
		return -1;
	}

	// update ROM calls list
	dbgromcall_refresh_window();

    // simply reset, don't restart
    ti68k_reset();

    return 0;
}
Esempio n. 4
0
gint display_set_tib_dbox(void)
{
    const gchar *filename;
	gchar *path, *name;
	int err;

    // get filename
	filename = create_fsel(inst_paths.base_dir, NULL, "*.89u;*.9xu;*.v2u;*.tib", FALSE);
	if (!filename)
		return 0;

	if(!ti68k_is_a_tib_file(filename))
	{
		msg_box("Error", "Don't seem to be an upgrade.");
		return -1;
	}

	path = g_path_get_dirname(filename);
	name = g_path_get_basename(filename);

	// set tib file
	g_free(params.tib_file);
	params.tib_file = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
	g_free(path); g_free(name);

	err = ti68k_load_upgrade(params.tib_file);
	handle_error();
	if(err)
	{
		msg_box("Error", "Can not load the upgrade.");
		return -1;
	}
    
    //msg_box(_("Information"), _("Your configuration has been saved."));
    //rcfile_write();

    // simply reset, don't restart
    ti68k_reset();

    return 0;
}
Esempio n. 5
0
/*
  Scan the command line, extract arguments and init variables
*/
int scan_cmdline(int argc, char **argv)
{
	int cnt;
	char *p;
	char msg[80];

	int import = 0;
	char *rom = NULL;
	char *tib = NULL;
	char *sav = NULL;
	char *fn = NULL;

	//for(cnt = 0; cnt < argc; cnt++)
	//	fprintf(stdout, "%i: [%s]\n", cnt, argv[cnt]);
  
	/* Parses list of arguments */
	for(cnt=1; cnt<argc; cnt++) 
	{
		p = argv[cnt];

#ifdef __WIN32__
		if(!stricmp(p, "/RegServer") || !stricmp(p, "-RegServer")
		   || !stricmp(p, "--RegServer")) {
			char *p;
			ITypeLib *tlb;
			char szModule[512];
			wchar_t tlbname[512];
			HMODULE hModule = GetModuleHandle(NULL);
			DWORD dwResult = GetModuleFileName(hModule, szModule, sizeof(szModule));

			if (!dwResult) exit(1);
			p = szModule + strlen(szModule) - 4;

			if (stricmp(p,".exe")) exit(1);
			strcpy(++p,"tlb");
			mbstowcs(tlbname, szModule, strlen(szModule)+1);

			if (RegisterServer(&CLSID_TiEmuOLE,
			                   "TiEmu OLE Interface",
			                   "TiEmu.TiEmuOLE",
			                   "TiEmu.TiEmuOLE.1", NULL)
			    || LoadTypeLib(tlbname, &tlb))
				exit(1);
			else {
				if (RegisterTypeLib(tlb, tlbname, NULL)) {
					tlb->lpVtbl->Release(tlb);
					exit(1);
				} else {
					tlb->lpVtbl->Release(tlb);
					fprintf(stdout, "TiEmu OLE Interface successfully registered.");
					exit(0);
				}
			}
		}

		if(!stricmp(p, "/UnregServer") || !stricmp(p, "-UnregServer")
		   || !stricmp(p, "--UnregServer")) {
			if (UnregisterServer(&CLSID_TiEmuOLE, "TiEmu.TiEmuOLE",
			                     "TiEmu.TiEmuOLE.1")
			    || UnRegisterTypeLib(&LIBID_TiEmuOLELib, 1, 0, 0,
			                         SYS_WIN32))
				exit(1);
			else {
				fprintf(stdout, "TiEmu OLE Interface successfully unregistered.");
				exit(0);
			}
		}
		if(!stricmp(p, "/Embedding") || !stricmp(p, "-Embedding")
		   || !stricmp(p, "--Embedding")) {
			// VB runs it with this option.
			continue;
		}
#endif

		if(*p == '-') 
		{
			// a long option (like --help)
			p++;
		} else 
		{
			fn = g_strdup(p);
			// a filename
			//g_free(params.rom_file);
			//params.rom_file = g_strdup(p);
		}
		strcpy(msg, p);

		if(strexact(msg, "-import")) 
			import = !0;

		if(strstr(msg, "rom="))
			rom = g_strdup(msg + 4);

		if(strstr(msg, "tib="))
			tib = g_strdup(msg + 4);

		if(strstr(msg, "sav=")) 
			sav = g_strdup(msg + 4);

		if(strstr(msg, "send="))
			file_to_send = g_strdup(msg + 5);
	      
		if(strexact(msg, "-help") || strexact(msg, "h")) 
			help();

		if(strexact(msg, "-version") || strexact(msg, "v")) 
			exit(0);
	}

	/* */
	if(fn && ti68k_is_a_rom_file(fn))
		rom = fn;
	else if(fn && ti68k_is_a_tib_file(fn))
		tib = fn;
	else if(fn && ti68k_is_a_sav_file(fn))
		sav = fn;

	/* And process them */
	if(rom && ti68k_is_a_rom_file(rom))
	{
		gchar *dstname;

		int err = ti68k_convert_rom_to_image(rom, inst_paths.img_dir, &dstname);
		if(err) 
		{
			tiemu_err(err, NULL);
			exit(-1);
		}

		if(import)
			exit(0);

		g_free(params.rom_file);
		params.rom_file = dstname;
		g_free(params.sav_file);
		params.sav_file = g_strdup("");
	}

	if(tib && ti68k_is_a_tib_file(tib))
	{
		gchar *dstname;

		int err = ti68k_convert_tib_to_image(tib, inst_paths.img_dir, &dstname, -1);
		if(err) 
		{
			tiemu_err(err, NULL);
			exit(-1);
		}

		if(import)
			exit(0);

		g_free(params.rom_file);
		params.rom_file = dstname;
		g_free(params.sav_file);
		params.sav_file = g_strdup("");
	 }

	if(sav && !fn)						// for compatibility
	{
		g_free(params.sav_file);
		params.sav_file = g_strdup(sav);
	}

	if(sav && ti68k_is_a_sav_file(sav) && fn)
	{
		gchar *rf, *tf;

		ti68k_state_parse(sav, &rf, &tf);
		
		if(!ti68k_is_a_img_file(rf))
			return 0;

		g_free(params.rom_file);
		params.rom_file = rf;

        g_free(params.tib_file);
		params.tib_file = tf;

		g_free(params.sav_file);
		params.sav_file = g_strdup(sav);
	}

	return 0;
}
Esempio n. 6
0
int import_romversion(const char *filename)
{
	char *dstname;
	int err;

	if(ti68k_is_a_rom_file(filename))
	{
		err = ti68k_convert_rom_to_image(filename, inst_paths.img_dir, &dstname);
		handle_error();
		g_free(dstname);
	}
	else if(ti68k_is_a_tib_file(filename))
	{
		#ifdef _MSC_VER
		IMG_INFO infos = {0};
		#else
		IMG_INFO infos = {};
		#endif
		int hw_type = HW2;

		err = ti68k_get_tib_infos(filename, &infos, 0);
		handle_error();
 
		if (!err)
		{
			if(infos.calc_type == TI92p || infos.calc_type == TI89)
			{
				int ret = msg_box3(_("HW type"), 
					_("The FLASH upgrade can be imported as HW1 or HW2. Please choose..."), 
					"HW1", "HW2", "Default");
				if(ret == BUTTON1)
					hw_type = HW1;
				else if(ret == BUTTON2)
					hw_type = HW2;
			}
			else if(infos.calc_type == TI89t)
			{
				int ret = msg_box3(_("HW type"), 
					_("The FLASH upgrade can be imported as HW3 or HW4. Please choose..."), 
					"HW3", "HW4", "Default");

				hw_type = HW3; // default is HW3 for the Titanium, there's no Titanium HW2

				if(ret == BUTTON1)
					hw_type = HW3;
				else if(ret == BUTTON2)
					hw_type = HW4;
			}
		}

		// fake rom
		err = ti68k_convert_tib_to_image(filename, inst_paths.img_dir, &dstname, hw_type);
		handle_error();
		g_free(dstname);
	}
	else
	{
		msg_box1(_("Error"), _("This is not a valid file"));
		return -1;
	}

	return 0;
}
Esempio n. 7
0
/*
  Scan the command line, extract arguments and init variables
*/
int scan_cmdline(int argc, char **argv)
{
	int cnt;
	char *p;
	char *q;
	char msg[80];
	gchar *dstname;
	int import = 0;
  
	for(cnt=1; cnt<argc; cnt++) 
	{
		p = argv[cnt];

		if(*p == '-' ) 
		{
			// a long option (like --help)
			p++;
		} else 
		{
			// an image to load
			g_free(params.rom_file);
			params.rom_file = g_strdup(p);
		}

		strcpy(msg, p);

		if(strexact(msg, "-import")) 
			import = !0;
      
	    if(strstr(msg, "rom=") || strstr(msg, "tib="))
		{	
			q=msg+4;

			if(ti68k_is_a_rom_file(q))
			{
				int err = ti68k_convert_rom_to_image(q, inst_paths.img_dir, &dstname);
				if(err) 
				{
					tiemu_error(err, NULL);
					exit(-1);
				}

				if(import)
					exit(0);

				g_free(params.rom_file);
				params.rom_file = dstname;
				g_free(params.sav_file);
				params.sav_file = g_strdup("");
			}
			else if(ti68k_is_a_tib_file(q))
			{
				int err = ti68k_convert_tib_to_image(q, inst_paths.img_dir, &dstname);
				if(err) 
				{
					tiemu_error(err, NULL);
					exit(-1);
				}

				if(import)
					exit(0);

				g_free(params.rom_file);
				params.rom_file = dstname;
				g_free(params.sav_file);
				params.sav_file = g_strdup("");
			}
			else
				exit(-1);
		}

		if(strstr(msg, "sav=")) 
		{
			q=msg+4;
			g_free(params.sav_file);
			params.sav_file = g_strdup(p);
		}
	      
		if(strexact(msg, "-help") || strexact(msg, "h")) 
			help();

	    if(strexact(msg, "-version") || strexact(msg, "v")) 
		{ 
			//version(); 
			exit(0); 
		}
	}

	return 0;
}
Esempio n. 8
0
/*
    Search for ROM dumps or FLASH upgrades in a given directory 
	and converts them into images (note: original file is deleted !).
*/
int ti68k_scan_files(const char *src_dir, const char *dst_dir, int erase)
{
    GDir *dir;
	GError *error = NULL;
	G_CONST_RETURN gchar *dirent;
    gchar *path;
    int ret;
    gchar *dstname;

    // Search for  files and convert them
	dir = g_dir_open(src_dir, 0, &error);
	if (dir == NULL) 
	{
		tiemu_warning(_("Opendir error"));
      	return ERR_CANT_OPEN_DIR;
	}

    while ((dirent = g_dir_read_name(dir)) != NULL) 
	{
  		if (dirent[0] == '.') 
  			continue;

        path = g_strconcat(src_dir, dirent, NULL);

        if(ti68k_is_a_rom_file(path))
        {
            ret = ti68k_convert_rom_to_image(path, dst_dir, &dstname);
			if(ret)
				{
					g_free(dstname);
					g_free(path);
					return ret;
						}

            if(erase)
                unlink(path);

            g_free(dstname);
        }

		if(ti68k_is_a_tib_file(path))
        {
            ret = ti68k_convert_tib_to_image(path, dst_dir, &dstname, -1);
			if(ret)
				{
					g_free(dstname);
					g_free(path);
				return ret;
					}

            if(erase)
                unlink(path);

            g_free(dstname);
        }

        g_free(path);
    }

    g_dir_close(dir);

    return 0;
}