-Refactored NES and PCE button orders.
-Realized that FixMnemonic is useless as GetControllersAsMnemonic() + WriteMovie() = Fixed. -Finished the NES / PCE importers, now without string builders (Thanks zeromus)! -Converted ImportMMV to this same method. TODO: -Decide how's the best way to handle the mnemonic header and implement it. Apparently, anything other than a predefined header and a | is considered as a comment, so I might do something like: comment Mnemonic format: [0|UDLRsSBA]
This commit is contained in:
parent
5534bbd8b5
commit
79d12b9181
|
@ -122,7 +122,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
|
|
||||||
int gg_check, gg_replace;
|
int gg_check, gg_replace;
|
||||||
|
|
||||||
|
|
||||||
NESWatch[] watches;
|
NESWatch[] watches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +185,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MyVideoProvider videoProvider;
|
MyVideoProvider videoProvider;
|
||||||
public IVideoProvider VideoProvider { get { return videoProvider; } }
|
public IVideoProvider VideoProvider { get { return videoProvider; } }
|
||||||
public ISoundProvider SoundProvider { get { return apu; } }
|
public ISoundProvider SoundProvider { get { return apu; } }
|
||||||
|
@ -194,9 +192,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
public static readonly ControllerDefinition NESController =
|
public static readonly ControllerDefinition NESController =
|
||||||
new ControllerDefinition
|
new ControllerDefinition
|
||||||
{
|
{
|
||||||
Name = "NES Controls",
|
Name = "NES Controller",
|
||||||
BoolButtons = { "P1 A","P1 B","P1 Select","P1 Start","P1 Left","P1 Up","P1 Down","P1 Right", "Reset",
|
BoolButtons = {
|
||||||
"P2 A", "P2 B", "P2 Select", "P2 Start", "P2 Up", "P2 Down", "P2 Left", "P2 Right"}
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Start", "P1 B", "P1 A", "Reset",
|
||||||
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Select", "P2 Start", "P2 B", "P2 A"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public ControllerDefinition ControllerDefinition { get { return NESController; } }
|
public ControllerDefinition ControllerDefinition { get { return NESController; } }
|
||||||
|
@ -208,7 +208,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
set { controller = value; }
|
set { controller = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface IPortDevice
|
interface IPortDevice
|
||||||
{
|
{
|
||||||
void Write(int value);
|
void Write(int value);
|
||||||
|
@ -230,9 +229,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
void Strobe()
|
void Strobe()
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
foreach (string str in new string[] { "P" + (player + 1).ToString() + " Right", "P" + (player + 1).ToString() + " Left",
|
foreach (
|
||||||
"P" + (player + 1).ToString() + " Down", "P" + (player + 1).ToString() + " Up", "P" + (player + 1).ToString() + " Start",
|
string str in new string[] {
|
||||||
"P" + (player + 1).ToString() + " Select", "P" + (player + 1).ToString() + " B", "P" + (player + 1).ToString() + " A" })
|
"P" + (player + 1).ToString() + " Right", "P" + (player + 1).ToString() + " Left",
|
||||||
|
"P" + (player + 1).ToString() + " Down", "P" + (player + 1).ToString() + " Up",
|
||||||
|
"P" + (player + 1).ToString() + " Start", "P" + (player + 1).ToString() + " Select",
|
||||||
|
"P" + (player + 1).ToString() + " B", "P" + (player + 1).ToString() + " A"
|
||||||
|
}
|
||||||
|
)
|
||||||
{
|
{
|
||||||
value <<= 1;
|
value <<= 1;
|
||||||
value |= nes.Controller.IsPressed(str) ? 1 : 0;
|
value |= nes.Controller.IsPressed(str) ? 1 : 0;
|
||||||
|
@ -271,7 +275,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int _frame;
|
int _frame;
|
||||||
int _lagcount;
|
int _lagcount;
|
||||||
bool lagged = true;
|
bool lagged = true;
|
||||||
|
@ -538,7 +541,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
LoadReport.Flush();
|
LoadReport.Flush();
|
||||||
CoreOutputComm.RomStatusDetails = LoadReport.ToString();
|
CoreOutputComm.RomStatusDetails = LoadReport.ToString();
|
||||||
|
|
||||||
|
|
||||||
//create the board's rom and vrom
|
//create the board's rom and vrom
|
||||||
board.ROM = new byte[choice.prg_size * 1024];
|
board.ROM = new byte[choice.prg_size * 1024];
|
||||||
Array.Copy(file, 16, board.ROM, 0, board.ROM.Length);
|
Array.Copy(file, 16, board.ROM, 0, board.ROM.Length);
|
||||||
|
@ -554,7 +556,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
if (cart.vram_size != 0)
|
if (cart.vram_size != 0)
|
||||||
board.VRAM = new byte[cart.vram_size * 1024];
|
board.VRAM = new byte[cart.vram_size * 1024];
|
||||||
|
|
||||||
|
|
||||||
HardReset();
|
HardReset();
|
||||||
SetupMemoryDomains();
|
SetupMemoryDomains();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
Name = "PC Engine Controller",
|
Name = "PC Engine Controller",
|
||||||
BoolButtons =
|
BoolButtons =
|
||||||
{
|
{
|
||||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 B2", "P1 B1", "P1 Select", "P1 Run",
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Run", "P1 B2", "P1 B1",
|
||||||
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 B2", "P2 B1", "P2 Select", "P2 Run",
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Select", "P2 Run", "P2 B2", "P2 B1",
|
||||||
"P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 B2", "P3 B1", "P3 Select", "P3 Run",
|
"P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Select", "P3 Run", "P3 B2", "P3 B1",
|
||||||
"P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 B2", "P4 B1", "P4 Select", "P4 Run",
|
"P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 Select", "P4 Run", "P4 B2", "P4 B1",
|
||||||
"P5 Up", "P5 Down", "P5 Left", "P5 Right", "P5 B2", "P5 B1", "P5 Select", "P5 Run"
|
"P5 Up", "P5 Down", "P5 Left", "P5 Right", "P5 Select", "P5 Run", "P5 B2", "P5 B1"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace BizHawk.MultiClient
|
||||||
//this allows users to restore a movie with any savestate from that "timeline"
|
//this allows users to restore a movie with any savestate from that "timeline"
|
||||||
|
|
||||||
MnemonicsGenerator mg = new MnemonicsGenerator();
|
MnemonicsGenerator mg = new MnemonicsGenerator();
|
||||||
|
|
||||||
mg.SetSource(source);
|
mg.SetSource(source);
|
||||||
Log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic());
|
Log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic());
|
||||||
}
|
}
|
||||||
|
@ -217,8 +217,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (str.Contains(MovieHeader.RERECORDS))
|
if (str.Contains(MovieHeader.RERECORDS))
|
||||||
{
|
{
|
||||||
rerecordStr = ParseHeader(str, MovieHeader.RERECORDS);
|
rerecordStr = ParseHeader(str, MovieHeader.RERECORDS);
|
||||||
|
@ -288,9 +287,9 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (Header.AddHeaderFromLine(str))
|
else if (Header.AddHeaderFromLine(str))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||||
{
|
{
|
||||||
Subtitles.AddSubtitle(str);
|
Subtitles.AddSubtitle(str);
|
||||||
|
@ -329,17 +328,6 @@ namespace BizHawk.MultiClient
|
||||||
return LoadText();
|
return LoadText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FixMnemonic()
|
|
||||||
{
|
|
||||||
int frame = 0;
|
|
||||||
while (frame < Log.Length())
|
|
||||||
{
|
|
||||||
// TODO: Correct mnemonics, using Log.GetFrame(frame))?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lastLog = frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DumpLogIntoSavestateText(TextWriter writer)
|
public void DumpLogIntoSavestateText(TextWriter writer)
|
||||||
{
|
{
|
||||||
writer.WriteLine("[Input]");
|
writer.WriteLine("[Input]");
|
||||||
|
@ -355,7 +343,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
var reader = new StreamReader(path);
|
var reader = new StreamReader(path);
|
||||||
int stateFrame = 0;
|
int stateFrame = 0;
|
||||||
//We are in record mode so replace the movie log with the one from the savestate
|
//We are in record mode so replace the movie log with the one from the savestate
|
||||||
if (!Global.MovieSession.MultiTrack.IsActive)
|
if (!Global.MovieSession.MultiTrack.IsActive)
|
||||||
{
|
{
|
||||||
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length() > 0)
|
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length() > 0)
|
||||||
|
@ -367,7 +355,6 @@ namespace BizHawk.MultiClient
|
||||||
int i = 0; //TODO: Debug remove me
|
int i = 0; //TODO: Debug remove me
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
string line = reader.ReadLine();
|
string line = reader.ReadLine();
|
||||||
if (line.Contains(".[NES")) //TODO: Remove debug
|
if (line.Contains(".[NES")) //TODO: Remove debug
|
||||||
{
|
{
|
||||||
|
@ -573,7 +560,7 @@ namespace BizHawk.MultiClient
|
||||||
if (Header.GetHeaderLine(MovieHeader.GUID) != GUID)
|
if (Header.GetHeaderLine(MovieHeader.GUID) != GUID)
|
||||||
{
|
{
|
||||||
//GUID Mismatch error
|
//GUID Mismatch error
|
||||||
var result = MessageBox.Show(GUID + " : " + Header.GetHeaderLine(MovieHeader.GUID) + "\n" +
|
var result = MessageBox.Show(GUID + " : " + Header.GetHeaderLine(MovieHeader.GUID) + "\n" +
|
||||||
"The savestate GUID does not match the current movie. Proceed anyway?", "GUID Mismatch error",
|
"The savestate GUID does not match the current movie. Proceed anyway?", "GUID Mismatch error",
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
|
|
||||||
|
@ -632,7 +619,6 @@ namespace BizHawk.MultiClient
|
||||||
return false; //For now throw an error if recording, ideally what should happen is that the state gets loaded, and the movie set to movie finished, the movie at its current state is preserved and the state is loaded just fine. This should probably also only happen if checktimelines passes
|
return false; //For now throw an error if recording, ideally what should happen is that the state gets loaded, and the movie set to movie finished, the movie at its current state is preserved and the state is loaded just fine. This should probably also only happen if checktimelines passes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (stateFrame == 0)
|
if (stateFrame == 0)
|
||||||
{
|
{
|
||||||
stateFrame = l.Length(); //In case the frame count failed to parse, revert to using the entire state input log
|
stateFrame = l.Length(); //In case the frame count failed to parse, revert to using the entire state input log
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -45,7 +46,6 @@ namespace BizHawk.MultiClient
|
||||||
mov = new Movie();
|
mov = new Movie();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mov.FixMnemonic();
|
|
||||||
mov.WriteMovie();
|
mov.WriteMovie();
|
||||||
return mov;
|
return mov;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,40 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
else if (str[0] == '|')
|
else if (str[0] == '|')
|
||||||
{
|
{
|
||||||
m.AppendFrame(str);
|
ArrayList frame = new ArrayList();
|
||||||
|
// Split up the sections of the frame.
|
||||||
|
string[] sections = str.Split('|');
|
||||||
|
string[] buttons = {};
|
||||||
|
string console = "";
|
||||||
|
switch (emulator)
|
||||||
|
{
|
||||||
|
case "FCEUX":
|
||||||
|
buttons = new string[8] {"Right", "Left", "Down", "Up", "Start", "Select", "B", "A"};
|
||||||
|
console = "NES";
|
||||||
|
break;
|
||||||
|
case "Mednafen/PCEjin":
|
||||||
|
buttons = new string[8] {"Up", "Down", "Left", "Right", "B1", "B2", "Run", "Select"};
|
||||||
|
console = "PC Engine";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SimpleController controllers = new SimpleController();
|
||||||
|
controllers.Type = new ControllerDefinition();
|
||||||
|
controllers.Type.Name = console + " Controller";
|
||||||
|
for (int player = 2; player < sections.Length; player++)
|
||||||
|
{
|
||||||
|
if (sections[player].Length == buttons.Length)
|
||||||
|
{
|
||||||
|
for (int button = 0; button < buttons.Length; button++)
|
||||||
|
{
|
||||||
|
controllers["P" + (player - 1).ToString() + " " + buttons[button]] = (
|
||||||
|
sections[player][button] != '.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MnemonicsGenerator mg = new MnemonicsGenerator();
|
||||||
|
mg.SetSource(controllers);
|
||||||
|
m.AppendFrame(mg.GetControllersAsMnemonic());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -183,7 +216,6 @@ namespace BizHawk.MultiClient
|
||||||
errorMsg = "This is not a valid FCM file!";
|
errorMsg = "This is not a valid FCM file!";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UInt32 version = r.ReadUInt32();
|
UInt32 version = r.ReadUInt32();
|
||||||
m.Header.SetHeaderLine(MovieHeader.MovieVersion, "FCEU movie version " + version.ToString() + " (.fcm)");
|
m.Header.SetHeaderLine(MovieHeader.MovieVersion, "FCEU movie version " + version.ToString() + " (.fcm)");
|
||||||
|
@ -410,40 +442,30 @@ namespace BizHawk.MultiClient
|
||||||
//TODO: format correctly
|
//TODO: format correctly
|
||||||
m.Header.SetHeaderLine("MD5", MD5);
|
m.Header.SetHeaderLine("MD5", MD5);
|
||||||
|
|
||||||
|
|
||||||
for (int x = 0; x < (framecount); x++)
|
for (int x = 0; x < (framecount); x++)
|
||||||
{
|
{
|
||||||
//TODO: use StringBuilder
|
|
||||||
|
|
||||||
string frame = "|";
|
|
||||||
char start;
|
|
||||||
byte tmp;
|
byte tmp;
|
||||||
|
SimpleController controllers = new SimpleController();
|
||||||
tmp = r.ReadByte();
|
controllers.Type = new ControllerDefinition();
|
||||||
if ((int)(tmp & 1) > 0) frame += "U"; else frame += ".";
|
controllers.Type.Name = "SMS Controller";
|
||||||
if ((int)(tmp & 2) > 0) frame += "D"; else frame += ".";
|
for (int player = 1; player <= 2; player++)
|
||||||
if ((int)(tmp & 4) > 0) frame += "L"; else frame += ".";
|
{
|
||||||
if ((int)(tmp & 8) > 0) frame += "R"; else frame += ".";
|
tmp = r.ReadByte();
|
||||||
if ((int)(tmp & 16) > 0) frame += "1"; else frame += ".";
|
controllers["P" + player + " Up"] = ((int)(tmp & 1) > 0);
|
||||||
if ((int)(tmp & 32) > 0) frame += "2|"; else frame += ".|";
|
controllers["P" + player + " Down"] = ((int)(tmp & 2) > 0);
|
||||||
|
controllers["P" + player + " Left"] = ((int)(tmp & 4) > 0);
|
||||||
if ((int)(tmp & 64) > 0 && (!gamegear)) start = 'P'; else start = '.';
|
controllers["P" + player + " Right"] = ((int)(tmp & 8) > 0);
|
||||||
if ((int)(tmp & 128) > 0 && gamegear) start = 'P'; else start = '.';
|
controllers["P" + player + " B1"] = ((int)(tmp & 16) > 0);
|
||||||
|
controllers["P" + player + " B2"] = ((int)(tmp & 32) > 0);
|
||||||
//Controller 2
|
if (player == 1)
|
||||||
tmp = r.ReadByte();
|
{
|
||||||
if ((int)(tmp & 1) > 0) frame += "U"; else frame += ".";
|
controllers["Pause"] = (((int)(tmp & 64) > 0 && (!gamegear)) || ((int)(tmp & 128) > 0 && gamegear));
|
||||||
if ((int)(tmp & 2) > 0) frame += "D"; else frame += ".";
|
}
|
||||||
if ((int)(tmp & 4) > 0) frame += "L"; else frame += ".";
|
}
|
||||||
if ((int)(tmp & 8) > 0) frame += "R"; else frame += ".";
|
MnemonicsGenerator mg = new MnemonicsGenerator();
|
||||||
if ((int)(tmp & 16) > 0) frame += "1"; else frame += ".";
|
mg.SetSource(controllers);
|
||||||
if ((int)(tmp & 32) > 0) frame += "2|"; else frame += ".|";
|
m.AppendFrame(mg.GetControllersAsMnemonic());
|
||||||
|
|
||||||
frame += start;
|
|
||||||
frame += ".|";
|
|
||||||
m.AppendFrame(frame);
|
|
||||||
}
|
}
|
||||||
m.WriteMovie();
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +542,6 @@ namespace BizHawk.MultiClient
|
||||||
else
|
else
|
||||||
numControllers = 1;
|
numControllers = 1;
|
||||||
|
|
||||||
|
|
||||||
byte MovieFlags = r.ReadByte();
|
byte MovieFlags = r.ReadByte();
|
||||||
|
|
||||||
if ((int)(MovieFlags & 1) == 0)
|
if ((int)(MovieFlags & 1) == 0)
|
||||||
|
@ -549,8 +570,6 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
UInt16 fd = r.ReadUInt16();
|
UInt16 fd = r.ReadUInt16();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -585,8 +604,6 @@ namespace BizHawk.MultiClient
|
||||||
m.Header.SetHeaderLine(MovieHeader.RERECORDS, m.Rerecords.ToString());
|
m.Header.SetHeaderLine(MovieHeader.RERECORDS, m.Rerecords.ToString());
|
||||||
Byte moviestartflags = r.ReadByte();
|
Byte moviestartflags = r.ReadByte();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool startfromquicksave = false;
|
bool startfromquicksave = false;
|
||||||
bool startfromsram = false;
|
bool startfromsram = false;
|
||||||
|
|
||||||
|
@ -709,9 +726,7 @@ namespace BizHawk.MultiClient
|
||||||
if ((controllerstate & 0x0001) > 0) frame += "A"; else frame += ".";
|
if ((controllerstate & 0x0001) > 0) frame += "A"; else frame += ".";
|
||||||
frame += "|";
|
frame += "|";
|
||||||
|
|
||||||
|
|
||||||
m.AppendFrame(frame);
|
m.AppendFrame(frame);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.WriteMovie();
|
m.WriteMovie();
|
||||||
|
|
Loading…
Reference in New Issue