Coleco Turbo Controller Functional
This commit is contained in:
parent
498b2b4dd9
commit
d87d5eb0e0
|
@ -143,42 +143,24 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
{
|
{
|
||||||
if (left_mode)
|
if (left_mode)
|
||||||
{
|
{
|
||||||
byte retval = 0x7B;
|
byte retval = 0x4B;
|
||||||
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0x3F;
|
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0x3F;
|
||||||
/*
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[1])) retval &= 0xF7;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[2])) retval &= 0xFB;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[3])) retval &= 0xFD;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[4])) retval &= 0xFE;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[5])) retval &= 0x7F;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[6])) retval &= 0xDF;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[7])) retval &= 0xEF;
|
|
||||||
*/
|
|
||||||
int x = (int)c.GetFloat(Definition.FloatControls[0]);
|
int x = (int)c.GetFloat(Definition.FloatControls[0]);
|
||||||
int y = (int)c.GetFloat(Definition.FloatControls[1]);
|
int y = (int)c.GetFloat(Definition.FloatControls[1]);
|
||||||
retval &= CalcDirection(x, y);
|
retval |= CalcDirection(x, y);
|
||||||
|
|
||||||
//Console.WriteLine(retval);
|
|
||||||
return retval;
|
return retval;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
byte retval = 0x7B;
|
byte retval = 0x4B;
|
||||||
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0x3F;
|
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0x3F;
|
||||||
/*
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[1])) retval &= 0xF7;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[2])) retval &= 0xFB;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[3])) retval &= 0xFD;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[4])) retval &= 0xFE;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[5])) retval &= 0x7F;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[6])) retval &= 0xDF;
|
|
||||||
if (c.IsPressed(Definition.BoolButtons[7])) retval &= 0xEF;
|
|
||||||
*/
|
|
||||||
int x = (int)c.GetFloat(Definition.FloatControls[0]);
|
int x = (int)c.GetFloat(Definition.FloatControls[0]);
|
||||||
int y = (int)c.GetFloat(Definition.FloatControls[1]);
|
int y = (int)c.GetFloat(Definition.FloatControls[1]);
|
||||||
retval &= CalcDirection(x, y);
|
retval |= CalcDirection(x, y);
|
||||||
|
|
||||||
//Console.WriteLine(retval);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +172,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
|
|
||||||
private static readonly string[] BaseBoolDefinition =
|
private static readonly string[] BaseBoolDefinition =
|
||||||
{
|
{
|
||||||
"Pedal", "T1", "T2", "T3", "T4", "T5", "T6", "T7"
|
"Pedal"
|
||||||
};
|
};
|
||||||
|
|
||||||
// x and y are both assumed to be in [-127, 127]
|
// x and y are both assumed to be in [-127, 127]
|
||||||
|
@ -199,41 +181,26 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
private static byte CalcDirection(int x, int y)
|
private static byte CalcDirection(int x, int y)
|
||||||
{
|
{
|
||||||
y = -y; // vflip to match the arrangement of FloatControllerButtons
|
y = -y; // vflip to match the arrangement of FloatControllerButtons
|
||||||
|
/*
|
||||||
// deadzone: if we're less than ? units from the origin, return no direction
|
// deadzone: if we're less than ? units from the origin, return no direction
|
||||||
if (x * x + y * y < Deadzone * Deadzone)
|
if (x * x + y * y < Deadzone * Deadzone)
|
||||||
{
|
{
|
||||||
return 0x7F; // nothing pressed
|
return 0x0F; // nothing pressed
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if ((y >= 0 && y>=Math.Abs(x)))
|
||||||
|
return 0x3F;
|
||||||
|
if ((y < 0 && Math.Abs(y) >= Math.Abs(x)))
|
||||||
|
return 0x1F;
|
||||||
|
if ((x > 0 && Math.Abs(y) < x))
|
||||||
|
return 0x0F;
|
||||||
|
if ((x < 0 && Math.Abs(y) < Math.Abs(x)))
|
||||||
|
return 0x2F;
|
||||||
|
|
||||||
|
Console.WriteLine("Error");
|
||||||
|
return 0x1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
double t = Math.Atan2(y, x) * 8.0 / Math.PI;
|
//private const int Deadzone = 50;
|
||||||
int i = (int)Math.Round(t);
|
|
||||||
return FloatControllerButtons[i & 15];
|
|
||||||
}
|
|
||||||
|
|
||||||
private const int Deadzone = 50;
|
|
||||||
|
|
||||||
private static byte[] FloatControllerButtons = new byte[]
|
|
||||||
{
|
|
||||||
0x6F, // E
|
|
||||||
0x4F, // ENE
|
|
||||||
0x4F, // NE
|
|
||||||
0x4F, // NNE
|
|
||||||
|
|
||||||
0x4F, // N
|
|
||||||
0x5F, // NNW
|
|
||||||
0x5F, // NW
|
|
||||||
0x5F, // WNW
|
|
||||||
|
|
||||||
0x5F, // W
|
|
||||||
0x7F, // WSW
|
|
||||||
0x7F, // SW
|
|
||||||
0x7F, // SSW
|
|
||||||
|
|
||||||
0x7F, // S
|
|
||||||
0x6F, // SSE
|
|
||||||
0x6F, // SE
|
|
||||||
0x6F, // ESE
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores.Components;
|
using BizHawk.Emulation.Cores.Components;
|
||||||
using BizHawk.Emulation.Cores.Components.Z80;
|
using BizHawk.Emulation.Cores.Components.Z80;
|
||||||
|
using BizHawk.Common.NumberExtensions;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.ColecoVision
|
namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
|
@ -48,7 +49,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
|
|
||||||
ControllerDeck = new ColecoVisionControllerDeck(this._syncSettings.Port1, this._syncSettings.Port2);
|
ControllerDeck = new ColecoVisionControllerDeck(this._syncSettings.Port1, this._syncSettings.Port2);
|
||||||
|
|
||||||
VDP = new TMS9918A(Cpu, ControllerDeck);
|
VDP = new TMS9918A(Cpu);
|
||||||
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(VDP);
|
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(VDP);
|
||||||
|
|
||||||
// TODO: hack to allow bios-less operation would be nice, no idea if its feasible
|
// TODO: hack to allow bios-less operation would be nice, no idea if its feasible
|
||||||
|
@ -65,8 +66,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
var serviceProvider = ServiceProvider as BasicServiceProvider;
|
var serviceProvider = ServiceProvider as BasicServiceProvider;
|
||||||
serviceProvider.Register<IDisassemblable>(new Disassembler());
|
serviceProvider.Register<IDisassemblable>(new Disassembler());
|
||||||
serviceProvider.Register<ITraceable>(Tracer);
|
serviceProvider.Register<ITraceable>(Tracer);
|
||||||
|
|
||||||
VDP.Controller = Controller;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
||||||
|
@ -91,8 +90,11 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
{
|
{
|
||||||
Cpu.Logger = (s) => Tracer.Put(s);
|
Cpu.Logger = (s) => Tracer.Put(s);
|
||||||
}
|
}
|
||||||
VDP.Controller = Controller;
|
|
||||||
VDP.ExecuteFrame();
|
byte temp_ret1 = ControllerDeck.ReadPort1(Controller, true);
|
||||||
|
byte temp_ret2 = ControllerDeck.ReadPort2(Controller, true);
|
||||||
|
|
||||||
|
VDP.ExecuteFrame(!temp_ret1.Bit(4), !temp_ret2.Bit(4));
|
||||||
PSG.EndFrame(Cpu.TotalExecutedCycles);
|
PSG.EndFrame(Cpu.TotalExecutedCycles);
|
||||||
|
|
||||||
if (_isLag)
|
if (_isLag)
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores.Components.Z80;
|
using BizHawk.Emulation.Cores.Components.Z80;
|
||||||
using BizHawk.Common.NumberExtensions;
|
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.ColecoVision
|
namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
{
|
{
|
||||||
|
@ -21,9 +19,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
byte VdpBuffer;
|
byte VdpBuffer;
|
||||||
int TmsMode;
|
int TmsMode;
|
||||||
|
|
||||||
// interrupt control for quadrature reads
|
|
||||||
bool spin_on1, spin_on2;
|
|
||||||
|
|
||||||
bool Mode1Bit { get { return (Registers[1] & 16) > 0; } }
|
bool Mode1Bit { get { return (Registers[1] & 16) > 0; } }
|
||||||
bool Mode2Bit { get { return (Registers[0] & 2) > 0; } }
|
bool Mode2Bit { get { return (Registers[0] & 2) > 0; } }
|
||||||
bool Mode3Bit { get { return (Registers[1] & 8) > 0; } }
|
bool Mode3Bit { get { return (Registers[1] & 8) > 0; } }
|
||||||
|
@ -46,7 +41,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
int TmsPatternNameTableBase;
|
int TmsPatternNameTableBase;
|
||||||
int TmsSpriteAttributeBase;
|
int TmsSpriteAttributeBase;
|
||||||
|
|
||||||
public void ExecuteFrame()
|
public void ExecuteFrame(bool spin1_I, bool spin2_I)
|
||||||
{
|
{
|
||||||
for (int scanLine = 0; scanLine < 262; scanLine++)
|
for (int scanLine = 0; scanLine < 262; scanLine++)
|
||||||
{
|
{
|
||||||
|
@ -63,25 +58,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
|
|
||||||
Cpu.ExecuteCycles(228);
|
Cpu.ExecuteCycles(228);
|
||||||
|
|
||||||
byte temp_ret1 = Deck.ReadPort1(Controller, true);
|
|
||||||
byte temp_ret2 = Deck.ReadPort2(Controller, true);
|
|
||||||
|
|
||||||
if (((temp_ret1.Bit(4) && !spin_on1) | ( temp_ret2.Bit(4) && !spin_on2)) && scanLine == 50)
|
Cpu.Interrupt = false;
|
||||||
|
if ((spin1_I | spin2_I) && scanLine == 50)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (EnableInterrupts)
|
if (EnableInterrupts)
|
||||||
Cpu.NonMaskableInterrupt = true;
|
Cpu.Interrupt = true;
|
||||||
|
|
||||||
if (temp_ret1.Bit(4) && !spin_on1)
|
|
||||||
spin_on1 = true;
|
|
||||||
|
|
||||||
if (temp_ret2.Bit(4) && !spin_on2)
|
|
||||||
spin_on2 = true;
|
|
||||||
}
|
}
|
||||||
if (!temp_ret1.Bit(4))
|
|
||||||
spin_on1 = false;
|
|
||||||
if (!temp_ret2.Bit(4))
|
|
||||||
spin_on2 = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -464,13 +447,10 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
}
|
}
|
||||||
|
|
||||||
Z80A Cpu;
|
Z80A Cpu;
|
||||||
ColecoVisionControllerDeck Deck;
|
|
||||||
public IController Controller;
|
|
||||||
|
|
||||||
public TMS9918A(Z80A cpu, ColecoVisionControllerDeck deck)
|
public TMS9918A(Z80A cpu)
|
||||||
{
|
{
|
||||||
this.Cpu = cpu;
|
this.Cpu = cpu;
|
||||||
this.Deck = deck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] FrameBuffer = new int[256 * 192];
|
public int[] FrameBuffer = new int[256 * 192];
|
||||||
|
|
Loading…
Reference in New Issue