2019-03-30 21:09:04 +00:00
|
|
|
|
using BizHawk.Common.NumberExtensions;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|
|
|
|
{
|
|
|
|
|
public partial class VectrexHawk : IEmulator, IVideoProvider
|
|
|
|
|
{
|
|
|
|
|
public IEmulatorServiceProvider ServiceProvider { get; }
|
|
|
|
|
|
|
|
|
|
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
|
|
|
|
|
|
|
|
|
|
public bool FrameAdvance(IController controller, bool render, bool rendersound)
|
|
|
|
|
{
|
|
|
|
|
if (_tracer.Enabled)
|
|
|
|
|
{
|
|
|
|
|
cpu.TraceCallback = s => _tracer.Put(s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cpu.TraceCallback = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_frame++;
|
|
|
|
|
|
|
|
|
|
if (controller.IsPressed("Power"))
|
|
|
|
|
{
|
|
|
|
|
HardReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_islag = true;
|
|
|
|
|
|
2019-06-16 12:17:34 +00:00
|
|
|
|
// button inputs go to port 14 in the audio registers
|
2019-06-16 22:18:21 +00:00
|
|
|
|
audio.Register[14] = (byte)(_controllerDeck.ReadPort1(controller) & 0xF);
|
2019-06-16 12:17:34 +00:00
|
|
|
|
audio.Register[14] |= (byte)(_controllerDeck.ReadPort2(controller) << 4);
|
|
|
|
|
|
2019-06-23 21:46:30 +00:00
|
|
|
|
frame_end = false;
|
|
|
|
|
|
2019-03-30 21:09:04 +00:00
|
|
|
|
do_frame();
|
|
|
|
|
|
|
|
|
|
if (_islag)
|
|
|
|
|
{
|
|
|
|
|
_lagcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void do_frame()
|
|
|
|
|
{
|
2019-06-22 18:59:15 +00:00
|
|
|
|
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
|
|
|
|
|
2019-06-23 21:46:30 +00:00
|
|
|
|
//for (int i = 0; i < 1000; i++)
|
|
|
|
|
while (!frame_end)
|
2019-04-08 23:57:21 +00:00
|
|
|
|
{
|
2019-06-23 21:46:30 +00:00
|
|
|
|
internal_state_tick();
|
2019-06-15 22:39:00 +00:00
|
|
|
|
audio.tick();
|
2019-06-22 18:59:15 +00:00
|
|
|
|
ppu.tick();
|
2019-05-26 13:16:53 +00:00
|
|
|
|
cpu.ExecuteOne();
|
2019-04-08 23:57:21 +00:00
|
|
|
|
}
|
2019-03-30 21:09:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Frame => _frame;
|
|
|
|
|
|
2019-04-08 23:57:21 +00:00
|
|
|
|
public string SystemId => "VEC";
|
2019-03-30 21:09:04 +00:00
|
|
|
|
|
|
|
|
|
public bool DeterministicEmulation { get; set; }
|
|
|
|
|
|
|
|
|
|
public void ResetCounters()
|
|
|
|
|
{
|
|
|
|
|
_frame = 0;
|
|
|
|
|
_lagcount = 0;
|
|
|
|
|
_islag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreComm CoreComm { get; }
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
audio.DisposeSound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Video provider
|
|
|
|
|
|
2019-06-23 21:46:30 +00:00
|
|
|
|
public int _frameHz = 50;
|
2019-03-30 21:09:04 +00:00
|
|
|
|
|
|
|
|
|
public int[] _vidbuffer;
|
|
|
|
|
|
|
|
|
|
public int[] GetVideoBuffer()
|
|
|
|
|
{
|
|
|
|
|
return _vidbuffer;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-22 18:59:15 +00:00
|
|
|
|
public int VirtualWidth => 256;
|
|
|
|
|
public int VirtualHeight => 384;
|
|
|
|
|
public int BufferWidth => 256;
|
|
|
|
|
public int BufferHeight => 384;
|
2019-03-30 21:09:04 +00:00
|
|
|
|
public int BackgroundColor => unchecked((int)0xFF000000);
|
|
|
|
|
public int VsyncNumerator => _frameHz;
|
|
|
|
|
public int VsyncDenominator => 1;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|