break some stuff. FDS can eject and insert disk sides now

This commit is contained in:
goyuken 2012-10-26 18:51:08 +00:00
parent 7ee00fbcb8
commit e6058e6bd8
10 changed files with 361 additions and 254 deletions

View File

@ -148,6 +148,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//if (resetSignal)
//Controller.UnpressButton("Reset"); TODO fix this
resetSignal = Controller["Reset"];
if (board is FDS)
{
var b = board as FDS;
if (Controller["FDS Eject"])
b.Eject();
for (int i = 0; i < b.NumSides; i++)
if (Controller["FDS Insert " + i])
b.InsertSide(i);
}
ppu.FrameAdvance();
if (lagged)
{

View File

@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override void WriteEXP(int addr, byte value)
{
Console.WriteLine("W{0:x4}:{1:x2} {2:x4}", addr + 0x4000, value, NES.cpu.PC);
//Console.WriteLine("W{0:x4}:{1:x2} {2:x4}", addr + 0x4000, value, NES.cpu.PC);
if (addr >= 0x0040)
{
@ -177,8 +177,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
break;
}
diskirq = diskdrive.irq;
if (addr != 0x0032)
Console.WriteLine("R{0:x4}:{1:x2} {2:x4}", addr + 0x4000, ret, NES.cpu.PC);
//if (addr != 0x0032)
// Console.WriteLine("R{0:x4}:{1:x2} {2:x4}", addr + 0x4000, ret, NES.cpu.PC);
return ret;
}

View File

@ -262,6 +262,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
return ret;
}
Sound.Utilities.DCFilter dc = new Sound.Utilities.DCFilter(4096);
public void ApplyCustomAudio(short[] samples)
{
for (int i = 0; i < samples.Length; i += 2)
@ -282,6 +284,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
//Console.WriteLine("##{0}##", samplebuffpos);
samplebuffpos = 0;
dc.PushThroughSamples(samples, samples.Length);
}
}
}

View File

