From 5755ae56c1e296c5ceb03847aa8948bd943adc3c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 28 Dec 2021 03:45:51 +0000 Subject: [PATCH] Add support for dumping Game Boy, Game Boy Color and Game Boy Advance cartridges using a Retrode. --- .../Devices/Dumping/LinearMemory/Retrode.cs | 57 ++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs index 8afe8549a..d424bcdc2 100644 --- a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs +++ b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs @@ -61,6 +61,21 @@ public partial class Dump 0x5A, 0x36, 0x34 }; + static readonly byte[] _gbExtension = + { + 0x47, 0x42, 0x20 + }; + + static readonly byte[] _gbcExtension = + { + 0x47, 0x42, 0x43 + }; + + static readonly byte[] _gbaExtension = + { + 0x47, 0x42, 0x41 + }; + /// Dumps a game cartridge using a Retrode adapter void Retrode() { @@ -112,6 +127,9 @@ public partial class Dump bool genesisFound = false; bool smsFound = false; bool n64Found = false; + bool gbFound = false; + bool gbcFound = false; + bool gbaFound = false; tmp = new byte[3]; for(romPos = 0; romPos < buffer.Length; romPos += 0x20) @@ -145,6 +163,27 @@ public partial class Dump break; } + + if(tmp.SequenceEqual(_gbExtension)) + { + gbFound = true; + + break; + } + + if(tmp.SequenceEqual(_gbcExtension)) + { + gbcFound = true; + + break; + } + + if(tmp.SequenceEqual(_gbaExtension)) + { + gbaFound = true; + + break; + } } if(!sfcFound && @@ -161,13 +200,17 @@ public partial class Dump ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A); uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C); - MediaType mediaType = n64Found - ? MediaType.N64GamePak - : smsFound - ? MediaType.MasterSystemCartridge - : genesisFound - ? MediaType.MegaDriveCartridge - : MediaType.SNESGamePak; + MediaType mediaType = gbaFound + ? MediaType.GameBoyAdvanceGamePak + : gbFound || gbcFound + ? MediaType.GameBoyGamePak + : n64Found + ? MediaType.N64GamePak + : smsFound + ? MediaType.MasterSystemCartridge + : genesisFound + ? MediaType.MegaDriveCartridge + : MediaType.SNESGamePak; uint blocksToRead = 64; double totalDuration = 0;