2015-09-21 23:47:03 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
2017-05-17 16:16:55 +00:00
|
|
|
|
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;
|
2015-09-21 23:47:03 +00:00
|
|
|
|
|
2015-09-22 21:46:59 +00:00
|
|
|
|
movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
|
2015-09-21 23:47:03 +00:00
|
|
|
|
|
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);
|
2015-09-21 23:47:03 +00:00
|
|
|
|
|
2017-05-19 18:17:07 +00:00
|
|
|
|
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
|
2015-09-21 23:47:03 +00:00
|
|
|
|
|
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-21 23:47:03 +00:00
|
|
|
|
|
2015-09-22 00:02:49 +00:00
|
|
|
|
movie.Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-21 23:47:03 +00:00
|
|
|
|
}
|