private static NES CreateCore() { string xmlPath = Path.Combine(PathUtils.ExeDirectoryPath, "NesCarts.xml"); var bootGodBytes = File.ReadAllBytes(xmlPath); BootGodDb.GetDatabaseBytes = () => bootGodBytes; var rom = GetRom(); var gameInfo = GameInfo.NullInstance; var pathEntries = new PathEntryCollection(); pathEntries.ResolveWithDefaults(); var cfp = new CoreFileProvider(Console.WriteLine, new FirmwareManager(), pathEntries, new Dictionary <string, string>()); var coreComm = new CoreComm(Console.WriteLine, Console.WriteLine, cfp); var settings = new NES.NESSettings(); var syncSettings = new NES.NESSyncSettings(); var nes = new NES(coreComm, gameInfo, rom, settings, syncSettings); for (int i = 0; i < 200; i++) { nes.FrameAdvance(EmptyController, true, true); } return(nes); }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "MAPPER004": if (Cart.inesmirroring != 2) // send these to TxROM return false; Cart.vram_size = 8; break; case "NES-TVROM": //rad racer II (U) AssertPrg(64); AssertChr(64); AssertVram(8); AssertWram(0); AssertBattery(false); break; case "NES-TR1ROM": // Gauntlet variant (untested!) break; default: return false; } BaseSetup(); return true; }
public static void Main(string[] args) { if (args == null || args.Length < 1 || string.IsNullOrWhiteSpace(args [0])) { Console.WriteLine("First argument should be path to NES rom."); return; } var fileInfo = new System.IO.FileInfo(args [0]); if (!fileInfo.Exists) { Console.WriteLine("File does not exist: {0}", fileInfo.FullName); return; } var rom = NesRom.Parse(fileInfo); var memory = new Memory(0x10000); var cpu = new CPU(memory); var nesEmulation = new NES(cpu, memory); nesEmulation.LoadRom(rom); nesEmulation.Reset(); nesEmulation.BeginEmulation(); Console.WriteLine("Press any key to whatever."); Console.ReadKey(); nesEmulation.EndEmulation(); }
public void Setup() { nes = new NES(); var c = TestRom.GetTestCartridge(); Assert.IsNotNull(c); nes.Bus.Cartridge = c; }
public void Setup() { c = Cartridge.FromFile("./TestData/nestest/nestest.nes"); Assert.IsNotNull(c); nes = new NES(); nes.Bus.Cartridge = c; nes.Bus.Cpu.PC = 0xC000; }
private void NesPPU_Load(object sender, EventArgs e) { LoadConfigSettings(); _nes = Global.Emulator as NES; ClearDetails(); RefreshRate.Value = Global.Config.NESPPURefreshRate; Generate(true); CHRROMViewReload(); }
private void StartEmulation(string gamePath) { _cancellationTokenSource?.Cancel(); _joypad.ResetJoypadState(); Cartridge cartridge = Cartridge.LoadCartridge(gamePath); var nes = new NES(cartridge, _joypad); _cancellationTokenSource = new CancellationTokenSource(); Task.Factory.StartNew(() => RunGame(nes, _cancellationTokenSource.Token), TaskCreationOptions.LongRunning); }
private void NESNameTableViewer_Load(object sender, EventArgs e) { if (Global.Config.NesNameTableSettings.UseWindowPosition) { Location = Global.Config.NesNameTableSettings.WindowPosition; } _nes = Global.Emulator as NES; RefreshRate.Value = Global.Config.NESNameTableRefreshRate; Generate(true); }
public void Restart() { if (Global.Emulator is NES) { _nes = Global.Emulator as NES; } else { Close(); } }
public DMC(double amplitude, NES nes) { this.amplitude = amplitude; this.nes = nes; // for reading CPU memory this.t = 1; this.Rate = RateIndex[0]; this.BitsRemaining = 8; this.OutputLevel = 64; }
static void Main(string[] args) { if (args == null || args.Length < 1) { Console.WriteLine("Enter the name of the NES game: "); args = new string[1] { Console.ReadLine() }; } if (args.Length < 2) { Console.WriteLine("Enter the path to the NES game to inject: "); args = new string[2] { args[0], Console.ReadLine().Replace("\"", "") }; } if (args.Length < 3) { Console.WriteLine("Enter your Animal Crossing game's region (J for Japan, E for North America, P for Europe, and U for Austrailia:"); args = new string[3] { args[0], args[1], Console.ReadLine() }; } if (args[0].Length >= 4 && File.Exists(args[1])) { int RegionIdx = Array.IndexOf(RegionCodes, args[2].ToUpper()); if (RegionIdx > -1) { NES NESFile = new NES(args[0], File.ReadAllBytes(args[1]), false, (Region)RegionIdx, false, false); string OutputFile = Path.GetDirectoryName(args[1]) + "\\" + args[0] + "_" + args[2].ToUpper() + "_InjectedData.gci"; using (var Stream = new FileStream(OutputFile, FileMode.OpenOrCreate)) { byte[] Data = NESFile.GenerateGCIFile(); PrintChecksum(Data); Stream.Write(Data, 0, Data.Length); } Console.WriteLine("Successfully generated a GCI file with the NES rom in it!\nFile Location: " + OutputFile); Console.ReadLine(); } else { Console.WriteLine("The region code you entered couldn't be found!\r\nThe supported codes are: J, E, P, and U!"); Console.ReadLine(); } } else { Console.WriteLine("The NES name must be four or more characters long!"); Console.ReadLine(); } }
public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) { case "MAPPER250": break; default: return false; } BaseSetup(); return true; }
public APU(NES nes) { for (int i = 0; i < pulseTable.Length; ++i) { pulseTable[i] = 95.52D / (8128D / i + 100D); } for (int i = 0; i < tndTable.Length; ++i) { tndTable[i] = 163.67D / (24329D / i + 100D); } }
public Screen(NES nes) { NES = nes; NES.CONTROLLER_1 = new MonoGameController(); graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = PPU.SCREEN_WIDTH * SCALE; graphics.PreferredBackBufferHeight = PPU.SCREEN_HEIGHT * SCALE; graphics.PreferredBackBufferFormat = SurfaceFormat.Color; graphics.ApplyChanges(); Content.RootDirectory = "Content"; }
public void Restart() { if (Global.Emulator is NES) { _nes = Global.Emulator as NES; Generate(true); CHRROMViewReload(); } else { Close(); } }
void Awake() { if (_instance == null) { _instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } objects = new List <NESObject> (GameObject.FindObjectsOfType <NESObject>()); objects.ForEach((obj) => obj.Init()); }
private void NesVsSettings_Load(object sender, EventArgs e) { _nes = (NES)Global.Emulator; _settings = _nes.GetSyncSettings(); Dipswitch1CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_1; Dipswitch2CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_2; Dipswitch3CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_3; Dipswitch4CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_4; Dipswitch5CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_5; Dipswitch6CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_6; Dipswitch7CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_7; Dipswitch8CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_8; }
//http://wiki.nesdev.com/w/index.php/INES_Mapper_192 public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "MAPPER192": break; default: return false; } VRAM = new byte[4096]; BaseSetup(); return true; }
public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) { case "MAPPER143": case "UNIF_UNL-SA-NROM": break; default: return false; } AssertPrg(32); AssertChr(8); SetMirrorType(Cart.pad_h, Cart.pad_v); return true; }
private void NESGraphicsConfig_Load(object sender, EventArgs e) { if (Global.Emulator is NES) { _nes = (NES)Global.Emulator; _settings = _nes.GetSettings(); } else { _subneshawk = (SubNESHawk)Global.Emulator; _settings = _subneshawk.GetSettings(); } LoadStuff(); }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "NES-TQROM": //high speed and pinbot AssertPrg(128); AssertChr(64); AssertVram(8); AssertWram(0); break; default: return false; } BaseSetup(); return true; }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "MAPPER119": // adelikat: Just in case, I didn't find a ROM with this but it could happen case "NES-TQROM": //high speed and pinbot AssertPrg(128); AssertChr(64); AssertVram(8); AssertWram(0); break; default: return false; } BaseSetup(); return true; }
static void Main() { var nes = new NES(); //nes.Load("cv2", 1); nes.Load("mario", 1); //nes.Load("mario3", 4); nes.Power(); var nesThread = new Thread(nes.StepForever); nesThread.Priority = ThreadPriority.Highest; nesThread.Start(); using (var game = new Screen(nes)) game.Run(); }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "NES-DRROM": //gauntlet (U) case "TENGEN-800004": // gauntlet (Unl) AssertPrg(128); AssertChr(64); AssertVram(2); AssertWram(0); break; default: return false; } BaseSetup(); SetMirroring(0, 1, 0, 1); return true; }
public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) { case "MAPPER218": // the cart actually has 0k vram, but due to massive abuse of the ines format, is labeled as 8k // supposed vram is (correctly) not used in our implementation AssertPrg(8, 16, 32); AssertChr(0); /*AssertVram(0);*/ AssertWram(0); Cart.vram_size = 0; // force vram size 0 break; default: return false; } // due to massive abuse of the ines format, the mirroring and 4 screen bits have slightly different meanings switch (Cart.inesmirroring) { case 1: // VA10 to PA10 // pattern: ABABABAB // nametable: ABAB (vertical) chr_addr_mask = 1 << 10; break; case 0: // VA10 to PA11 // pattern: AABBAABB // nametable: AABB (horizontal) chr_addr_mask = 1 << 11; break; case 2: // VA10 to PA12 // pattern: AAAABBBB // nametable: AAAA (one screen A) chr_addr_mask = 1 << 12; break; case 3: // VA10 to PA13 // pattern: AAAAAAAA // nametable: BBBB (one screen B) chr_addr_mask = 1 << 13; break; default: // we need an ines identification for correct mirroring return false; } prg_byte_mask = (Cart.prg_size * 1024) - 1; return true; }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "MAPPER119": Cart.vram_size = 8; Cart.wram_size = 0; // Junk ROMs get these wrong break; case "NES-TQROM": // High Speed and Pin Bot AssertPrg(128); AssertChr(64); AssertVram(8); AssertWram(0); break; default: return false; } BaseSetup(); return true; }
public void Awake() { this.palette = new PaletteHandler(); this.rend = this.GetComponent <Renderer>(); this.texture = new Texture2D(256, 240, TextureFormat.ARGB32, mipmap: false); this.rend.material.mainTexture = texture; this.ioc = new StandardKernel(new NintendoModule()); this.nes = this.ioc.Get <NES>(); var cartridge = NESLoader.CreateCartridge(@"C:\emulators\nes\games\Super Mario Bros.nes"); this.nes.LoadCartridge(cartridge); this.nes.PowerOn(); this.nesThread = new Thread(NESStep); this.nesThread.Start(); }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "NAMCOT-3425": //dragon buster (J) AssertPrg(128); AssertChr(32); AssertVram(0); AssertWram(0); break; case "MAPPER095": AssertVram(0); break; default: return false; } BaseSetup(); SetMirrorType(EMirrorType.Vertical); return true; }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "NAMCOT-3443": case "NAMCOT-3433": case "MAPPER088": break; default: return false; } BaseSetup(); SetMirrorType(EMirrorType.Vertical); chr_bank_mask_1k = Cart.chr_size - 1; return true; }
public PPU(NES nes) { NES = nes; for (int i = 0; i < PALETTE.Length; ++i) { uint color = PALETTE[i]; uint r = (byte)((color >> 16) & 0xFF); uint g = (byte)((color >> 8) & 0xFF); uint b = (byte)((color >> 0) & 0xFF); // RGBA -> ABGR uint newCol = 0xFF000000; newCol |= (r >> 0); // R newCol |= (g << 8); // G newCol |= (b << 16); // B PALETTE[i] = newCol; } }
private void RunGame(NES nes, CancellationToken cancellationToken) { bool abortEmulation = false; var stopwatch = new Stopwatch(); var frameStopWatch = new Stopwatch(); while (!abortEmulation) { stopwatch.Restart(); for (int i = 0; i < FramesPerSecond; i++) { if (cancellationToken.IsCancellationRequested) { abortEmulation = true; break; } frameStopWatch.Restart(); _frameBuffer = nes.Frame(); while (frameStopWatch.ElapsedMilliseconds < _frameRate) { Thread.Sleep(0); } _gameScreen.Invalidate(); } stopwatch.Stop(); Console.WriteLine($"{stopwatch.ElapsedMilliseconds} ms elapsed to process 60 frames per second."); } }
public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type switch (Cart.board_type) { case "NES-TLSROM": //pro sport hockey (U) AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0); break; case "MAPPER118": AssertVram(0); break; case "HVC-TKSROM": //ys III: wanderers from ys (J) AssertPrg(256); AssertChr(128); AssertVram(0); AssertWram(8); AssertBattery(true); break; case "TENGEN-800037": //Alien Syndrome (U) // this board is actually a RAMBO-1 (mapper064) with TLS-style rewiring // but it seems to work fine here, so lets not worry about it AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0); break; case "MAPPER158": // as above AssertVram(0); Cart.wram_size = 0; break; case "HVC-TLSROM": AssertPrg(256); AssertChr(128); AssertVram(0); AssertWram(0); break; default: return false; } BaseSetup(); SetMirrorType(EMirrorType.Vertical); return true; }
static void Main(string[] args) { // Enable Shift-JIS support. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); string inputName = null; string outputName = null; string romName = null; string tagsFileName = null; string region = null; var ePlus = false; var canSave = true; var forceCompress = false; if (args == null || args.Length < 1) { Console.WriteLine("usage: ACNESCreator.CommandLine.exe nesRomFile outputFile"); } else { for (var i = 0; i < args.Length; i++) { if (i + 1 < args.Length) { switch (args[i].ToLower()) { case "-i": case "-input": i++; inputName = args[i]; break; case "-o": case "-output": i++; outputName = args[i]; break; case "-n": case "-name": i++; romName = args[i]; break; case "-nosave": canSave = false; break; case "-c": case "-compress": forceCompress = true; break; case "-e": case "-eplus": ePlus = true; region = "J"; break; case "-t": case "-tags": i++; tagsFileName = args[i]; break; case "-r": case "-region": i++; if (!ePlus) { region = args[i]; } break; default: if (inputName == null) { inputName = args[i + 1]; } else if (outputName == null) { outputName = args[i + 1]; } break; } } } if (inputName == null || !File.Exists(inputName)) { Console.WriteLine("The input file doesn't exist!"); } else { if (string.IsNullOrWhiteSpace(outputName)) { Console.WriteLine("An output file name must be supplied!"); } else { if (tagsFileName != null && !File.Exists(tagsFileName)) { Console.WriteLine("The tags file doesn't exist! Default tags will be generated."); tagsFileName = null; } if (romName != null && romName.Trim().Length == 0) { Console.WriteLine("The name supplied is invalid. Default name will be used."); romName = "Custom NES Game"; } if (region != null && !RegionCodes.Contains(region.ToUpper())) { Console.WriteLine("The region code supplied is invalid. Region code E (NTSC-U, Animal Crossing) will be used."); region = "E"; } // Generate the file with the supplied arguments. try { Stream tagsStream = null; if (tagsFileName != null) { tagsStream = File.OpenRead(tagsFileName); } using (tagsStream) { NES nesFile = new NES(romName, File.ReadAllBytes(inputName), forceCompress, (Region)Array.IndexOf(RegionCodes, region), canSave, ePlus, null, tagsStream); var outputFile = Path.Combine(Path.GetDirectoryName(inputName), $"{Path.GetFileNameWithoutExtension(outputName)}.gci"); using (var stream = new FileStream(outputFile, FileMode.OpenOrCreate)) { var data = nesFile.GenerateGCIFile(); PrintChecksum(data); stream.Write(data, 0, data.Length); } Console.WriteLine("Successfully generated a GCI file with the NES rom in it!"); Console.WriteLine($"File Location: {outputFile}"); } } catch (Exception e) { Console.WriteLine("An error occurred during file generation."); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } } } } Console.WriteLine("Press any key to close the window..."); Console.ReadKey(); }
public void FileSignatures_TestNESFile() { NES testFile = new NES(Path.Combine(resourceDir, "FileSignature_Emulation_NESFile.nes")); Assert.AreEqual(true, testFile.EntireFileIsValid); }
public CPU(NES nes) { NES = nes; OP = InitOP(); }
private void NESGraphicsConfig_Load(object sender, EventArgs e) { _nes = (NES)Global.Emulator; _settings = _nes.GetSettings(); LoadStuff(); }
public static void Main(string[] args) { _nes = CreateCore(); var summary = BenchmarkRunner.Run <Program>(); }
public MMC1(NES nes) { }
public Form1(ISystem system) { this.InitializeComponent(); NES.IsDebug = false; this.system = system; if (this.system is NES nes) { this.nes = nes; } else { throw new ArgumentException("Only handles NESs right now"); } this.graphics = this.CreateGraphics(); this.graphics.InterpolationMode = InterpolationMode.NearestNeighbor; this.bitmap = new Bitmap(256, 240, PixelFormat.Format8bppIndexed); ColorPalette palette = this.bitmap.Palette; // TODO: Move this to PaletteHandler palette.Entries[0x0] = Color.FromArgb(84, 84, 84); palette.Entries[0x1] = Color.FromArgb(0, 30, 116); palette.Entries[0x2] = Color.FromArgb(8, 16, 144); palette.Entries[0x3] = Color.FromArgb(48, 0, 136); palette.Entries[0x4] = Color.FromArgb(68, 0, 100); palette.Entries[0x5] = Color.FromArgb(92, 0, 48); palette.Entries[0x6] = Color.FromArgb(84, 4, 0); palette.Entries[0x7] = Color.FromArgb(60, 24, 0); palette.Entries[0x8] = Color.FromArgb(32, 42, 0); palette.Entries[0x9] = Color.FromArgb(8, 58, 0); palette.Entries[0xa] = Color.FromArgb(0, 64, 0); palette.Entries[0xb] = Color.FromArgb(0, 60, 0); palette.Entries[0xc] = Color.FromArgb(0, 50, 60); palette.Entries[0xd] = Color.FromArgb(0, 0, 0); palette.Entries[0xe] = Color.FromArgb(0, 0, 0); palette.Entries[0xf] = Color.FromArgb(0, 0, 0); palette.Entries[0x10] = Color.FromArgb(152, 150, 152); palette.Entries[0x11] = Color.FromArgb(8, 76, 196); palette.Entries[0x12] = Color.FromArgb(48, 50, 236); palette.Entries[0x13] = Color.FromArgb(92, 30, 228); palette.Entries[0x14] = Color.FromArgb(136, 20, 176); palette.Entries[0x15] = Color.FromArgb(160, 20, 100); palette.Entries[0x16] = Color.FromArgb(152, 34, 32); palette.Entries[0x17] = Color.FromArgb(120, 60, 0); palette.Entries[0x18] = Color.FromArgb(84, 90, 0); palette.Entries[0x19] = Color.FromArgb(40, 114, 0); palette.Entries[0x1a] = Color.FromArgb(8, 124, 0); palette.Entries[0x1b] = Color.FromArgb(0, 118, 40); palette.Entries[0x1c] = Color.FromArgb(0, 102, 120); palette.Entries[0x1d] = Color.FromArgb(0, 0, 0); palette.Entries[0x1e] = Color.FromArgb(0, 0, 0); palette.Entries[0x1f] = Color.FromArgb(0, 0, 0); palette.Entries[0x20] = Color.FromArgb(236, 238, 236); palette.Entries[0x21] = Color.FromArgb(76, 154, 236); palette.Entries[0x22] = Color.FromArgb(120, 124, 236); palette.Entries[0x23] = Color.FromArgb(176, 98, 236); palette.Entries[0x24] = Color.FromArgb(228, 84, 236); palette.Entries[0x25] = Color.FromArgb(236, 88, 180); palette.Entries[0x26] = Color.FromArgb(236, 106, 100); palette.Entries[0x27] = Color.FromArgb(212, 136, 32); palette.Entries[0x28] = Color.FromArgb(160, 170, 0); palette.Entries[0x29] = Color.FromArgb(116, 196, 0); palette.Entries[0x2a] = Color.FromArgb(76, 208, 32); palette.Entries[0x2b] = Color.FromArgb(56, 204, 108); palette.Entries[0x2c] = Color.FromArgb(56, 180, 204); palette.Entries[0x2d] = Color.FromArgb(60, 60, 60); palette.Entries[0x2e] = Color.FromArgb(0, 0, 0); palette.Entries[0x2f] = Color.FromArgb(0, 0, 0); palette.Entries[0x30] = Color.FromArgb(236, 238, 236); palette.Entries[0x31] = Color.FromArgb(168, 204, 236); palette.Entries[0x32] = Color.FromArgb(188, 188, 236); palette.Entries[0x33] = Color.FromArgb(212, 178, 236); palette.Entries[0x34] = Color.FromArgb(236, 174, 236); palette.Entries[0x35] = Color.FromArgb(236, 174, 212); palette.Entries[0x36] = Color.FromArgb(236, 180, 176); palette.Entries[0x37] = Color.FromArgb(228, 196, 144); palette.Entries[0x38] = Color.FromArgb(204, 210, 120); palette.Entries[0x39] = Color.FromArgb(180, 222, 120); palette.Entries[0x3a] = Color.FromArgb(168, 226, 144); palette.Entries[0x3b] = Color.FromArgb(152, 226, 180); palette.Entries[0x3c] = Color.FromArgb(160, 214, 228); palette.Entries[0x3d] = Color.FromArgb(160, 162, 160); palette.Entries[0x3e] = Color.FromArgb(0, 0, 0); palette.Entries[0x3f] = Color.FromArgb(0, 0, 0); this.bitmap.Palette = palette; }
private void NESGraphicsConfig_Load(object sender, EventArgs e) { nes = Global.Emulator as NES; settings = (NES.NESSettings)nes.GetSettings(); LoadStuff(); }
public CNROM(NES nes) { }
private void NESDebugger_Load(object sender, EventArgs e) { LoadConfigSettings(); _nes = Global.Emulator as NES; }