Ejemplo n.º 1
0
        private static void MEMHardReset()
        {
            // memory
            WRAM          = new byte[0x800];
            WRAM[0x0008]  = 0xF7;
            WRAM[0x0008]  = 0xF7;
            WRAM[0x0009]  = 0xEF;
            WRAM[0x000A]  = 0xDF;
            WRAM[0x000F]  = 0xBF;
            palettes_bank = new byte[]                                                                          // Miscellaneous, real NES loads values similar to these during power up
            {
                0x09, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x0D, 0x08, 0x10, 0x08, 0x24, 0x00, 0x00, 0x04, 0x2C, // Bkg palette
                0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, 0x08, 0x3A, 0x00, 0x02, 0x00, 0x20, 0x2C, 0x08  // Spr palette
            };
            oam_ram       = new byte[256];
            oam_secondary = new byte[32];
            BUS_ADDRESS   = 0;
            BUS_RW        = false;
            BUS_RW_P      = false;
            // Read SRAM if found
            Trace.WriteLine("Reading SRAM");
            if (File.Exists(SRAMFileName))
            {
                Stream str    = new FileStream(SRAMFileName, FileMode.Open, FileAccess.Read);
                byte[] inData = new byte[str.Length];
                str.Read(inData, 0, inData.Length);
                str.Flush();
                str.Close();

                byte[] outData = new byte[0];
                ZlipWrapper.DecompressData(inData, out outData);

                board.LoadSRAM(outData);

                Trace.WriteLine("SRAM read successfully.");
            }
            else
            {
                Trace.WriteLine("SRAM file not found; rom has no SRAM or file not exist.");
            }
            board.HardReset();
        }