public override Task <ReadResponse> ReadPpu(ReadRequest request, ServerCallContext context) { var result = new ReadResponse(); try { if (request.Length > 1) { Console.Write($"Reading 0x{request.Address:X4}-0x{request.Address + request.Length - 1:X4} @ PPU... "); } else { Console.Write($"Reading 0x{request.Address:X4} @ PPU... "); } byte[] data; if (request.HasLength) { data = dumper.ReadPpu((ushort)request.Address, (ushort)request.Length); } else { data = new byte[] { dumper.ReadPpu((ushort)request.Address) } }; if (data.Length <= 32) { foreach (var b in data) { Console.Write($"{b:X2} "); } Console.WriteLine(); } else { Console.WriteLine("OK"); } result.Data = ByteString.CopyFrom(data); } catch (Exception ex) { PrintError(ex); result.ErrorInfo = new ErrorInfo() { ExceptionName = ex.GetType().ToString(), ExceptionMessage = ex.Message }; } return(Task.FromResult(result)); }
public static byte DetectVersion(IFamicomDumperConnectionExt dumper) { byte version; Console.Write("Detecting COOLBOY version... "); // 0th CHR bank using both methods dumper.WriteCpu(0x5000, 0, 0, 0, 0x10); dumper.WriteCpu(0x6000, 0, 0, 0, 0x10); // Writing 0 dumper.WritePpu(0x0000, 0); // First CHR bank using both methods dumper.WriteCpu(0x5000, 0, 0, 1, 0x10); dumper.WriteCpu(0x6000, 0, 0, 1, 0x10); // Writing 1 dumper.WritePpu(0x0000, 1); // 0th bank using first method dumper.WriteCpu(0x6000, 0, 0, 0, 0x10); byte v6000 = dumper.ReadPpu(0x0000); // return dumper.WriteCpu(0x6000, 0, 0, 1, 0x10); // 0th bank using second method dumper.WriteCpu(0x5000, 0, 0, 0, 0x10); byte v5000 = dumper.ReadPpu(0x0000); if (v6000 == 0 && v5000 == 1) { version = 1; } else if (v6000 == 1 && v5000 == 0) { version = 2; } else { throw new IOException("Can't detect COOLBOY version"); } Console.WriteLine($"Version: {version}"); return(version); }