Use named constants for hardcoded rom checksums in Hawk cores

This commit is contained in:
YoshiRulz 2021-10-04 10:57:35 +10:00
parent d8dc06cbd2
commit cf7cc3bd0e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 73 additions and 28 deletions

View File

@ -11,6 +11,15 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public partial class Atari2600 : IEmulator, IDebuggable, IInputPollable, IBoardInfo, IRomInfo,
IRegionable, ICreateGameDBEntries, ISettable<Atari2600.A2600Settings, Atari2600.A2600SyncSettings>
{
internal static class RomChecksums
{
public const string CongoBongo = /*sha1:*/"3A77DB43B6583E8689435F0F14AA04B9E57BDDED";
public const string KangarooNotInGameDB = /*sha1:*/"982B8016B393A9AA7DD110295A53C4612ECF2141";
public const string Tapper = /*sha1:*/"E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620";
}
[CoreConstructor("A26")]
public Atari2600(GameInfo game, byte[] rom, Atari2600.A2600Settings settings, Atari2600.A2600SyncSettings syncSettings)
{
@ -35,9 +44,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
var romHashSHA1 = Rom.HashSHA1();
if (romHashSHA1 == "3A77DB43B6583E8689435F0F14AA04B9E57BDDED" ||
romHashSHA1 == "E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620" ||
romHashSHA1 == "982B8016B393A9AA7DD110295A53C4612ECF2141")
if (romHashSHA1 is RomChecksums.CongoBongo or RomChecksums.Tapper or RomChecksums.KangarooNotInGameDB)
{
game.RemoveOption("m");
game.AddOption("m", "F8_sega");

View File

@ -12,6 +12,13 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public partial class A7800Hawk : IEmulator, ISaveRam, IDebuggable, IInputPollable,
IRegionable, IBoardInfo, ISettable<A7800Hawk.A7800Settings, A7800Hawk.A7800SyncSettings>
{
internal static class RomChecksums
{
public const string KaratekaPAL = "md5:5E0A1E832BBCEA6FACB832FDE23A440A";
public const string Serpentine = "md5:9BD70C06D3386F76F8162881699A777A";
}
// this register selects between 2600 and 7800 mode in the A7800
// however, we already have a 2600 emulator so this core will only be loading A7800 games
// furthermore, the location of the register is in the same place as TIA registers (0x0-0x1F)
@ -189,7 +196,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
cart_RAM = 8;
// the homebrew game serpentine requires extra RAM, but in the alternative style
if (hash_md5 == "md5:9BD70C06D3386F76F8162881699A777A")
if (hash_md5 == RomChecksums.Serpentine)
{
cart_RAM = 16;
}
@ -216,7 +223,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
small_flag = true;
// additionally, PAL Karateka has bank 6 (actually 2) at 0x4000
if (hash_md5 == "md5:5E0A1E832BBCEA6FACB832FDE23A440A")
if (hash_md5 == RomChecksums.KaratekaPAL)
{
PAL_Kara = true;
}

View File

@ -11,6 +11,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
public partial class VectrexHawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable,
ISettable<object, VectrexHawk.VectrexSyncSettings>
{
internal static class RomChecksums
{
public const string Minestorm = /*sha1:*/"65D07426B520DDD3115D40F255511E0FD2E20AE7";
}
public byte[] RAM = new byte[0x400];
public byte[] _bios, minestorm;
@ -58,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
_rom = rom;
// If the game is minstorm, then no cartridge is inserted, retun 0xFF
if (romHashSHA1 == "65D07426B520DDD3115D40F255511E0FD2E20AE7")
if (romHashSHA1 == RomChecksums.Minestorm)
{
_rom = new byte[0x8000];

View File

@ -24,6 +24,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public partial class GBHawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable, IGameboyCommon,
ISettable<GBHawk.GBSettings, GBHawk.GBSyncSettings>
{
internal static class RomChecksums
{
public const string BombermanCollection = /*md5:*/"9FB9C42CF52DCFDCFBAD5E61AE1B5777";
public const string BombermanSelectionKORNotInGameDB = /*md5:*/"D0C6FFC3602D91C0B2B1B0461553DE33";
public const string MortalKombatIAndIIUSAEU = /*md5:*/"CF1F58AB72112716D3C615A553B2F481";
public const string PirateRockMan8 = /*md5:*/"CAE0998A899DF2EE6ABA8E7695C2A096";
public const string PirateSachen1 = /*md5:*/"D3C1924D847BC5D125BF54C2076BE27A";
public const string UnknownRomA = /*md5:*/"97122B9B183AAB4079C8D36A4CE6E9C1";
public const string WisdomTreeExodus = /*md5:*/"AB1FA0ED0207B1D0D5F401F0CD17BEBF";
public const string WisdomTreeJoshua = /*md5:*/"2C07CAEE51A1F0C91C72C7C6F380B0F6";
public const string WisdomTreeKJVBible = /*md5:*/"BA2AC3587B3E1B36DE52E740274071B0";
public const string WisdomTreeNIVBible = /*md5:*/"8CDDB8B2DCD3EC1A3FDD770DF8BDA07C";
public const string WisdomTreeSpiritualWarfare = /*md5:*/"37E017C8D1A45BAB609FB5B43FB64337";
}
// this register controls whether or not the GB BIOS is mapped into memory
public byte GB_bios_register;
@ -542,21 +567,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
// special case for multi cart mappers
if (romHashMD5 == "97122B9B183AAB4079C8D36A4CE6E9C1"
|| romHashMD5 == "9FB9C42CF52DCFDCFBAD5E61AE1B5777"
|| romHashMD5 == "CF1F58AB72112716D3C615A553B2F481"
|| romHashMD5 == "D0C6FFC3602D91C0B2B1B0461553DE33") // Bomberman Selection
if (romHashMD5 is RomChecksums.UnknownRomA or RomChecksums.BombermanCollection or RomChecksums.MortalKombatIAndIIUSAEU or RomChecksums.BombermanSelectionKORNotInGameDB)
{
Console.WriteLine("Using Multi-Cart Mapper");
mapper = new MapperMBC1Multi();
}
// Wisdom Tree does not identify their mapper, so use hash instead
if (romHashMD5 == "2C07CAEE51A1F0C91C72C7C6F380B0F6" // Joshua
|| romHashMD5 == "37E017C8D1A45BAB609FB5B43FB64337" // Spiritual Warfare
|| romHashMD5 == "AB1FA0ED0207B1D0D5F401F0CD17BEBF" // Exodus
|| romHashMD5 == "BA2AC3587B3E1B36DE52E740274071B0" // Bible - KJV
|| romHashMD5 == "8CDDB8B2DCD3EC1A3FDD770DF8BDA07C") // Bible - NIV
else if (romHashMD5 is RomChecksums.WisdomTreeJoshua or RomChecksums.WisdomTreeSpiritualWarfare or RomChecksums.WisdomTreeExodus or RomChecksums.WisdomTreeKJVBible or RomChecksums.WisdomTreeNIVBible)
{
Console.WriteLine("Using Wisdom Tree Mapper");
mapper = new MapperWT();
@ -564,12 +582,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
// special case for bootlegs
if (romHashMD5 == "CAE0998A899DF2EE6ABA8E7695C2A096")
else if (romHashMD5 == RomChecksums.PirateRockMan8)
{
Console.WriteLine("Using RockMan 8 (Unlicensed) Mapper");
mapper = new MapperRM8();
}
if (romHashMD5 == "D3C1924D847BC5D125BF54C2076BE27A")
else if (romHashMD5 == RomChecksums.PirateSachen1)
{
Console.WriteLine("Using Sachen 1 (Unlicensed) Mapper");
mapper = new MapperSachen1();

View File

@ -90,8 +90,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
chr_mask = (Cart.ChrSize / 8) - 1;
SetMirrorType(Cart.PadH, Cart.PadV);
if (Cart.Sha1 == "sha1:4C9C05FAD6F6F33A92A27C2EDC1E7DE12D7F216D")
seicross = true;
if (Cart.Sha1 == NES.RomChecksums.SeicrossRev2) seicross = true;
return true;
}

View File

@ -13,6 +13,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
public partial class NES : IEmulator, ISoundProvider, ICycleTiming
{
internal static class RomChecksums
{
public const string CamericaGolden5 = /*sha1:*/"60FC5FA5B5ACCAF3AEFEBA73FC8BFFD3C4DAE558";
public const string CamericaGolden5Overdump = /*sha1:*/"BAD382331C30B22A908DA4BFF2759C25113CC26A";
public const string CamericaPegasus4in1 = /*sha1:*/"40409FEC8249EFDB772E6FFB2DCD41860C6CCA23";
public const string DancingBlocks = /*sha1:*/"68ABE1E49C9E9CCEA978A48232432C252E5912C0";
public const string SeicrossRev2 = "sha1:4C9C05FAD6F6F33A92A27C2EDC1E7DE12D7F216D"; // yes this is meant to include the prefix
public const string SilvaSaga = /*sha1:*/"00C50062A2DECE99580063777590F26A253AAB6B";
}
//hardware/state
public MOS6502X<CpuLink> cpu;
public PPU ppu;
@ -244,22 +259,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (cart.GameInfo!=null)
{
if (cart.GameInfo.Hash == "60FC5FA5B5ACCAF3AEFEBA73FC8BFFD3C4DAE558" // Camerica Golden 5
|| cart.GameInfo.Hash == "BAD382331C30B22A908DA4BFF2759C25113CC26A" // Camerica Golden 5
|| cart.GameInfo.Hash == "40409FEC8249EFDB772E6FFB2DCD41860C6CCA23" // Camerica Pegasus 4-in-1
)
if (cart.GameInfo.Hash is RomChecksums.CamericaGolden5 or RomChecksums.CamericaGolden5Overdump or RomChecksums.CamericaPegasus4in1)
{
ram[0x701] = 0xFF;
}
if (cart.GameInfo.Hash == "68ABE1E49C9E9CCEA978A48232432C252E5912C0") // Dancing Blocks
else if (cart.GameInfo.Hash == RomChecksums.DancingBlocks)
{
ram[0xEC] = 0;
ram[0xED] = 0;
}
if (cart.GameInfo.Hash == "00C50062A2DECE99580063777590F26A253AAB6B") // Silva Saga
else if (cart.GameInfo.Hash == RomChecksums.SilvaSaga)
{
for (int i = 0; i < Board.Wram.Length; i++)
{