Beispiel #1
0
        public static NesCartMapper Build(Nes nes, NesCartHeader header)
        {
            var mapperId = header.MapperNumber;
            var mapper   = GetMapper(nes, mapperId);

            return(mapper);
        }
Beispiel #2
0
 public Gui()
 {
     c         = Nes.Instance;
     mem       = new MemoryEditor();
     inputtext = "";
     atlinenum = 3;
 }
Beispiel #3
0
 public NesEmulator()
 {
     InitializeComponent();
     _nes               = new Nes();
     cpuControl.Nes     = _nes;
     cpuControl.Enabled = false;
 }
Beispiel #4
0
 public MySfmlNesApp(int x, int y, uint w, uint h, string rom, uint scale = 1) : base("NES", w, h, scale)
 {
     Nes = new Nes(this, Controller1);
     Nes.LoadRom(rom);
     Nes.RunOnThread();
     Position = new SFML.System.Vector2i(x, y);
 }
        public static NesCart LoadFromFile(Nes nes, string filename)
        {
            var fileContents = System.IO.File.ReadAllBytes(filename);

            var position = 0;
            var header   = ReadHeader(fileContents.AsSpan(0, 16));

            position += 16;

            if (header.hasTrainer)
            {
                position += 512;
            }

            var prgRomSize = 16 * 1024 * header.PrgRomPages;
            var prgRom     = fileContents.AsSpan(position, prgRomSize);

            position += prgRomSize;

            var chrRomSize = 8 * 1024 * header.ChrRomPages;
            var chrRom     = fileContents.AsSpan(position, chrRomSize);

            return(new NesCart(
                       System.IO.Path.GetFileName(filename),
                       header,
                       prgRom.ToArray(),
                       chrRom.ToArray(),
                       new byte[NesConsts.PrgPageSize + 1],
                       NesCartMapper.Build(nes, header)
                       ));
        }
Beispiel #6
0
        public OpenRomCommand(Nes nesEmulator, ILoaderProvider loaderProvider)
        {
            _nesEmulator    = nesEmulator;
            _loaderProvider = loaderProvider;

            MenuText = Resources.Text.FileOpen;
            Shortcut = Application.Instance.CommonModifier | Keys.O;
        }
Beispiel #7
0
        public Cpu(Nes nes)
        {
            this.nes = nes;

            Status = new StatusRegister();

            InitInstructions();

            cycles = 0;
        }
Beispiel #8
0
        public NesCpu(Nes nes)
        {
            this.Nes    = nes;
            this.Bus    = new NesCpuAddressBus(nes);
            this.Memory = new NesCpuMemory(nes);

            CacheOpcodes();

            CurrentState = new NesCpuState();
        }
Beispiel #9
0
        protected NesCartMapper(Nes nes)
        {
            this.Nes = nes;

            CPUStartRange = GetMemoryMapAttribute(AddressBus.CPU).Start;
            CPUEndRange   = GetMemoryMapAttribute(AddressBus.CPU).End;
            PPUStartRange = GetMemoryMapAttribute(AddressBus.PPU).Start;
            PPUEndRange   = GetMemoryMapAttribute(AddressBus.PPU).End;

            OpenBus = new byte[3];
            PrgRam  = new byte[(8 * 1024) + 1];
        }
Beispiel #10
0
        public NesPpu(Nes nes)
        {
            this.Nes    = nes;
            this.Bus    = new NesPpuAddressBus(nes);
            this.Memory = new NesPpuMemory(nes);

            this.ImageBuffer = new uint[NesConsts.IMAGE_BUFFER_SIZE];
            this.OAM1        = new Sprite[8];
            this.OAM2        = new Sprite[8];

            this.Control = new ControlRegisterValues(0);
            this.Mask    = new MaskRegisterValues(0);
            this.Status  = new StatusRegisterValues(0);
        }
Beispiel #11
0
        public ConsoleView(Nes nes)
        {
            this.Nes            = nes;
            this.TickTrackTimer = new Stopwatch();

            try
            {
                Console.Clear();
                AttachedToConsole = true;
            }
            catch (IOException)
            {
                AttachedToConsole = false;
            }
        }
Beispiel #12
0
        private async void btnControlsConfigure_Click(object sender, RoutedEventArgs e)
        {
            // get button name
            Button button = (Button)sender;
            string name   = button.Name;

            // remove beginning and end
            name = name.Replace("btn", "").Replace("Configure", "");

            // get the relevant combox
            ComboBox cb = (ComboBox)this.FindName("cmb" + name);

            // get the virtual port number
            //ComboBoxItem typeItem = (ComboBoxItem)cb.SelectedItem;
            string selectedString = cb.SelectionBoxItem.ToString();
            int    portNum        = Convert.ToInt32(selectedString.Replace("Virtual Port ", ""));

            // Get device definition for this controller
            DeviceDefinition dev = new DeviceDefinition();

            switch (name)
            {
            case "NesGamepad":
                dev = Nes.GamePad(portNum);
                break;

            case "NesZapper":
                dev = Nes.Zapper(portNum);
                break;

            default:
                return;
            }

            mw.ControllerDefinition = dev;

            // launch controller configuration window
            Grid RootGrid = (Grid)mw.FindName("RootGrid");
            await mw.ShowChildWindowAsync(new ConfigureController()
            {
                IsModal         = true,
                AllowMove       = false,
                Title           = "Controller Configuration",
                CloseByEscape   = false,
                CloseOnOverlay  = false,
                ShowCloseButton = false
            }, RootGrid);
        }
