AppleII - Add MemoryCallbacks, Breakpoint Support, Set Registers in Debugger to proper bit size.
This commit is contained in:
parent
0a6fb3dce2
commit
43dd015b51
|
@ -20,12 +20,28 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
reg.Key,
|
reg.Key,
|
||||||
reg.Key.Contains("Flag")
|
reg.Key.Contains("Flag")
|
||||||
? reg.Value > 0
|
? reg.Value > 0
|
||||||
: (RegisterValue)reg.Value);
|
: getRegisterValue(reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
return dic;
|
return dic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RegisterValue getRegisterValue(KeyValuePair<string, int> reg)
|
||||||
|
{
|
||||||
|
switch (reg.Key)
|
||||||
|
{
|
||||||
|
case "A":
|
||||||
|
case "X":
|
||||||
|
case "Y":
|
||||||
|
case "S":
|
||||||
|
return (byte)reg.Value;
|
||||||
|
case "PC":
|
||||||
|
return (ushort)reg.Value;
|
||||||
|
default:
|
||||||
|
return reg.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetCpuRegister(string register, int value)
|
public void SetCpuRegister(string register, int value)
|
||||||
{
|
{
|
||||||
switch (register)
|
switch (register)
|
||||||
|
@ -189,10 +205,6 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
|
|
||||||
private const byte JSRSize = 3;
|
private const byte JSRSize = 3;
|
||||||
|
|
||||||
public IMemoryCallbackSystem MemoryCallbacks
|
public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
|
||||||
{
|
|
||||||
[FeatureNotImplemented]
|
|
||||||
get { throw new NotImplementedException(); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
{
|
{
|
||||||
if (addr < 0 || addr >= 0xC000)
|
if (addr < 0 || addr >= 0xC000)
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
return (byte)_machine.Memory.Read((int)addr);
|
return (byte)_machine.Memory.Peek((int)addr);
|
||||||
},
|
},
|
||||||
(addr, value) =>
|
(addr, value) =>
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
{
|
{
|
||||||
if (addr < 0 || addr >= 65536)
|
if (addr < 0 || addr >= 65536)
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
return (byte)_machine.Memory.Read((int)addr);
|
return (byte)_machine.Memory.Peek((int)addr);
|
||||||
},
|
},
|
||||||
(addr, value) =>
|
(addr, value) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,9 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
ServiceProvider = ser;
|
ServiceProvider = ser;
|
||||||
CoreComm = comm;
|
CoreComm = comm;
|
||||||
|
|
||||||
|
Tracer = new TraceBuffer();
|
||||||
|
MemoryCallbacks = new MemoryCallbackSystem();
|
||||||
|
|
||||||
_disk1 = rom;
|
_disk1 = rom;
|
||||||
RomSet.Add(rom);
|
RomSet.Add(rom);
|
||||||
|
|
||||||
|
@ -48,10 +51,13 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
||||||
//for junk.dsk the .dsk is important because it determines the format from that
|
//for junk.dsk the .dsk is important because it determines the format from that
|
||||||
InitDisk();
|
InitDisk();
|
||||||
|
|
||||||
//trace logger stuff
|
|
||||||
Tracer = new TraceBuffer();
|
|
||||||
ser.Register<ITraceable>(Tracer);
|
ser.Register<ITraceable>(Tracer);
|
||||||
|
|
||||||
|
//Set up Memory Callbacks
|
||||||
|
_machine.Memory.ReadCallback = MemoryCallbacks.CallReads;
|
||||||
|
_machine.Memory.WriteCallback = MemoryCallbacks.CallWrites;
|
||||||
|
_machine.Memory.ExecuteCallback = MemoryCallbacks.CallExecutes;
|
||||||
|
|
||||||
InitSaveStates();
|
InitSaveStates();
|
||||||
SetupMemoryDomains();
|
SetupMemoryDomains();
|
||||||
PutSettings(settings ?? new Settings());
|
PutSettings(settings ?? new Settings());
|
||||||
|
|
|
@ -405,7 +405,7 @@ namespace Jellyfish.Virtu
|
||||||
}
|
}
|
||||||
|
|
||||||
CC = 0;
|
CC = 0;
|
||||||
OpCode = _memory.Read(RPC);
|
OpCode = _memory.ReadOpcode(RPC);
|
||||||
RPC = (RPC + 1) & 0xFFFF;
|
RPC = (RPC + 1) & 0xFFFF;
|
||||||
_executeOpCode[OpCode]();
|
_executeOpCode[OpCode]();
|
||||||
Cycles += CC;
|
Cycles += CC;
|
||||||
|
|
|
@ -183,7 +183,33 @@ namespace Jellyfish.Virtu
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Core Read & Write
|
#region Core Read & Write
|
||||||
|
public int ReadOpcode(int address)
|
||||||
|
{
|
||||||
|
int region = PageRegion[address >> 8];
|
||||||
|
var result = ((address & 0xF000) != 0xC000) ? _regionRead[region][address - RegionBaseAddress[region]] : ReadIoRegionC0CF(address);
|
||||||
|
if (ExecuteCallback != null)
|
||||||
|
{
|
||||||
|
ExecuteCallback((uint)address);
|
||||||
|
}
|
||||||
|
if (ReadCallback != null)
|
||||||
|
{
|
||||||
|
ReadCallback((uint)address);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public int Read(int address)
|
public int Read(int address)
|
||||||
|
{
|
||||||
|
int region = PageRegion[address >> 8];
|
||||||
|
var result = ((address & 0xF000) != 0xC000) ? _regionRead[region][address - RegionBaseAddress[region]] : ReadIoRegionC0CF(address);
|
||||||
|
if (ReadCallback != null)
|
||||||
|
{
|
||||||
|
ReadCallback((uint)address);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Peek(int address)
|
||||||
{
|
{
|
||||||
int region = PageRegion[address >> 8];
|
int region = PageRegion[address >> 8];
|
||||||
return ((address & 0xF000) != 0xC000) ? _regionRead[region][address - RegionBaseAddress[region]] : ReadIoRegionC0CF(address);
|
return ((address & 0xF000) != 0xC000) ? _regionRead[region][address - RegionBaseAddress[region]] : ReadIoRegionC0CF(address);
|
||||||
|
@ -191,6 +217,10 @@ namespace Jellyfish.Virtu
|
||||||
|
|
||||||
public int ReadZeroPage(int address)
|
public int ReadZeroPage(int address)
|
||||||
{
|
{
|
||||||
|
if (ReadCallback != null)
|
||||||
|
{
|
||||||
|
ReadCallback((uint)address);
|
||||||
|
}
|
||||||
return _zeroPage[address];
|
return _zeroPage[address];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,16 +229,28 @@ namespace Jellyfish.Virtu
|
||||||
int region = PageRegion[address >> 8];
|
int region = PageRegion[address >> 8];
|
||||||
if (_writeRegion[region] == null)
|
if (_writeRegion[region] == null)
|
||||||
{
|
{
|
||||||
|
if (WriteCallback != null)
|
||||||
|
{
|
||||||
|
WriteCallback((uint)(_regionWrite[region][address - RegionBaseAddress[region]]));
|
||||||
|
}
|
||||||
_regionWrite[region][address - RegionBaseAddress[region]] = (byte)data;
|
_regionWrite[region][address - RegionBaseAddress[region]] = (byte)data;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (WriteCallback != null)
|
||||||
|
{
|
||||||
|
WriteCallback((uint)address);
|
||||||
|
}
|
||||||
_writeRegion[region](address, (byte)data);
|
_writeRegion[region](address, (byte)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteZeroPage(int address, int data)
|
public void WriteZeroPage(int address, int data)
|
||||||
{
|
{
|
||||||
|
if (WriteCallback != null)
|
||||||
|
{
|
||||||
|
WriteCallback((uint)address);
|
||||||
|
}
|
||||||
_zeroPage[address] = (byte)data;
|
_zeroPage[address] = (byte)data;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -2088,6 +2130,10 @@ namespace Jellyfish.Virtu
|
||||||
private Action<int, byte> _writeIoRegionC8CF;
|
private Action<int, byte> _writeIoRegionC8CF;
|
||||||
private Action<int, byte> _writeRomRegionD0FF;
|
private Action<int, byte> _writeRomRegionD0FF;
|
||||||
|
|
||||||
|
public Action<uint> ReadCallback;
|
||||||
|
public Action<uint> WriteCallback;
|
||||||
|
public Action<uint> ExecuteCallback;
|
||||||
|
|
||||||
private Keyboard _keyboard;
|
private Keyboard _keyboard;
|
||||||
private GamePort _gamePort;
|
private GamePort _gamePort;
|
||||||
private Cassette _cassette;
|
private Cassette _cassette;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue