move bkm files to the import folder now that they are only used for import

This commit is contained in:
adelikat 2019-12-21 12:55:57 -06:00
parent c127d92296
commit 8ac53f51c0
5 changed files with 1140 additions and 1140 deletions

View File

@ -208,10 +208,10 @@
<Compile Include="movie\bk2\Bk2Movie.ModeApi.cs"> <Compile Include="movie\bk2\Bk2Movie.ModeApi.cs">
<DependentUpon>Bk2Movie.cs</DependentUpon> <DependentUpon>Bk2Movie.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="movie\bkm\BkmControllerAdapter.cs" /> <Compile Include="movie\import\bkm\BkmControllerAdapter.cs" />
<Compile Include="movie\bkm\BkmHeader.cs" /> <Compile Include="movie\import\bkm\BkmHeader.cs" />
<Compile Include="movie\bkm\BkmMnemonicConstants.cs" /> <Compile Include="movie\import\bkm\BkmMnemonicConstants.cs" />
<Compile Include="movie\bkm\BkmMovie.cs" /> <Compile Include="movie\import\bkm\BkmMovie.cs" />
<Compile Include="movie\conversions\MovieConversionExtensions.cs" /> <Compile Include="movie\conversions\MovieConversionExtensions.cs" />
<Compile Include="movie\HeaderKeys.cs" /> <Compile Include="movie\HeaderKeys.cs" />
<Compile Include="movie\import\Fm2Import.cs" /> <Compile Include="movie\import\Fm2Import.cs" />

View File

@ -1,118 +1,118 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal class BkmHeader : Dictionary<string, string> internal class BkmHeader : Dictionary<string, string>
{ {
public BkmHeader() public BkmHeader()
{ {
Comments = new List<string>(); Comments = new List<string>();
Subtitles = new SubtitleList(); Subtitles = new SubtitleList();
this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion(); this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : ""; this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : "";
this[HeaderKeys.GAMENAME] = ""; this[HeaderKeys.GAMENAME] = "";
this[HeaderKeys.AUTHOR] = ""; this[HeaderKeys.AUTHOR] = "";
this[HeaderKeys.RERECORDS] = "0"; this[HeaderKeys.RERECORDS] = "0";
} }
public List<string> Comments { get; } public List<string> Comments { get; }
public SubtitleList Subtitles { get; } public SubtitleList Subtitles { get; }
public string SavestateBinaryBase64Blob public string SavestateBinaryBase64Blob
{ {
get get
{ {
if (ContainsKey(HeaderKeys.SAVESTATEBINARYBASE64BLOB)) if (ContainsKey(HeaderKeys.SAVESTATEBINARYBASE64BLOB))
{ {
return this[HeaderKeys.SAVESTATEBINARYBASE64BLOB]; return this[HeaderKeys.SAVESTATEBINARYBASE64BLOB];
} }
return null; return null;
} }
set set
{ {
if (value == null) if (value == null)
{ {
Remove(HeaderKeys.SAVESTATEBINARYBASE64BLOB); Remove(HeaderKeys.SAVESTATEBINARYBASE64BLOB);
} }
else else
{ {
Add(HeaderKeys.SAVESTATEBINARYBASE64BLOB, value); Add(HeaderKeys.SAVESTATEBINARYBASE64BLOB, value);
} }
} }
} }
public new string this[string key] public new string this[string key]
{ {
get => ContainsKey(key) ? base[key] : ""; get => ContainsKey(key) ? base[key] : "";
set set
{ {
if (ContainsKey(key)) if (ContainsKey(key))
{ {
base[key] = value; base[key] = value;
} }
else else
{ {
Add(key, value); Add(key, value);
} }
} }
} }
public new void Clear() public new void Clear()
{ {
Comments.Clear(); Comments.Clear();
Subtitles.Clear(); Subtitles.Clear();
base.Clear(); base.Clear();
} }
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var kvp in this) foreach (var kvp in this)
{ {
sb sb
.Append(kvp.Key) .Append(kvp.Key)
.Append(' ') .Append(' ')
.Append(kvp.Value) .Append(kvp.Value)
.AppendLine(); .AppendLine();
} }
sb.Append(Subtitles); sb.Append(Subtitles);
Comments.ForEach(comment => sb.AppendLine(comment)); Comments.ForEach(comment => sb.AppendLine(comment));
return sb.ToString(); return sb.ToString();
} }
public bool ParseLineFromFile(string line) public bool ParseLineFromFile(string line)
{ {
if (!string.IsNullOrWhiteSpace(line)) if (!string.IsNullOrWhiteSpace(line))
{ {
var splitLine = line.Split(new[] { ' ' }, 2); var splitLine = line.Split(new[] { ' ' }, 2);
if (HeaderKeys.Contains(splitLine[0]) && !ContainsKey(splitLine[0])) if (HeaderKeys.Contains(splitLine[0]) && !ContainsKey(splitLine[0]))
{ {
Add(splitLine[0], splitLine[1]); Add(splitLine[0], splitLine[1]);
} }
else if (line.StartsWith("subtitle") || line.StartsWith("sub")) else if (line.StartsWith("subtitle") || line.StartsWith("sub"))
{ {
Subtitles.AddFromString(line); Subtitles.AddFromString(line);
} }
else if (line.StartsWith("comment")) else if (line.StartsWith("comment"))
{ {
Comments.Add(line.Substring(8, line.Length - 8)); Comments.Add(line.Substring(8, line.Length - 8));
} }
else if (line.StartsWith("|")) else if (line.StartsWith("|"))
{ {
return false; return false;
} }
} }
return true; return true;
} }
} }
} }

