BizHawk/BizHawk.Client.Common/movie/import/PXMImport.cs

43 lines
1017 B
C#
Raw Normal View History

using System.IO;
namespace BizHawk.Client.Common.Movie.Import
2015-09-22 00:02:49 +00:00
{
// PXM files are directly compatible with binary-format PJM files, with the only
// difference being fewer flags implemented in the header, hence just calling the
// base class methods via a subclass.
//
// However, the magic number/file signature is slightly different, requiring some
// refactoring to avoid PXM-specific code in the PJMImport class.
[ImportExtension(".pxm")]
2017-05-09 18:19:55 +00:00
public class PxmImport : PjmImport
2015-09-22 00:02:49 +00:00
{
protected override void RunImport()
{
Bk2Movie movie = Result.Movie;
movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
2015-09-22 00:02:49 +00:00
using (var fs = SourceFile.OpenRead())
{
using (var br = new BinaryReader(fs))
{
2017-05-09 18:19:55 +00:00
var info = ParseHeader(movie, "PXM ", br);
2017-05-19 18:17:07 +00:00
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
2017-05-19 18:17:07 +00:00
if (info.BinaryFormat)
2015-09-22 00:02:49 +00:00
{
2017-05-09 18:19:55 +00:00
ParseBinaryInputLog(br, movie, info);
2015-09-22 00:02:49 +00:00
}
else
{
2017-05-09 18:19:55 +00:00
ParseTextInputLog(br, movie, info);
2015-09-22 00:02:49 +00:00
}
}
}
2015-09-22 00:02:49 +00:00
movie.Save();
}
}
}