Added original 16k speccy (even though it sucks)
This commit is contained in:
parent
eff8ce69b4
commit
fc8b89c837
|
@ -271,6 +271,7 @@
|
|||
<Compile Include="Computers\SinclairSpectrum\Hardware\TapeBlockSetPlayer.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\Hardware\TapeDataBlockPlayer.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\Hardware\TapeFilePlayer.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\Machine\ZXSpectrum16K\ZX16.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\SoundProviderMixer.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\Machine\MachineType.cs" />
|
||||
<Compile Include="Computers\SinclairSpectrum\Machine\SpectrumBase.cs" />
|
||||
|
|
|
@ -8,6 +8,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
{
|
||||
public enum MachineType
|
||||
{
|
||||
/// <summary>
|
||||
/// Original Sinclair Spectrum 16K model
|
||||
/// </summary>
|
||||
ZXSpectrum16,
|
||||
|
||||
/// <summary>
|
||||
/// Sinclair Spectrum 48K model
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
using BizHawk.Emulation.Cores.Components.Z80A;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||
{
|
||||
public class ZX16 : ZX48
|
||||
{
|
||||
#region Construction
|
||||
|
||||
/// <summary>
|
||||
/// Main constructor
|
||||
/// </summary>
|
||||
/// <param name="spectrum"></param>
|
||||
/// <param name="cpu"></param>
|
||||
public ZX16(ZXSpectrum spectrum, Z80A cpu, byte[] file)
|
||||
: base(spectrum, cpu, file)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Memory
|
||||
|
||||
/* 48K Spectrum has NO memory paging
|
||||
*
|
||||
*
|
||||
| Bank 0 |
|
||||
| |
|
||||
| |
|
||||
| screen |
|
||||
0x4000 +--------+
|
||||
| ROM 0 |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
0x0000 +--------+
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Simulates reading from the bus (no contention)
|
||||
/// Paging should be handled here
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public override byte ReadBus(ushort addr)
|
||||
{
|
||||
int divisor = addr / 0x4000;
|
||||
// paging logic goes here
|
||||
|
||||
if (divisor > 1)
|
||||
{
|
||||
// memory does not exist
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
var bank = Memory[divisor];
|
||||
var index = addr % 0x4000;
|
||||
return bank[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simulates writing to the bus (no contention)
|
||||
/// Paging should be handled here
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <param name="value"></param>
|
||||
public override void WriteBus(ushort addr, byte value)
|
||||
{
|
||||
int divisor = addr / 0x4000;
|
||||
// paging logic goes here
|
||||
|
||||
if (divisor > 1)
|
||||
{
|
||||
// memory does not exist
|
||||
return;
|
||||
}
|
||||
|
||||
var bank = Memory[divisor];
|
||||
var index = addr % 0x4000;
|
||||
bank[index] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte of data from a specified memory address
|
||||
/// (with memory contention if appropriate)
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <returns></returns>
|
||||
public override byte ReadMemory(ushort addr)
|
||||
{
|
||||
var data = ReadBus(addr);
|
||||
if ((addr & 0xC000) == 0x4000)
|
||||
{
|
||||
// addr is in RAM not ROM - apply memory contention if neccessary
|
||||
if (addr >= 0x8000)
|
||||
{
|
||||
data = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
var delay = GetContentionValue(CurrentFrameCycle);
|
||||
CPU.TotalExecutedCycles += delay;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a byte of data to a specified memory address
|
||||
/// (with memory contention if appropriate)
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
/// <param name="value"></param>
|
||||
public override void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
if (addr < 0x4000)
|
||||
{
|
||||
// Do nothing - we cannot write to ROM
|
||||
return;
|
||||
}
|
||||
else if (addr >= 0x8000)
|
||||
{
|
||||
// memory does not exist
|
||||
return;
|
||||
}
|
||||
else if (addr < 0x8000)
|
||||
{
|
||||
// possible contended RAM
|
||||
var delay = GetContentionValue(CurrentFrameCycle);
|
||||
CPU.TotalExecutedCycles += delay;
|
||||
}
|
||||
|
||||
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
|
||||
/// </summary>
|
||||
/// <param name="buffer"></param>
|
||||
/// <param name="startAddress"></param>
|
||||
public override void InitROM(RomData romData)
|
||||
{
|
||||
RomData = romData;
|
||||
// for 16/48k machines only ROM0 is used (no paging)
|
||||
RomData.RomBytes?.CopyTo(ROM0, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -36,6 +36,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
switch (SyncSettings.MachineType)
|
||||
{
|
||||
case MachineType.ZXSpectrum16:
|
||||
ControllerDefinition = ZXSpectrumControllerDefinition;
|
||||
Init(MachineType.ZXSpectrum16, SyncSettings.BorderType, SyncSettings.TapeLoadSpeed, _file);
|
||||
break;
|
||||
case MachineType.ZXSpectrum48:
|
||||
ControllerDefinition = ZXSpectrumControllerDefinition;
|
||||
Init(MachineType.ZXSpectrum48, SyncSettings.BorderType, SyncSettings.TapeLoadSpeed, _file);
|
||||
|
@ -132,6 +136,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// setup the emulated model based on the MachineType
|
||||
switch (machineType)
|
||||
{
|
||||
case MachineType.ZXSpectrum16:
|
||||
_machine = new ZX16(this, _cpu, file);
|
||||
var _systemRom16 = GetFirmware(0x4000, "48ROM");
|
||||
var romData16 = RomData.InitROM(machineType, _systemRom16);
|
||||
_machine.InitROM(romData16);
|
||||
break;
|
||||
case MachineType.ZXSpectrum48:
|
||||
_machine = new ZX48(this, _cpu, file);
|
||||
var _systemRom = GetFirmware(0x4000, "48ROM");
|
||||
|
|
Loading…
Reference in New Issue