diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart/VesCartBase.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart/VesCartBase.cs index ce676dac84..5698c4a59c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart/VesCartBase.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart/VesCartBase.cs @@ -1,7 +1,8 @@ -using BizHawk.Common; +using System.Collections; + +using BizHawk.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; -using System.Collections; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs index b546b3f7f8..d4e91def2c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs index 0a0fc3044b..254f197a4c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs index 1eeaa8fa1a..b0fb46bfd1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs @@ -40,13 +40,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF CPU.TraceCallback = null; } + PollInput(); + while (FrameClock++ < ClockPerFrame) { CPU.ExecuteOne(); } - PollInput(); - FrameClock = 0; _frame++; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs index d8167229c3..3ab64a87e3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs @@ -1,4 +1,5 @@ using System.ComponentModel; + using BizHawk.Common; using BizHawk.Emulation.Common; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs index 465b4000a4..37c9b63ee3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs @@ -32,6 +32,9 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF ser.Sync(nameof(StateRight), ref StateRight, false); ser.Sync(nameof(StateLeft), ref StateLeft, false); + ser.Sync(nameof(OutputLatch), ref OutputLatch, false); + ser.Sync(nameof(LS368Enable), ref LS368Enable); + //ser.Sync(nameof(ControllersEnabled), ref ControllersEnabled); CPU.SyncState(ser); Cartridge.SyncState(ser); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs index e4ce1a40f3..fd027810f3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs @@ -28,55 +28,49 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF public bool PollInput() { bool noInput = true; - - InputCallbacks.Call(); - - lock (this) + for (int i = 0; i < ButtonsConsole.Length; i++) { - for (int i = 0; i < ButtonsConsole.Length; i++) + var key = ButtonsConsole[i]; + bool prevState = StateConsole[i]; // CTRLConsole.Bit(i); + bool currState = _controller.IsPressed(key); + if (currState != prevState) { - var key = ButtonsConsole[i]; - bool prevState = StateConsole[i]; // CTRLConsole.Bit(i); - bool currState = _controller.IsPressed(key); - if (currState != prevState) - { - StateConsole[i] = currState; - noInput = false; + StateConsole[i] = currState; + noInput = false; - if (key == "RESET" && StateConsole[i]) + if (key == "RESET" && StateConsole[i]) + { + CPU.Reset(); + for (int l = 0; l < OutputLatch.Length; l++) { - CPU.Reset(); - for (int l = 0; l < OutputLatch.Length; l++) - { - OutputLatch[l] = 0; - } - return true; + OutputLatch[l] = 0; } + return true; } } + } - for (int i = 0; i < ButtonsRight.Length; i++) + for (int i = 0; i < ButtonsRight.Length; i++) + { + var key = "P1 " + ButtonsRight[i]; + bool prevState = StateRight[i]; + bool currState = _controller.IsPressed(key); + if (currState != prevState) { - var key = "P1 " + ButtonsRight[i]; - bool prevState = StateRight[i]; - bool currState = _controller.IsPressed(key); - if (currState != prevState) - { - StateRight[i] = currState; - noInput = false; - } + StateRight[i] = currState; + noInput = false; } + } - for (int i = 0; i < ButtonsLeft.Length; i++) + for (int i = 0; i < ButtonsLeft.Length; i++) + { + var key = "P2 " + ButtonsLeft[i]; + bool prevState = StateLeft[i]; + bool currState = _controller.IsPressed(key); + if (currState != prevState) { - var key = "P2 " + ButtonsLeft[i]; - bool prevState = StateLeft[i]; - bool currState = _controller.IsPressed(key); - if (currState != prevState) - { - StateLeft[i] = currState; - noInput = false; - } + StateLeft[i] = currState; + noInput = false; } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs index ded0b21ef6..62353990dd 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; + using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs index c2357f3efb..ae2a7e995b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; + using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.FairchildF8; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs index 1c06bf5bae..b161c4660b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs @@ -39,6 +39,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF // b3: START // RESET button is connected directly to the RST pin on the CPU (this is handled here in the PollInput() method) result = (~DataConsole & 0x0F) | OutputLatch[addr]; + InputCallbacks.Call(); _isLag = false; break; @@ -53,6 +54,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF // b5: CW var v1 = LS368Enable ? DataRight : DataRight | 0xC0; result = (~v1) | OutputLatch[addr]; + InputCallbacks.Call(); _isLag = false; break; @@ -71,7 +73,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF var v2 = LS368Enable ? DataLeft : 0xFF; result = (~v2) | OutputLatch[addr]; if (LS368Enable) + { + InputCallbacks.Call(); _isLag = false; + } break; case 5: @@ -97,13 +102,14 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF case 0: OutputLatch[addr] = value; LS368Enable = !value.Bit(6); - if (value.Bit(5)) + if (value.Bit(5)) { // WRT pulse // pulse clocks the 74195 parallel access shift register which feeds inputs of 2 NAND gates // writing data to both sets of even and odd VRAM chips (based on the row and column addresses latched into the 7493 ICs) - VRAM[((latch_y) * 0x80) + latch_x] = (byte)latch_colour; + VRAM[((latch_y) * 0x80) + latch_x] = (byte)latch_colour; } + break; case 1: @@ -117,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF break; case 5: - OutputLatch[addr] = value; + OutputLatch[addr] = value; latch_y = (value | 0xC0) ^ 0xFF; var audio = ((value) >> 6) & 0x03; if (audio != tone) @@ -125,6 +131,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF tone = audio; AudioChange(); } + break; default: @@ -132,6 +139,6 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF Cartridge.WritePort(addr, value); break; } - } + } } }