Beispiel #1
0
        /// <summary>
        /// Contructor for the NES console object. Uses Dependency Injection to create components.
        /// Mainly used for testing in this form.
        /// </summary>
        public NES()
        {
            Cart = new Cartridge();
            const string FileName = @"C:\Users\panda\Downloads\Super Mario Bros. 3 (USA).nes";
            Input        input1   = new Input();
            Input        input2   = new Input();

            ppu    = PPU.Instance;
            Cart   = Cart.getCart(FileName);
            Mapper = new MMC3(Cart);
            //Create and pass the mapper to the memory
            Memory.Create(2048, Mapper, input1, input2);
            RAM = Memory.Instance;
            //Pass the memory to the CPU & PPU
            CPU6502.Create(RAM);
            CPU = CPU6502.Instance;
        }
Beispiel #2
0
        /// <summary>
        /// Open a NES rom
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openNesRom_Click(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            dialog.Filter           = "NES Roms (*.nes)|*.nes"; // Filter files by extension
            dialog.FilterIndex      = 1;
            // Show open file dialog box
            if (dialog.ShowDialog() == true)
            {
                cartridgeReader_ = new CartridgeReader(dialog.FileName);
                filePath_        = dialog.FileName;
                try
                {
                    input1         = new Input();
                    input2         = new Input();
                    testCartridge_ = cartridgeReader_.readCart();
                    MMC3 mapper = new MMC3(testCartridge_);
                    ppu_ = PPU.Instance;
                    Memory.Create(2048, mapper, input1, input2);
                    mem_ = Memory.Instance;
                    CPU6502.Create(mem_);
                    cpu_             = CPU6502.Instance;
                    registerBox.Text = cpu_.ToString();
                    memoryBox.Text   = mem_.ToString();
                    addressBox.Text  = cpu_.CurrentAddress.ToString("X4");
                    Display.Source   = BitmapToImageSource(ppu_.getFrame());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Exception!", MessageBoxButton.OK);
                    Debug.WriteLine(ex.StackTrace);
                }
            }
        }