Ejemplo n.º 1
0
static int real_main2 (int argc, TCHAR **argv)
{

#ifdef USE_SDL
	SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);
#endif
	set_config_changed ();
	if (restart_config[0]) {
		default_prefs (&currprefs, true, 0);
		fixup_prefs (&currprefs, true);
	}

	if (! graphics_setup ()) {
		exit (1);
	}

#ifdef NATMEM_OFFSET
	//preinit_shm ();
#endif

	if (restart_config[0])
		parse_cmdline_and_init_file (argc, argv);
	else
		currprefs = changed_prefs;

	if (!machdep_init ()) {
		restart_program = 0;
		return -1;
	}

	if (console_emulation) {
		consolehook_config (&currprefs);
		fixup_prefs (&currprefs, true);
	}

	if (! setup_sound ()) {
		write_log (_T("Sound driver unavailable: Sound output disabled\n"));
		currprefs.produce_sound = 0;
	}
	inputdevice_init ();

	changed_prefs = currprefs;
	no_gui = ! currprefs.start_gui;
	if (restart_program == 2)
		no_gui = 1;
	else if (restart_program == 3)
		no_gui = 0;
	restart_program = 0;
	if (! no_gui) {
		int err = gui_init ();
		currprefs = changed_prefs;
		set_config_changed ();
		if (err == -1) {
			write_log (_T("Failed to initialize the GUI\n"));
			return -1;
		} else if (err == -2) {
			return 1;
		}
	}

	memset (&gui_data, 0, sizeof gui_data);
	gui_data.cd = -1;
	gui_data.hd = -1;
	gui_data.md = (currprefs.cs_cd32nvram || currprefs.cs_cdtvram) ? 0 : -1;
	logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded
						 a config using the cmd-line.  This case handles loads through the GUI. */

#ifdef NATMEM_OFFSET
	init_shm ();
#endif
#ifdef WITH_LUA
	uae_lua_init ();
#endif
#ifdef PICASSO96
	picasso_reset ();
#endif

#if 0
#ifdef JIT
	if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize))
		canbang = 0;
#endif
#endif

	fixup_prefs (&currprefs, true);
#ifdef RETROPLATFORM
	rp_fixup_options (&currprefs);
#endif
	changed_prefs = currprefs;
	target_run ();
	/* force sound settings change */
	currprefs.produce_sound = 0;

	savestate_init ();
	keybuf_init (); /* Must come after init_joystick */

	memory_hardreset (2);
	memory_reset ();

#ifdef AUTOCONFIG
	native2amiga_install ();
#endif
	custom_init (); /* Must come after memory_init */
#ifdef SERIAL_PORT
	serial_init ();
#endif
	DISK_init ();
#ifdef WITH_PPC
	uae_ppc_reset(true);
