Exemplo n.º 1
0
		Result Tracker::Execute
		(
			Machine& machine,
			Video::Output* const video,
			Sound::Output* const sound,
			Input::Controllers* input
		)
		{
			if (machine.Is(Api::Machine::ON))
			{
				++frame;

				try
				{
					if (machine.Is(Api::Machine::GAME))
					{
						if (rewinder)
						{
							rewinder->Execute( video, sound, input );
							return RESULT_OK;
						}
						else if (movie)
						{
							if (!movie->Execute())
							{
								StopMovie();
							}
							else if (movie->IsPlaying())
							{
								input = NULL;
							}
						}
					}

					machine.Execute( video, sound, input );
					return RESULT_OK;
				}
				catch (Result result)
				{
					return machine.PowerOff( result );
				}
				catch (const std::bad_alloc&)
				{
					return machine.PowerOff( RESULT_ERR_OUT_OF_MEMORY );
				}
				catch (...)
				{
					return machine.PowerOff( RESULT_ERR_GENERIC );
				}
			}
			else
			{
				return RESULT_ERR_NOT_READY;
			}
		}
Exemplo n.º 2
0
		Result Tracker::PlayMovie(Machine& emulator,std::istream& stream)
		{
			if (!emulator.Is(Api::Machine::GAME))
				return RESULT_ERR_NOT_READY;

			UpdateRewinderState( false );

			Result result;

			try
			{
				if (movie == NULL)
				{
					movie = new Movie
					(
						emulator,
						&Machine::LoadState,
						&Machine::SaveState,
						emulator.cpu,
						emulator.Is(Api::Machine::CARTRIDGE) ? emulator.image->GetPrgCrc() : 0
					);
				}

				if (movie->Play( stream ))
				{
					if (emulator.Is(Api::Machine::ON))
						emulator.Reset( true );

					return RESULT_OK;
				}
				else
				{
					return RESULT_NOP;
				}
			}
			catch (Result r)
			{
				result = r;
			}
			catch (const std::bad_alloc&)
			{
				result = RESULT_ERR_OUT_OF_MEMORY;
			}
			catch (...)
			{
				result = RESULT_ERR_GENERIC;
			}

			StopMovie();

			return result;
		}
Exemplo n.º 3
0
		Result Tracker::Execute
		(
			Machine& emulator,
			Video::Output* const video,
			Sound::Output* const sound,
			Input::Controllers* input
		)
		{
			if (emulator.Is(Api::Machine::ON))
			{
				++frame;

				if (emulator.Is(Api::Machine::GAME))
				{
					if (rewinder)
					{
						rewinder->Execute( video, sound, input );
						return RESULT_OK;
					}
					else if (movie)
					{
						if (!movie->Execute())
						{
							StopMovie();
						}
						else if (movie->IsPlaying())
						{
							input = NULL;
						}
					}
				}

				emulator.Execute( video, sound, input );
				return RESULT_OK;
			}
			else
			{
				return RESULT_ERR_NOT_READY;
			}
		}
Exemplo n.º 4
0
		Result Tracker::RecordMovie(Machine& emulator,std::iostream& stream,const bool append)
		{
			if (!emulator.Is(Api::Machine::GAME))
				return RESULT_ERR_NOT_READY;

			UpdateRewinderState( false );

			Result result;

			try
			{
				if (movie == NULL)
				{
					movie = new Movie
					(
						emulator,
						&Machine::LoadState,
						&Machine::SaveState,
						emulator.cpu,
						emulator.image->GetPrgCrc()
					);
				}

				return movie->Record( stream, append ) ? RESULT_OK : RESULT_NOP;
			}
			catch (Result r)
			{
				result = r;
			}
			catch (const std::bad_alloc&)
			{
				result = RESULT_ERR_OUT_OF_MEMORY;
			}
			catch (...)
			{
				result = RESULT_ERR_GENERIC;
			}

			StopMovie();

			return result;
		}