2012-07-08 04:20:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using BizHawk.Emulation.CPUs.CP1610;
|
|
|
|
|
|
2012-07-09 05:29:45 +00:00
|
|
|
|
namespace BizHawk.Emulation.Consoles.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
|
|
|
|
|
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-08-10 20:40:34 +00:00
|
|
|
|
public void LoadExecutiveRom()
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream("C:/erom.int", FileMode.Open, FileAccess.Read);
|
|
|
|
|
BinaryReader r = new BinaryReader(fs);
|
|
|
|
|
byte[] erom = r.ReadBytes(8192);
|
|
|
|
|
int index = 0;
|
|
|
|
|
// Combine every two bytes into a word.
|
|
|
|
|
while (index + 1 < erom.Length)
|
2012-08-10 20:40:34 +00:00
|
|
|
|
ExecutiveRom[index / 2] = (ushort)((erom[index++] << 8) | erom[index++]);
|
2012-07-19 00:05:08 +00:00
|
|
|
|
r.Close();
|
|
|
|
|
fs.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-10 20:40:34 +00:00
|
|
|
|
public void LoadGraphicsRom()
|
2012-07-19 00:05:08 +00:00
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream("C:/grom.int", FileMode.Open, FileAccess.Read);
|
|
|
|
|
BinaryReader r = new BinaryReader(fs);
|
|
|
|
|
byte[] grom = r.ReadBytes(2048);
|
|
|
|
|
for (int index = 0; index < grom.Length; index++)
|
2012-08-10 20:40:34 +00:00
|
|
|
|
GraphicsRom[index] = grom[index];
|
2012-07-19 00:05:08 +00:00
|
|
|
|
r.Close();
|
|
|
|
|
fs.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
public Intellivision(GameInfo game, byte[] rom)
|
|
|
|
|
{
|
|
|
|
|
Rom = rom;
|
|
|
|
|
Game = game;
|
2012-08-10 20:40:34 +00:00
|
|
|
|
LoadExecutiveRom();
|
|
|
|
|
LoadGraphicsRom();
|
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-08-13 08:10:15 +00:00
|
|
|
|
Stic.Reset();
|
|
|
|
|
|
2012-08-08 23:05:55 +00:00
|
|
|
|
Psg = new PSG();
|
|
|
|
|
|
2012-08-14 03:58:11 +00:00
|
|
|
|
Connect();
|
|
|
|
|
|
2012-07-15 08:38:50 +00:00
|
|
|
|
CoreOutputComm = new CoreOutputComm();
|
2012-08-13 08:10:15 +00:00
|
|
|
|
|
|
|
|
|
Cpu.LogData();
|
2012-07-15 08:38:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FrameAdvance(bool render)
|
|
|
|
|
{
|
2012-09-04 06:26:08 +00:00
|
|
|
|
Cpu.AddPendingCycles(14394 + 3791);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This is all crap to worry about later.
|
|
|
|
|
|
|
|
|
|
public IVideoProvider VideoProvider { get { return new NullEmulator(); } }
|
|
|
|
|
public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } }
|
|
|
|
|
|
|
|
|
|
public ControllerDefinition ControllerDefinition
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IController Controller { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int Frame
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int LagCount
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
set { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsLagFrame { get { return false; } }
|
|
|
|
|
public string SystemId
|
|
|
|
|
{
|
|
|
|
|
get { return "INTV"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DeterministicEmulation { get; set; }
|
|
|
|
|
|
2012-09-04 07:09:00 +00:00
|
|
|
|
public byte[] ReadSaveRam { get { return null; } }
|
2012-07-15 08:38:50 +00:00
|
|
|
|
|
|
|
|
|
public bool SaveRamModified
|
|
|
|
|
{
|
|
|
|
|
get { return false; }
|
|
|
|
|
set { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetFrameCounter()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreInputComm CoreInputComm { get; set; }
|
|
|
|
|
public CoreOutputComm CoreOutputComm { get; private set; }
|
|
|
|
|
|
|
|
|
|
public IList<MemoryDomain> MemoryDomains
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemoryDomain MainMemory
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-08 04:20:53 +00:00
|
|
|
|
}
|