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

45 lines
1.0 KiB
C#
Raw Normal View History

using System.IO;
2015-09-22 00:02:49 +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")]
class PXMImport : PJMImport
{
protected override void RunImport()
{
Bk2Movie movie = Result.Movie;
MiscHeaderInfo info;
2015-09-22 00:02:49 +00:00
movie.HeaderEntries.Add(HeaderKeys.PLATFORM, "PSX");
2015-09-22 00:02:49 +00:00
using (var fs = SourceFile.OpenRead())
{
using (var br = new BinaryReader(fs))
{
info = parseHeader(movie, "PXM ", br);
2015-09-22 00:02:49 +00:00
fs.Seek(info.controllerDataOffset, SeekOrigin.Begin);
2015-09-22 00:02:49 +00:00
if (info.binaryFormat)
{
parseBinaryInputLog(br, movie, info);
}
else
{
parseTextInputLog(br, movie, info);
}
}
}
2015-09-22 00:02:49 +00:00
movie.Save();
}
}
}