[ChannelF] Move PollInput() to before CPU loop, add missing variables to states, fixup usings

This commit is contained in:
CasualPokePlayer 2024-09-04 18:18:07 -07:00
parent c1ec22c26a
commit 7f3a1668d8
10 changed files with 55 additions and 45 deletions

View File

@ -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
{

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.ChannelF

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.ChannelF

View File

@ -40,13 +40,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
CPU.TraceCallback = null;
}
PollInput();
while (FrameClock++ < ClockPerFrame)
{
CPU.ExecuteOne();
}
PollInput();
FrameClock = 0;
_frame++;

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using BizHawk.Common;
using BizHawk.Emulation.Common;

View File

@ -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);

View File

@ -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;
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.ChannelF

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components.FairchildF8;

View File

@ -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;
}
}
}
}
}