コード例 #1
0
        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);
        }
コード例 #2
0
        public override Task <EmptyResponse> WritePpu(WriteRequest request, ServerCallContext context)
        {
            var result = new EmptyResponse();

            try
            {
                if (request.Data.Length <= 32)
                {
                    Console.Write($"Writing ");
                    foreach (var b in request.Data)
                    {
                        Console.Write($"0x{b:X2} ");
                    }
                    if (request.Data.Length > 1)
                    {
                        Console.Write($"=> 0x{request.Address:X4}-0x{request.Address + request.Data.Length - 1:X4} @ PPU... ");
                    }
                    else
                    {
                        Console.Write($"=> 0x{request.Address:X4} @ PPU... ");
                    }
                }
                else
                {
                    Console.Write($"Writing to 0x{request.Address:X4}-0x{request.Address + request.Data.Length - 1:X4} @ PPU... ");
                }
                dumper.WritePpu((ushort)request.Address, request.Data.ToByteArray());
                Console.WriteLine("OK");
            }
            catch (Exception ex)
            {
                PrintError(ex);
                result.ErrorInfo = new ErrorInfo()
                {
                    ExceptionName    = ex.GetType().ToString(),
                    ExceptionMessage = ex.Message
                };
            }
            return(Task.FromResult(result));
        }