Fixed zx16 machine after memory changes
This commit is contained in:
parent
33aa77d8e3
commit
97c453ae91
|
@ -32,12 +32,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
public byte[] RAM6 = new byte[0x4000]; // Bank 6
|
||||
public byte[] RAM7 = new byte[0x4000]; // Bank 7
|
||||
|
||||
/// <summary>
|
||||
/// Represents the addressable memory space of the spectrum
|
||||
/// All banks for the emulated system should be added during initialisation
|
||||
/// </summary>
|
||||
public Dictionary<int, byte[]> Memory = new Dictionary<int, byte[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Simulates reading from the bus
|
||||
/// Paging should be handled here
|
||||
|
|
|
@ -51,17 +51,18 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
public override byte ReadBus(ushort addr)
|
||||
{
|
||||
int divisor = addr / 0x4000;
|
||||
var index = addr % 0x4000;
|
||||
|
||||
// paging logic goes here
|
||||
|
||||
if (divisor > 1)
|
||||
switch (divisor)
|
||||
{
|
||||
case 0: return ROM0[index];
|
||||
case 1: return RAM0[index];
|
||||
default:
|
||||
// memory does not exist
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
var bank = Memory[divisor];
|
||||
var index = addr % 0x4000;
|
||||
return bank[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -73,17 +74,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
public override void WriteBus(ushort addr, byte value)
|
||||
{
|
||||
int divisor = addr / 0x4000;
|
||||
var index = addr % 0x4000;
|
||||
|
||||
// paging logic goes here
|
||||
|
||||
if (divisor > 1)
|
||||
switch (divisor)
|
||||
{
|
||||
// memory does not exist
|
||||
return;
|
||||
case 0:
|
||||
// cannot write to ROM
|
||||
break;
|
||||
case 1:
|
||||
RAM0[index] = value;
|
||||
break;
|
||||
}
|
||||
|
||||
var bank = Memory[divisor];
|
||||
var index = addr % 0x4000;
|
||||
bank[index] = value;
|
||||
// update ULA screen buffer if necessary
|
||||
if ((addr & 49152) == 16384 && _render)
|
||||
ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -97,8 +104,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
if (ULADevice.IsContended(addr))
|
||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||
|
||||
CPU.TotalExecutedCycles += 3;
|
||||
|
||||
var data = ReadBus(addr);
|
||||
return data;
|
||||
}
|
||||
|
@ -115,24 +120,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
if (ULADevice.IsContended(addr))
|
||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||
|
||||
CPU.TotalExecutedCycles += 3;
|
||||
|
||||
WriteBus(addr, value);
|
||||
}
|
||||
/*
|
||||
public override void ReInitMemory()
|
||||
{
|
||||
if (Memory.ContainsKey(0))
|
||||
Memory[0] = ROM0;
|
||||
else
|
||||
Memory.Add(0, ROM0);
|
||||
|
||||
if (Memory.ContainsKey(1))
|
||||
Memory[1] = RAM1;
|
||||
else
|
||||
Memory.Add(1, RAM1);
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Sets up the ROM
|
||||
|
|
|
@ -101,7 +101,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
if (ULADevice.IsContended(addr))
|
||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||
|
||||
|
||||
var data = ReadBus(addr);
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
isPorted: false,
|
||||
isReleased: false)]
|
||||
[ServiceNotApplicable(typeof(IDriveLight))]
|
||||
public partial class ZXSpectrum : IDebuggable, IInputPollable, IStatable, IRegionable
|
||||
public partial class ZXSpectrum : IRegionable
|
||||
{
|
||||
public ZXSpectrum(CoreComm comm, IEnumerable<byte[]> files, List<GameInfo> game, object settings, object syncSettings)
|
||||
{
|
||||
|
@ -85,8 +85,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
_cpu.MemoryCallbacks = MemoryCallbacks;
|
||||
|
||||
//HardReset = _machine.HardReset;
|
||||
//SoftReset = _machine.SoftReset;
|
||||
HardReset = _machine.HardReset;
|
||||
SoftReset = _machine.SoftReset;
|
||||
|
||||
_cpu.FetchMemory = _machine.ReadMemory;
|
||||
_cpu.ReadMemory = _machine.ReadMemory;
|
||||
|
@ -103,18 +103,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
if (_machine.AYDevice != null)
|
||||
SoundMixer.AddSource(_machine.AYDevice);
|
||||
|
||||
//dcf = new DCFilter(SoundMixer, 256);
|
||||
ser.Register<ISoundProvider>(SoundMixer);
|
||||
|
||||
|
||||
|
||||
//HardReset();
|
||||
HardReset();
|
||||
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
//public Action HardReset;
|
||||
//public Action SoftReset;
|
||||
public Action HardReset;
|
||||
public Action SoftReset;
|
||||
|
||||
private readonly Z80A _cpu;
|
||||
private readonly TraceBuffer _tracer;
|
||||
|
@ -125,9 +123,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
private SoundProviderMixer SoundMixer;
|
||||
|
||||
private DCFilter dcf;
|
||||
|
||||
//private byte[] _file;
|
||||
private readonly List<byte[]> _files;
|
||||
|
||||
public bool DiagRom = false;
|
||||
|
|
Loading…
Reference in New Issue