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[] RAM6 = new byte[0x4000]; // Bank 6
|
||||||
public byte[] RAM7 = new byte[0x4000]; // Bank 7
|
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>
|
/// <summary>
|
||||||
/// Simulates reading from the bus
|
/// Simulates reading from the bus
|
||||||
/// Paging should be handled here
|
/// Paging should be handled here
|
||||||
|
|
|
@ -51,17 +51,18 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
public override byte ReadBus(ushort addr)
|
public override byte ReadBus(ushort addr)
|
||||||
{
|
{
|
||||||
int divisor = addr / 0x4000;
|
int divisor = addr / 0x4000;
|
||||||
|
var index = addr % 0x4000;
|
||||||
|
|
||||||
// paging logic goes here
|
// paging logic goes here
|
||||||
|
|
||||||
if (divisor > 1)
|
switch (divisor)
|
||||||
{
|
{
|
||||||
|
case 0: return ROM0[index];
|
||||||
|
case 1: return RAM0[index];
|
||||||
|
default:
|
||||||
// memory does not exist
|
// memory does not exist
|
||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bank = Memory[divisor];
|
|
||||||
var index = addr % 0x4000;
|
|
||||||
return bank[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -73,17 +74,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
public override void WriteBus(ushort addr, byte value)
|
public override void WriteBus(ushort addr, byte value)
|
||||||
{
|
{
|
||||||
int divisor = addr / 0x4000;
|
int divisor = addr / 0x4000;
|
||||||
|
var index = addr % 0x4000;
|
||||||
|
|
||||||
// paging logic goes here
|
// paging logic goes here
|
||||||
|
|
||||||
if (divisor > 1)
|
switch (divisor)
|
||||||
{
|
{
|
||||||
// memory does not exist
|
case 0:
|
||||||
return;
|
// cannot write to ROM
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
RAM0[index] = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bank = Memory[divisor];
|
// update ULA screen buffer if necessary
|
||||||
var index = addr % 0x4000;
|
if ((addr & 49152) == 16384 && _render)
|
||||||
bank[index] = value;
|
ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -97,8 +104,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (ULADevice.IsContended(addr))
|
if (ULADevice.IsContended(addr))
|
||||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||||
|
|
||||||
CPU.TotalExecutedCycles += 3;
|
|
||||||
|
|
||||||
var data = ReadBus(addr);
|
var data = ReadBus(addr);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -115,24 +120,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (ULADevice.IsContended(addr))
|
if (ULADevice.IsContended(addr))
|
||||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||||
|
|
||||||
CPU.TotalExecutedCycles += 3;
|
|
||||||
|
|
||||||
WriteBus(addr, value);
|
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>
|
/// <summary>
|
||||||
/// Sets up the ROM
|
/// Sets up the ROM
|
||||||
|
|
|
@ -101,7 +101,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (ULADevice.IsContended(addr))
|
if (ULADevice.IsContended(addr))
|
||||||
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
CPU.TotalExecutedCycles += ULADevice.contentionTable[CurrentFrameCycle];
|
||||||
|
|
||||||
|
|
||||||
var data = ReadBus(addr);
|
var data = ReadBus(addr);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
isPorted: false,
|
isPorted: false,
|
||||||
isReleased: false)]
|
isReleased: false)]
|
||||||
[ServiceNotApplicable(typeof(IDriveLight))]
|
[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)
|
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;
|
_cpu.MemoryCallbacks = MemoryCallbacks;
|
||||||
|
|
||||||
//HardReset = _machine.HardReset;
|
HardReset = _machine.HardReset;
|
||||||
//SoftReset = _machine.SoftReset;
|
SoftReset = _machine.SoftReset;
|
||||||
|
|
||||||
_cpu.FetchMemory = _machine.ReadMemory;
|
_cpu.FetchMemory = _machine.ReadMemory;
|
||||||
_cpu.ReadMemory = _machine.ReadMemory;
|
_cpu.ReadMemory = _machine.ReadMemory;
|
||||||
|
@ -103,18 +103,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
if (_machine.AYDevice != null)
|
if (_machine.AYDevice != null)
|
||||||
SoundMixer.AddSource(_machine.AYDevice);
|
SoundMixer.AddSource(_machine.AYDevice);
|
||||||
|
|
||||||
//dcf = new DCFilter(SoundMixer, 256);
|
|
||||||
ser.Register<ISoundProvider>(SoundMixer);
|
ser.Register<ISoundProvider>(SoundMixer);
|
||||||
|
|
||||||
|
|
||||||
|
HardReset();
|
||||||
//HardReset();
|
|
||||||
|
|
||||||
SetupMemoryDomains();
|
SetupMemoryDomains();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public Action HardReset;
|
public Action HardReset;
|
||||||
//public Action SoftReset;
|
public Action SoftReset;
|
||||||
|
|
||||||
private readonly Z80A _cpu;
|
private readonly Z80A _cpu;
|
||||||
private readonly TraceBuffer _tracer;
|
private readonly TraceBuffer _tracer;
|
||||||
|
@ -125,9 +123,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
|
|
||||||
private SoundProviderMixer SoundMixer;
|
private SoundProviderMixer SoundMixer;
|
||||||
|
|
||||||
private DCFilter dcf;
|
|
||||||
|
|
||||||
//private byte[] _file;
|
|
||||||
private readonly List<byte[]> _files;
|
private readonly List<byte[]> _files;
|
||||||
|
|
||||||
public bool DiagRom = false;
|
public bool DiagRom = false;
|
||||||
|
|
Loading…
Reference in New Issue