2016-08-09 17:03:23 +00:00
|
|
|
|
using System;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
2017-07-09 14:21:03 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
2016-12-11 17:14:42 +00:00
|
|
|
|
public partial class GPGX : IEmulator, ISoundProvider
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
|
|
|
|
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
|
|
|
|
|
2017-07-17 22:49:16 +00:00
|
|
|
|
public ControllerDefinition ControllerDefinition { get; private set; }
|
|
|
|
|
|
|
|
|
|
// TODO: use render and rendersound
|
2017-05-02 01:09:11 +00:00
|
|
|
|
public void FrameAdvance(IController controller, bool render, bool rendersound = true)
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
2017-05-02 01:09:11 +00:00
|
|
|
|
if (controller.IsPressed("Reset"))
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Core.gpgx_reset(false);
|
2017-05-02 01:09:11 +00:00
|
|
|
|
if (controller.IsPressed("Power"))
|
2017-07-17 22:49:16 +00:00
|
|
|
|
Core.gpgx_reset(true);
|
|
|
|
|
if (_cds != null)
|
|
|
|
|
{
|
|
|
|
|
var prev = controller.IsPressed("Previous Disk");
|
|
|
|
|
var next = controller.IsPressed("Next Disk");
|
|
|
|
|
int newDisk = _discIndex;
|
|
|
|
|
if (prev && !_prevDiskPressed)
|
|
|
|
|
newDisk--;
|
|
|
|
|
if (next && !_nextDiskPressed)
|
|
|
|
|
newDisk++;
|
|
|
|
|
|
2017-07-22 21:07:27 +00:00
|
|
|
|
_prevDiskPressed = prev;
|
|
|
|
|
_nextDiskPressed = next;
|
|
|
|
|
|
2017-07-17 22:49:16 +00:00
|
|
|
|
if (newDisk < -1)
|
|
|
|
|
newDisk = -1;
|
|
|
|
|
if (newDisk >= _cds.Length)
|
|
|
|
|
newDisk = _cds.Length - 1;
|
|
|
|
|
|
|
|
|
|
if (newDisk != _discIndex)
|
|
|
|
|
{
|
|
|
|
|
_discIndex = newDisk;
|
|
|
|
|
Core.gpgx_swap_disc(_discIndex == -1 ? null : GetCDDataStruct(_cds[_discIndex]));
|
|
|
|
|
Console.WriteLine("IMMA CHANGING MAH DISKS");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this shouldn't be needed, as nothing has changed
|
|
|
|
|
// if (!Core.gpgx_get_control(input, inputsize))
|
|
|
|
|
// throw new Exception("gpgx_get_control() failed!");
|
|
|
|
|
|
2016-08-09 17:03:23 +00:00
|
|
|
|
ControlConverter.ScreenWidth = vwidth;
|
|
|
|
|
ControlConverter.ScreenHeight = vheight;
|
2017-05-02 01:09:11 +00:00
|
|
|
|
ControlConverter.Convert(controller, input);
|
2016-08-09 17:03:23 +00:00
|
|
|
|
|
2016-08-10 19:27:46 +00:00
|
|
|
|
if (!Core.gpgx_put_control(input, inputsize))
|
2016-08-09 17:03:23 +00:00
|
|
|
|
throw new Exception("gpgx_put_control() failed!");
|
|
|
|
|
|
|
|
|
|
IsLagFrame = true;
|
|
|
|
|
Frame++;
|
|
|
|
|
_drivelight = false;
|
|
|
|
|
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Core.gpgx_advance();
|
2016-08-09 17:03:23 +00:00
|
|
|
|
UpdateVideo();
|
|
|
|
|
update_audio();
|
|
|
|
|
|
|
|
|
|
if (IsLagFrame)
|
|
|
|
|
LagCount++;
|
|
|
|
|
|
2017-07-17 22:49:16 +00:00
|
|
|
|
if (_cds != null)
|
2016-08-09 17:03:23 +00:00
|
|
|
|
DriveLightOn = _drivelight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Frame { get; private set; }
|
|
|
|
|
|
|
|
|
|
public string SystemId
|
|
|
|
|
{
|
|
|
|
|
get { return "GEN"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DeterministicEmulation
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetCounters()
|
|
|
|
|
{
|
|
|
|
|
Frame = 0;
|
|
|
|
|
IsLagFrame = false;
|
|
|
|
|
LagCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CoreComm CoreComm { get; private set; }
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2017-05-21 13:27:29 +00:00
|
|
|
|
if (!_disposed)
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
2017-05-21 13:27:29 +00:00
|
|
|
|
if (_elf != null)
|
|
|
|
|
_elf.Dispose();
|
2017-07-17 22:49:16 +00:00
|
|
|
|
if (_cds != null)
|
|
|
|
|
foreach (var cd in _cds)
|
|
|
|
|
cd.Dispose();
|
2017-05-21 13:27:29 +00:00
|
|
|
|
_disposed = true;
|
2016-08-09 17:03:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|