Пример #1
0
// returns true if Taseditor is engaged at the end of the function
bool enterTASEditor()
{
	if (taseditorWindow.hwndTASEditor)
	{
		// TAS Editor is already engaged, just set focus to its window
		if (!taseditorConfig.windowIsMaximized)
			ShowWindow(taseditorWindow.hwndTASEditor, SW_SHOWNORMAL);
		SetForegroundWindow(taseditorWindow.hwndTASEditor);
		return true;
	} else if (FCEU_IsValidUI(FCEUI_TASEDITOR))
	{
		// start TAS Editor
		// create window
		taseditorWindow.init();
		if (taseditorWindow.hwndTASEditor)
		{
			enableGeneralKeyboardInput();
			// save "eoptions"
			saved_eoptions = eoptions;
			// set "Run in background"
			eoptions |= EO_BGRUN;
			// "Set high-priority thread"
			eoptions |= EO_HIGHPRIO;
			DoPriority();
			// switch off autosaves
			saved_EnableAutosave = EnableAutosave;
			EnableAutosave = 0;
			// switch on frame_display
			saved_frame_display = frame_display;
			frame_display = 1;
			UpdateCheckedMenuItems();
			
			// init modules
			editor.init();
			pianoRoll.init();
			selection.init();
			splicer.init();
			playback.init();
			greenzone.init();
			recorder.init();
			markersManager.init();
			project.init();
			bookmarks.init();
			branches.init();
			popupDisplay.init();
			history.init();
			taseditor_lua.init();
			// either start new movie or use current movie
			if (!FCEUMOV_Mode(MOVIEMODE_RECORD|MOVIEMODE_PLAY) || currMovieData.savestate.size() != 0)
			{
				if (currMovieData.savestate.size() != 0)
					FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
				// create new movie
				FCEUI_StopMovie();
				movieMode = MOVIEMODE_TASEDITOR;
				FCEUMOV_CreateCleanMovie();
				playback.restartPlaybackFromZeroGround();
			} else
			{
				// use current movie to create a new project
				FCEUI_StopMovie();
				movieMode = MOVIEMODE_TASEDITOR;
			}
			// if movie length is less or equal to currFrame, pad it with empty frames
			if (((int)currMovieData.records.size() - 1) < currFrameCounter)
				currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1));
			// ensure that movie has correct set of ports/fourscore
			setInputType(currMovieData, getInputType(currMovieData));
			// force the input configuration stored in the movie to apply to FCEUX config
			applyMovieInputConfig();
			// reset some modules that need MovieData info
			pianoRoll.reset();
			recorder.reset();
			// create initial snapshot in history
			history.reset();
			// reset Taseditor variables
			mustCallManualLuaFunction = false;
			
			SetFocus(history.hwndHistoryList);		// set focus only once, to show blue selection cursor
			SetFocus(pianoRoll.hwndList);
			FCEU_DispMessage("TAS Editor engaged", 0);
			taseditorWindow.redraw();
			return true;
		} else
		{
			// couldn't init window
			return false;
		}
	} else
	{
		// right now TAS Editor launch is not allowed by emulator
		return true;
	}
}
Пример #2
0
///Skip may be passed in, if FRAMESKIP is #defined, to cause this to emulate more than one frame
void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int skip)
{
	//skip initiates frame skip if 1, or frame skip and sound skip if 2
	int r,ssize;

	JustFrameAdvanced = false;

	if (frameAdvanceRequested)
	{
		if (frameAdvanceDelay==0 || frameAdvanceDelay>=10)
			EmulationPaused = 3;
		if (frameAdvanceDelay==0 || frameAdvanceDelay < 10)
			frameAdvanceDelay++;
	}

	if(EmulationPaused&2)
		EmulationPaused &= ~1;        // clear paused flag temporarily (frame advance)
	else if((EmulationPaused&1))
	{
		memcpy(XBuf, XBackBuf, 256*256);
		FCEU_PutImage();
		*pXBuf=XBuf;
		*SoundBuf=WaveFinal;
		*SoundBufSize=0;

		return;
	}

	AutoFire();
	UpdateAutosave();

#ifdef _S9XLUA_H
	FCEU_LuaFrameBoundary();
#endif

	FCEU_UpdateInput();
	lagFlag = 1;

#ifdef _S9XLUA_H
	CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION);
#endif

	if(geniestage!=1) FCEU_ApplyPeriodicCheats();
	r = FCEUPPU_Loop(skip);

	if (skip != 2) ssize=FlushEmulateSound(); //If skip = 2 we are skipping sound processing

#ifdef _S9XLUA_H
	CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
#endif

#ifdef WIN32
	//These Windows only dialogs need to be updated only once per frame so they are included here
	UpdateCheatList(); // CaH4e3: can't see why, this is only cause problems with selection - adelikat: selection is only a problem when not paused, it shoudl be paused to select, we want to see the values update
	UpdateTextHooker();
	Update_RAM_Search(); // Update_RAM_Watch() is also called.
	RamChange();
	UpdateLogWindow();
	//FCEUI_AviVideoUpdate(XBuf);
	extern int KillFCEUXonFrame;
	if (KillFCEUXonFrame && (FCEUMOV_GetFrame() >= KillFCEUXonFrame))
		DoFCEUExit();
#endif

	timestampbase += timestamp;
	timestamp = 0;

	*pXBuf=skip?0:XBuf;
	if (skip == 2) //If skip = 2, then bypass sound
	{
		*SoundBuf=0;
		*SoundBufSize=0;
	}
	else
	{
		*SoundBuf=WaveFinal;
		*SoundBufSize=ssize;
	}

	if (EmulationPaused&2 && ( !frameAdvanceLagSkip || !lagFlag) )
	//Lots of conditions here.  EmulationPaused&2 must be true.  In addition frameAdvanceLagSkip or lagFlag must be false
	{
		EmulationPaused = 1;		   // restore paused flag
		JustFrameAdvanced = true;
		#ifdef WIN32
			if(soundoptions&SO_MUTEFA) //mute the frame advance if the user requested it
				*SoundBufSize=0;       //keep sound muted
		#endif

	}

	if (lagFlag)
	{
		lagCounter++;
		justLagged = true;
	}
	else justLagged = false;

	if (movieSubtitles)
		ProcessSubtitles();

#ifdef WIN32
	if(FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
		greenzone.TryDumpIncremental(lagFlag != 0);
#endif
}