public PCEngine(CoreComm comm, GameInfo game, Disc disc, object Settings, object syncSettings) { CoreComm = comm; CoreComm.CpuTraceAvailable = true; CoreComm.UsesDriveLed = true; systemid = "PCECD"; Type = NecSystemType.TurboCD; this.disc = disc; this._settings = (PCESettings)Settings ?? new PCESettings(); _syncSettings = (PCESyncSettings)syncSettings ?? new PCESyncSettings(); GameInfo biosInfo; byte[] rom = CoreComm.CoreFileProvider.GetFirmwareWithGameInfo("PCECD", "Bios", true, out biosInfo, "PCE-CD System Card not found. Please check the BIOS settings in Config->Firmwares."); if (biosInfo.Status == RomStatus.BadDump) { CoreComm.ShowMessage( "The PCE-CD System Card you have selected is known to be a bad dump. This may cause problems playing PCE-CD games.\n\n" + "It is recommended that you find a good dump of the system card. Sorry to be the bearer of bad news!"); } else if (biosInfo.NotInDatabase) { CoreComm.ShowMessage( "The PCE-CD System Card you have selected is not recognized in our database. That might mean it's a bad dump, or isn't the correct rom."); } else if (biosInfo["BIOS"] == false) { //zeromus says: someone please write a note about how this could possibly happen. //it seems like this is a relic of using gameDB for storing whether something is a bios? firmwareDB should be handling it now. CoreComm.ShowMessage( "The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom. FYI-Please report this to developers, I don't think this error message should happen."); } if (biosInfo["SuperSysCard"]) { game.AddOption("SuperSysCard"); } if (game["NeedSuperSysCard"] && game["SuperSysCard"] == false) { CoreComm.ShowMessage( "This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in the firmware configuration."); throw new Exception(); } game.FirmwareHash = rom.HashSHA1(); Init(game, rom); // the default RomStatusDetails don't do anything with Disc CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, disc.GetHash()); SetControllerButtons(); }
public static GameInfo GetGameInfo(byte[] romData, string fileName) { var hash = $"{CRC32.Calculate(romData):X8}"; if (DB.TryGetValue(hash, out var cgi)) { return(new GameInfo(cgi)); } hash = romData.HashMD5(); if (DB.TryGetValue(hash, out cgi)) { return(new GameInfo(cgi)); } hash = romData.HashSHA1(); if (DB.TryGetValue(hash, out cgi)) { return(new GameInfo(cgi)); } // rom is not in database. make some best-guesses var game = new GameInfo { Hash = hash, Status = RomStatus.NotInDatabase, NotInDatabase = true }; Console.WriteLine( "Game was not in DB. CRC: {0:X8} MD5: {1}", CRC32.Calculate(romData), System.Security.Cryptography.MD5.Create().ComputeHash(romData).BytesToHexString()); var ext = Path.GetExtension(fileName)?.ToUpperInvariant(); switch (ext) { case ".NES": case ".UNF": case ".FDS": game.System = "NES"; break; case ".SFC": case ".SMC": game.System = "SNES"; break; case ".GB": game.System = "GB"; break; case ".GBC": game.System = "GBC"; break; case ".GBA": game.System = "GBA"; break; case ".SMS": game.System = "SMS"; break; case ".GG": game.System = "GG"; break; case ".SG": game.System = "SG"; break; case ".GEN": case ".MD": case ".SMD": game.System = "GEN"; break; case ".PSF": case ".MINIPSF": game.System = "PSX"; break; case ".PCE": game.System = "PCE"; break; case ".SGX": game.System = "SGX"; break; case ".A26": game.System = "A26"; break; case ".A78": game.System = "A78"; break; case ".COL": game.System = "Coleco"; break; case ".INT": game.System = "INTV"; break; case ".PRG": case ".D64": case ".T64": case ".G64": case ".CRT": game.System = "C64"; break; case ".TZX": case ".PZX": case ".CSW": case ".WAV": game.System = "ZXSpectrum"; break; case ".CDT": game.System = "AmstradCPC"; break; case ".TAP": byte[] head = romData.Take(8).ToArray(); game.System = Encoding.Default.GetString(head).Contains("C64-TAPE") ? "C64" : "ZXSpectrum"; break; case ".Z64": case ".V64": case ".N64": game.System = "N64"; break; case ".DEBUG": game.System = "DEBUG"; break; case ".WS": case ".WSC": game.System = "WSWAN"; break; case ".LNX": game.System = "Lynx"; break; case ".83P": game.System = "83P"; break; case ".DSK": var dId = new DSKIdentifier(romData); game.System = dId.IdentifiedSystem; break; case ".PO": case ".DO": game.System = "AppleII"; break; case ".VB": game.System = "VB"; break; case ".NGP": case ".NGC": game.System = "NGP"; break; case ".O2": game.System = "O2"; break; case ".UZE": game.System = "UZE"; break; case ".32X": game.System = "32X"; game.AddOption("32X", "true"); break; case ".VEC": game.System = "VEC"; game.AddOption("VEC", "true"); break; // refactor to use mame db (output of "mame -listxml" command) // there's no good definition for Arcade anymore, so we might limit to coin-based machines? case ".ZIP": game.System = "Arcade"; break; } game.Name = Path.GetFileNameWithoutExtension(fileName)?.Replace('_', ' '); // If filename is all-caps, then attempt to proper-case the title. if (!string.IsNullOrWhiteSpace(game.Name) && game.Name == game.Name.ToUpperInvariant()) { game.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(game.Name.ToLower()); } return(game); }
public static GameInfo GetGameInfo(byte[] romData, string fileName) { CompactGameInfo cgi; var hash = $"{CRC32.Calculate(romData):X8}"; if (DB.TryGetValue(hash, out cgi)) { return new GameInfo(cgi); } hash = romData.HashMD5(); if (DB.TryGetValue(hash, out cgi)) { return new GameInfo(cgi); } hash = romData.HashSHA1(); if (DB.TryGetValue(hash, out cgi)) { return new GameInfo(cgi); } // rom is not in database. make some best-guesses var game = new GameInfo { Hash = hash, Status = RomStatus.NotInDatabase, NotInDatabase = true }; Console.WriteLine( "Game was not in DB. CRC: {0:X8} MD5: {1}", CRC32.Calculate(romData), System.Security.Cryptography.MD5.Create().ComputeHash(romData).BytesToHexString()); var ext = Path.GetExtension(fileName)?.ToUpperInvariant(); switch (ext) { case ".NES": case ".UNF": case ".FDS": game.System = "NES"; break; case ".SFC": case ".SMC": game.System = "SNES"; break; case ".GB": game.System = "GB"; break; case ".GBC": game.System = "GBC"; break; case ".GBA": game.System = "GBA"; break; case ".SMS": game.System = "SMS"; break; case ".GG": game.System = "GG"; break; case ".SG": game.System = "SG"; break; case ".GEN": case ".MD": case ".SMD": game.System = "GEN"; break; case ".PSF": case ".MINIPSF": game.System = "PSX"; break; case ".PCE": game.System = "PCE"; break; case ".SGX": game.System = "SGX"; break; case ".A26": game.System = "A26"; break; case ".A78": game.System = "A78"; break; case ".COL": game.System = "Coleco"; break; case ".INT": game.System = "INTV"; break; case ".PRG": case ".D64": case ".T64": case ".G64": case ".CRT": game.System = "C64"; break; case ".TZX": game.System = "ZXSpectrum"; break; case ".TAP": byte[] head = romData.Take(8).ToArray(); if (System.Text.Encoding.Default.GetString(head).Contains("C64-TAPE")) game.System = "C64"; else game.System = "ZXSpectrum"; break; case ".Z64": case ".V64": case ".N64": game.System = "N64"; break; case ".DEBUG": game.System = "DEBUG"; break; case ".WS": case ".WSC": game.System = "WSWAN"; break; case ".LNX": game.System = "Lynx"; break; case ".83P": game.System = "83P"; break; case ".DSK": byte[] head2 = romData.Take(20).ToArray(); string ident = System.Text.Encoding.Default.GetString(head2); if (ident.ToUpper().Contains("EXTENDED CPC DSK") || ident.ToUpper().Contains("MV - CPC")) game.System = "ZXSpectrum"; else game.System = "AppleII"; break; case ".PO": case ".DO": game.System = "AppleII"; break; case ".VB": game.System = "VB"; break; case ".NGP": case ".NGC": game.System = "NGP"; break; case ".O2": game.System = "O2"; break; case ".UZE": game.System = "UZE"; break; case ".32X": game.System = "32X"; game.AddOption("32X", "true"); break; } game.Name = Path.GetFileNameWithoutExtension(fileName)?.Replace('_', ' '); // If filename is all-caps, then attempt to proper-case the title. if (!string.IsNullOrWhiteSpace(game.Name) && game.Name == game.Name.ToUpperInvariant()) { game.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(game.Name.ToLower()); } return game; }
public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { Ram = new byte[128]; CoreComm = comm; Settings = (A2600Settings)settings ?? new A2600Settings(); SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings(); var domains = new List<MemoryDomain> { new MemoryDomain( "Main RAM", 128, MemoryDomain.Endian.Little, addr => Ram[addr], (addr, value) => Ram[addr] = value), new MemoryDomain( "TIA", 16, MemoryDomain.Endian.Little, addr => _tia.ReadMemory((ushort)addr, true), (addr, value) => this._tia.WriteMemory((ushort)addr, value)), new MemoryDomain( "PIA", 1024, MemoryDomain.Endian.Little, addr => M6532.ReadMemory((ushort)addr, true), (addr, value) => M6532.WriteMemory((ushort)addr, value)), new MemoryDomain( "System Bus", 8192, MemoryDomain.Endian.Little, addr => _mapper.PeekMemory((ushort) addr), (addr, value) => _mapper.PokeMemory((ushort) addr, value)) }; CoreComm.CpuTraceAvailable = true; Rom = rom; _game = game; if (!game.GetOptionsDict().ContainsKey("m")) { game.AddOption("m", DetectMapper(rom)); } Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]); RebootCore(); if (_mapper is mDPC) // TODO: also mDPCPlus { domains.Add(new MemoryDomain( "DPC", 2048, MemoryDomain.Endian.Little, addr => (_mapper as mDPC).DspData[addr], (addr, value) => (_mapper as mDPC).DspData[addr] = value)); } if (_mapper.HasCartRam) { domains.Add(new MemoryDomain( "Cart Ram", _mapper.CartRam.Len, MemoryDomain.Endian.Little, addr => _mapper.CartRam[addr], (addr, value) => _mapper.CartRam[addr] = value)); } MemoryDomains = new MemoryDomainList(domains); }