commodore64: directional data port improved
This commit is contained in:
parent
7cf1a5cfae
commit
c1f3ec2a41
|
@ -37,11 +37,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
|
||||
// initialize cia timers
|
||||
cia0 = new Cia(signal);
|
||||
cia0.ports[0] = new DirectionalDataPort(0x00, 0x00);
|
||||
cia0.ports[1] = new DirectionalDataPort(0x00, 0x00);
|
||||
cia0.ports[0] = new DirectionalDataPort(0x00, 0x00, 0xFF);
|
||||
cia0.ports[1] = new DirectionalDataPort(0x00, 0x00, 0xFF);
|
||||
cia1 = new Cia(signal);
|
||||
cia1.ports[0] = new DirectionalDataPort(0x00, 0x00);
|
||||
cia1.ports[1] = new DirectionalDataPort(0x00, 0x00);
|
||||
cia1.ports[0] = new DirectionalDataPort(0x00, 0x00, 0xFF);
|
||||
cia1.ports[1] = new DirectionalDataPort(0x00, 0x00, 0xFF);
|
||||
|
||||
// initialize vic
|
||||
signal = new ChipSignals();
|
||||
|
|
|
@ -8,11 +8,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
public class DirectionalDataPort
|
||||
{
|
||||
protected byte _data;
|
||||
protected byte _remoteData;
|
||||
public byte Direction;
|
||||
public Action<byte> WritePort;
|
||||
|
||||
public DirectionalDataPort(byte initData, byte initDirection)
|
||||
public DirectionalDataPort(byte initData, byte initDirection, byte initRemoteData)
|
||||
{
|
||||
_remoteData = initRemoteData;
|
||||
_data = initData;
|
||||
Direction = initDirection;
|
||||
WritePort = WritePortDummy;
|
||||
|
@ -23,19 +25,28 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
{
|
||||
get
|
||||
{
|
||||
return (byte)(_data);
|
||||
byte result = _remoteData;
|
||||
result &= (byte)~Direction;
|
||||
result |= (byte)(_data & Direction);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
_data &= (byte)~Direction;
|
||||
_data |= (byte)(value & Direction);
|
||||
_data = value;
|
||||
WritePort(_data);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRemoteData(byte val)
|
||||
public byte RemoteData
|
||||
{
|
||||
_data = val;
|
||||
get
|
||||
{
|
||||
return _remoteData;
|
||||
}
|
||||
set
|
||||
{
|
||||
_remoteData = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void WritePortDummy(byte val)
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
byte port0result = 0xFF;
|
||||
byte port1result = 0xFF;
|
||||
|
||||
port0result = (byte)(keyboardColumnData & joystickLatch[1]);
|
||||
port0result = (byte)(joystickLatch[1]);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -95,8 +95,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
}
|
||||
port1result &= joystickLatch[0];
|
||||
|
||||
ports[0].SetRemoteData(port0result);
|
||||
ports[1].SetRemoteData(port1result);
|
||||
ports[0].RemoteData = port0result;
|
||||
ports[1].RemoteData = port1result;
|
||||
}
|
||||
|
||||
public void WritePortA(byte data)
|
||||
|
|
|
@ -62,8 +62,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
|
||||
// registers
|
||||
public byte busData;
|
||||
public DirectionalDataPort cia1PortA = new DirectionalDataPort(0x7F, 0x00);
|
||||
public DirectionalDataPort cia1PortB = new DirectionalDataPort(0xFF, 0x00);
|
||||
public DirectionalDataPort cia1PortA = new DirectionalDataPort(0x7F, 0x00, 0xFF);
|
||||
public DirectionalDataPort cia1PortB = new DirectionalDataPort(0xFF, 0x00, 0xFF);
|
||||
public DirectionalDataPort cpuPort;
|
||||
public bool readTrigger = true;
|
||||
public bool writeTrigger = true;
|
||||
|
@ -188,7 +188,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
ram = new byte[0x10000];
|
||||
colorRam = new byte[0x1000];
|
||||
WipeMemory();
|
||||
cpuPort = new DirectionalDataPort(0x37, 0x2F);
|
||||
cpuPort = new DirectionalDataPort(0x37, 0x2F, 0x00);
|
||||
layout = new MemoryLayout();
|
||||
UpdateLayout();
|
||||
UpdateVicOffset(cia1PortA.Data);
|
||||
|
|
Loading…
Reference in New Issue