commodore64: fix up some timer chip routines, and directional dataport should be more accurate
This commit is contained in:
parent
e4ff87e92a
commit
245ce3d72f
|
@ -117,6 +117,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
LagCount++;
|
||||
_frame++;
|
||||
|
||||
Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4));
|
||||
|
||||
CoreOutputComm.DriveLED = DriveLED;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,11 +64,31 @@ namespace BizHawk.Emulation.Computers.Commodore64.Disk
|
|||
WriteVia0 = board.pla.WriteVia0;
|
||||
WriteVia1 = board.pla.WriteVia1;
|
||||
}
|
||||
|
||||
public ushort PC
|
||||
{
|
||||
get
|
||||
{
|
||||
return board.cpu.PC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// because the VIC1541 doesn't have bank switching like the system does,
|
||||
// we simplify things by processing the rom bytes directly.
|
||||
|
||||
// note: when a byte is read, the drive mechanics will cause
|
||||
// the V flag on the 6502 to be enabled
|
||||
|
||||
// note: 6502 IRQ is wired to both VIA0 and VIA1. the NMI
|
||||
// pin is not connected to any other source and is always
|
||||
// held low.
|
||||
|
||||
// note: there is a GATE ARRAY that directs the signal
|
||||
// between different parts of the board. it is not emulated
|
||||
// directly, we are actually performing all its functions
|
||||
// within the motherboard class itself.
|
||||
|
||||
public class VIC1541Motherboard
|
||||
{
|
||||
public MOS6502X cpu;
|
||||
|
@ -182,8 +202,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.Disk
|
|||
via1.WriteCB1 = ((bool val) => { via1CB1 = val; });
|
||||
via1.WriteDirA = ((byte val) => { via1DirA = val; });
|
||||
via1.WriteDirB = ((byte val) => { via1DirB = val; });
|
||||
via1.WritePortA = ((byte val) => { via1DataA = Port.CPUWrite(via1DataA, val, via1DirA); });
|
||||
via1.WritePortB = ((byte val) => { via1DataB = Port.CPUWrite(via1DataB, val, via1DirB); });
|
||||
via1.WritePortA = ((byte val) => {
|
||||
via1DataA = Port.CPUWrite(via1DataA, val, via1DirA);
|
||||
});
|
||||
via1.WritePortB = ((byte val) => {
|
||||
via1DataB = Port.CPUWrite(via1DataB, val, via1DirB);
|
||||
});
|
||||
}
|
||||
|
||||
public void Connect(SerialPort newSerPort)
|
||||
|
|
|
@ -112,6 +112,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
|
||||
// ------------------------------------
|
||||
|
||||
public ushort PC
|
||||
{
|
||||
get
|
||||
{
|
||||
return cpu.PC;
|
||||
}
|
||||
}
|
||||
|
||||
public byte Peek(int addr)
|
||||
{
|
||||
if (addr == 0x0000)
|
||||
|
|
|
@ -250,9 +250,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
}
|
||||
break;
|
||||
case tControlLoadPB:
|
||||
if (pbPulse[i])
|
||||
pbPulse[i] = false;
|
||||
else
|
||||
if (!pbPulse[i])
|
||||
WritePortB((byte)(ReadPortB() & portMask[i]));
|
||||
|
||||
if (timer[i] > 0)
|
||||
|
@ -261,7 +259,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
if (timer[i] == 0)
|
||||
{
|
||||
irqT[i] = true;
|
||||
WritePortB((byte)(ReadPortB() | portBit[i]));
|
||||
if (irqT[i])
|
||||
WritePortB((byte)(ReadPortB() | portBit[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -401,7 +400,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
(byte)((pcrControlB[0] & 0x2) << 3) |
|
||||
(byte)((pcrControlB[1] & 0x3) << 5)
|
||||
);
|
||||
case 0xD:
|
||||
case 0xD: //IFR
|
||||
return (byte)(
|
||||
(irqCA[1] ? 0x01 : 0x00) |
|
||||
(irqCA[0] ? 0x02 : 0x00) |
|
||||
|
@ -412,7 +411,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
(irqT[0] ? 0x40 : 0x00) |
|
||||
(pinIRQ ? 0x00 : 0x80)
|
||||
);
|
||||
case 0xE:
|
||||
case 0xE: //IER
|
||||
return (byte)(
|
||||
(enableIrqCA[1] ? 0x01 : 0x00) |
|
||||
(enableIrqCA[0] ? 0x02 : 0x00) |
|
||||
|
@ -421,7 +420,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
(enableIrqCB[0] ? 0x10 : 0x00) |
|
||||
(enableIrqT[1] ? 0x20 : 0x00) |
|
||||
(enableIrqT[0] ? 0x40 : 0x00) |
|
||||
(0x80)
|
||||
(0x00)
|
||||
);
|
||||
default:
|
||||
return 0x00;
|
||||
|
@ -454,11 +453,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
break;
|
||||
case 0x2:
|
||||
WriteDirB(val);
|
||||
WritePortB(val);
|
||||
WritePortB(pbOut);
|
||||
break;
|
||||
case 0x3:
|
||||
WriteDirA(val);
|
||||
WritePortA(val);
|
||||
WritePortA(paOut);
|
||||
break;
|
||||
case 0x4:
|
||||
case 0x6:
|
||||
|
@ -469,18 +468,20 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
WriteRegister(0x4, ReadRegister(0x6));
|
||||
WriteRegister(0x5, ReadRegister(0x7));
|
||||
irqT[0] = false;
|
||||
pbPulse[0] = false;
|
||||
break;
|
||||
case 0x9:
|
||||
timer[1] = timerLatch[1];
|
||||
irqT[1] = false;
|
||||
pbPulse[1] = false;
|
||||
break;
|
||||
case 0xE:
|
||||
intEnable = ((val & 0x80) != 0);
|
||||
result = ReadRegister(addr);
|
||||
if (intEnable)
|
||||
result |= val;
|
||||
result |= (byte)(val & 0x7F);
|
||||
else
|
||||
result &= (byte)(val ^ 0x7F);
|
||||
result &= (byte)((val & 0x7F) ^ 0x7F);
|
||||
WriteRegister(0xE, result);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
todAlarm = new byte[4];
|
||||
|
||||
SetTodIn(chipRegion);
|
||||
HardReset();
|
||||
pinFlag = true;
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
@ -194,7 +194,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
todPM = false;
|
||||
|
||||
pinCnt = false;
|
||||
pinFlag = true;
|
||||
pinPC = true;
|
||||
}
|
||||
|
||||
|
@ -248,7 +247,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
{
|
||||
uint t = timer[index];
|
||||
bool u = false;
|
||||
|
||||
|
||||
{
|
||||
switch (timerInMode[index])
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
static public byte CPUWrite(byte latch, byte val, byte dir)
|
||||
{
|
||||
byte result;
|
||||
result = (byte)(latch & (byte)(~dir & 0xFF));
|
||||
result = (byte)(latch & (byte)(dir ^ 0xFF));
|
||||
result |= (byte)(val & dir);
|
||||
return result;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|||
{
|
||||
byte result;
|
||||
result = (byte)(latch & dir);
|
||||
result |= (byte)(val & (byte)(~dir & 0xFF));
|
||||
result |= (byte)(val & (byte)(dir ^ 0xFF));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue