support pce-cd and sgx in nyma
This commit is contained in:
parent
8c9f4e24d8
commit
bc8d298a88
|
@ -525,9 +525,9 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO: pass disc in
|
||||
throw new NotImplementedException();
|
||||
// nextEmulator = new TerboGrafix(game, null, nextComm, "dunno what to put here");
|
||||
nextEmulator = new TerboGrafix(game, new[] { disc }, nextComm,
|
||||
(Emulation.Cores.Waterbox.NymaCore.NymaSettings)GetCoreSettings<TerboGrafix>(),
|
||||
(Emulation.Cores.Waterbox.NymaCore.NymaSyncSettings)GetCoreSyncSettings<TerboGrafix>());
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace BizHawk.Emulation.Common
|
|||
FirmwareAndOption("FECBAE2CEC76C710422486BAA186FFA7CA1CF925", 53248, "SNES", "ST011", "st011.rom", "ST011 Rom");
|
||||
FirmwareAndOption("91383B92745CC7CC4F15409AC5BC2C2F699A43F1", 163840, "SNES", "ST018", "st018.rom", "ST018 Rom");
|
||||
FirmwareAndOption("79F5FF55DD10187C7FD7B8DAAB0B3FFBD1F56A2C", 262144, "PCECD", "Bios", "pcecd-3.0-(J).pce", "Super CD Bios (J)");
|
||||
FirmwareAndOption("014881a959e045e00f4db8f52955200865d40280", 32768, "PCECD", "GE-Bios", "gecard.pce", "Games Express CD Card (Japan)");
|
||||
FirmwareAndOption("D9D134BB6B36907C615A594CC7688F7BFCEF5B43", 4096, "A78", "Bios_NTSC", "7800NTSCBIOS.bin", "NTSC Bios");
|
||||
//FirmwareAndOption("CE236581AB7921B59DB95BA12837C22F160896CB", 4096, "A78", "Bios_NTSC", "speed_bios.bin", "NTSC Bios speed");
|
||||
|
||||
|
|
|
@ -1,17 +1,31 @@
|
|||
using System.Collections.Generic;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
|
||||
{
|
||||
[Core(CoreNames.TurboNyma, "Mednafen Team", true, false, "1.24.3", "", false)]
|
||||
public class TerboGrafix : NymaCore, IRegionable
|
||||
{
|
||||
[CoreConstructor("PCE")]
|
||||
[CoreConstructor(new[] { "PCE", "SGX" })]
|
||||
public TerboGrafix(GameInfo game, byte[] rom, CoreComm comm, string extension,
|
||||
NymaSettings settings, NymaSyncSettings syncSettings)
|
||||
: base(game, rom, comm, "PCE", "PC Engine Controller", settings, syncSettings)
|
||||
: base(comm, "PCE", "PC Engine Controller", settings, syncSettings)
|
||||
{
|
||||
DoInit<LibNymaCore>(game, rom, "pce.wbx", extension);
|
||||
DoInit<LibNymaCore>(game, rom, null, "pce.wbx", extension);
|
||||
}
|
||||
public TerboGrafix(GameInfo game, Disc[] discs, CoreComm comm,
|
||||
NymaSettings settings, NymaSyncSettings syncSettings)
|
||||
: base(comm, "PCE", "PC Engine Controller", settings, syncSettings)
|
||||
{
|
||||
// TODO: detect GECD and only ask for the firmware we need
|
||||
var firmwares = new Dictionary<string, byte[]>
|
||||
{
|
||||
{ "FIRMWARE:syscard3.pce", comm.CoreFileProvider.GetFirmware("PCECD", "Bios", true) },
|
||||
{ "FIRMWARE:gecard.pce", comm.CoreFileProvider.GetFirmware("PCECD", "GE-Bios", true) },
|
||||
};
|
||||
DoInit<LibNymaCore>(game, null, discs, "pce.wbx", null, firmwares);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,13 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
/// Load a ROM
|
||||
/// </summary>
|
||||
[BizImport(CC, Compatibility = true)]
|
||||
public abstract bool Init([In]InitData data);
|
||||
public abstract bool InitRom([In]InitData data);
|
||||
|
||||
/// <summary>
|
||||
/// Load some CDs
|
||||
/// </summary>
|
||||
[BizImport(CC)]
|
||||
public abstract bool InitCd(int numdisks);
|
||||
|
||||
public enum CommandType : int
|
||||
{
|
||||
|
@ -290,5 +296,30 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
[BizImport(CC)]
|
||||
public abstract void SetFrontendSettingQuery(FrontendSettingQuery q);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class TOC
|
||||
{
|
||||
public int FirstTrack;
|
||||
public int LastTrack;
|
||||
public int DiskType;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Track
|
||||
{
|
||||
public int Adr;
|
||||
public int Control;
|
||||
public int Lba;
|
||||
public int Valid;
|
||||
}
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 101)]
|
||||
public Track[] Tracks;
|
||||
}
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
public delegate void CDTOCCallback(int disk, [In, Out]TOC toc);
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
public delegate void CDSectorCallback(int disk, int lba, IntPtr dest);
|
||||
[BizImport(CC)]
|
||||
public abstract void SetCDCallbacks(CDTOCCallback toccallback, CDSectorCallback sectorcallback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Waterbox
|
||||
{
|
||||
abstract partial class NymaCore : IDriveLight
|
||||
{
|
||||
// this code was mostly copied from Saturnus, which it will replace soon(R)
|
||||
private static readonly DiscSectorReaderPolicy _diskPolicy = new DiscSectorReaderPolicy
|
||||
{
|
||||
DeinterleavedSubcode = false
|
||||
};
|
||||
private LibNymaCore.CDTOCCallback _cdTocCallback;
|
||||
private LibNymaCore.CDSectorCallback _cdSectorCallback;
|
||||
private Disc[] _disks;
|
||||
private DiscSectorReader[] _diskReaders;
|
||||
|
||||
private static void SetupTOC(LibNymaCore.TOC t, DiscTOC tin)
|
||||
{
|
||||
// everything that's not commented, we're sure about
|
||||
t.FirstTrack = tin.FirstRecordedTrackNumber;
|
||||
t.LastTrack = tin.LastRecordedTrackNumber;
|
||||
t.DiskType = (int)tin.Session1Format;
|
||||
for (int i = 0; i < 101; i++)
|
||||
{
|
||||
t.Tracks[i].Adr = tin.TOCItems[i].Exists ? 1 : 0; // ????
|
||||
t.Tracks[i].Lba = tin.TOCItems[i].LBA;
|
||||
t.Tracks[i].Control = (int)tin.TOCItems[i].Control;
|
||||
t.Tracks[i].Valid = tin.TOCItems[i].Exists ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void CDTOCCallback(int disk, [In, Out]LibNymaCore.TOC t)
|
||||
{
|
||||
SetupTOC(t, _disks[disk].TOC);
|
||||
}
|
||||
private void CDSectorCallback(int disk, int lba, IntPtr dest)
|
||||
{
|
||||
var buff = new byte[2448];
|
||||
_diskReaders[disk].ReadLBA_2448(lba, buff, 0);
|
||||
Marshal.Copy(buff, 0, dest, 2448);
|
||||
DriveLightOn = true;
|
||||
}
|
||||
|
||||
public bool DriveLightEnabled => _disks?.Length > 0;
|
||||
public bool DriveLightOn { get; private set; }
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
{
|
||||
var ret = new ControllerDefinition
|
||||
{
|
||||
Name = "TODO"
|
||||
Name = "Mednafen Controller"
|
||||
};
|
||||
|
||||
var finalDevices = new List<string>();
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string SettingdValue { get; set; }
|
||||
public string SettingValue { get; set; }
|
||||
}
|
||||
public class Port
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
{
|
||||
Name = dev.FullName,
|
||||
Description = dev.Description,
|
||||
SettingdValue = dev.ShortName
|
||||
SettingValue = dev.ShortName
|
||||
};
|
||||
})
|
||||
.ToList()
|
||||
|
|
|
@ -5,12 +5,14 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Waterbox
|
||||
{
|
||||
public unsafe abstract partial class NymaCore : WaterboxCore
|
||||
{
|
||||
protected NymaCore(GameInfo game, byte[] rom, CoreComm comm, string systemId, string controllerDeckName,
|
||||
protected NymaCore(CoreComm comm,
|
||||
string systemId, string controllerDeckName,
|
||||
NymaSettings settings, NymaSyncSettings syncSettings)
|
||||
: base(comm, new Configuration { SystemId = systemId })
|
||||
{
|
||||
|
@ -21,7 +23,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
}
|
||||
|
||||
private LibNymaCore _nyma;
|
||||
protected T DoInit<T>(GameInfo game, byte[] rom, string wbxFilename, string extension)
|
||||
protected T DoInit<T>(GameInfo game, byte[] rom, Disc[] discs, string wbxFilename, string extension,
|
||||
ICollection<KeyValuePair<string, byte[]>> firmwares = null)
|
||||
where T : LibNymaCore
|
||||
{
|
||||
var t = PreInit<T>(new WaterboxOptions
|
||||
|
@ -38,27 +41,55 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
});
|
||||
_nyma = t;
|
||||
_settingsQueryDelegate = new LibNymaCore.FrontendSettingQuery(SettingsQuery);
|
||||
var fn = game.FilesystemSafeName();
|
||||
|
||||
using (_exe.EnterExit())
|
||||
{
|
||||
_nyma.PreInit();
|
||||
InitSyncSettingsInfo();
|
||||
_exe.AddReadonlyFile(rom, fn);
|
||||
_nyma.SetFrontendSettingQuery(_settingsQueryDelegate);
|
||||
|
||||
var didInit = _nyma.Init(new LibNymaCore.InitData
|
||||
if (firmwares != null)
|
||||
{
|
||||
// TODO: Set these as some cores need them
|
||||
FileNameBase = "",
|
||||
FileNameExt = extension.Trim('.').ToLowerInvariant(),
|
||||
FileNameFull = fn
|
||||
});
|
||||
foreach (var kvp in firmwares)
|
||||
{
|
||||
_exe.AddReadonlyFile(kvp.Value, kvp.Key);
|
||||
}
|
||||
}
|
||||
if (discs?.Length > 0)
|
||||
{
|
||||
_disks = discs;
|
||||
_diskReaders = _disks.Select(d => new DiscSectorReader(d) { Policy = _diskPolicy }).ToArray();
|
||||
_cdTocCallback = CDTOCCallback;
|
||||
_cdSectorCallback = CDSectorCallback;
|
||||
_nyma.SetCDCallbacks(_cdTocCallback, _cdSectorCallback);
|
||||
var didInit = _nyma.InitCd(_disks.Length);
|
||||
if (!didInit)
|
||||
throw new InvalidOperationException("Core rejected the CDs!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var fn = game.FilesystemSafeName();
|
||||
_exe.AddReadonlyFile(rom, fn);
|
||||
|
||||
if (!didInit)
|
||||
throw new InvalidOperationException("Core rejected the rom!");
|
||||
var didInit = _nyma.InitRom(new LibNymaCore.InitData
|
||||
{
|
||||
// TODO: Set these as some cores need them
|
||||
FileNameBase = "",
|
||||
FileNameExt = extension.Trim('.').ToLowerInvariant(),
|
||||
FileNameFull = fn
|
||||
});
|
||||
|
||||
_exe.RemoveReadonlyFile(fn);
|
||||
if (!didInit)
|
||||
throw new InvalidOperationException("Core rejected the rom!");
|
||||
|
||||
_exe.RemoveReadonlyFile(fn);
|
||||
}
|
||||
if (firmwares != null)
|
||||
{
|
||||
foreach (var kvp in firmwares)
|
||||
{
|
||||
_exe.RemoveReadonlyFile(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
var info = *_nyma.GetSystemInfo();
|
||||
_videoBuffer = new int[info.MaxWidth * info.MaxHeight];
|
||||
|
@ -84,9 +115,11 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
|
||||
InitControls();
|
||||
_nyma.SetFrontendSettingQuery(null);
|
||||
_nyma.SetCDCallbacks(null, null);
|
||||
PostInit();
|
||||
SettingsInfo.LayerNames = GetLayerData();
|
||||
_nyma.SetFrontendSettingQuery(_settingsQueryDelegate);
|
||||
_nyma.SetCDCallbacks(_cdTocCallback, _cdSectorCallback);
|
||||
PutSettings(_settings);
|
||||
}
|
||||
|
||||
|
@ -96,6 +129,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
protected override void LoadStateBinaryInternal(BinaryReader reader)
|
||||
{
|
||||
_nyma.SetFrontendSettingQuery(_settingsQueryDelegate);
|
||||
_nyma.SetCDCallbacks(_cdTocCallback, _cdSectorCallback);
|
||||
}
|
||||
|
||||
// todo: bleh
|
||||
|
|
|
@ -1,6 +1,53 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"*.mak": "makefile",
|
||||
"typeinfo": "cpp"
|
||||
"typeinfo": "cpp",
|
||||
"*.inc": "cpp",
|
||||
"new": "cpp",
|
||||
"__bit_reference": "cpp",
|
||||
"__config": "cpp",
|
||||
"__debug": "cpp",
|
||||
"__functional_base": "cpp",
|
||||
"__hash_table": "cpp",
|
||||
"__node_handle": "cpp",
|
||||
"__nullptr": "cpp",
|
||||
"__split_buffer": "cpp",
|
||||
"__string": "cpp",
|
||||
"__tree": "cpp",
|
||||
"__tuple": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"exception": "cpp",
|
||||
"functional": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iterator": "cpp",
|
||||
"limits": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"optional": "cpp",
|
||||
"queue": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"utility": "cpp",
|
||||
"vector": "cpp"
|
||||
}
|
||||
}
|
|
@ -25,7 +25,25 @@ namespace Mednafen
|
|||
|
||||
std::string MDFN_MakeFName(MakeFName_Type type, int id1, const char *cd1)
|
||||
{
|
||||
return "";
|
||||
std::string ret;
|
||||
switch (type)
|
||||
{
|
||||
case MDFNMKF_STATE: ret += "STATE:"; break;
|
||||
case MDFNMKF_SNAP: ret += "SNAP:"; break;
|
||||
case MDFNMKF_SAV: ret += "SAV:"; break;
|
||||
case MDFNMKF_SAVBACK: ret += "SAVBACK:"; break;
|
||||
case MDFNMKF_CHEAT: ret += "CHEAT:"; break;
|
||||
case MDFNMKF_PALETTE: ret += "PALETTE:"; break;
|
||||
case MDFNMKF_IPS: ret += "IPS:"; break;
|
||||
case MDFNMKF_MOVIE: ret += "MOVIE:"; break;
|
||||
case MDFNMKF_SNAP_DAT: ret += "SNAP_DAT:"; break;
|
||||
case MDFNMKF_CHEAT_TMP: ret += "CHEAT_TMP:"; break;
|
||||
case MDFNMKF_FIRMWARE: ret += "FIRMWARE:"; break;
|
||||
case MDFNMKF_PGCONFIG: ret += "PGCONFIG:"; break;
|
||||
default: ret += "UNKNOWN:"; break;
|
||||
}
|
||||
ret += cd1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// mednafen-driver.h
|
||||
|
|
|
@ -24,32 +24,37 @@ struct InitData
|
|||
|
||||
enum { MAX_PORTS = 16 };
|
||||
enum { MAX_PORT_DATA = 16 };
|
||||
static uint8_t InputPortData[MAX_PORTS * MAX_PORT_DATA];
|
||||
static uint8_t InputPortData[(MAX_PORTS + 1) * MAX_PORT_DATA];
|
||||
|
||||
ECL_EXPORT void PreInit()
|
||||
{
|
||||
SetupMDFNGameInfo();
|
||||
}
|
||||
|
||||
ECL_EXPORT bool Init(const InitData& data)
|
||||
static void Setup()
|
||||
{
|
||||
pixels = new uint32_t[Game->fb_width * Game->fb_height];
|
||||
samples = new int16_t[22050 * 2];
|
||||
Surf = new MDFN_Surface(
|
||||
pixels, Game->fb_width, Game->fb_height, Game->fb_width,
|
||||
MDFN_PixelFormat(MDFN_COLORSPACE_RGB, 16, 8, 0, 24)
|
||||
);
|
||||
EES = new EmulateSpecStruct();
|
||||
EES->surface = Surf;
|
||||
EES->VideoFormatChanged = true;
|
||||
EES->LineWidths = new int32_t[Game->fb_height];
|
||||
memset(EES->LineWidths, 0xff, Game->fb_height * sizeof(int32_t));
|
||||
EES->SoundBuf = samples;
|
||||
EES->SoundBufMaxSize = 22050;
|
||||
EES->SoundFormatChanged = true;
|
||||
EES->SoundRate = 44100;
|
||||
}
|
||||
|
||||
ECL_EXPORT bool InitRom(const InitData& data)
|
||||
{
|
||||
try
|
||||
{
|
||||
pixels = new uint32_t[Game->fb_width * Game->fb_height];
|
||||
samples = new int16_t[22050 * 2];
|
||||
Surf = new MDFN_Surface(
|
||||
pixels, Game->fb_width, Game->fb_height, Game->fb_width,
|
||||
MDFN_PixelFormat(MDFN_COLORSPACE_RGB, 16, 8, 0, 24)
|
||||
);
|
||||
EES = new EmulateSpecStruct();
|
||||
EES->surface = Surf;
|
||||
EES->VideoFormatChanged = true;
|
||||
EES->LineWidths = new int32_t[Game->fb_height];
|
||||
memset(EES->LineWidths, 0xff, Game->fb_height * sizeof(int32_t));
|
||||
EES->SoundBuf = samples;
|
||||
EES->SoundBufMaxSize = 22050;
|
||||
EES->SoundFormatChanged = true;
|
||||
EES->SoundRate = 44100;
|
||||
Setup();
|
||||
|
||||
std::unique_ptr<Stream> gamestream(new FileStream(data.FileNameFull, FileStream::MODE_READ, false));
|
||||
GameFile gf({
|
||||
|
@ -72,6 +77,22 @@ ECL_EXPORT bool Init(const InitData& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
void StartGameWithCds(int numdisks);
|
||||
|
||||
ECL_EXPORT bool InitCd(int numdisks)
|
||||
{
|
||||
try
|
||||
{
|
||||
Setup();
|
||||
StartGameWithCds(numdisks);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
struct MyFrameInfo: public FrameInfo
|
||||
{
|
||||
// true to skip video rendering
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
#include "mednafen/src/types.h"
|
||||
#include <emulibc.h>
|
||||
#include <waterboxcore.h>
|
||||
#include <mednafen/mednafen.h>
|
||||
#include <stdint.h>
|
||||
#include <mednafen/cdrom/CDInterface.h>
|
||||
#include <mednafen/cdrom/CDInterface_MT.h>
|
||||
#include <mednafen/cdrom/CDInterface_ST.h>
|
||||
#include <mednafen/cdrom/CDAccess.h>
|
||||
#include <trio/trio.h>
|
||||
|
||||
#include "cdrom.h"
|
||||
|
||||
using namespace Mednafen;
|
||||
|
||||
struct NymaTOC
|
||||
{
|
||||
int32_t FirstTrack;
|
||||
int32_t LastTrack;
|
||||
int32_t DiskType;
|
||||
struct
|
||||
{
|
||||
int32_t Adr;
|
||||
int32_t Control;
|
||||
int32_t Lba;
|
||||
int32_t Valid;
|
||||
} Tracks[101];
|
||||
};
|
||||
|
||||
static void (*ReadTOCCallback)(int disk, NymaTOC *dest);
|
||||
static void (*ReadSector2448Callback)(int disk, int lba, uint8 *dest);
|
||||
|
||||
ECL_EXPORT void SetCDCallbacks(void (*toccallback)(int disk, NymaTOC *dest), void (*sectorcallback)(int disk, int lba, uint8 *dest))
|
||||
{
|
||||
ReadTOCCallback = toccallback;
|
||||
ReadSector2448Callback = sectorcallback;
|
||||
}
|
||||
|
||||
CDInterfaceNyma::CDInterfaceNyma(int d) : disk(d)
|
||||
{
|
||||
NymaTOC t;
|
||||
ReadTOCCallback(disk, &t);
|
||||
disc_toc.first_track = t.FirstTrack;
|
||||
disc_toc.last_track = t.LastTrack;
|
||||
disc_toc.disc_type = t.DiskType;
|
||||
for (int i = 0; i < 101; i++)
|
||||
{
|
||||
disc_toc.tracks[i].adr = t.Tracks[i].Adr;
|
||||
disc_toc.tracks[i].control = t.Tracks[i].Control;
|
||||
disc_toc.tracks[i].lba = t.Tracks[i].Lba;
|
||||
disc_toc.tracks[i].valid = t.Tracks[i].Valid;
|
||||
}
|
||||
}
|
||||
|
||||
void CDInterfaceNyma::HintReadSector(int32 lba) {}
|
||||
bool CDInterfaceNyma::ReadRawSector(uint8 *buf, int32 lba)
|
||||
{
|
||||
ReadSector2448Callback(disk, lba, buf);
|
||||
return true;
|
||||
}
|
||||
bool CDInterfaceNyma::ReadRawSectorPWOnly(uint8 *pwbuf, int32 lba, bool hint_fullread)
|
||||
{
|
||||
uint8 buff[2448];
|
||||
ReadSector2448Callback(disk, lba, buff);
|
||||
memcpy(pwbuf, buff + 2352, 96);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<CDInterface*>* CDInterfaces;
|
||||
|
||||
void StartGameWithCds(int numdisks)
|
||||
{
|
||||
CDInterfaces = new std::vector<CDInterface*>();
|
||||
for (int d = 0; d < numdisks; d++)
|
||||
{
|
||||
CDInterfaces->push_back(new CDInterfaceNyma(d));
|
||||
}
|
||||
MDFNGameInfo->LoadCD(CDInterfaces);
|
||||
|
||||
// TODO: Figure out wtf all this RMD stuff is
|
||||
auto rmd = new RMD_Layout();
|
||||
{
|
||||
RMD_Drive dr;
|
||||
|
||||
dr.Name = "Virtual CD Drive";
|
||||
dr.PossibleStates.push_back(RMD_State({"Tray Open", false, false, true}));
|
||||
dr.PossibleStates.push_back(RMD_State({"Tray Closed (Empty)", false, false, false}));
|
||||
dr.PossibleStates.push_back(RMD_State({"Tray Closed", true, true, false}));
|
||||
dr.CompatibleMedia.push_back(0);
|
||||
dr.MediaMtoPDelay = 2000;
|
||||
|
||||
rmd->Drives.push_back(dr);
|
||||
rmd->DrivesDefaults.push_back(RMD_DriveDefaults({0, 0, 0}));
|
||||
rmd->MediaTypes.push_back(RMD_MediaType({"CD"}));
|
||||
}
|
||||
|
||||
const int default_cd = 0;
|
||||
|
||||
for(size_t i = 0; i < CDInterfaces->size(); i++)
|
||||
{
|
||||
if (i == default_cd)
|
||||
{
|
||||
rmd->DrivesDefaults[0].State = 2; // Tray Closed
|
||||
rmd->DrivesDefaults[0].Media = i;
|
||||
rmd->DrivesDefaults[0].Orientation = 0;
|
||||
}
|
||||
char namebuf[128];
|
||||
trio_snprintf(namebuf, sizeof(namebuf), _("Disc %zu of %zu"), i + 1, CDInterfaces->size());
|
||||
rmd->Media.push_back(RMD_Media({namebuf, 0}));
|
||||
}
|
||||
MDFNGameInfo->RMD = rmd;
|
||||
|
||||
// TODO: Wire up a way for the user to change disks
|
||||
Mednafen::MDFNGameInfo->SetMedia(
|
||||
0, // drive: 0 unless there's more than one drive
|
||||
2, // state: 0 = open, 1 = closed (media absent), 2 = closed (media present)
|
||||
0, // media: index into the disk list
|
||||
0 // orientation: flip sides on NES FDS. not used elsewhere?
|
||||
);
|
||||
}
|
||||
|
||||
// CDInterface::Load pulls in a bunch of things that we do not want, stub them out here
|
||||
namespace Mednafen
|
||||
{
|
||||
using namespace CDUtility;
|
||||
CDInterface_MT::CDInterface_Message::~CDInterface_Message(){}
|
||||
CDInterface_MT::CDInterface_Queue::CDInterface_Queue(){}
|
||||
CDInterface_MT::CDInterface_Queue::~CDInterface_Queue(){}
|
||||
CDInterface_MT::CDInterface_MT(std::unique_ptr<CDAccess> cda, const uint64 affinity){}
|
||||
CDInterface_MT::~CDInterface_MT(){}
|
||||
bool CDInterface_MT::ReadRawSector(uint8 *buf, int32 lba){return false;}
|
||||
bool CDInterface_MT::ReadRawSectorPWOnly(uint8* pwbuf, int32 lba, bool hint_fullread){return false;}
|
||||
void CDInterface_MT::HintReadSector(int32 lba){}
|
||||
CDInterface_ST::CDInterface_ST(std::unique_ptr<CDAccess> cda) : disc_cdaccess(std::move(cda)){}
|
||||
CDInterface_ST::~CDInterface_ST(){}
|
||||
void CDInterface_ST::HintReadSector(int32 lba){}
|
||||
bool CDInterface_ST::ReadRawSector(uint8 *buf, int32 lba){return false;}
|
||||
bool CDInterface_ST::ReadRawSectorPWOnly(uint8* pwbuf, int32 lba, bool hint_fullread){return false;}
|
||||
CDAccess* CDAccess_Open(VirtualFS* vfs, const std::string& path, bool image_memcache){return nullptr;}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "mednafen/src/types.h"
|
||||
#include <mednafen/mednafen.h>
|
||||
#include <mednafen/cdrom/CDInterface.h>
|
||||
|
||||
class CDInterfaceNyma : public Mednafen::CDInterface
|
||||
{
|
||||
private:
|
||||
int disk;
|
||||
|
||||
public:
|
||||
CDInterfaceNyma(int disk);
|
||||
virtual void HintReadSector(int32 lba) override;
|
||||
virtual bool ReadRawSector(uint8 *buf, int32 lba) override;
|
||||
virtual bool ReadRawSectorPWOnly(uint8 *pwbuf, int32 lba, bool hint_fullread) override;
|
||||
};
|
|
@ -1,17 +1,24 @@
|
|||
include common.mak
|
||||
|
||||
# $(call cppdir,hw_video/huc6270)
|
||||
# $(call cppdir,hw_sound/pce_psg)
|
||||
# $(filter-out %CDAFReader_SF.cpp,$(call cppdir,cdrom))
|
||||
# $(call cdir,tremor)
|
||||
# $(call cdir,mpcdec)
|
||||
# mednafen/src/mthreading/MThreading_POSIX.cpp
|
||||
|
||||
SRCS += \
|
||||
$(filter-out %debug.cpp,$(call cppdir,pce)) \
|
||||
$(filter-out %CDAFReader_SF.cpp,$(call cppdir,cdrom)) \
|
||||
$(call cdir,tremor) \
|
||||
$(call cdir,mpcdec) \
|
||||
mednafen/src/mthreading/MThreading_POSIX.cpp \
|
||||
$(call cppdir,hw_sound/pce_psg) \
|
||||
$(call cppdir,hw_misc/arcade_card) \
|
||||
$(call cppdir,hw_video/huc6270) \
|
||||
mednafen/src/cdrom/CDInterface.cpp \
|
||||
mednafen/src/cdrom/scsicd.cpp \
|
||||
mednafen/src/cdrom/CDUtility.cpp \
|
||||
mednafen/src/cdrom/lec.cpp \
|
||||
mednafen/src/cdrom/recover-raw.cpp \
|
||||
mednafen/src/cdrom/l-ec.cpp \
|
||||
mednafen/src/cdrom/crc32.cpp \
|
||||
mednafen/src/cdrom/galois.cpp \
|
||||
cdrom.cpp \
|
||||
pce.cpp
|
||||
|
||||
include ../common.mak
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
include common.mak
|
||||
|
||||
# $(filter-out %CDAFReader_SF.cpp,$(call cppdir,cdrom))
|
||||
# $(call cdir,tremor)
|
||||
# $(call cdir,mpcdec)
|
||||
# mednafen/src/mthreading/MThreading_POSIX.cpp
|
||||
|
||||
SRCS += \
|
||||
$(filter-out %debug.cpp,$(call cppdir,pcfx)) \
|
||||
$(call cppdir,hw_cpu/v810) \
|
||||
$(filter-out %CDAFReader_SF.cpp,$(call cppdir,cdrom)) \
|
||||
$(call cppdir,hw_video/huc6270) \
|
||||
$(call cppdir,hw_sound/pce_psg) \
|
||||
$(call cdir,tremor) \
|
||||
$(call cdir,mpcdec) \
|
||||
mednafen/src/mthreading/MThreading_POSIX.cpp
|
||||
$(call cppdir,hw_sound/pce_psg)
|
||||
|
||||
include ../common.mak
|
||||
|
|
Loading…
Reference in New Issue