Exemple #1
0
        private static byte[] GetInitialProgram(CartridgeModel cartridgeModel)
        {
            var initialProgram = new byte[cartridgeModel.ROMBanks.GetLength(0) > 1 ? 32768 : 16384];

            Array.Copy(cartridgeModel.ROMBanks[0], initialProgram, 16384);
            Array.Copy(cartridgeModel.ROMBanks[1], 0, initialProgram, 16384, 16384);

            return(initialProgram);
        }
Exemple #2
0
        /// <summary>
        /// Gets a new instance of the 6502 Processor
        /// </summary>
        /// <param name="cartridgeModel">The cartridge to load. </param>
        /// <param name="programCounter">The initial Program Counter</param>
        /// <returns>A Processor Object</returns>
        internal static CPU GetProcessor(this CartridgeModel cartridgeModel, int programCounter)
        {
            var initialProgram = GetInitialProgram(cartridgeModel);

            var cpu = new CPU();

            cpu.LoadProgram(0x8000, initialProgram, programCounter);

            return(cpu);
        }
Exemple #3
0
        /// <summary>
        /// Public Constructor for the Engine
        /// </summary>
        /// <param name="rawBytes">The raw bytes from a .net cartridge file</param>
        public Engine(byte[] rawBytes)
        {
            CreateNewBackgroundWorker();

            _cartridgeModel       = CartridgeLoaderUtility.LoadCartridge(rawBytes);
            Processor             = _cartridgeModel.GetProcessor();
            PictureProcessingUnit = new PPU(_cartridgeModel, Processor);

            if (Processor.DisassemblyEnabled)
            {
                Processor.GenerateDisassembledMemory();
            }
        }
Exemple #4
0
 private void model_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((model.SelectedItem as CartridgeModel).ID == -1)
     {
         StringReference newModel = new StringReference();
         if (new NewValueForm(newModel, "Модель картриджа").ShowDialog() == DialogResult.OK)
         {
             CartridgeModel nMod = new CartridgeModel(newModel.Value);
             nMod.Create();
             CommonElements.CartridgeModels.Insert(0, nMod);
             model.SelectedIndex = 0;
         }
     }
 }
        /// <summary>
        /// Constructor for the PPU
        /// </summary>
        /// <param name="cartridgeModel"></param>
        /// <param name="cpu"></param>
        internal PictureProcessingUnit(CartridgeModel cartridgeModel, CPU cpu)
        {
            _cpu = cpu;
            _cpu.CycleCountIncrementedAction = CPUCycleCountIncremented;
            _cpu.ReadMemoryAction            = ReadMemoryAction;
            _cpu.WriteMemoryAction           = WriteMemoryAction;

            LoadInitialMemory(cartridgeModel);
            OnNewFrameAction     = () => { };
            ScanLine             = 241;
            CycleCount           = 0;
            _isRenderingDisabled = true;

            CurrentFrame = new byte[195840];
            _newFrame    = new byte[195840];
        }
Exemple #6
0
 /// <summary>
 /// Public Constructor for the Engine
 /// </summary>
 /// <param name="rawBytes">The raw bytes from a .net cartridge file</param>
 public Engine(byte[] rawBytes)
 {
     _cartridgeModel       = CartridgeLoaderUtility.LoadCartridge(rawBytes);
     Processor             = _cartridgeModel.GetProcessor();
     PictureProcessingUnit = new PPU(_cartridgeModel, Processor);
 }
Exemple #7
0
 /// <summary>
 /// Public Constructor for the Engine
 /// </summary>
 /// <param name="fileName">The full path of a .nes cartridge file</param>
 public Engine(string fileName)
 {
     _cartridgeModel       = CartridgeLoaderUtility.LoadCartridge(fileName);
     Processor             = _cartridgeModel.GetProcessor();
     PictureProcessingUnit = new PPU(_cartridgeModel, Processor);
 }
 private void LoadInitialMemory(CartridgeModel cartridgeModel)
 {
     Array.Copy(cartridgeModel.VROMBanks[0], _internalMemory, 8192);
 }