View File

@ -1,237 +1,237 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal static class BkmMnemonicConstants internal static class BkmMnemonicConstants
{ {
public static readonly Dictionary<string, Dictionary<string, string>> Buttons = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Buttons = new Dictionary<string, Dictionary<string, string>>
{ {
{ {
"Gameboy Controller", new Dictionary<string, string> "Gameboy Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" }
} }
}, },
{ {
"Lynx Controller", new Dictionary<string, string> "Lynx Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "A", "A" }
} }
}, },
{ {
"GBA Controller", new Dictionary<string, string> "GBA Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" }, { "L", "L" }, { "R", "R" } { "A", "A" }, { "L", "L" }, { "R", "R" }
} }
}, },
{ {
"Genesis 3-Button Controller", new Dictionary<string, string> "Genesis 3-Button Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Start", "S" }, { "A", "A" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Start", "S" }, { "A", "A" }, { "B", "B" },
{ "C", "C" } { "C", "C" }
} }
}, },
{ {
"GPGX Genesis Controller", new Dictionary<string, string> "GPGX Genesis Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "C", "C" },
{ "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "Mode", "M" } { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "Mode", "M" }
} }
}, },
{ {
"GPGX 3-Button Controller", new Dictionary<string, string> "GPGX 3-Button Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "A", "A" }, { "B", "B" },
{ "C", "C" }, { "Start", "S" }, { "C", "C" }, { "Start", "S" },
} }
}, },
{ {
"NES Controller", new Dictionary<string, string> "NES Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" } { "A", "A" }
} }
}, },
{ {
"SNES Controller", new Dictionary<string, string> "SNES Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Start", "S" }, { "B", "B" },
{ "A", "A" }, { "X", "X" }, { "Y", "Y" }, { "L", "L" }, { "R", "R" } { "A", "A" }, { "X", "X" }, { "Y", "Y" }, { "L", "L" }, { "R", "R" }
} }
}, },
{ {
"PC Engine Controller", new Dictionary<string, string> "PC Engine Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Run", "r" }, { "B2", "2" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Select", "s" }, { "Run", "r" }, { "B2", "2" },
{ "B1", "1" } { "B1", "1" }
} }
}, },
{ {
"SMS Controller", new Dictionary<string, string> "SMS Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "B1", "1" }, { "B2", "2" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "B1", "1" }, { "B2", "2" }
} }
}, },
{ {
"TI83 Controller", new Dictionary<string, string> "TI83 Controller", new Dictionary<string, string>
{ {
{ "0", "0" }, { "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" }, { "5", "5" }, { "6", "6" }, { "7", "7" }, { "0", "0" }, { "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" }, { "5", "5" }, { "6", "6" }, { "7", "7" },
{ "8", "8" }, { "9", "9" }, { "DOT", "`" }, { "ON", "O" }, { "ENTER", "=" }, { "UP", "U" }, { "DOWN", "D" }, { "8", "8" }, { "9", "9" }, { "DOT", "`" }, { "ON", "O" }, { "ENTER", "=" }, { "UP", "U" }, { "DOWN", "D" },
{ "LEFT", "L" }, { "RIGHT", "R" }, { "PLUS", "+" }, { "MINUS", "_" }, { "MULTIPLY", "*" }, { "DIVIDE", "/" }, { "LEFT", "L" }, { "RIGHT", "R" }, { "PLUS", "+" }, { "MINUS", "_" }, { "MULTIPLY", "*" }, { "DIVIDE", "/" },
{ "CLEAR", "c" }, { "EXP", "^" }, { "DASH", "-" }, { "PARAOPEN", "(" }, { "PARACLOSE", ")" }, { "TAN", "T" }, { "CLEAR", "c" }, { "EXP", "^" }, { "DASH", "-" }, { "PARAOPEN", "(" }, { "PARACLOSE", ")" }, { "TAN", "T" },
{ "VARS", "V" }, { "COS", "C" }, { "PRGM", "P" }, { "STAT", "s" }, { "MATRIX", "m" }, { "X", "X" }, { "STO", ">" }, { "VARS", "V" }, { "COS", "C" }, { "PRGM", "P" }, { "STAT", "s" }, { "MATRIX", "m" }, { "X", "X" }, { "STO", ">" },
{ "LN", "n" }, { "LOG", "L" }, { "SQUARED", "2" }, { "NEG1", "1" }, { "MATH", "H" }, { "ALPHA", "A" }, { "LN", "n" }, { "LOG", "L" }, { "SQUARED", "2" }, { "NEG1", "1" }, { "MATH", "H" }, { "ALPHA", "A" },
{ "GRAPH", "G" }, { "TRACE", "t" }, { "ZOOM", "Z" }, { "WINDOW", "W" }, { "Y", "Y" }, { "2ND", "&" }, { "MODE", "O" }, { "GRAPH", "G" }, { "TRACE", "t" }, { "ZOOM", "Z" }, { "WINDOW", "W" }, { "Y", "Y" }, { "2ND", "&" }, { "MODE", "O" },
{ "DEL", "D" }, { "COMMA", "," }, { "SIN", "S" } { "DEL", "D" }, { "COMMA", "," }, { "SIN", "S" }
} }
}, },
{ {
"Atari 2600 Basic Controller", new Dictionary<string, string> "Atari 2600 Basic Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
} }
}, },
{ {
"Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Trigger", "1" }, { "Trigger 2", "2" }
} }
}, },
{ {
"Commodore 64 Controller", new Dictionary<string, string> "Commodore 64 Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" } { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Button", "B" }
} }
}, },
{ {
"Commodore 64 Keyboard", new Dictionary<string, string> "Commodore 64 Keyboard", new Dictionary<string, string>
{ {
{ "Key F1", "1" }, { "Key F3", "3" }, { "Key F5", "5" }, { "Key F7", "7" }, { "Key F1", "1" }, { "Key F3", "3" }, { "Key F5", "5" }, { "Key F7", "7" },
{ "Key Left Arrow", "l" }, { "Key 1", "1" }, { "Key 2", "2" }, { "Key 3", "3" }, { "Key 4", "4" }, { "Key 5", "5" }, { "Key 6", "6" }, { "Key 7", "7" }, { "Key 8", "8" }, { "Key 9", "9" }, { "Key 0", "0" }, { "Key Plus", "+" }, { "Key Minus", "-" }, { "Key Pound", "l" }, { "Key Clear/Home", "c" }, { "Key Insert/Delete", "i" }, { "Key Left Arrow", "l" }, { "Key 1", "1" }, { "Key 2", "2" }, { "Key 3", "3" }, { "Key 4", "4" }, { "Key 5", "5" }, { "Key 6", "6" }, { "Key 7", "7" }, { "Key 8", "8" }, { "Key 9", "9" }, { "Key 0", "0" }, { "Key Plus", "+" }, { "Key Minus", "-" }, { "Key Pound", "l" }, { "Key Clear/Home", "c" }, { "Key Insert/Delete", "i" },
{ "Key Control", "c" }, { "Key Q", "Q" }, { "Key W", "W" }, { "Key E", "E" }, { "Key R", "R" }, { "Key T", "T" }, { "Key Y", "Y" }, { "Key U", "U" }, { "Key I", "I" }, { "Key O", "O" }, { "Key P", "P" }, { "Key At", "@" }, { "Key Asterisk", "*" }, { "Key Up Arrow", "u" }, { "Key Restore", "r" }, { "Key Control", "c" }, { "Key Q", "Q" }, { "Key W", "W" }, { "Key E", "E" }, { "Key R", "R" }, { "Key T", "T" }, { "Key Y", "Y" }, { "Key U", "U" }, { "Key I", "I" }, { "Key O", "O" }, { "Key P", "P" }, { "Key At", "@" }, { "Key Asterisk", "*" }, { "Key Up Arrow", "u" }, { "Key Restore", "r" },
{ "Key Run/Stop", "s" }, { "Key Lck", "k" }, { "Key A", "A" }, { "Key S", "S" }, { "Key D", "D" }, { "Key F", "F" }, { "Key G", "G" }, { "Key H", "H" }, { "Key J", "J" }, { "Key K", "K" }, { "Key L", "L" }, { "Key Colon", ":" }, { "Key Semicolon", ";" }, { "Key Equal", "=" }, { "Key Return", "e" }, { "Key Run/Stop", "s" }, { "Key Lck", "k" }, { "Key A", "A" }, { "Key S", "S" }, { "Key D", "D" }, { "Key F", "F" }, { "Key G", "G" }, { "Key H", "H" }, { "Key J", "J" }, { "Key K", "K" }, { "Key L", "L" }, { "Key Colon", ":" }, { "Key Semicolon", ";" }, { "Key Equal", "=" }, { "Key Return", "e" },
{ "Key Commodore", "o" }, { "Key Left Shift", "s" }, { "Key Z", "Z" }, { "Key X", "X" }, { "Key C", "C" }, { "Key V", "V" }, { "Key B", "B" }, { "Key N", "N" }, { "Key M", "M" }, { "Key Comma", "," }, { "Key Period", ">" }, { "Key Slash", "/" }, { "Key Right Shift", "s" }, { "Key Cursor Up/Down", "u" }, { "Key Cursor Left/Right", "l" }, { "Key Commodore", "o" }, { "Key Left Shift", "s" }, { "Key Z", "Z" }, { "Key X", "X" }, { "Key C", "C" }, { "Key V", "V" }, { "Key B", "B" }, { "Key N", "N" }, { "Key M", "M" }, { "Key Comma", "," }, { "Key Period", ">" }, { "Key Slash", "/" }, { "Key Right Shift", "s" }, { "Key Cursor Up/Down", "u" }, { "Key Cursor Left/Right", "l" },
{ "Key Space", "_" } { "Key Space", "_" }
} }
}, },
{ {
"ColecoVision Basic Controller", new Dictionary<string, string> "ColecoVision Basic Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "L", "l" }, { "R", "r" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "L", "l" }, { "R", "r" },
{ "Key1", "1" }, { "Key2", "2" }, { "Key3", "3" }, { "Key4", "4" }, { "Key5", "5" }, { "Key6", "6" }, { "Key1", "1" }, { "Key2", "2" }, { "Key3", "3" }, { "Key4", "4" }, { "Key5", "5" }, { "Key6", "6" },
{ "Key7", "7" }, { "Key8", "8" }, { "Key9", "9" }, { "Star", "*" }, { "Key0", "0" }, { "Pound", "#" } { "Key7", "7" }, { "Key8", "8" }, { "Key9", "9" }, { "Star", "*" }, { "Key0", "0" }, { "Pound", "#" }
} }
}, },
{ {
"Nintendo 64 Controller", new Dictionary<string, string> "Nintendo 64 Controller", new Dictionary<string, string>
{ {
{ "DPad U", "U" }, { "DPad D", "D" }, { "DPad L", "L" }, { "DPad R", "R" }, { "DPad U", "U" }, { "DPad D", "D" }, { "DPad L", "L" }, { "DPad R", "R" },
{ "B", "B" }, { "A", "A" }, { "Z", "Z" }, { "Start", "S" }, { "L", "L" }, { "R", "R" }, { "B", "B" }, { "A", "A" }, { "Z", "Z" }, { "Start", "S" }, { "L", "L" }, { "R", "R" },
{ "C Up", "u" }, { "C Down", "d" }, { "C Left", "l" }, { "C Right", "r" } { "C Up", "u" }, { "C Down", "d" }, { "C Left", "l" }, { "C Right", "r" }
} }
}, },
{ {
"Saturn Controller", new Dictionary<string, string> "Saturn Controller", new Dictionary<string, string>
{ {
{ "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" }, { "Up", "U" }, { "Down", "D" }, { "Left", "L" }, { "Right", "R" },
{ "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "A", "A" }, { "B", "B" }, { "C", "C" }, { "Start", "S" }, { "X", "X" }, { "Y", "Y" }, { "Z", "Z" }, { "A", "A" }, { "B", "B" }, { "C", "C" },
{ "L", "l" }, { "R", "r" }, { "L", "l" }, { "R", "r" },
} }
} }
}; };
public static readonly Dictionary<string, Dictionary<string, string>> Analogs = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Analogs = new Dictionary<string, Dictionary<string, string>>
{ {
{ "Nintendo 64 Controller", new Dictionary<string, string> { { "X Axis", "X" }, { "Y Axis", "Y" } } } { "Nintendo 64 Controller", new Dictionary<string, string> { { "X Axis", "X" }, { "Y Axis", "Y" } } }
}; };
public static readonly Dictionary<string, Dictionary<string, string>> Commands = new Dictionary<string, Dictionary<string, string>> public static readonly Dictionary<string, Dictionary<string, string>> Commands = new Dictionary<string, Dictionary<string, string>>
{ {
{ "Atari 2600 Basic Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } }, { "Atari 2600 Basic Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } }, { "Atari 7800 ProLine Joystick Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Select", "s" } } },
{ "Gameboy Controller", new Dictionary<string, string> { { "Power", "P" } } }, { "Gameboy Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "GBA Controller", new Dictionary<string, string> { { "Power", "P" } } }, { "GBA Controller", new Dictionary<string, string> { { "Power", "P" } } },
{ "Genesis 3-Button Controller", new Dictionary<string, string> { { "Reset", "r" } } }, { "Genesis 3-Button Controller", new Dictionary<string, string> { { "Reset", "r" } } },
{ "GPGX Genesis Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "GPGX Genesis Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "NES Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Power", "P" }, { "FDS Eject", "E" }, { "FDS Insert 0", "0" }, { "FDS Insert 1", "1" }, { "VS Coin 1", "c" }, { "VS Coin 2", "C" } } }, { "NES Controller", new Dictionary<string, string> { { "Reset", "r" }, { "Power", "P" }, { "FDS Eject", "E" }, { "FDS Insert 0", "0" }, { "FDS Insert 1", "1" }, { "VS Coin 1", "c" }, { "VS Coin 2", "C" } } },
{ "SNES Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "SNES Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "PC Engine Controller", new Dictionary<string, string>() }, { "PC Engine Controller", new Dictionary<string, string>() },
{ "SMS Controller", new Dictionary<string, string> { { "Pause", "p" }, { "Reset", "r" } } }, { "SMS Controller", new Dictionary<string, string> { { "Pause", "p" }, { "Reset", "r" } } },
{ "TI83 Controller", new Dictionary<string, string>() }, { "TI83 Controller", new Dictionary<string, string>() },
{ "Nintendo 64 Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "Nintendo 64 Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "Saturn Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }, { "Saturn Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } },
{ "GPGX 3-Button Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } } { "GPGX 3-Button Controller", new Dictionary<string, string> { { "Power", "P" }, { "Reset", "r" } } }
}; };
public static readonly Dictionary<string, int> Players = new Dictionary<string, int> public static readonly Dictionary<string, int> Players = new Dictionary<string, int>
{ {
{ "Gameboy Controller", 1 }, { "GBA Controller", 1 }, { "Genesis 3-Button Controller", 2 }, { "GPGX Genesis Controller", 2 }, { "NES Controller", 4 }, { "Gameboy Controller", 1 }, { "GBA Controller", 1 }, { "Genesis 3-Button Controller", 2 }, { "GPGX Genesis Controller", 2 }, { "NES Controller", 4 },
{ "SNES Controller", 4 }, { "PC Engine Controller", 5 }, { "SMS Controller", 2 }, { "TI83 Controller", 1 }, { "Atari 2600 Basic Controller", 2 }, { "Atari 7800 ProLine Joystick Controller", 2 }, { "SNES Controller", 4 }, { "PC Engine Controller", 5 }, { "SMS Controller", 2 }, { "TI83 Controller", 1 }, { "Atari 2600 Basic Controller", 2 }, { "Atari 7800 ProLine Joystick Controller", 2 },
{ "ColecoVision Basic Controller", 2 }, { "Commodore 64 Controller", 2 }, { "Nintendo 64 Controller", 4 }, { "Saturn Controller", 2 }, { "ColecoVision Basic Controller", 2 }, { "Commodore 64 Controller", 2 }, { "Nintendo 64 Controller", 4 }, { "Saturn Controller", 2 },
{ "GPGX 3-Button Controller", 2 }, { "Lynx Controller", 1 } { "GPGX 3-Button Controller", 2 }, { "Lynx Controller", 1 }
}; };
// just experimenting with different possibly more painful ways to handle mnemonics // just experimenting with different possibly more painful ways to handle mnemonics
// |P|UDLRsSBA| // |P|UDLRsSBA|
public static readonly Tuple<string, char>[] DgbMnemonic = public static readonly Tuple<string, char>[] DgbMnemonic =
{ {
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 Power", 'P'), new Tuple<string, char>("P1 Power", 'P'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 Up", 'U'), new Tuple<string, char>("P1 Up", 'U'),
new Tuple<string, char>("P1 Down", 'D'), new Tuple<string, char>("P1 Down", 'D'),
new Tuple<string, char>("P1 Left", 'L'), new Tuple<string, char>("P1 Left", 'L'),
new Tuple<string, char>("P1 Right", 'R'), new Tuple<string, char>("P1 Right", 'R'),
new Tuple<string, char>("P1 Select", 's'), new Tuple<string, char>("P1 Select", 's'),
new Tuple<string, char>("P1 Start", 'S'), new Tuple<string, char>("P1 Start", 'S'),
new Tuple<string, char>("P1 B", 'B'), new Tuple<string, char>("P1 B", 'B'),
new Tuple<string, char>("P1 A", 'A'), new Tuple<string, char>("P1 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 Power", 'P'), new Tuple<string, char>("P2 Power", 'P'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 Up", 'U'), new Tuple<string, char>("P2 Up", 'U'),
new Tuple<string, char>("P2 Down", 'D'), new Tuple<string, char>("P2 Down", 'D'),
new Tuple<string, char>("P2 Left", 'L'), new Tuple<string, char>("P2 Left", 'L'),
new Tuple<string, char>("P2 Right", 'R'), new Tuple<string, char>("P2 Right", 'R'),
new Tuple<string, char>("P2 Select", 's'), new Tuple<string, char>("P2 Select", 's'),
new Tuple<string, char>("P2 Start", 'S'), new Tuple<string, char>("P2 Start", 'S'),
new Tuple<string, char>("P2 B", 'B'), new Tuple<string, char>("P2 B", 'B'),
new Tuple<string, char>("P2 A", 'A'), new Tuple<string, char>("P2 A", 'A'),
new Tuple<string, char>(null, '|') new Tuple<string, char>(null, '|')
}; };
public static readonly Tuple<string, char>[] WsMnemonic = public static readonly Tuple<string, char>[] WsMnemonic =
{ {
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P1 X1", '1'), new Tuple<string, char>("P1 X1", '1'),
new Tuple<string, char>("P1 X3", '3'), new Tuple<string, char>("P1 X3", '3'),
new Tuple<string, char>("P1 X4", '4'), new Tuple<string, char>("P1 X4", '4'),
new Tuple<string, char>("P1 X2", '2'), new Tuple<string, char>("P1 X2", '2'),
new Tuple<string, char>("P1 Y1", '1'), new Tuple<string, char>("P1 Y1", '1'),
new Tuple<string, char>("P1 Y3", '3'), new Tuple<string, char>("P1 Y3", '3'),
new Tuple<string, char>("P1 Y4", '4'), new Tuple<string, char>("P1 Y4", '4'),
new Tuple<string, char>("P1 Y2", '2'), new Tuple<string, char>("P1 Y2", '2'),
new Tuple<string, char>("P1 Start", 'S'), new Tuple<string, char>("P1 Start", 'S'),
new Tuple<string, char>("P1 B", 'B'), new Tuple<string, char>("P1 B", 'B'),
new Tuple<string, char>("P1 A", 'A'), new Tuple<string, char>("P1 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("P2 X1", '1'), new Tuple<string, char>("P2 X1", '1'),
new Tuple<string, char>("P2 X3", '3'), new Tuple<string, char>("P2 X3", '3'),
new Tuple<string, char>("P2 X4", '4'), new Tuple<string, char>("P2 X4", '4'),
new Tuple<string, char>("P2 X2", '2'), new Tuple<string, char>("P2 X2", '2'),
new Tuple<string, char>("P2 Y1", '1'), new Tuple<string, char>("P2 Y1", '1'),
new Tuple<string, char>("P2 Y3", '3'), new Tuple<string, char>("P2 Y3", '3'),
new Tuple<string, char>("P2 Y4", '4'), new Tuple<string, char>("P2 Y4", '4'),
new Tuple<string, char>("P2 Y2", '2'), new Tuple<string, char>("P2 Y2", '2'),
new Tuple<string, char>("P2 Start", 'S'), new Tuple<string, char>("P2 Start", 'S'),
new Tuple<string, char>("P2 B", 'B'), new Tuple<string, char>("P2 B", 'B'),
new Tuple<string, char>("P2 A", 'A'), new Tuple<string, char>("P2 A", 'A'),
new Tuple<string, char>(null, '|'), new Tuple<string, char>(null, '|'),
new Tuple<string, char>("Power", 'P'), new Tuple<string, char>("Power", 'P'),
new Tuple<string, char>("Rotate", 'R'), new Tuple<string, char>("Rotate", 'R'),
new Tuple<string, char>(null, '|') new Tuple<string, char>(null, '|')
}; };
} }
} }

