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
|
|
|
|
{
|
2015-06-18 16:44:30 +00:00
|
|
|
|
[CoreConstructor("INTV")]
|
|
|
|
|
public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
|
|
|
|
|
{
|
|
|
|
|
ServiceProvider = new BasicServiceProvider(this);
|
|
|
|
|
CoreComm = comm;
|
|
|
|
|
|
|
|
|
|
_rom = rom;
|
|
|
|
|
_gameInfo = game;
|
|
|
|
|
_cart = new Intellicart();
|
|
|
|
|
if (_cart.Parse(_rom) == -1)
|
|
|
|
|
{
|
|
|
|
|
_cart = new Cartridge();
|
|
|
|
|
_cart.Parse(_rom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_cpu = new CP1610();
|
|
|
|
|
_cpu.ReadMemory = ReadMemory;
|
|
|
|
|
_cpu.WriteMemory = WriteMemory;
|
|
|
|
|
_cpu.Reset();
|
|
|
|
|
|
|
|
|
|
_stic = new STIC();
|
|
|
|
|
_stic.ReadMemory = ReadMemory;
|
|
|
|
|
_stic.WriteMemory = WriteMemory;
|
|
|
|
|
_stic.Reset();
|
|
|
|
|
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(_stic);
|
|
|
|
|
|
|
|
|
|
_psg = new PSG();
|
|
|
|
|
_psg.ReadMemory = ReadMemory;
|
|
|
|
|
_psg.WriteMemory = WriteMemory;
|
|
|
|
|
|
|
|
|
|
Connect();
|
|
|
|
|
|
|
|
|
|
_cpu.LogData();
|
|
|
|
|
|
|
|
|
|
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required."));
|
|
|
|
|
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required."));
|
|
|
|
|
}
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2015-06-18 16:44:30 +00:00
|
|
|
|
private byte[] _rom;
|
|
|
|
|
private GameInfo _gameInfo;
|
|
|
|
|
|
|
|
|
|
private CP1610 _cpu;
|
|
|
|
|
private ICart _cart;
|
|
|
|
|
private STIC _stic;
|
|
|
|
|
private 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
|
|
|
|
{
|
2015-06-18 16:44:30 +00:00
|
|
|
|
_cpu.SetIntRM(_stic.GetSr1());
|
|
|
|
|
_cpu.SetBusRq(_stic.GetSr2());
|
|
|
|
|
_stic.SetSst(_cpu.GetBusAk());
|
2012-08-13 08:10:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 23:07:48 +00:00
|
|
|
|
public void LoadExecutiveRom(byte[] erom)
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
2012-12-17 04:23:59 +00:00
|
|
|
|
if (erom.Length != 8192)
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("EROM file is wrong size - expected 8192 bytes");
|
|
|
|
|
}
|
2015-06-18 16:44:30 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 23:07:48 +00:00
|
|
|
|
public void LoadGraphicsRom(byte[] grom)
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
2015-02-05 23:07:48 +00:00
|
|
|
|
if (grom.Length != 2048)
|
2012-12-17 04:23:59 +00:00
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("GROM file is wrong size - expected 2048 bytes");
|
|
|
|
|
}
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
2015-06-18 16:44:30 +00:00
|
|
|
|
GraphicsRom = grom;
|
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
|
|
|
|
}
|
2012-07-08 04:20:53 +00:00
|
|
|
|
}
|