diff --git a/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs index 22629526c9..a017f235d3 100644 --- a/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs @@ -52,12 +52,16 @@ namespace BizHawk.Emulation.Consoles.Coleco PSG.EndFrame(Cpu.TotalExecutedCycles); } - void LoadRom(byte[] rom) - { - RomData = new byte[0x8000]; - for (int i = 0; i < 0x8000; i++) - RomData[i] = rom[i % rom.Length]; - } + void LoadRom(byte[] rom) + { + RomData = new byte[0x8000]; + for (int i = 0; i < 0x8000; i++) + RomData[i] = rom[i % rom.Length]; + +// hack to skip colecovision title screen +//RomData[0] = 0x55; +//RomData[1] = 0xAA; + } void Reset() { @@ -77,6 +81,13 @@ namespace BizHawk.Emulation.Consoles.Coleco return VDP.ReadVdpStatus(); } + if (port >= 0xE0) + { + if ((port & 1) == 0) + return ReadController1(); + return ReadController2(); + } + return 0xFF; } @@ -84,7 +95,7 @@ namespace BizHawk.Emulation.Consoles.Coleco { port &= 0xFF; - if (port >= 0xA0 && port < 0xC0) + if (port >= 0xA0 && port <= 0xBF) { if ((port & 1) == 0) VDP.WriteVdpData(value); @@ -93,12 +104,23 @@ namespace BizHawk.Emulation.Consoles.Coleco return; } - if (port >= 0xE0) - { - PSG.WritePsgData(value, Cpu.TotalExecutedCycles); - return; - } + if (port >= 0x80 && port <= 0x9F) + { + InputPortSelection = InputPortMode.Right; + return; + } + if (port >= 0xC0 && port <= 0xDF) + { + InputPortSelection = InputPortMode.Left; + return; + } + + if (port >= 0xE0) + { + PSG.WritePsgData(value, Cpu.TotalExecutedCycles); + return; + } //Console.WriteLine("Write port {0:X2}:{1:X2}", port, value); } diff --git a/BizHawk.Emulation/Consoles/Coleco/Input.cs b/BizHawk.Emulation/Consoles/Coleco/Input.cs index b0a13e8a30..4933cfab71 100644 --- a/BizHawk.Emulation/Consoles/Coleco/Input.cs +++ b/BizHawk.Emulation/Consoles/Coleco/Input.cs @@ -22,11 +22,64 @@ public ControllerDefinition ControllerDefinition { get { return ColecoVisionControllerDefinition; } } public IController Controller { get; set; } - public int Frame { get { return _frame; } /*set { _frame = value; }*/ } + enum InputPortMode { Left, Right } + InputPortMode InputPortSelection; + + byte ReadController1() + { + IsLagFrame = false; + + if (InputPortSelection == InputPortMode.Left) + { + byte retval = 0x7F; + if (Controller["P1 Up"]) retval &= 0xFE; + if (Controller["P1 Right"]) retval &= 0xFD; + if (Controller["P1 Down"]) retval &= 0xFB; + if (Controller["P1 Left"]) retval &= 0xF7; + if (Controller["P1 L1"]) retval &= 0x3F; + + return retval; + } + + if (InputPortSelection == InputPortMode.Right) + { + byte retval = 0x0F; + + // 0x00; + if (Controller["P1 Key8"]) retval = 0x01; + if (Controller["P1 Key4"]) retval = 0x02; + if (Controller["P1 Key5"]) retval = 0x03; + // 0x04; + if (Controller["P1 Key7"]) retval = 0x05; + if (Controller["P1 Pound"]) retval = 0x06; + if (Controller["P1 Key2"]) retval = 0x07; + // 0x08; + if (Controller["P1 Star"]) retval = 0x09; + if (Controller["P1 Key0"]) retval = 0x0A; + if (Controller["P1 Key9"]) retval = 0x0B; + if (Controller["P1 Key3"]) retval = 0x0C; + if (Controller["P1 Key1"]) retval = 0x0D; + if (Controller["P1 Key6"]) retval = 0x0E; + + if (Controller["P1 R1"] == false) retval |= 0x40; + return retval; + } + + return 0xFF; + } + + + byte ReadController2() + { + IsLagFrame = false; + // TODO copy/paste from player 1 but.... debugging some things first + return 0xFF; + } + + + public int Frame { get; set; } public int LagCount { get { return _lagcount; } set { _lagcount = value; } } - public bool IsLagFrame { get { return _islag; } } - private bool _islag = true; + public bool IsLagFrame { get; private set; } private int _lagcount = 0; - private int _frame = 0; } }