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
|
|
|
|
{
|
2014-04-25 01:19:57 +00:00
|
|
|
|
[CoreAttributes(
|
|
|
|
|
"IntelliHawk",
|
|
|
|
|
"BrandonE",
|
|
|
|
|
isPorted: false,
|
|
|
|
|
isReleased: false
|
|
|
|
|
)]
|
2014-11-30 23:41:54 +00:00
|
|
|
|
[ServiceNotApplicable(typeof(ISaveRam))]
|
2014-11-23 17:22:43 +00:00
|
|
|
|
public sealed partial class Intellivision : IEmulator
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-08-23 19:06:37 +00:00
|
|
|
|
[CoreConstructor("INTV")]
|
2012-12-10 00:43:43 +00:00
|
|
|
|
public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
|
2012-07-15 08:38:50 +00:00
|
|
|
|
{
|
2014-12-04 03:38:30 +00:00
|
|
|
|
ServiceProvider = new BasicServiceProvider(this);
|
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();
|
2015-01-14 22:37:37 +00:00
|
|
|
|
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(Stic);
|
2012-08-13 08:10:15 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-12-04 03:38:30 +00:00
|
|
|
|
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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",
|
2014-06-29 12:32:36 +00:00
|
|
|
|
"P1 Key 0", "P1 Key 1", "P1 Key 2", "P1 Key 3", "P1 Key 4", "P1 Key 5",
|
|
|
|
|
"P1 Key 6", "P1 Key 7", "P1 Key 8", "P1 Key 9", "P1 Enter", "P1 Clear",
|
2012-12-22 01:56:14 +00:00
|
|
|
|
|
|
|
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right",
|
|
|
|
|
"P2 L", "P2 R",
|
2014-06-29 12:32:36 +00:00
|
|
|
|
"P2 Key 0", "P2 Key 1", "P2 Key 2", "P2 Key 3", "P2 Key 4", "P2 Key 5",
|
|
|
|
|
"P2 Key 6", "P2 Key 7", "P2 Key 8", "P2 Key 9", "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 string SystemId
|
|
|
|
|
{
|
|
|
|
|
get { return "INTV"; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 01:05:47 +00:00
|
|
|
|
[FeatureNotImplemented]
|
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
|
|
|
|
|
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;
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-10 00:43:43 +00:00
|
|
|
|
public CoreComm CoreComm { get; private set; }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-08 04:20:53 +00:00
|
|
|
|
}
|