2012-03-25 01:33:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using BizHawk.Emulation.CPUs.Z80;
|
|
|
|
|
using BizHawk.Emulation.Sound;
|
2012-03-25 17:39:50 +00:00
|
|
|
|
using BizHawk.Emulation.Consoles.Sega;
|
2012-03-25 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Consoles.Coleco
|
|
|
|
|
{
|
|
|
|
|
public partial class ColecoVision : IEmulator
|
|
|
|
|
{
|
2012-05-18 22:57:05 +00:00
|
|
|
|
public byte[] rom = new byte[2048];
|
|
|
|
|
public byte[] expansion = new byte[0x4000];
|
|
|
|
|
public byte[] cartridgeslot = new byte[0xFFFF]; //TODO: how big should this be?
|
2012-03-25 01:33:05 +00:00
|
|
|
|
public Z80A cpu;
|
2012-03-25 17:39:50 +00:00
|
|
|
|
public VDP Vdp; //adelikat: Using the SMS one for now
|
2012-03-25 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
public byte ReadMemory(ushort addr)
|
|
|
|
|
{
|
2012-05-18 22:57:05 +00:00
|
|
|
|
if (addr < 0x2000)
|
|
|
|
|
{
|
|
|
|
|
return rom[addr];
|
|
|
|
|
}
|
|
|
|
|
else if (addr >= 0x2000 && addr < 0x6000)
|
|
|
|
|
{
|
|
|
|
|
return expansion[addr];
|
|
|
|
|
}
|
|
|
|
|
else if (addr >= 0x6000 && addr < 0x8000)
|
|
|
|
|
{
|
|
|
|
|
return ram[addr & 1023];
|
|
|
|
|
}
|
|
|
|
|
else if (addr >= 0x8000)
|
|
|
|
|
{
|
|
|
|
|
return cartridgeslot[addr];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else return 0xFF;
|
2012-03-25 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WriteMemory(ushort addr, byte value)
|
|
|
|
|
{
|
2012-05-18 22:57:05 +00:00
|
|
|
|
if (addr >= 0x6000 && addr < 0x8000)
|
|
|
|
|
{
|
|
|
|
|
ram[addr] = value;
|
|
|
|
|
}
|
2012-03-25 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HardReset()
|
|
|
|
|
{
|
2012-03-25 17:39:50 +00:00
|
|
|
|
_lagcount = 0;
|
|
|
|
|
cpu = new Z80A();
|
2012-05-06 02:48:39 +00:00
|
|
|
|
Vdp = new VDP(this, cpu, VdpMode.SMS, DisplayType);
|
2012-05-06 01:15:02 +00:00
|
|
|
|
cpu.ReadMemory = ReadMemory;
|
|
|
|
|
cpu.WriteMemory = WriteMemory;
|
2012-03-25 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FrameAdvance(bool render)
|
|
|
|
|
{
|
2012-03-25 17:39:50 +00:00
|
|
|
|
_frame++;
|
|
|
|
|
_islag = true;
|
|
|
|
|
|
2012-05-06 02:48:39 +00:00
|
|
|
|
Vdp.ExecFrame(render);
|
|
|
|
|
|
|
|
|
|
//if (render == false) return;
|
|
|
|
|
//for (int i = 0; i < 256 * 192; i++)
|
|
|
|
|
// frameBuffer[i] = 0; //black
|
2012-03-25 17:39:50 +00:00
|
|
|
|
|
2012-05-06 01:15:02 +00:00
|
|
|
|
if (_islag)
|
|
|
|
|
_lagcount++;
|
2012-03-25 01:33:05 +00:00
|
|
|
|
}
|
2012-05-06 02:48:39 +00:00
|
|
|
|
|
|
|
|
|
public byte ReadControls()
|
|
|
|
|
{
|
|
|
|
|
byte value = 0xFF;
|
|
|
|
|
|
|
|
|
|
if (Controller["P1 Up"]) value &= 0xFF; //TODO;
|
|
|
|
|
if (Controller["P1 Down"]) value &= 0xFF; //TODO;
|
|
|
|
|
if (Controller["P1 Left"]) value &= 0xFF; //TODO;
|
|
|
|
|
if (Controller["P1 Right"]) value &= 0xFF; //TODO;
|
|
|
|
|
//TODO: remaining buttons
|
|
|
|
|
|
|
|
|
|
_islag = false;
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
|
|
}
|
2012-03-25 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|