Exemplo n.º 1
0
        public static void PasswordProgramm(FamicomDumperLocal dumper, byte[] password)
        {
            if (password.Length != 8)
            {
                throw new InvalidDataException("Invalid password length");
            }
            Console.Write("Programming password... ");
            // Password Protection Set Entry
            dumper.WriteCpu(0x8AAA, 0xAA);
            dumper.WriteCpu(0x8555, 0x55);
            dumper.WriteCpu(0x8AAA, 0x60);
            try
            {
                for (byte i = 0; i < password.Length; i++)
                {
                    dumper.WriteCpu(0x8000, 0xA0);
                    dumper.WriteCpu((ushort)(0x8000 + i), password[i]);
                }
                var verify = dumper.ReadCpu(0x8000, 8);
                for (byte i = 0; i < password.Length; i++)
                {
                    if (password[i] != verify[i])
                    {
                        throw new InvalidDataException("Password verification failed");
                    }
                }
            }
            finally
            {
                ResetFlash(dumper);
            }
            Console.WriteLine("OK");

            Console.Write("Programming lock register... ");
            // Lock Register Set Entry
            dumper.WriteCpu(0x8AAA, 0xAA);
            dumper.WriteCpu(0x8555, 0x55);
            dumper.WriteCpu(0x8AAA, 0x40);
            try
            {
                // Bits Program
                dumper.WriteCpu(0x8000, 0xA0);
                dumper.WriteCpu(0x8000, (byte)(1 << 2) ^ 0xFF); // password protection
                var r = dumper.ReadCpu(0x8000);
                if ((r & 7) != 3)
                {
                    throw new InvalidDataException("Lock bit verification failed");
                }
            }
            finally
            {
                ResetFlash(dumper);
            }
            Console.WriteLine("OK");
        }
Exemplo n.º 2
0
 public static void PasswordUnlock(FamicomDumperLocal dumper, byte[] password)
 {
     try
     {
         if (password.Length != 8)
         {
             throw new InvalidDataException("Invalid password length");
         }
         Console.Write("Unlocking password... ");
         // Password Protection Set Entry
         dumper.WriteCpu(0x8AAA, 0xAA);
         dumper.WriteCpu(0x8555, 0x55);
         dumper.WriteCpu(0x8AAA, 0x60);
         // Password unlock
         dumper.WriteCpu(0x8000, 0x25);
         dumper.WriteCpu(0x8000, 0x03);
         for (byte i = 0; i < password.Length; i++)
         {
             dumper.WriteCpu((ushort)(0x8000 + i), password[i]);
         }
         dumper.WriteCpu(0x8000, 0x29);
         Console.WriteLine("OK");
     }
     finally
     {
         ResetFlash(dumper);
     }
 }