Ejemplo n.º 1
0
void systemStartGamePlayback(const wxString& fname)
{
    GameArea* panel = wxGetApp().frame->GetPanel();

    if (!panel || panel->game_type() == IMAGE_UNKNOWN || !panel->emusys->emuReadState) {
        wxLogError(_("No game in progress to record"));
        return;
    }

    if (game_recording) {
        wxLogError(_("Cannot play game recording while recording"));
        return;
    }

    systemStopGamePlayback();
    wxString fn = fname;

    if (fn.size() < 4 || !wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".vmv"), false))
        fn.append(wxT(".vmv"));

    u32 version;

    if (!game_file.Open(fn.c_str(), wxT("rb")) || game_file.Read(&version, sizeof(version)) != sizeof(version) || wxUINT32_SWAP_ON_BE(version) != 1) {
        wxLogError(_("Cannot open recording file %s"), fname.c_str());
        return;
    }

    u32 gf, jp;

    if (game_file.Read(&gf, sizeof(gf)) != sizeof(gf) || game_file.Read(&jp, sizeof(jp)) != sizeof(jp)) {
        wxLogError(_("Error reading game recording"));
        game_file.Close();
        return;
    }

    game_next_frame = wxUINT32_SWAP_ON_BE(gf);
    game_next_joypad = wxUINT32_SWAP_ON_BE(jp);
    fn[fn.size() - 1] = wxT('0');

    if (!panel->emusys->emuReadState(fn.mb_fn_str())) {
        wxLogError(_("Error reading game recording"));
        game_file.Close();
        return;
    }

    game_frame = 0;
    game_joypad = 0;
    game_playback = true;
    MainFrame* mf = wxGetApp().frame;
    mf->cmd_enable &= ~(CMDEN_NGREC | CMDEN_GREC | CMDEN_NGPLAY);
    mf->cmd_enable |= CMDEN_GPLAY;
    mf->enable_menus();
}
Ejemplo n.º 2
0
void systemStopGamePlayback()
{
	if (!game_playback)
		return;

	game_file.Close();
	game_playback = false;
	MainFrame* mf = wxGetApp().frame;
	mf->cmd_enable &= ~CMDEN_GPLAY;
	mf->cmd_enable |= CMDEN_NGREC | CMDEN_NGPLAY;
	mf->enable_menus();
}
Ejemplo n.º 3
0
void systemStopGameRecording()
{
	if (!game_recording)
		return;

	if (game_file.Write(&game_frame, sizeof(game_frame)) != sizeof(game_frame) ||
	        game_file.Write(&game_joypad, sizeof(game_joypad)) != sizeof(game_joypad) ||
	        !game_file.Close())
		wxLogError(_("Error writing game recording"));

	game_recording = false;
	MainFrame* mf = wxGetApp().frame;
	mf->cmd_enable &= ~CMDEN_GREC;
	mf->cmd_enable |= CMDEN_NGREC | CMDEN_NGPLAY;
	mf->enable_menus();
}
Ejemplo n.º 4
0
void systemStartGameRecording(const wxString &fname)
{
	GameArea* panel = wxGetApp().frame->GetPanel();

	if (!panel || panel->game_type() == IMAGE_UNKNOWN ||
	        !panel->emusys->emuWriteState)
	{
		wxLogError(_("No game in progress to record"));
		return;
	}

	systemStopGamePlayback();
	wxString fn = fname;

	if (fn.size() < 4 || !wxString(fn.substr(fn.size() - 4)).IsSameAs(wxT(".vmv"), false))
		fn.append(wxT(".vmv"));

	u32 version = 1;

	if (!game_file.Open(fn.c_str(), wxT("wb")) ||
	        game_file.Write(&version, sizeof(version)) != sizeof(version))
	{
		wxLogError(_("Cannot open output file %s"), fname.c_str());
		return;
	}

	fn[fn.size() - 1] = wxT('0');

	if (!panel->emusys->emuWriteState(fn.mb_fn_str()))
	{
		wxLogError(_("Error writing game recording"));
		game_file.Close();
		return;
	}

	game_frame = 0;
	game_joypad = 0;
	game_recording = true;
	MainFrame* mf = wxGetApp().frame;
	mf->cmd_enable &= ~(CMDEN_NGREC | CMDEN_GPLAY | CMDEN_NGPLAY);
	mf->cmd_enable |= CMDEN_GREC;
	mf->enable_menus();
}
Ejemplo n.º 5
0
// return information about the given joystick, -1 for default joystick
u32 systemReadJoypad(int joy)
{
	if (joy < 0 || joy > 3)
		joy = gopts.default_stick - 1;

	uint32_t ret = joypress[joy];

	if (turbo)
		ret |= KEYM_SPEED;

	u32 af = autofire;

	if (ret & KEYM_AUTO_A)
	{
		ret |= KEYM_A;
		af |= KEYM_A;
	}

	if (ret & KEYM_AUTO_B)
	{
		ret |= KEYM_B;
		af |= KEYM_B;
	}

	static int autofire_trigger = 1;
	static bool autofire_state = true;
	u32 af_but = af & ret;

	if (af_but)
	{
		if (!autofire_state)
			ret &= ~af_but;

		if (!--autofire_trigger)
		{
			autofire_trigger = gopts.autofire_rate;
			autofire_state = !autofire_state;
		}
	}
	else
	{
		autofire_state = true;
		autofire_trigger = gopts.autofire_rate;
	}

	// disallow opposite directionals simultaneously
	ret &= ~((ret & (KEYM_LEFT | KEYM_DOWN | KEYM_MOTION_DOWN | KEYM_MOTION_RIGHT)) >> 1);
	ret &= REALKEY_MASK;

	if (game_recording)
	{
		u32 rret = ret & ~(KEYM_SPEED | KEYM_CAPTURE);

		if (rret != game_joypad)
		{
			game_joypad = rret;
			u32 gf = wxUINT32_SWAP_ON_BE(game_frame);
			u32 jp = wxUINT32_SWAP_ON_BE(game_joypad);

			if (game_file.Write(&gf, sizeof(gf)) != sizeof(gf) ||
			        game_file.Write(&jp, sizeof(jp)) != sizeof(jp))
			{
				game_file.Close();
				game_recording = false;
				wxLogError(_("Error writing game recording"));
			}
		}
	}
	else if (game_playback)
	{
		while (game_frame >= game_next_frame)
		{
			game_joypad = game_next_joypad;
			u32 gf, jp;

			if (game_file.Read(&gf, sizeof(gf)) != sizeof(gf) ||
			        game_file.Read(&jp, sizeof(jp)) != sizeof(jp))
			{
				game_file.Close();
				game_playback = false;
				wxString msg(_("Playback ended"));
				systemScreenMessage(msg);
				break;
			}

			game_next_frame = wxUINT32_SWAP_ON_BE(gf);
			game_next_joypad = wxUINT32_SWAP_ON_BE(jp);
		}

		ret = game_joypad;
	}

	return ret;
}