#endif

	reset_frame_rate_hack ();
	init_m68k (); /* must come after reset_frame_rate_hack (); */

	gui_update ();

	if (graphics_init (true)) {
		setup_brkhandler ();
		if (currprefs.start_debugger && debuggable ())
			activate_debugger ();

		if (!init_audio ()) {
			if (sound_available && currprefs.produce_sound > 1) {
				write_log (_T("Sound driver unavailable: Sound output disabled\n"));
			}
			currprefs.produce_sound = 0;
		}
		start_program ();
	}
	return 0;
}
Ejemplo n.º 2
0
static int real_main2 (int argc, TCHAR **argv)
{
#ifdef USE_SDL
	int result = (SDL_Init (SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == 0);
	if (result)
		atexit (SDL_Quit);
#endif
	set_config_changed ();
	if (restart_config[0]) {
		default_prefs (&currprefs, 0);
		fixup_prefs (&currprefs);
	}

	if (! graphics_setup ()) {
		write_log (_T("Graphics Setup Failed\n"));
		exit (1);
	}

	if (restart_config[0])
		parse_cmdline_and_init_file (argc, argv);
	else
		currprefs = changed_prefs;

//	uae_inithrtimer ();

	if (!machdep_init ()) {
		write_log (_T("Machine Init Failed.\n"));
		restart_program = 0;
		return -1;
	}

	if (console_emulation) {
		consolehook_config (&currprefs);
		fixup_prefs (&currprefs);
	}

	if (! setup_sound ()) {
		write_log (_T("Sound driver unavailable: Sound output disabled\n"));
		currprefs.produce_sound = 0;
	}
	inputdevice_init ();

	changed_prefs = currprefs;
	no_gui = ! currprefs.start_gui;

	if (restart_program == 2)
		no_gui = 1;
	else if (restart_program == 3)
		no_gui = 0;

	restart_program = 0;
	if (! no_gui && currprefs.start_gui) {
		int err = gui_init ();
		currprefs = changed_prefs;
		set_config_changed ();
		if (err == -1) {
			write_log (_T("Failed to initialize the GUI\n"));
			return -1;
		} else if (err == -2) {
			return 1;
		}
	}

	memset (&gui_data, 0, sizeof gui_data);
	gui_data.cd = -1;
	gui_data.hd = -1;
	gui_data.md = -1;

#ifdef NATMEM_OFFSET
	init_shm ();
#endif

#ifdef PICASSO96
	picasso_reset ();
#endif

	fixup_prefs (&currprefs);

#ifdef RETROPLATFORM
	rp_fixup_options (&currprefs);
#endif

	changed_prefs = currprefs;
	target_run ();
	/* force sound settings change */
	currprefs.produce_sound = 0;

	savestate_init ();
	keybuf_init (); /* Must come after init_joystick */

	memory_hardreset (2);
	memory_reset ();

#ifdef AUTOCONFIG
	native2amiga_install ();
#endif

	custom_init (); /* Must come after memory_init */

#ifdef SERIAL_PORT
	serial_init ();
#endif

	DISK_init ();

	reset_frame_rate_hack ();
	init_m68k (); /* must come after reset_frame_rate_hack (); */

	gui_update ();

	if (graphics_init ()) {

#ifdef DEBUGGER
		setup_brkhandler ();
		if (currprefs.start_debugger && debuggable ())
			activate_debugger ();
#endif

		if (!init_audio ()) {
			if (sound_available && currprefs.produce_sound > 1) {
				write_log (_T("Sound driver unavailable: Sound output disabled\n"));
			}
			currprefs.produce_sound = 0;
		}
		start_program ();
	}

	return 0;
}
Ejemplo n.º 3
0
bool my_kbd_handler (int keyboard, int scancode, int newstate)
{
	int code = 0;
	int scancode_new;
	bool amode = currprefs.input_keyboard_type == 0;
	bool special = false;
	static int swapperdrive = 0;

#if 0
	if (scancode == specialkeycode ()) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return;
	}
#endif
#if 0
	if (scancode == DIK_F1) {
		if (newstate) {
			extern int paska;
			paska++;
		}
		return;
	}
	if (scancode == DIK_F2) {
		if (newstate) {
			extern int paska;
			paska--;
		}
		return;
	}
#endif

	if (amode && scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
		code = AKS_QUIT;

	if (scancode == DIK_F9 && specialpressed ()) {
		if (newstate)
			toggle_rtg (-1);
		return true;
	}

	scancode_new = scancode;
	if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
		scancode = 0;
	
	if (newstate) {
		int defaultguikey = amode ? DIK_F12 : DIK_NUMLOCK;
		if (currprefs.win32_guikey >= 0x100) {
			if (scancode_new == DIK_F12)
				return true;
		} else if (currprefs.win32_guikey >= 0) {
			if (scancode_new == defaultguikey && currprefs.win32_guikey != scancode_new) {
				scancode = 0;
				if (specialpressed () && ctrlpressed() && shiftpressed() && altpressed ())
					inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			} else if (scancode_new == currprefs.win32_guikey ) {
				inputdevice_add_inputcode (AKS_ENTERGUI, 1);
				scancode = 0;
			}
		} else if (!specialpressed () && !ctrlpressed() && !shiftpressed() && !altpressed () && scancode_new == defaultguikey) {
			inputdevice_add_inputcode (AKS_ENTERGUI, 1);
			scancode = 0;
		}
	}

	//write_log (_T("keyboard = %d scancode = 0x%02x state = %d\n"), keyboard, scancode, newstate );

	if (newstate && code == 0 && amode) {

		switch (scancode)
		{
#if 0
		case DIK_F1:
		case DIK_F2:
		case DIK_F3:
		case DIK_F4:
			if (specialpressed ()) {
				if (ctrlpressed ()) {
				} else {
					if (shiftpressed ())
						code = AKS_EFLOPPY0 + (scancode - DIK_F1);
					else
						code = AKS_FLOPPY0 + (scancode - DIK_F1);
				}
			}
			special = true;
			break;
		case DIK_F5:
#if 0
			{
				disk_prevnext (0, -1);
				return;
				//crap++;
				//write_log (_T("%d\n"), crap);
			}
#endif
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_STATESAVEDIALOG;
				else
					code = AKS_STATERESTOREDIALOG;
			}
			special = true;
			break;
#endif

		case DIK_1:
		case DIK_2:
		case DIK_3:
		case DIK_4:
		case DIK_5:
		case DIK_6:
		case DIK_7:
		case DIK_8:
		case DIK_9:
		case DIK_0:
			if (specialpressed ()) {
				int num = scancode - DIK_1;
				if (shiftpressed ())
					num += 10;
				if (ctrlpressed ()) {
					swapperdrive = num;
					if (swapperdrive > 3)
						swapperdrive = 0;
				} else {
					int i;
					for (i = 0; i < 4; i++) {
						if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
							changed_prefs.floppyslots[i].df[0] = 0;
					}
					_tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]);
					set_config_changed ();
				}
				special = true;
			}
			break;
		case DIK_NUMPAD0:
		case DIK_NUMPAD1:
		case DIK_NUMPAD2:
		case DIK_NUMPAD3:
		case DIK_NUMPAD4:
		case DIK_NUMPAD5:
		case DIK_NUMPAD6:
		case DIK_NUMPAD7:
		case DIK_NUMPAD8:
		case DIK_NUMPAD9:
		case DIK_NUMPADPERIOD:
			if (specialpressed ()) {
				int i = 0, v = -1;
				while (np[i] >= 0) {
					v = np[i + 1];
					if (np[i] == scancode)
						break;
					i += 2;
				}
				if (v >= 0)
					code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1);
				special = true;
			}
			break;
