//the main interaction point between the emulator and the movie system.
//either dumps the current joystick state or loads one state from the movie
void FCEUMOV_AddInputState()
{
#if defined(WIN32) && !defined(DINGUX)
	if (movieMode == MOVIEMODE_TASEDITOR)
	{
		// if movie length is less or equal to currFrame, pad it with empty frames
		if (((int)currMovieData.records.size() - 1) < (currFrameCounter + 1))
			currMovieData.insertEmpty(-1, (currFrameCounter + 1) - ((int)currMovieData.records.size() - 1));

		MovieRecord* mr = &currMovieData.records[currFrameCounter];
		if (isTaseditorRecording())
		{
			// record commands and buttons
			mr->commands |= _currCommand;
			joyports[0].log(mr);
			joyports[1].log(mr);
			recordInputByTaseditor();
		}
		// replay buttons
		joyports[0].load(mr);
		joyports[1].load(mr);
		// replay commands
		if (mr->command_power())
			PowerNES();
		if (mr->command_reset())
			ResetNES();
		if (mr->command_fds_insert())
			FCEU_FDSInsert();
		if (mr->command_fds_select())
			FCEU_FDSSelect();
		if (mr->command_vs_insertcoin())
			FCEU_VSUniCoin();
		_currCommand = 0;
	} else
#endif
	if (movieMode == MOVIEMODE_PLAY)
	{
		//stop when we run out of frames
		if (currFrameCounter >= (int)currMovieData.records.size())
		{
			FinishPlayback();
			//tell all drivers to poll input and set up their logical states
			for(int port=0;port<2;port++)
				joyports[port].driver->Update(port,joyports[port].ptr,joyports[port].attrib);
			portFC.driver->Update(portFC.ptr,portFC.attrib);
		} else
		{
			MovieRecord* mr = &currMovieData.records[currFrameCounter];

			//reset and power cycle if necessary
			if(mr->command_power())
				PowerNES();
			if(mr->command_reset())
				ResetNES();
			if(mr->command_fds_insert())
				FCEU_FDSInsert();
			if(mr->command_fds_select())
				FCEU_FDSSelect();
			if (mr->command_vs_insertcoin())
				FCEU_VSUniCoin();

			joyports[0].load(mr);
			joyports[1].load(mr);
		}

		//if we are on the last frame, then pause the emulator if the player requested it
		if (currFrameCounter == currMovieData.records.size()-1)
		{
			if(FCEUD_PauseAfterPlayback())
			{
				FCEUI_ToggleEmulationPause();
			}
		}

		//pause the movie at a specified frame
		if (FCEUMOV_ShouldPause() && FCEUI_EmulationPaused()==0)
		{
			FCEUI_ToggleEmulationPause();
			FCEU_DispMessage("Paused at specified movie frame",0);
		}

	} else if (movieMode == MOVIEMODE_RECORD)
	{
		MovieRecord mr;

		joyports[0].log(&mr);
		joyports[1].log(&mr);
		mr.commands = _currCommand;
		_currCommand = 0;

		//Adelikat: in normal mode, this is done at the time of loading a savestate in read+write mode
		//If the user chooses it can be delayed to here
		if (fullSaveStateLoads && (currFrameCounter < (int)currMovieData.records.size()))
			currMovieData.truncateAt(currFrameCounter);

		mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size());	// to disk

		currMovieData.records.push_back(mr);
	}

	currFrameCounter++;

	extern uint8 joy[4];
	memcpy(&cur_input_display,joy,4);
}
Exemple #2
0
 //the main interaction point between the emulator and the movie system.
 //either dumps the current joystick state or loads one state from the movie
void MOV_AddInputState()
 {
	 if(LagFrameFlag == 1)
		 LagFrameCounter++;
	 LagFrameFlag=1;

	 if(movieMode == MOVIEMODE_PLAY)
	 {
		 //stop when we run out of frames
		 if(currFrameCounter >= (int)currMovieData.records.size())
		 {
			 StopPlayback();
		 }
		 else
		 {
			 strcpy(MovieStatusM, "Playback");

			 MovieRecord* mr = &currMovieData.records[currFrameCounter];

			 //reset if necessary
			 if(mr->command_reset())
				 PCE_Power();


			 if(mr->command_power())
				 PCE_Power();

			 NDS_setPadFromMovie(mr->pad);
		 }

		 //if we are on the last frame, then pause the emulator if the player requested it
		 if(currFrameCounter == (int)currMovieData.records.size()-1)
		 {
			 /*if(FCEUD_PauseAfterPlayback())	//TODO: Implement pause after playback?
			 {
			 FCEUI_ToggleEmulationPause();
			 }*/
		 }
	 }
	 else if(movieMode == MOVIEMODE_RECORD)
	 {
		 MovieRecord mr;
		mr.commands = _currCommand;
		_currCommand = 0;

		 strcpy(MovieStatusM, "Recording");

		 int II, I, n, s, u, r, d, l;

		 for (int i = 0; i < currMovieData.ports; i++) {

			 pcepad = pcejin.pads[i];

#define FIX(b) (b?1:0)
			 II = FIX(pcepad &(1 << 1));
			 I = FIX(pcepad & (1 << 0));
			 n = FIX(pcepad & (1 << 2));
			 s = FIX(pcepad & (1 << 3));
			 u = FIX(pcepad & (1 << 4));
			 r = FIX(pcepad & (1 << 7));
			 d = FIX(pcepad & (1 << 6));
			 l = FIX(pcepad & (1 << 5));

			 mr.pad[i] =
				 (FIX(r)<<5)|
				 (FIX(l)<<4)|
				 (FIX(u)<<7)|
				 (FIX(d)<<6)|
				 (FIX(I)<<3)|
				 (FIX(II)<<2)|
				 (FIX(s)<<1)|
				 (FIX(n)<<0);
		 }

		 mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size());
		 currMovieData.records.push_back(mr);
	 }

	 currFrameCounter++;

	 /*extern u8 joy[4];
	 memcpy(&cur_input_display,joy,4);*/
 }