Add support for dumping Genesis / Mega Drive cartridges using a Retrode.

This commit is contained in:
2021-12-28 03:30:34 +00:00
parent 14510f2fdf
commit c1a694a7ed
2 changed files with 30 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Aaru" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="$PROJECT_DIR$/Aaru/bin/Debug/net6/aaru" />
<option name="PROGRAM_PARAMETERS" value="m dump /dev/sda foo.sfc" />
<option name="PROGRAM_PARAMETERS" value="m dump /dev/sdb foo2.md" />
<option name="WORKING_DIRECTORY" value="$USER_HOME$/Desktop" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />

View File

@@ -46,7 +46,12 @@ public partial class Dump
0x53, 0x46, 0x43
};
/// <summary>Dumps a CFW PlayStation Portable UMD</summary>
static readonly byte[] _genesisExtension =
{
0x42, 0x49, 0x4E
};
/// <summary>Dumps a game cartridge using a Retrode adapter</summary>
void Retrode()
{
bool sense = _dev.Read10(out byte[] buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, _dev.Timeout,
@@ -94,21 +99,30 @@ public partial class Dump
int romPos;
bool sfcFound = false;
bool genesisFound = false;
tmp = new byte[3];
for(romPos = 0; romPos < buffer.Length; romPos += 0x20)
{
Array.Copy(buffer, romPos + 8, tmp, 0, 3);
if(!tmp.SequenceEqual(_sfcExtension))
continue;
if(tmp.SequenceEqual(_sfcExtension))
{
sfcFound = true;
break;
}
if(!sfcFound)
if(tmp.SequenceEqual(_genesisExtension))
{
genesisFound = true;
break;
}
}
if(!sfcFound &&
!genesisFound)
{
StoppingErrorMessage?.Invoke("No cartridge found, not dumping...");
_dumpLog.WriteLine("No cartridge found, not dumping...");
@@ -119,7 +133,7 @@ public partial class Dump
ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A);
uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C);
const MediaType mediaType = MediaType.SNESGamePak;
MediaType mediaType = genesisFound ? MediaType.MegaDriveCartridge : MediaType.SNESGamePak;
uint blocksToRead = 64;
double totalDuration = 0;
double currentSpeed = 0;