Beispiel #13
0
        private static NesCartMapper GetMapper(Nes nes, int id)
        {
            var targetedMapper = typeof(NesCartMapper)
                                 .Assembly.GetTypes()
                                 .FirstOrDefault(s => s.GetCustomAttributes(typeof(MapperAttribute), false)
                                                 .Cast <MapperAttribute>()
                                                 .FirstOrDefault()
                                                 ?.MapperNumber == id
                                                 );

            if (targetedMapper == null)
            {
                throw new MapperNotImplemented(id);
            }

            return((NesCartMapper)Activator.CreateInstance(targetedMapper, new object[] { nes }));
        }
Beispiel #14
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            nes = new Nes();

            RenderOptions.SetBitmapScalingMode(NesScreen, BitmapScalingMode.NearestNeighbor);
            RenderOptions.SetEdgeMode(NesScreen, EdgeMode.Aliased);

            nesScreenBitmap  = new WriteableBitmap(256, 240, 96, 96, PixelFormats.Bgr32, null);
            NesScreen.Source = nesScreenBitmap;

            nesThread = new Thread(new ThreadStart(RunNes));
            nesThread.IsBackground = true;
            nesThread.Priority     = ThreadPriority.Highest;
            nesThread.Start();
        }
Beispiel #15
0
        private void LoadStateCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                NesPause();

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.DefaultExt = ".state";
                dialog.Filter     = "NES save state (*.state)|*.state";

                if (dialog.ShowDialog() == true)
                {
                    IFormatter formatter = new BinaryFormatter();
                    using (var fileStream = new FileStream(dialog.FileName, FileMode.Open))
                    {
                        nes = formatter.Deserialize(fileStream) as Nes;

                        // Reattach controllers
                        nes.controllers[0] = ControllerManager.Instance.Controllers[0];
                        nes.controllers[1] = ControllerManager.Instance.Controllers[1];

                        UpdateWindowTitle();

                        gameInserted = true;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show
                (
                    "Failed to load state file",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                );
            }
            finally
            {
                NesResume();
            }
        }
        public IEnumerable <Nes> ReadEntries(string sheet, string columnRange)
        {
            SetupCredentials();

            var sheetWithRange = $"{sheet}!{columnRange}";

            SpreadsheetsResource.ValuesResource.GetRequest request =
                service.Spreadsheets.Values.Get(SpreadsheetId, sheetWithRange);


            var response = request.Execute();
            IList <IList <object> > values = response.Values;

            List <Nes> something = Enumerable.Empty <Nes>().ToList();

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    var nes = new Nes
                    {
                        Name             = row[0].ToString(),
                        NumberOfPlayers  = row[1].ToString(),
                        Type             = row[2].ToString(),
                        Save             = row[3].ToString(),
                        SimultaneousTurn = row[4].ToString(),
                        NumberOfScrews   = row[5].ToString(),
                        Instructions     = row[6].ToString(),
                        Box         = row[7].ToString(),
                        MarkingsEtc = row[8].ToString(),
                        Publisher   = row[9].ToString(),
                        Feature     = row.Count > 10 ? row[10].ToString() : string.Empty
                    };
                    something.Add(nes);
                }
            }
            return(something);
        }
Beispiel #17
0
        public GamePageViewModel()
        {
            nes             = Nes.NesInstance;
            UpButtonCommand = new DelegateCommand(() =>
            {
                nes.InputKey(1, 4);
            });

            DownButtonCommand = new DelegateCommand(() =>
            {
                nes.InputKey(1, 5);
            });

            LeftButtonCommand = new DelegateCommand(() =>
            {
                nes.InputKey(1, 6);
            });

            RightButtonCommand = new DelegateCommand(() =>
            {
                nes.InputKey(1, 7);
            });
        }
Beispiel #18
0
 public NesCpuMemory(Nes nes) : base(nes, AddressBus.CPU)
 {
     BidirectionalIO = new byte[2];
     WorkingRam      = new byte[(2 * 1024) + 1];
 }
Beispiel #19
0
 protected NesMemory(Nes nes, AddressBus bus)
 {
     this.Nes = nes;
     this.Bus = bus;
 }
 public NesPpuAddressBus(Nes nes)
 {
     Nes = nes;
 }
Beispiel #21
0
 public NesPpuMemory(Nes nes) : base(nes, AddressBus.PPU)
 {
     Vram       = new byte[(NesConsts.ChrPageSize * 2) + 1];
     PaletteRAM = new byte[0x20 + 1];
     OAMram     = new byte[0x100 + 1];
 }
Beispiel #22
0
 public Mapper0(Nes nes) : base(nes)
 {
 }
Beispiel #23
0
 public NesDebugger(Nes nes)
 {
     this.Nes         = nes;
     this.ConsoleView = new ConsoleView(nes);
     this._debugInfo  = new DebugInfo();
 }
Beispiel #24
0
 public SdlGui(Nes nes)
 {
     this.Nes = nes;
 }
Beispiel #25
0
 public Mapper1(Nes nes) : base(nes)
 {
     Registers = new byte[4];
 }
Beispiel #26
0
 public DebugWindow(string title, uint width, uint height, Nes nes) : base(title, width, height)
 {
     _nes = nes;
     _ppu = _nes.PPU;
 }
Beispiel #27
0
 public Mapper4(Nes nes) : base(nes)
 {
     Registers = new byte[8];
 }