@ -96,6 +96,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
disk = null;
state = RamAdapterState.IDLE;
SetCycles();
Console.WriteLine("FDS: Disk ejected");
}
public void Insert(byte[] side, int bitlength, bool writeprotect)
@ -106,6 +107,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
this.writeprotect = writeprotect;
state = RamAdapterState.INSERTING;
SetCycles();
Console.WriteLine("FDS: Disk Inserted");
}
/// <summary>
@ -177,11 +179,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
// control reg
public void Write4025(byte value)
{
if ((value & 1) != 0) // start motor
{
if (state == RamAdapterState.IDLE)
if (state == RamAdapterState.IDLE && disk != null) // no spinup when no disk
{
state = RamAdapterState.SPINUP;
SetCycles();
@ -224,7 +224,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{
bytetransferflag = false;
irq = false; //??
Console.WriteLine("{0:x2} @{1}", readreglatch, lastreaddiskpos);
//Console.WriteLine("{0:x2} @{1}", readreglatch, lastreaddiskpos);
// it seems very hard to avoid this situation, hence the switch to latched shift regs
//if (readregpos != 0)
//{

View File

@ -25,6 +25,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
SetPalette(Palettes.FCEUX_Standard);
videoProvider = new MyVideoProvider(this);
Init(game, rom, fdsbios);
ControllerDefinition = new ControllerDefinition(NESController);
if (board is FDS)
{
var b = board as FDS;
ControllerDefinition.BoolButtons.Add("FDS Eject");
for (int i = 0; i < b.NumSides; i++)
ControllerDefinition.BoolButtons.Add("FDS Insert " + i);
}
}
private NES()
@ -222,7 +230,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
};
public ControllerDefinition ControllerDefinition { get { return NESController; } }
public ControllerDefinition ControllerDefinition { get; private set; }
IController controller;
public IController Controller

View File

@ -7,6 +7,19 @@ namespace BizHawk
public string Name;
public List<string> BoolButtons = new List<string>();
public List<string> FloatControls = new List<string>();
/// <summary>
/// copy
/// </summary>
/// <param name="source"></param>
public ControllerDefinition(ControllerDefinition source)
{
this.Name = source.Name;
foreach (var s in source.BoolButtons)
this.BoolButtons.Add(s);
foreach (var s in source.FloatControls)
this.FloatControls.Add(s);
}
public ControllerDefinition() { }
}
public interface IController

View File

@ -43,6 +43,22 @@ namespace BizHawk.Emulation.Sound.Utilities
buffer.Enqueue(0);
}
/// <summary>
/// detached mode
/// </summary>
/// <param name="filterwidth"></param>
public DCFilter(int filterwidth)
{
if (filterwidth < 1 || filterwidth > 65536)
throw new ArgumentOutOfRangeException();
this.input = null;
this.syncinput = null;
this.depth = filterwidth;
this.buffer = new Queue<short>(depth * 2);
for (int i = 0; i < depth * 2; i++)
buffer.Enqueue(0);
}
public DCFilter(ISyncSoundProvider input, int filterwidth)
{
if (filterwidth < 1 || filterwidth > 65536)

View File

@ -17,6 +17,8 @@ namespace BizHawk.MultiClient
}
public ControllerDefinition Type { get { return type; } }
/// <summary>don't do this</summary>
public void ForceType(ControllerDefinition newtype) { this.type = newtype; }
public bool this[string button] { get { return IsPressed(button); } }
public bool IsPressed(string button)
{
@ -65,14 +67,17 @@ namespace BizHawk.MultiClient
/// </summary>
public void OR_FromLogical(IController controller)
{
foreach (string button in type.BoolButtons)
{
if (controller.IsPressed(button))
// change: or from each button that the other input controller has
//foreach (string button in type.BoolButtons)
if (controller.Type != null)
foreach (string button in controller.Type.BoolButtons)
{
buttons[button] = true;
//Console.WriteLine(button);
if (controller.IsPressed(button))
{
buttons[button] = true;
//Console.WriteLine(button);
}
}
}
}
public void BindButton(string button, string control)

File diff suppressed because it is too large Load Diff

View File

@ -1174,6 +1174,7 @@ namespace BizHawk.MultiClient
break;
case "NES":
NESToolStripMenuItem.Visible = true;
NESFDSMenuControls();
break;
case "PCE":
case "PCECD":
@ -1212,6 +1213,44 @@ namespace BizHawk.MultiClient
}
}
void NESFDSMenuAdd(string name, string button, string msg)
{
fDSToolStripMenuItem.Visible = true;
fDSToolStripMenuItem.DropDownItems.Add(name, null, delegate(object sender, EventArgs e)
{
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(button))
{
if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished)
{
Global.ClickyVirtualPadController.Click(button);
Global.OSD.AddMessage(msg);
}
}
}
);
}
void NESFDSMenuControls()
{
// ugly and hacky
fDSToolStripMenuItem.Visible = false;
fDSToolStripMenuItem.DropDownItems.Clear();
var ss = Global.Emulator.ControllerDefinition.BoolButtons;
if (ss.Contains("FDS Eject"))
NESFDSMenuAdd("Eject Disk", "FDS Eject", "FDS Disk Ejected.");
for (int i = 0; i < 16; i++)
{
string s = "FDS Insert " + i;
if (ss.Contains(s))
NESFDSMenuAdd("Insert Disk " + i, s, "FDS Disk " + i + " inserted.");
}
}
void SyncControls()
{
if (Global.Game == null) return;
@ -1267,7 +1306,9 @@ namespace BizHawk.MultiClient
Global.ActiveController = Global.NullControls;
break;
}
// allow propogating controls that are in the current controller definition but not in the prebaked one
Global.ActiveController.ForceType(new ControllerDefinition(Global.Emulator.ControllerDefinition));
Global.ClickyVirtualPadController.Type = new ControllerDefinition(Global.Emulator.ControllerDefinition);
RewireInputChain();
}