#if 0
		case DIK_PAUSE:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_IRQ7;
				else
					code = AKS_WARP;
			} else {
				code = AKS_PAUSE;
			}
			special = true;
			break;
#if 0
		case DIK_SCROLL:
			code = AKS_INHIBITSCREEN;
			break;
#endif
		case DIK_NUMPADMINUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_DECREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLDOWN;
				else
					code = AKS_VOLDOWN;
			}
			special = true;
			break;
		case DIK_NUMPADPLUS:
			if (specialpressed ()) {
				if (shiftpressed ())
					code = AKS_INCREASEREFRESHRATE;
				else if (ctrlpressed ())
					code = AKS_MVOLUP;
				else
					code = AKS_VOLUP;
			}
			special = true;
			break;
		case DIK_NUMPADSTAR:
			if (specialpressed ()) {
				if (ctrlpressed ())
					code = AKS_MVOLMUTE;
				else
					code = AKS_VOLMUTE;
			}
			special = true;
			break;
		case DIK_NUMPADSLASH:
			if (specialpressed ())
				code = AKS_STATEREWIND;
			special = true;
			break;
#endif
		}
	}

	if (code) {
		inputdevice_add_inputcode (code, 1);
		return true;
	}


	scancode = scancode_new;
	if (!specialpressed () && newstate) {
		if (scancode == DIK_CAPITAL) {
			host_capslockstate = host_capslockstate ? 0 : 1;
			capslockstate = host_capslockstate;
		}
		if (scancode == DIK_NUMLOCK) {
			host_numlockstate = host_numlockstate ? 0 : 1;
			capslockstate = host_numlockstate;
		}
		if (scancode == DIK_SCROLL) {
			host_scrolllockstate = host_scrolllockstate ? 0 : 1;
			capslockstate = host_scrolllockstate;
		}
	}

	if (special) {
		inputdevice_checkqualifierkeycode (keyboard, scancode, newstate);
		return true;
	}

	return inputdevice_translatekeycode (keyboard, scancode, newstate) != 0;
}