gpgx: multidisk? dunno
This commit is contained in:
parent
e61f7d7876
commit
c31ebe176d
|
@ -554,7 +554,7 @@ namespace BizHawk.Client.Common
|
|||
switch (game.System)
|
||||
{
|
||||
case "GEN":
|
||||
var genesis = new GPGX(nextComm, null, disc, GetCoreSettings<GPGX>(), GetCoreSyncSettings<GPGX>());
|
||||
var genesis = new GPGX(nextComm, null, new[] { disc }, GetCoreSettings<GPGX>(), GetCoreSyncSettings<GPGX>());
|
||||
nextEmulator = genesis;
|
||||
break;
|
||||
case "SAT":
|
||||
|
|
|
@ -16,6 +16,28 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
Core.gpgx_reset(false);
|
||||
if (controller.IsPressed("Power"))
|
||||
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++;
|
||||
|
||||
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))
|
||||
|
@ -39,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
if (IsLagFrame)
|
||||
LagCount++;
|
||||
|
||||
if (CD != null)
|
||||
if (_cds != null)
|
||||
DriveLightOn = _drivelight;
|
||||
}
|
||||
|
||||
|
@ -70,8 +92,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
{
|
||||
if (_elf != null)
|
||||
_elf.Dispose();
|
||||
if (CD != null)
|
||||
CD.Dispose();
|
||||
if (_cds != null)
|
||||
foreach (var cd in _cds)
|
||||
cd.Dispose();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
Frame = reader.ReadInt32();
|
||||
LagCount = reader.ReadInt32();
|
||||
IsLagFrame = reader.ReadBoolean();
|
||||
_discIndex = reader.ReadInt32();
|
||||
_prevDiskPressed = reader.ReadBoolean();
|
||||
_nextDiskPressed = reader.ReadBoolean();
|
||||
// any managed pointers that we sent to the core need to be resent now!
|
||||
Core.gpgx_set_input_callback(InputCallback);
|
||||
RefreshMemCallbacks();
|
||||
|
@ -51,6 +54,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
writer.Write(Frame);
|
||||
writer.Write(LagCount);
|
||||
writer.Write(IsLagFrame);
|
||||
writer.Write(_discIndex);
|
||||
writer.Write(_prevDiskPressed);
|
||||
writer.Write(_nextDiskPressed);
|
||||
}
|
||||
|
||||
public byte[] SaveStateBinary()
|
||||
|
|
|
@ -7,6 +7,8 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||
{
|
||||
|
@ -27,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
{
|
||||
}
|
||||
|
||||
public GPGX(CoreComm comm, byte[] rom, DiscSystem.Disc CD, object settings, object syncSettings)
|
||||
public GPGX(CoreComm comm, byte[] rom, IEnumerable<Disc> cds, object settings, object syncSettings)
|
||||
{
|
||||
ServiceProvider = new BasicServiceProvider(this);
|
||||
// this can influence some things internally (autodetect romtype, etc)
|
||||
|
@ -64,12 +66,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
LoadCallback = new LibGPGX.load_archive_cb(load_archive);
|
||||
|
||||
this.romfile = rom;
|
||||
this.CD = CD;
|
||||
if (CD != null)
|
||||
|
||||
if (cds != null)
|
||||
{
|
||||
this.DiscSectorReader = new DiscSystem.DiscSectorReader(CD);
|
||||
_cds = cds.ToArray();
|
||||
_cdReaders = cds.Select(c => new DiscSectorReader(c)).ToArray();
|
||||
cd_callback_handle = new LibGPGX.cd_read_cb(CDRead);
|
||||
Core.gpgx_set_cdd_callback(cd_callback_handle);
|
||||
DriveLightEnabled = true;
|
||||
}
|
||||
|
||||
LibGPGX.INPUT_SYSTEM system_a = LibGPGX.INPUT_SYSTEM.SYSTEM_NONE;
|
||||
|
@ -139,9 +143,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
InputCallback = new LibGPGX.input_cb(input_callback);
|
||||
Core.gpgx_set_input_callback(InputCallback);
|
||||
|
||||
if (CD != null)
|
||||
DriveLightEnabled = true;
|
||||
|
||||
// process the non-init settings now
|
||||
PutSettings(_settings);
|
||||
|
||||
|
@ -159,8 +160,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
private LibGPGX Core;
|
||||
private PeRunner _elf;
|
||||
|
||||
DiscSystem.Disc CD;
|
||||
DiscSystem.DiscSectorReader DiscSectorReader;
|
||||
private Disc[] _cds;
|
||||
private int _discIndex;
|
||||
private DiscSectorReader[] _cdReaders;
|
||||
private bool _prevDiskPressed;
|
||||
private bool _nextDiskPressed;
|
||||
|
||||
byte[] romfile;
|
||||
|
||||
private bool _disposed = false;
|
||||
|
@ -217,12 +222,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
else
|
||||
{
|
||||
if (CD == null)
|
||||
if (_cds == null)
|
||||
{
|
||||
Console.WriteLine("Couldn't satisfy firmware request {0} because none was provided.", filename);
|
||||
return 0;
|
||||
}
|
||||
srcdata = GetCDData(CD);
|
||||
srcdata = GetCDData(_cds[0]);
|
||||
if (srcdata.Length != maxsize)
|
||||
{
|
||||
Console.WriteLine("Couldn't satisfy firmware request {0} because of struct size.", filename);
|
||||
|
@ -282,13 +287,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
|
||||
void CDRead(int lba, IntPtr dest, bool audio)
|
||||
{
|
||||
if ((uint)_discIndex < _cds.Length)
|
||||
{
|
||||
if (audio)
|
||||
{
|
||||
byte[] data = new byte[2352];
|
||||
if (lba < CD.Session1.LeadoutLBA)
|
||||
if (lba < _cds[_discIndex].Session1.LeadoutLBA)
|
||||
{
|
||||
DiscSectorReader.ReadLBA_2352(lba, data, 0);
|
||||
_cdReaders[_discIndex].ReadLBA_2352(lba, data, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -301,18 +308,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
else
|
||||
{
|
||||
byte[] data = new byte[2048];
|
||||
DiscSectorReader.ReadLBA_2048(lba, data, 0);
|
||||
_cdReaders[_discIndex].ReadLBA_2048(lba, data, 0);
|
||||
Marshal.Copy(data, 0, dest, 2048);
|
||||
_drivelight = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LibGPGX.cd_read_cb cd_callback_handle;
|
||||
|
||||
public static unsafe byte[] GetCDData(Disc cd)
|
||||
public static LibGPGX.CDData GetCDDataStruct(Disc cd)
|
||||
{
|
||||
LibGPGX.CDData ret = new LibGPGX.CDData();
|
||||
int size = Marshal.SizeOf(ret);
|
||||
var ret = new LibGPGX.CDData();
|
||||
|
||||
var ses = cd.Session1;
|
||||
int ntrack = ses.InformationTrackCount;
|
||||
|
@ -338,6 +345,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static unsafe byte[] GetCDData(Disc cd)
|
||||
{
|
||||
var ret = GetCDDataStruct(cd);
|
||||
int size = Marshal.SizeOf(ret);
|
||||
byte[] retdata = new byte[size];
|
||||
|
||||
fixed (byte* p = &retdata[0])
|
||||
|
@ -360,7 +374,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
if (!Core.gpgx_get_control(input, inputsize))
|
||||
throw new Exception("gpgx_get_control() failed");
|
||||
|
||||
ControlConverter = new GPGXControlConverter(input);
|
||||
ControlConverter = new GPGXControlConverter(input, _cds != null);
|
||||
ControllerDefinition = ControlConverter.ControllerDef;
|
||||
}
|
||||
|
||||
|
@ -369,7 +383,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
return (LibGPGX.INPUT_DEVICE[])input.dev.Clone();
|
||||
}
|
||||
|
||||
public bool IsMegaCD { get { return CD != null; } }
|
||||
public bool IsMegaCD { get { return _cds != null; } }
|
||||
|
||||
public class VDPView : IMonitor
|
||||
{
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
});
|
||||
}
|
||||
|
||||
public GPGXControlConverter(LibGPGX.InputData input)
|
||||
public GPGXControlConverter(LibGPGX.InputData input, bool cdButtons)
|
||||
{
|
||||
Console.WriteLine("Genesis Controller report:");
|
||||
foreach (var e in input.system)
|
||||
|
@ -189,6 +189,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
ControllerDef.BoolButtons.Add("Power");
|
||||
ControllerDef.BoolButtons.Add("Reset");
|
||||
if (cdButtons)
|
||||
{
|
||||
ControllerDef.BoolButtons.Add("Previous Disk");
|
||||
ControllerDef.BoolButtons.Add("Next Disk");
|
||||
}
|
||||
|
||||
for (int i = 0; i < LibGPGX.MAX_DEVICES; i++)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
public uint BackdropColor;
|
||||
}
|
||||
|
||||
[BizImport(CallingConvention.Cdecl, Compatibility=true)]
|
||||
[BizImport(CallingConvention.Cdecl, Compatibility = true)]
|
||||
public abstract bool gpgx_init(string feromextension, load_archive_cb feload_archive_cb, bool sixbutton, INPUT_SYSTEM system_a, INPUT_SYSTEM system_b, Region region, [In]InitSettings settings);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
|
@ -151,8 +151,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract void gpgx_set_cd_callback(CDCallback cd);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// not every flag is valid for every device!
|
||||
/// </summary>
|
||||
|
@ -277,6 +275,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract void gpgx_set_cdd_callback(cd_read_cb cddcb);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl, Compatibility = true)]
|
||||
public abstract void gpgx_swap_disc(CDData toc);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct VDPNameTable
|
||||
{
|
||||
|
|
Binary file not shown.
|
@ -192,6 +192,14 @@ GPGX_EX void gpgx_advance(void)
|
|||
nsamples = audio_update(soundbuffer);
|
||||
}
|
||||
|
||||
GPGX_EX void gpgx_swap_disc(const toc_t* toc)
|
||||
{
|
||||
if (system_hw == SYSTEM_MCD)
|
||||
{
|
||||
cdd_hotswap(toc);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 width; // in cells
|
||||
|
|
|
@ -203,6 +203,21 @@ void cdd_unload(void)
|
|||
memset(&cdd.toc, 0x00, sizeof(cdd.toc));
|
||||
}
|
||||
|
||||
void cdd_hotswap(const toc_t *toc)
|
||||
{
|
||||
if (toc)
|
||||
{
|
||||
cdd.loaded = 1;
|
||||
memcpy(&cdd.toc, &toc, sizeof(cdd.toc));
|
||||
}
|
||||
else
|
||||
{
|
||||
cdd.loaded = 0;
|
||||
memset(&cdd.toc, 0x00, sizeof(cdd.toc));
|
||||
}
|
||||
cdd_reset();
|
||||
}
|
||||
|
||||
void cdd_read_data(uint8 *dst)
|
||||
{
|
||||
/* only read DATA track sectors */
|
||||
|
@ -348,7 +363,7 @@ void cdd_read_audio(unsigned int samples)
|
|||
void cdd_update(void)
|
||||
{
|
||||
#ifdef LOG_CDD
|
||||
error("LBA = %d (track n°%d)(latency=%d)\n", cdd.lba, cdd.index, cdd.latency);
|
||||
error("LBA = %d (track n<EFBFBD>%d)(latency=%d)\n", cdd.lba, cdd.index, cdd.latency);
|
||||
#endif
|
||||
|
||||
/* seeking disc */
|
||||
|
|
|
@ -103,4 +103,8 @@ extern void cdd_read_audio(unsigned int samples);
|
|||
extern void cdd_update(void);
|
||||
extern void cdd_process(void);
|
||||
|
||||
// switch disks after emulation was started
|
||||
// pass NULL to open tray
|
||||
void cdd_hotswap(const toc_t *toc);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue