Add support for dumping Nintendo 64 cartridges using a Retrode.

This commit is contained in:
2021-12-28 03:42:32 +00:00
parent 60f957b539
commit 77f3d2fde0
2 changed files with 23 additions and 7 deletions

View File

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

View File

@@ -56,6 +56,11 @@ public partial class Dump
0x53, 0x4D, 0x53 0x53, 0x4D, 0x53
}; };
static readonly byte[] _z64Extension =
{
0x5A, 0x36, 0x34
};
/// <summary>Dumps a game cartridge using a Retrode adapter</summary> /// <summary>Dumps a game cartridge using a Retrode adapter</summary>
void Retrode() void Retrode()
{ {
@@ -106,6 +111,7 @@ public partial class Dump
bool sfcFound = false; bool sfcFound = false;
bool genesisFound = false; bool genesisFound = false;
bool smsFound = false; bool smsFound = false;
bool n64Found = false;
tmp = new byte[3]; tmp = new byte[3];
for(romPos = 0; romPos < buffer.Length; romPos += 0x20) for(romPos = 0; romPos < buffer.Length; romPos += 0x20)
@@ -132,11 +138,19 @@ public partial class Dump
break; break;
} }
if(tmp.SequenceEqual(_z64Extension))
{
n64Found = true;
break;
}
} }
if(!sfcFound && if(!sfcFound &&
!genesisFound && !genesisFound &&
!smsFound) !smsFound &&
!n64Found)
{ {
StoppingErrorMessage?.Invoke("No cartridge found, not dumping..."); StoppingErrorMessage?.Invoke("No cartridge found, not dumping...");
_dumpLog.WriteLine("No cartridge found, not dumping..."); _dumpLog.WriteLine("No cartridge found, not dumping...");
@@ -147,11 +161,13 @@ public partial class Dump
ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A); ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A);
uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C); uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C);
MediaType mediaType = smsFound MediaType mediaType = n64Found
? MediaType.MasterSystemCartridge ? MediaType.N64GamePak
: genesisFound : smsFound
? MediaType.MegaDriveCartridge ? MediaType.MasterSystemCartridge
: MediaType.SNESGamePak; : genesisFound
? MediaType.MegaDriveCartridge
: MediaType.SNESGamePak;
uint blocksToRead = 64; uint blocksToRead = 64;
double totalDuration = 0; double totalDuration = 0;