2012-07-08 04:20:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Collections.Generic;
|
2013-11-04 01:06:36 +00:00
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-01-22 01:14:36 +00:00
|
|
|
|
using BizHawk.Emulation.Cores.Components.CP1610;
|
2012-07-08 04:20:53 +00:00
|
|
|
|
|
2013-11-13 03:32:25 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Intellivision
|
2012-07-08 04:20:53 +00:00
|
|
|
|
{
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public sealed partial class Intellivision : IEmulator
|
|
|
|
|
{
|
|
|
|
|
byte[] Rom;
|
|
|
|
|
GameInfo Game;
|
|
|
|
|
|
|
|
|
|
CP1610 Cpu;
|
2012-07-31 06:54:20 +00:00
|
|
|
|
ICart Cart;
|
2012-08-08 23:05:55 +00:00
|
|
|
|
STIC Stic;
|
|
|
|
|
PSG Psg;
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2014-04-19 22:23:13 +00:00
|
|
|
|
public Dictionary<string, int> GetCpuFlagsAndRegisters()
|
2013-11-11 03:20:33 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-14 03:58:11 +00:00
|
|
|
|
public void Connect()
|
2012-08-13 08:10:15 +00:00
|
|
|
|
{
|
2012-08-14 03:58:11 +00:00
|
|
|
|
Cpu.SetIntRM(Stic.GetSr1());
|
|
|
|
|
Cpu.SetBusRq(Stic.GetSr2());
|
|
|
|
|
Stic.SetSst(Cpu.GetBusAk());
|
2012-08-13 08:10:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-07 06:18:58 +00:00
|
|
|
|
public void LoadExecutiveRom(string path)
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
2012-09-07 06:18:58 +00:00
|
|
|
|
var erom = File.ReadAllBytes(path);
|
2012-12-17 04:23:59 +00:00
|
|
|
|
if (erom.Length != 8192)
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("EROM file is wrong size - expected 8192 bytes");
|
|
|
|
|
}
|
2012-07-19 00:05:08 +00:00
|
|
|
|
int index = 0;
|
|
|
|
|
// Combine every two bytes into a word.
|
|
|
|
|
while (index + 1 < erom.Length)
|
2012-12-17 04:23:59 +00:00
|
|
|
|
{
|
2012-08-10 20:40:34 +00:00
|
|
|
|
ExecutiveRom[index / 2] = (ushort)((erom[index++] << 8) | erom[index++]);
|
2012-12-17 04:23:59 +00:00
|
|
|
|
}
|
2012-07-19 00:05:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-07 06:18:58 +00:00
|
|
|
|
public void LoadGraphicsRom(string path)
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
2012-09-07 06:18:58 +00:00
|
|
|
|
GraphicsRom = File.ReadAllBytes(path);
|
2012-12-17 04:23:59 +00:00
|
|
|
|
if (GraphicsRom.Length != 2048)
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("GROM file is wrong size - expected 2048 bytes");
|
|
|
|
|
}
|
2012-07-19 00:05:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 00:43:43 +00:00
|
|
|
|
public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
2012-12-10 00:43:43 +00:00
|
|
|
|
CoreComm = comm;
|
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
Rom = rom;
|
|
|
|
|
Game = game;
|
2012-07-31 06:54:20 +00:00
|
|
|
|
Cart = new Intellicart();
|
|
|
|
|
if (Cart.Parse(Rom) == -1)
|
|
|
|
|
{
|
|
|
|
|
Cart = new Cartridge();
|
|
|
|
|
Cart.Parse(Rom);
|
|
|
|
|
}
|
2012-08-13 08:10:15 +00:00
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
Cpu = new CP1610();
|
|
|
|
|
Cpu.ReadMemory = ReadMemory;
|
|
|
|
|
Cpu.WriteMemory = WriteMemory;
|
2012-08-13 08:10:15 +00:00
|
|
|
|
Cpu.Reset();
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2012-08-08 23:05:55 +00:00
|
|
|
|
Stic = new STIC();
|
2012-09-06 04:51:17 +00:00
|
|
|
|
Stic.ReadMemory = ReadMemory;
|
|
|
|
|
Stic.WriteMemory = WriteMemory;
|
2012-08-13 08:10:15 +00:00
|
|
|
|
Stic.Reset();
|
|
|
|
|
|
2012-08-08 23:05:55 +00:00
|
|
|
|
Psg = new PSG();
|
2012-09-06 04:51:17 +00:00
|
|
|
|
Psg.ReadMemory = ReadMemory;
|
|
|
|
|
Psg.WriteMemory = WriteMemory;
|
2012-08-08 23:05:55 +00:00
|
|
|
|
|
2012-08-14 03:58:11 +00:00
|
|
|
|
Connect();
|
|
|
|
|
|
2012-08-13 08:10:15 +00:00
|
|
|
|
Cpu.LogData();
|
2013-12-10 18:16:39 +00:00
|
|
|
|
|
|
|
|
|
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmwarePath("INTV", "EROM", true, "Executive ROM is required."));
|
|
|
|
|
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmwarePath("INTV", "GROM", true, "Graphics ROM is required."));
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-20 19:52:47 +00:00
|
|
|
|
public void FrameAdvance(bool render, bool rendersound)
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
2012-09-05 04:42:49 +00:00
|
|
|
|
Frame++;
|
2012-12-17 04:23:59 +00:00
|
|
|
|
Cpu.AddPendingCycles(14934);
|
2012-08-14 03:58:11 +00:00
|
|
|
|
while (Cpu.GetPendingCycles() > 0)
|
|
|
|
|
{
|
2012-09-04 06:26:08 +00:00
|
|
|
|
int cycles = Cpu.Execute();
|
|
|
|
|
Stic.Execute(cycles);
|
2012-08-14 03:58:11 +00:00
|
|
|
|
Connect();
|
|
|
|
|
Cpu.LogData();
|
|
|
|
|
}
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-05 04:42:49 +00:00
|
|
|
|
public IVideoProvider VideoProvider { get { return Stic; } }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } }
|
sound api changes. added a new ISyncSoundProvider, which works similarly to ISoundProvider except the source (not the sink) determines the number of samples to process. Added facilities to metaspu, dcfilter, speexresampler to work with ISyncSoundProvider. Add ISyncSoundProvider to IEmulator. All IEmulators must provide sync sound, but they need not provide async sound. When async is needed and an IEmulator doesn't provide it, the frontend will wrap it in a vecna metaspu. SNES, GB changed to provide sync sound only. All other emulator cores mostly unchanged; they just provide stub fakesync alongside async, for now. For the moment, the only use of the sync sound is for realtime audio throttling, where it works and sounds quite nice. In the future, sync sound will be supported for AV dumping as well.
2012-10-11 00:44:59 +00:00
|
|
|
|
public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(NullSound.SilenceProvider, 735); } }
|
|
|
|
|
public bool StartAsyncSound() { return true; }
|
|
|
|
|
public void EndAsyncSound() { }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2012-09-07 05:41:33 +00:00
|
|
|
|
public static readonly ControllerDefinition IntellivisionController =
|
|
|
|
|
new ControllerDefinition
|
|
|
|
|
{
|
|
|
|
|
Name = "Intellivision Controller",
|
|
|
|
|
BoolButtons = {
|
2012-12-22 01:56:14 +00:00
|
|
|
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right",
|
|
|
|
|
"P1 L", "P1 R",
|
|
|
|
|
"P1 Key0", "P1 Key1", "P1 Key2", "P1 Key3", "P1 Key4", "P1 Key5",
|
|
|
|
|
"P1 Key6", "P1 Key7", "P1 Key8", "P1 Key9", "P1 Enter", "P1 Clear",
|
|
|
|
|
|
|
|
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right",
|
|
|
|
|
"P2 L", "P2 R",
|
|
|
|
|
"P2 Key0", "P2 Key1", "P2 Key2", "P2 Key3", "P2 Key4", "P2 Key5",
|
|
|
|
|
"P2 Key6", "P2 Key7", "P2 Key8", "P2 Key9", "P2 Enter", "P2 Clear"
|
2012-09-07 05:41:33 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public ControllerDefinition ControllerDefinition
|
|
|
|
|
{
|
2012-09-07 05:41:33 +00:00
|
|
|
|
get { return IntellivisionController; }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IController Controller { get; set; }
|
2012-09-05 04:42:49 +00:00
|
|
|
|
public int Frame { get; set; }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
|
|
|
|
public int LagCount
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
set { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsLagFrame { get { return false; } }
|
2012-09-05 04:42:49 +00:00
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public string SystemId
|
|
|
|
|
{
|
|
|
|
|
get { return "INTV"; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-24 16:54:22 +00:00
|
|
|
|
public string BoardName { get { return null; } }
|
|
|
|
|
|
2012-10-03 15:31:04 +00:00
|
|
|
|
public bool DeterministicEmulation { get { return true; } }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
|
|
|
|
|
2012-09-14 22:28:38 +00:00
|
|
|
|
public byte[] ReadSaveRam() { return null; }
|
|
|
|
|
public void StoreSaveRam(byte[] data) { }
|
|
|
|
|
public void ClearSaveRam() { }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public bool SaveRamModified
|
|
|
|
|
{
|
|
|
|
|
get { return false; }
|
|
|
|
|
set { }
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 16:29:51 +00:00
|
|
|
|
public void ResetCounters()
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
2012-11-25 15:41:40 +00:00
|
|
|
|
Frame = 0;
|
|
|
|
|
LagCount = 0;
|
2012-11-25 15:51:18 +00:00
|
|
|
|
//IsLagFrame = false;
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveStateText(TextWriter writer)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadStateText(TextReader reader)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveStateBinary(BinaryWriter writer)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadStateBinary(BinaryReader reader)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] SaveStateBinary()
|
|
|
|
|
{
|
|
|
|
|
return new byte[0];
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-06 20:51:28 +00:00
|
|
|
|
public bool BinarySaveStatesPreferred { get { return false; } }
|
|
|
|
|
|
2012-12-10 00:43:43 +00:00
|
|
|
|
public CoreComm CoreComm { get; private set; }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2013-11-06 02:15:29 +00:00
|
|
|
|
public MemoryDomainList MemoryDomains
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-12-22 00:44:39 +00:00
|
|
|
|
|
|
|
|
|
public object GetSettings() { return null; }
|
|
|
|
|
public object GetSyncSettings() { return null; }
|
|
|
|
|
public bool PutSettings(object o) { return false; }
|
2013-12-23 02:51:41 +00:00
|
|
|
|
public bool PutSyncSettings(object o) { return false; }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
2012-07-08 04:20:53 +00:00
|
|
|
|
}
|