View File

@ -1,150 +1,150 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
internal class BkmMovie internal class BkmMovie
{ {
private readonly List<string> _log = new List<string>(); private readonly List<string> _log = new List<string>();
private int? _loopOffset; private int? _loopOffset;
public BkmMovie() public BkmMovie()
{ {
Header = new BkmHeader { [HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1" }; Header = new BkmHeader { [HeaderKeys.MOVIEVERSION] = "BizHawk v0.0.1" };
} }
public string PreferredExtension => "bkm"; public string PreferredExtension => "bkm";
public BkmHeader Header { get; } public BkmHeader Header { get; }
public string Filename { get; set; } = ""; public string Filename { get; set; } = "";
public bool Loaded { get; private set; } public bool Loaded { get; private set; }
public int InputLogLength => _log.Count; public int InputLogLength => _log.Count;
public double FrameCount public double FrameCount
{ {
get get
{ {
if (_loopOffset.HasValue) if (_loopOffset.HasValue)
{ {
return double.PositiveInfinity; return double.PositiveInfinity;
} }
if (Loaded) if (Loaded)
{ {
return _log.Count; return _log.Count;
} }
return 0; return 0;
} }
} }
public BkmControllerAdapter GetInputState(int frame) public BkmControllerAdapter GetInputState(int frame)
{ {
if (frame < FrameCount && frame >= 0) if (frame < FrameCount && frame >= 0)
{ {
int getFrame; int getFrame;
if (_loopOffset.HasValue) if (_loopOffset.HasValue)
{ {
if (frame < _log.Count) if (frame < _log.Count)
{ {
getFrame = frame; getFrame = frame;
} }
else else
{ {
getFrame = ((frame - _loopOffset.Value) % (_log.Count - _loopOffset.Value)) + _loopOffset.Value; getFrame = ((frame - _loopOffset.Value) % (_log.Count - _loopOffset.Value)) + _loopOffset.Value;
} }
} }
else else
{ {
getFrame = frame; getFrame = frame;
} }
var adapter = new BkmControllerAdapter var adapter = new BkmControllerAdapter
{ {
Definition = Global.MovieSession.MovieControllerAdapter.Definition Definition = Global.MovieSession.MovieControllerAdapter.Definition
}; };
adapter.SetControllersAsMnemonic(_log[getFrame]); adapter.SetControllersAsMnemonic(_log[getFrame]);
return adapter; return adapter;
} }
return null; return null;
} }
public IDictionary<string, string> HeaderEntries => Header; public IDictionary<string, string> HeaderEntries => Header;
public SubtitleList Subtitles => Header.Subtitles; public SubtitleList Subtitles => Header.Subtitles;
public IList<string> Comments => Header.Comments; public IList<string> Comments => Header.Comments;
public string SyncSettingsJson public string SyncSettingsJson
{ {
get => Header[HeaderKeys.SYNCSETTINGS]; get => Header[HeaderKeys.SYNCSETTINGS];
set => Header[HeaderKeys.SYNCSETTINGS] = value; set => Header[HeaderKeys.SYNCSETTINGS] = value;
} }
public string TextSavestate { get; set; } public string TextSavestate { get; set; }
public byte[] BinarySavestate { get; set; } public byte[] BinarySavestate { get; set; }
public bool Load() public bool Load()
{ {
var file = new FileInfo(Filename); var file = new FileInfo(Filename);
if (file.Exists == false) if (file.Exists == false)
{ {
Loaded = false; Loaded = false;
return false; return false;
} }
Header.Clear(); Header.Clear();
_log.Clear(); _log.Clear();
using (var sr = file.OpenText()) using (var sr = file.OpenText())
{ {
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
{ {
if (line == "") if (line == "")
{ {
continue; continue;
} }
if (line.Contains("LoopOffset")) if (line.Contains("LoopOffset"))
{ {
try try
{ {
_loopOffset = int.Parse(line.Split(new[] { ' ' }, 2)[1]); _loopOffset = int.Parse(line.Split(new[] { ' ' }, 2)[1]);
} }
catch (Exception) catch (Exception)
{ {
continue; continue;
} }
} }
else if (Header.ParseLineFromFile(line)) else if (Header.ParseLineFromFile(line))
{ {
continue; continue;
} }
else if (line.StartsWith("|")) else if (line.StartsWith("|"))
{ {
_log.Add(line); _log.Add(line);
} }
else else
{ {
Header.Comments.Add(line); Header.Comments.Add(line);
} }
} }
} }
if (Header.SavestateBinaryBase64Blob != null) if (Header.SavestateBinaryBase64Blob != null)
{ {
BinarySavestate = Convert.FromBase64String(Header.SavestateBinaryBase64Blob); BinarySavestate = Convert.FromBase64String(Header.SavestateBinaryBase64Blob);
} }
Loaded = true; Loaded = true;
return true; return true;
} }
} }
} }