Ejemplo n.º 1
0
Archivo: sdcard.c Proyecto: MEGA65/xemu
// data = D68B write
static void sdcard_mount_d81 ( Uint8 data )
{
	printf("SD/FDC mount register request @ $D68B val=$%02X at PC=$%04X" NL, data, cpu_pc);
	if ((data & 3) == 3) {
		if (d81fd >= 0)
			use_d81 = QUESTION_WINDOW("Use D81 from SD-card|Use external D81 image file", "Hypervisor mount request, and you have defined external D81 image.");
		else
			use_d81 = 0;
		if (!use_d81) {
			fdc_set_disk(1, sd_is_read_only ? 0 : QUESTION_WINDOW("Use read-only access|Use R/W access (can be dangerous, can corrupt the image!)", "Hypervisor seems to be about mounting a D81 image. You can override the access mode now."));
			printf("SD/FDC: (re-?)mounted D81 for starting sector $%02X%02X%02X%02X" NL,
				sd_d81_img1_start[3], sd_d81_img1_start[2], sd_d81_img1_start[1], sd_d81_img1_start[0]
			);
		} else {
			fdc_set_disk(1, !d81_is_read_only);
			printf("SD/FDC: mount *EXTERNAL* D81 image, not from SD card (emulator feature only)!" NL);
		}
		mounted = 1;
	} else {
		if (mounted)
			printf("SD/FDC: unmounted D81" NL);
		fdc_set_disk(0, 0);
		mounted = 0;
	}
}
Ejemplo n.º 2
0
static void __emu_one_frame(int rasters, int frameskip)
{
	SDL_Event e;
	while (SDL_PollEvent(&e) != 0)
		switch (e.type) {
			case SDL_WINDOWEVENT:
				if (!is_fullscreen && e.window.event == SDL_WINDOWEVENT_RESIZED) {
					DEBUG("UI: Window is resized to %d x %d" NL,
						e.window.data1,
						e.window.data2
					);
					screen_window_resized(e.window.data1, e.window.data2);
				}
				break;
			case SDL_QUIT:
				if (QUESTION_WINDOW("?No|!Yes", "Are you sure to exit?") == 1)
					XEMUEXIT(0);
				return;
			case SDL_KEYDOWN:
			case SDL_KEYUP:
				if (e.key.repeat == 0 && (e.key.windowID == sdl_winid || e.key.windowID == 0)) {
					int code = emu_kbd(e.key.keysym, e.key.state == SDL_PRESSED);
					if (code == 0xF9)		// // OSD REPLAY, default key GRAVE
						osd_replay(e.key.state == SDL_PRESSED ? 0 : OSD_FADE_START);
					else if (code && e.key.state == SDL_PRESSED)
						switch(code) {
#ifndef __EMSCRIPTEN__
							case 0xFF:	// FULLSCREEN toogle, default key F11
								screen_set_fullscreen(!is_fullscreen);
								break;
							case 0xFE:	// EXIT, default key F9
								if (QUESTION_WINDOW("?No|!Yes", "Are you sure to exit?") == 1)
									XEMUEXIT(0);
								break;
							case 0xFD:	// SCREENSHOT, default key F10
								screen_shot(ep_pixels, current_directory, "screenshot-*.png");
								break;
#endif
							case 0xFC:	// RESET, default key PAUSE
								if (e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
									zxemu_on = 0;
									(void)ep_init_ram();
								}
								ep_reset();
								break;
							case 0xFB:	// DOWNGRADE CPU SPEED, default key PAGE DOWN
								if (_cpu_speed_index)
									set_cpu_clock_with_osd(_cpu_speeds[-- _cpu_speed_index]);
								break;
							case 0xFA:	// UPGRADE CPU SPEED, default key PAGE UP
								if (_cpu_speed_index < 3)
									set_cpu_clock_with_osd(_cpu_speeds[++ _cpu_speed_index]);
								break;
							case 0xF8:	// CONSOLE, key pad minus
								if (!console_is_open)
									console_open_window();
								break;
						}
				} else if (e.key.repeat == 0)
					DEBUG("UI: NOT HANDLED KEY EVENT: repeat = %d windowid = %d [our win = %d]" NL, e.key.repeat, e.key.windowID, sdl_winid);
				break;
			case SDL_MOUSEMOTION:
				if (e.motion.windowID == sdl_winid)
					emu_mouse_motion(e.motion.xrel, e.motion.yrel);
				break;
			case SDL_MOUSEWHEEL:
				if (e.wheel.windowID == sdl_winid)
					emu_mouse_wheel(
						e.wheel.x, e.wheel.y,
						e.wheel.direction == SDL_MOUSEWHEEL_FLIPPED
					);
				break;
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				if (e.button.windowID == sdl_winid)
					emu_mouse_button(e.button.button, e.button.state == SDL_PRESSED);
				break;
			default:
				joy_sdl_event(&e);
				break;
		}
	if (!frameskip)
		screen_present_frame(ep_pixels);	// this should be after the event handler, as eg screenshot function needs locked texture state if this feature is used at all
	xepgui_iteration();
	monitor_process_queued();
	emu_timekeeping_delay((1000000.0 * rasters * 57.0) / (double)NICK_SLOTS_PER_SEC);
}
Ejemplo n.º 3
0
static int download_file_by_db ( const char *filename, const char *storepath )
{
	char *p;
	int i;
	if (!xemu_installer_db)
		return -1;
	strcpy(installer_store_to, storepath);
	p = xemu_installer_db;
	i = strlen(filename);
	while (*p) {
		while (*p && *p <= 32)
			p++;
		if (!strncmp(filename, p, i) && (p[i] == '\t' || p[i] == ' ')) {
			p += i + 1;
			while (*p == ' ' || *p == '\t')
				p++;
			if (*p > 32) {
				long int sizereq;
				char *q;
				if (strncasecmp(p, "http://", 7) && strncasecmp(p, "https://", 8) && strncasecmp(p, "ftp://", 6)) {
					ERROR_WINDOW("Bad download descriptor file at URL field (bar protocol) for record \"%s\"", filename);
					return -1;
				}
				q = installer_fetch_url;
				sizereq = 0;
				while (*p > 32) {
					if (sizereq == sizeof(installer_fetch_url) - 2) {
						ERROR_WINDOW("Bad download descriptor file at URL field (too long) for record \"%s\"", filename);
						return -1;
					}
					*q++ = *p++;
					sizereq++;
				}
				*q = 0;
				sizereq = strtol(p, &p, 0);
				if (*p > 32)
					sizereq = -1;
				if (sizereq > 0 && sizereq <= 4194304) {
					int ret;
					char msgbuffer[sizeof(installer_fetch_url) + 256];
					if (legal_warning) {
						INFO_WINDOW("Legal-warning blah-blah ...");
						legal_warning = 0;
					}
					sprintf(msgbuffer, "Downloading file \"%s\". Do you agree?\nSource: %s", filename, installer_fetch_url);
					if (QUESTION_WINDOW("YES|NO", msgbuffer))
						return -1;
					ret = download_file(sizereq);
					if (!ret)
						INFO_WINDOW("File %s seems to be downloaded nicely with %s", filename, *downloader_utility_spec_start_p);
					return ret;
				} else {
					ERROR_WINDOW("Bad download descriptor file at size field for record \"%s\" (or this file is not auto-installable)", filename);
					return -1;
				}
			}
		}
		while (*p && *p != '\n' && *p != '\r')
			p++;
	}
	DEBUGPRINT("INSTALLER: file-key %s cannot be found in the download description file" NL, filename);
	return -1;
}