Saturnus: Add CD sanity checks
This commit is contained in:
parent
40680a9d74
commit
4d875e0c24
|
@ -1,4 +1,5 @@
|
|||
using BizHawk.Common.BizInvoke;
|
||||
using BizHawk.Common.BufferExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
using BizHawk.Emulation.DiscSystem;
|
||||
|
@ -6,6 +7,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -27,6 +29,30 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
private bool _isPal;
|
||||
private SaturnusControllerDeck _controllerDeck;
|
||||
|
||||
private static bool CheckDisks(IEnumerable<DiscSectorReader> readers)
|
||||
{
|
||||
var buff = new byte[2048 * 16];
|
||||
foreach (var r in readers)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (r.ReadLBA_2048(i, buff, 2048 * i) != 2048)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Encoding.ASCII.GetString(buff, 0, 16) != "SEGA SEGASATURN ")
|
||||
return false;
|
||||
|
||||
using (var sha256 = SHA256.Create())
|
||||
{
|
||||
sha256.ComputeHash(buff, 0x100, 0xd00);
|
||||
if (sha256.Hash.BytesToHexString() != "96B8EA48819CFA589F24C40AA149C224C420DCCF38B730F00156EFE25C9BBC8F")
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Saturnus(CoreComm comm, IEnumerable<Disc> disks)
|
||||
{
|
||||
ServiceProvider = new BasicServiceProvider(this);
|
||||
|
@ -34,6 +60,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
|
|||
|
||||
_disks = disks.ToArray();
|
||||
_diskReaders = disks.Select(d => new DiscSectorReader(d) { Policy = _diskPolicy }).ToArray();
|
||||
if (!CheckDisks(_diskReaders))
|
||||
throw new InvalidOperationException("Some disks are not valid");
|
||||
InitCallbacks();
|
||||
|
||||
_exe = new PeRunner(new PeRunnerOptions
|
||||
|
|
|
@ -225,74 +225,11 @@ EXPORT void SetupInput(const int* portdevices, const int* multitaps)
|
|||
SMPC_SetInput(i, DeviceNames[portdevices[i]], ControllerInput + i * 32);
|
||||
}
|
||||
|
||||
/*void VDP2REND_SetGetVideoParams(MDFNGI* gi, const bool caspect, const int sls, const int sle, const bool show_h_overscan, const bool dohblend)
|
||||
{
|
||||
CorrectAspect = caspect;
|
||||
ShowHOverscan = show_h_overscan;
|
||||
DoHBlend = dohblend;
|
||||
LineVisFirst = sls;
|
||||
LineVisLast = sle;
|
||||
//
|
||||
//
|
||||
//
|
||||
gi->fb_width = 704;
|
||||
|
||||
if(PAL)
|
||||
{
|
||||
gi->nominal_width = (ShowHOverscan ? 365 : 354);
|
||||
gi->fb_height = 576;
|
||||
}
|
||||
else
|
||||
{
|
||||
gi->nominal_width = (ShowHOverscan ? 302 : 292);
|
||||
gi->fb_height = 480;
|
||||
}
|
||||
gi->nominal_height = LineVisLast + 1 - LineVisFirst;
|
||||
|
||||
|
||||
gi->lcm_width = (ShowHOverscan? 10560 : 10240);
|
||||
gi->lcm_height = (LineVisLast + 1 - LineVisFirst) * 2;
|
||||
//
|
||||
//
|
||||
//
|
||||
if(!CorrectAspect)
|
||||
{
|
||||
gi->nominal_width = (ShowHOverscan ? 352 : 341);
|
||||
gi->lcm_width = gi->nominal_width * 2;
|
||||
}
|
||||
}
|
||||
void SetGetVideoParams(MDFNGI* gi, const bool caspect, const int sls, const int sle, const bool show_h_overscan, const bool dohblend)
|
||||
{
|
||||
if(PAL)
|
||||
gi->fps = 65536 * 256 * (1734687500.0 / 61 / 4 / 455 / ((313 + 312.5) / 2.0));
|
||||
else
|
||||
gi->fps = 65536 * 256 * (1746818181.8 / 61 / 4 / 455 / ((263 + 262.5) / 2.0));
|
||||
|
||||
VDP2REND_SetGetVideoParams(gi, caspect, sls, sle, show_h_overscan, dohblend);
|
||||
}*/
|
||||
|
||||
// if (BackupRAM_Dirty)SaveBackupRAM();
|
||||
// if (CART_GetClearNVDirty())SaveCartNV();
|
||||
|
||||
/*static MDFN_COLD bool IsSaturnDisc(const uint8 *sa32k)
|
||||
{
|
||||
//if(sha256(&sa32k[0x100], 0xD00) != "96b8ea48819cfa589f24c40aa149c224c420dccf38b730f00156efe25c9bbc8f"_sha256)
|
||||
// return false;
|
||||
|
||||
if (memcmp(&sa32k[0], "SEGA SEGASATURN ", 16))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}*/
|
||||
/*static MDFN_COLD bool TestMagicCD(std::vector<CDIF *> *CDInterfaces)
|
||||
{
|
||||
std::unique_ptr<uint8[]> buf(new uint8[2048 * 16]);
|
||||
|
||||
if ((*CDInterfaces)[0]->ReadSector(&buf[0], 0, 16, true) != 0x1)
|
||||
return false;
|
||||
|
||||
return IsSaturnDisc(&buf[0]);
|
||||
}*/
|
||||
|
||||
/*static MDFN_COLD void CloseGame(void)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue