commodore64: 1541 disk drive CPU emulated when a D64 or G64 is loaded, not attached to serial bus and no mechanical emulation yet

This commit is contained in:
saxxonpike 2012-11-15 15:58:26 +00:00
parent 020dedb1a0
commit 46ff936d41
4 changed files with 26 additions and 2 deletions

View File

@ -49,6 +49,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void HardReset()
{
cpu = new MOS6502X();
cpu.PC = (ushort)(Read(0xFFFC) + (Read(0xFFFD) << 8));
cpu.ReadMemory = Read;
cpu.WriteMemory = Write;
cpu.DummyReadMemory = Read;
ram = new byte[0x800];
via0 = new Via();
via1 = new Via();
@ -60,8 +65,9 @@ namespace BizHawk.Emulation.Computers.Commodore64
disk = newDisk;
}
public byte Peek(ushort addr)
public byte Peek(int addr)
{
addr &= 0xFFFF;
if (addr < 0x0800)
{
return ram[addr];
@ -83,10 +89,12 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void PerformCycle()
{
cpu.ExecuteOne();
}
public void Poke(ushort addr, byte val)
public void Poke(int addr, byte val)
{
addr &= 0xFFFF;
if (addr < 0x0800)
{
ram[addr] = val;

View File

@ -22,6 +22,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
return (byte)((mem.colorRam[addr & 0x3FF] & 0xF) | mem.busData);
}
public byte PeekDiskDrive(int addr)
{
if (diskDriveAttached)
return diskDrive.Peek(addr);
return 0xFF;
}
public byte PeekMemory(ushort addr)
{
return mem.Peek(addr);
@ -62,6 +69,12 @@ namespace BizHawk.Emulation.Computers.Commodore64
mem.colorRam[addr & 0x3FF] = (byte)(val & 0xF);
}
public void PokeDiskDrive(int addr, byte val)
{
if (diskDriveAttached)
diskDrive.Poke(addr, val);
}
public void PokeMemoryInt(int addr, byte val)
{
mem.Poke((ushort)(addr & 0xFFFF), val);

View File

@ -124,6 +124,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
domains.Add(new MemoryDomain("SID", 0x20, Endian.Little, new Func<int, byte>(PeekSid), new Action<int, byte>(PokeSid)));
domains.Add(new MemoryDomain("VIC", 0x40, Endian.Little, new Func<int, byte>(PeekVic), new Action<int, byte>(PokeVic)));
domains.Add(new MemoryDomain("CRAM", 0x400, Endian.Little, new Func<int, byte>(PeekColorRAM), new Action<int, byte>(PokeColorRAM)));
domains.Add(new MemoryDomain("DISKRAM", 0x10000, Endian.Little, new Func<int, byte>(PeekDiskDrive), new Action<int, byte>(PokeDiskDrive)));
memoryDomains = domains.AsReadOnly();
}

View File

@ -447,6 +447,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
// reading this reg clears it
result = regs[0x0D];
regs[0x0D] = 0x00;
UpdateInterrupt();
return result;
default:
return regs[addr];
@ -581,6 +582,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
regs.EIALARM = ((intMask & 0x04) != 0x00);
regs.EISP = ((intMask & 0x08) != 0x00);
regs.EIFLAG = ((intMask & 0x10) != 0x00);
UpdateInterrupt();
break;
default:
regs[addr] = val;