Esempio n. 1
0
 /// <summary>
 /// Call this at application start up to set nes default stuff
 /// </summary>
 public void WarmUp()
 {
     this.apu.InitializeSoundMixTable();
     NesCartDatabase.LoadDatabase("database.xml");
 }
Esempio n. 2
0
        /// <summary>
        /// Initialize the board
        /// </summary>
        /// <param name="sha1">The rom sha1 calculated without the header</param>
        /// <param name="prg_dump">The prg data dump.</param>
        /// <param name="chr_dump">The chr data dump</param>
        /// <param name="trainer_dump">The trainer data dump.</param>
        /// <param name="defaultMirroring">The default mirroring as defined in rom.</param>
        public virtual void Initialize(string sha1, byte[] prg_dump, byte[] chr_dump, byte[] trainer_dump, Mirroring defaultMirroring)
        {
            RomSHA1 = sha1;
            // Find on DB
            GameInfo = NesCartDatabase.Find(sha1, out IsGameFoundOnDB);
            //set cart info
            if (GameInfo.Cartridges != null)
            {
                foreach (NesCartDatabaseCartridgeInfo cartinf in GameInfo.Cartridges)
                {
                    if (cartinf.SHA1.ToLower() == sha1.ToLower())
                    {
                        GameCartInfo = cartinf;
                        break;
                    }
                }
            }
            BoardType  = "N/A";
            BoardPCB   = "N/A";
            this.Chips = new List <string>();
            if (IsGameFoundOnDB)
            {
                Console.WriteLine("Game found in Database !!");
                Console.WriteLine("> Game name: " + GameInfo.Game_Name);
                Console.WriteLine("> Game alt name: " + GameInfo.Game_AltName);
                BoardType = GameCartInfo.Board_Type;
                Console.WriteLine("> Board Type: " + BoardType);
                BoardPCB = GameCartInfo.Board_Pcb;
                Console.WriteLine("> Board Pcb: " + BoardPCB);
                // Chips ... important for some boards
                if (GameCartInfo.chip_type != null)
                {
                    for (int i = 0; i < GameCartInfo.chip_type.Count; i++)
                    {
                        Console.WriteLine(string.Format("> CHIP {0}: {1}", (i + 1).ToString(),
                                                        GameCartInfo.chip_type[i]));
                        this.Chips.Add(GameCartInfo.chip_type[i]);
                    }
                }
            }
            // Mirroring
            this.default_mirroring = defaultMirroring;
            nmt_banks = new byte[4][]
            {
                new byte[0x0400], new byte[0x0400], new byte[0x0400], new byte[0x0400]
                /*Only 2 nmt banks should be used in normal state*/
            };
            nmt_indexes = new int[4];
            SwitchNMT(defaultMirroring);
            // PRG data ***********************************************
            List <BankInfo> prgBanks = new List <BankInfo>(GetPRGRAM());

            prg_rom_bank_offset = prgBanks.Count;
            prgBanks.AddRange(GetPRGROM(prg_dump));
            SRAMSaveRequired = false;
            prg_banks        = new byte[prgBanks.Count][];
            prg_enable       = new bool[prgBanks.Count];
            prg_isram        = new bool[prgBanks.Count];
            prg_writable     = new bool[prgBanks.Count];
            prg_battery      = new bool[prgBanks.Count];
            for (int i = 0; i < prgBanks.Count; i++)
            {
                prg_banks[i]    = prgBanks[i].DATA;
                prg_enable[i]   = prgBanks[i].Enabled;
                prg_writable[i] = prgBanks[i].Writable;
                prg_isram[i]    = prgBanks[i].IsRAM;
                prg_battery[i]  = prgBanks[i].IsBattery;
                if (!SRAMSaveRequired)
                {
                    if (prg_battery[i])
                    {
                        SRAMSaveRequired = true;
                    }
                }
            }
            prg_indexes = new int[5];
            // ********************************************************
            // CHR data ***********************************************
            List <BankInfo> chrBanks = new List <BankInfo>(GetCHRRAM());

            chr_rom_bank_offset = chrBanks.Count;
            chrBanks.AddRange(GetCHRROM(chr_dump));
            chr_banks    = new byte[chrBanks.Count][];
            chr_enable   = new bool[chrBanks.Count];
            chr_isram    = new bool[chrBanks.Count];
            chr_writable = new bool[chrBanks.Count];
            for (int i = 0; i < chrBanks.Count; i++)
            {
                chr_banks[i]    = chrBanks[i].DATA;
                chr_enable[i]   = chrBanks[i].Enabled;
                chr_writable[i] = chrBanks[i].Writable;
                chr_isram[i]    = chrBanks[i].IsRAM;
            }
            chr_indexes = new int[8];
            // ********************************************************
        }
Esempio n. 3
0
 /// <summary>
 /// Call this at application start up to set nes default stuff
 /// </summary>
 public static void WarmUp()
 {
     InitializeDACTables();
     NesCartDatabase.LoadDatabase("database.xml");
 }