Exemplo n.º 1
0
void primo_emulator_execute ( void )
{
	int a;
	/* Save state of various things to be able to revert into EP mode later, without any data lost */
	memcpy(memory_backup, memory + 0xFA * 0x4000, MEMORY_BACKUP_SIZE);	// save memory
	memcpy(ports_backup, ports, 0x100); 	// backup ports [note: on restore, we don't want to rewrite all values, maybe only Dave/Nick!
	memcpy(&z80ex_backup, &z80ex, sizeof(Z80EX_CONTEXT));

//	memcpy();	// save Dave registers
//	memcpy();	// save Nick registers

	/* set an LPT */
	memcpy(memory + (PRIMO_LPT_SEG << 14), primo_lpt, sizeof primo_lpt);
	z80ex_pwrite_cb(0x82, (PRIMO_LPT_SEG << 10) & 0xFF);	// LPT address, low byte
	z80ex_pwrite_cb(0x83, ((PRIMO_LPT_SEG << 2) & 0xF));
	z80ex_pwrite_cb(0x83, ((PRIMO_LPT_SEG << 2) & 0xF) | 64);
	z80ex_pwrite_cb(0x83, ((PRIMO_LPT_SEG << 2) & 0xF) | 64 | 128);
	z80ex_pwrite_cb(0x81, 0);	// border color
	/* do our stuffs ... */
	z80ex_pwrite_cb(0xA7, 8 | 16);	// D/A mode for Dave audio
	for (a = 0xA8; a < 0xB0; a++)
		z80ex_pwrite_cb(a, 0);	// volumes of L/H channels
	z80ex_pwrite_cb(0xB4, 0xAA);	// disable all interrupts on Dave (z80 won't get INT but the cloned NMI directly from Nick "translated" from VINT) and reset latches
	z80ex_pwrite_cb(0xB0, PRIMO_ROM_SEG);	// first segment is the Primo ROM now
	z80ex_pwrite_cb(0xB1, PRIMO_MEM1_SEG);	// normal RAM segment
	z80ex_pwrite_cb(0xB2, PRIMO_MEM2_SEG);	// normal RAM segment
	z80ex_pwrite_cb(0xB3, PRIMO_VID_SEG);	// a video segment as the Primo video RAM
	primo_switch(128 | 64);		// turn on Primo I/O mode
	Z80_PC = 0;			// Z80 reset address to the Primo ROM
	z80ex_reset();			// reset the CPU only!!
	set_ep_cpu(CPU_Z80);		// good old Z80 NMOS CPU is selected
	set_cpu_clock(2500000);
}
Exemplo n.º 2
0
int main (int argc, char *argv[])
{
	const char *snapshot;
	atexit(shutdown_sdl);
	if (SDL_Init(
#ifdef __EMSCRIPTEN__
		// It seems there is an issue with emscripten SDL2: SDL_Init does not work if TIMER and/or HAPTIC is tried to be intialized or just "EVERYTHING" is used!!
		SDL_INIT_EVERYTHING & ~(SDL_INIT_TIMER | SDL_INIT_HAPTIC)
#else
		SDL_INIT_EVERYTHING
#endif
	) != 0) {
		ERROR_WINDOW("Fatal SDL initialization problem: %s", SDL_GetError());
		return 1;
	}
	if (config_init(argc, argv)) {
#ifdef __EMSCRIPTEN__
		ERROR_WINDOW("Error with config parsing. Please check the (javascript) console of your browser to learn about the error.");
#endif
		return 1;
	}
	guarded_exit = 1;	// turn on guarded exit, with custom de-init stuffs
	DEBUGPRINT("EMU: sleeping = \"%s\", timing = \"%s\"" NL,
		__SLEEP_METHOD_DESC, __TIMING_METHOD_DESC
	);
	fileio_init(
#ifdef __EMSCRIPTEN__
		"/",
#else
		app_pref_path,
#endif
	"files");
	if (screen_init())
		return 1;
	if (xepgui_init())
		return 1;
	audio_init(config_getopt_int("audio"));
	z80ex_init();
	set_ep_cpu(CPU_Z80);
	ep_pixels = nick_init();
	if (ep_pixels == NULL)
		return 1;
	snapshot = config_getopt_str("snapshot");
	if (strcmp(snapshot, "none")) {
		if (ep128snap_load(snapshot))
			snapshot = NULL;
	} else
		snapshot = NULL;
	if (!snapshot) {
		if (roms_load())
			return 1;
		primo_rom_seg = primo_search_rom();
		ep_set_ram_config(config_getopt_str("ram"));
	}
	mouse_setup(config_getopt_int("mousemode"));
	ep_reset();
	kbd_matrix_reset();
	joy_sdl_event(NULL); // this simply inits joy layer ...
#ifdef CONFIG_SDEXT_SUPPORT
	if (!snapshot)
		sdext_init();
#endif
#ifdef CONFIG_EXDOS_SUPPORT
	wd_exdos_reset();
	wd_attach_disk_image(config_getopt_str("wdimg"));
#endif
#ifdef CONFIG_W5300_SUPPORT
	w5300_init(NULL);
#endif
	ticks = SDL_GetTicks();
	balancer = 0;
	set_cpu_clock(DEFAULT_CPU_CLOCK);
	emu_timekeeping_start();
	audio_start();
	if (config_getopt_int("fullscreen"))
		screen_set_fullscreen(1);
	DEBUGPRINT(NL "EMU: entering into main emulation loop" NL);
	sram_ready = 1;
	if (strcmp(config_getopt_str("primo"), "none") && !snapshot) {
		// TODO: da stuff ...
		primo_emulator_execute();
		OSD("Primo Emulator Mode");
	}
	if (snapshot)
		ep128snap_set_cpu_and_io();
	console_monitor_ready();	// OK to run monitor on console now!
#ifdef __EMSCRIPTEN__
	emscripten_set_main_loop(xep128_emulation, 50, 1);
#else
	for (;;)
		xep128_emulation();
#endif
	printf("EXITING FROM main()?!" NL);
	return 0;
}