Movie Convert - started implementing an error message system, did FCM and MMV
This commit is contained in:
parent
2c683dc90a
commit
a8c66418e7
|
@ -534,7 +534,7 @@ namespace BizHawk.MultiClient
|
|||
Global.PCEControls = pceControls;
|
||||
|
||||
var nesControls = new Controller(NES.NESController);
|
||||
//nesControls.BindMulti("Reset", Global.Config.NESReset); //Let multiclient handle all resets the same
|
||||
|
||||
for (int i = 0; i < 2 /*TODO*/; i++)
|
||||
{
|
||||
nesControls.BindMulti("P" + (i + 1) + " Up", Global.Config.NESController[i].Up);
|
||||
|
@ -572,7 +572,7 @@ namespace BizHawk.MultiClient
|
|||
Global.GenControls = genControls;
|
||||
|
||||
var TI83Controls = new Controller(TI83.TI83Controller);
|
||||
TI83Controls.BindMulti("0", Global.Config.TI83Controller[0]._0); //TODO numpad 4,8,6,2 (up/down/left/right) dont work in slimdx!! wtf!!
|
||||
TI83Controls.BindMulti("0", Global.Config.TI83Controller[0]._0);
|
||||
TI83Controls.BindMulti("1", Global.Config.TI83Controller[0]._1);
|
||||
TI83Controls.BindMulti("2", Global.Config.TI83Controller[0]._2);
|
||||
TI83Controls.BindMulti("3", Global.Config.TI83Controller[0]._3);
|
||||
|
@ -668,9 +668,14 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".FCM")
|
||||
{
|
||||
//TODO: error checking of some kind and don't play on error
|
||||
LoadRom(CurrentlyOpenRom);
|
||||
StartNewMovie(MovieConvert.ConvertFCM(filePaths[0]), false);
|
||||
string error = "";
|
||||
Movie m = MovieConvert.ConvertFCM(filePaths[0], out error);
|
||||
if (error.Length > 0)
|
||||
MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
else
|
||||
StartNewMovie(m, false);
|
||||
|
||||
}
|
||||
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".SMV")
|
||||
{
|
||||
|
@ -681,9 +686,13 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".MMV")
|
||||
{
|
||||
//TODO: error checking of some kind and don't play on error
|
||||
LoadRom(CurrentlyOpenRom);
|
||||
StartNewMovie(MovieConvert.ConvertMMV(filePaths[0]), false);
|
||||
string error = "";
|
||||
Movie m = MovieConvert.ConvertMMV(filePaths[0], out error);
|
||||
if (error.Length > 0)
|
||||
MessageBox.Show(error, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
else
|
||||
StartNewMovie(m, false);
|
||||
}
|
||||
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".VBM")
|
||||
{
|
||||
|
|
|
@ -8,20 +8,25 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
public static class MovieConvert
|
||||
{
|
||||
public static Movie ConvertFCM(string path)
|
||||
public static Movie ConvertFCM(string path, out string errorMsg)
|
||||
{
|
||||
errorMsg = "";
|
||||
|
||||
try
|
||||
{
|
||||
Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY);
|
||||
|
||||
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
BinaryReader r = new BinaryReader(fs);
|
||||
//TODO: if fail to open...do some kind of error
|
||||
|
||||
byte[] signatureBytes = new byte[4];
|
||||
for (int x = 0; x < 4; x++)
|
||||
signatureBytes[x] = r.ReadByte();
|
||||
string signature = System.Text.Encoding.UTF8.GetString(signatureBytes);
|
||||
if (signature.Substring(0, 3) != "FCM")
|
||||
return null; //TODO: invalid movie type error
|
||||
{
|
||||
errorMsg = "This is not a valid FCM file!";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
UInt32 version = r.ReadUInt32();
|
||||
|
@ -107,24 +112,28 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
byte joy = r.ReadByte();
|
||||
|
||||
|
||||
//Read each byte of controller one data
|
||||
|
||||
|
||||
frame += "|";
|
||||
|
||||
r.ReadBytes(3); //Lose remaining controllers for now
|
||||
m.AppendFrame(frame);
|
||||
}
|
||||
|
||||
|
||||
//set 4 score flag if necessary
|
||||
r.Close();
|
||||
return m;
|
||||
}
|
||||
|
||||
public static Movie ConvertMMV(string path)
|
||||
catch
|
||||
{
|
||||
errorMsg = "Error opening file.";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Movie ConvertMMV(string path, out string errorMsg)
|
||||
{
|
||||
errorMsg = "";
|
||||
Movie m = new Movie(Path.ChangeExtension(path, ".tas"), MOVIEMODE.PLAY);
|
||||
|
||||
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
|
@ -135,7 +144,10 @@ namespace BizHawk.MultiClient
|
|||
signatureBytes[x] = r.ReadByte();
|
||||
string signature = System.Text.Encoding.UTF8.GetString(signatureBytes);
|
||||
if (signature != "MMV\0")
|
||||
return null; //TODO: invalid movie type error
|
||||
{
|
||||
errorMsg = "This is not a valid MMV file.";
|
||||
return null;
|
||||
}
|
||||
|
||||
UInt32 version = r.ReadUInt32();
|
||||
m.SetHeaderLine(MovieHeader.MOVIEVERSION, "Dega version " + version.ToString());
|
||||
|
@ -147,7 +159,10 @@ namespace BizHawk.MultiClient
|
|||
|
||||
UInt32 IsFromReset = r.ReadUInt32();
|
||||
if (IsFromReset == 0)
|
||||
return null; //TODO: Movies from savestate not supported error
|
||||
{
|
||||
errorMsg = "Movies that begin with a savestate are not supported.";
|
||||
return null;
|
||||
}
|
||||
|
||||
UInt32 stateOffset = r.ReadUInt32();
|
||||
UInt32 inputDataOffset = r.ReadUInt32();
|
||||
|
|
Loading…
Reference in New Issue