public override bool Configure(NES.EDetectionOrigin origin)
        {
            //configure
            switch (Cart.board_type)
            {
                case "MAPPER033":
                    break;
                case "TAITO-TC0190FMC":
                case "TAITO-TC0350FMR":
                    AssertPrg(128, 256); AssertChr(128, 256); AssertWram(0); AssertVram(0);
                    pal16 = false;
                    break;
                case "TAITO-TC0190FMC+PAL16R4":
                    //this is the same as the base TAITO-TC0190FMC, with an added PAL16R4ACN which is a "programmable TTL device", presumably just the IRQ and mirroring
                    AssertPrg(128, 256); AssertChr(256); AssertWram(0); AssertVram(0);
                    pal16 = true;
                    mmc3 = new MMC3Variant(this);
                    break;
                default:
                    return false;
            }

            prg_bank_mask = Cart.prg_size / 8 - 1;
            chr_bank_mask = Cart.chr_size - 1;

            prg_regs_8k[0] = 0x00;
            prg_regs_8k[1] = 0x00;
            prg_regs_8k[2] = 0xFE; //constant
            prg_regs_8k[3] = 0xFF; //constant

            SyncMirror();

            return true;
        }
        public override bool Configure(NES.EDetectionOrigin origin)
        {
            switch (Cart.board_type)
            {
                case "UNIF_UNL-DRIPGAME":
                    break;
                default:
                    return false;
            }
            Cart.wram_size = 8;
            Cart.wram_battery = false;
            AssertPrg(16, 32, 64, 128, 256); // 4 bits x 16
            AssertChr(8, 16, 32); // 4 bits x 2

            AutoMapperProps.Apply(this);

            prgmask = Cart.prg_size / 16 - 1;
            chrmask = Cart.prg_size / 2 - 1;

            prg[1] = prgmask;
            SetMirror(0);

            if (NES.apu != null) // don't start up sound when in configurator
            {
                sound0 = new SoundChannel(NES.apu.ExternalQueue);
                sound1 = new SoundChannel(NES.apu.ExternalQueue);
            }

            return true;
        }
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER087":
					AssertPrg(8, 16, 32);
					AssertChr(8, 16, 32);
					AssertVram(0);
					Cart.wram_size = 0;
					break;
				case "JALECO-JF-05":
				case "JALECO-JF-06":
				case "TAITO-74*139/74":
				case "JALECO-JF-07":
				case "JALECO-JF-08":
				case "JALECO-JF-09": // untested
				case "KONAMI-74*139/74":
				case "JALECO-JF-10":
					AssertPrg(16, 32); AssertChr(16, 32); AssertVram(0); AssertWram(0);
					break;
				default:
					return false;
			}
			prg_byte_mask = Cart.prg_size * 1024 - 1;
			chr_mask_8k = Cart.chr_size / 8 - 1;
			SetMirrorType(Cart.pad_h, Cart.pad_v);

			return true;
		}
Exemple #4
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER091":
					break;
				default:
					return false;
			}

			int chrSize = Cart.chr_size;
			if (chrSize > 256) // Hack to support some bad dumps
			{
				chrSize = 512;
			}

			chr_bank_mask_2k = chrSize / 2 - 1;
			prg_bank_mask_8k = Cart.prg_size / 8 - 1;

			prg_regs_8k[3] = 0xFF;
			prg_regs_8k[2] = 0xFE;
			
			mmc3 = new MMC3(this, 0x7FFFFFFF);

			SetMirrorType(Cart.pad_h, Cart.pad_v);

			return true;
		}
Exemple #5
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER105":
					break;
				case "NES-EVENT":
					AssertPrg(256); AssertChr(0); AssertVram(8); AssertWram(8);
					break;
				default:
					return false;
			}

			prg_bank_mask_16k = Cart.prg_size / 16 - 1;

			SetMirrorType(EMirrorType.Vertical);

			scnt = new MMC1.MMC1_SerialController();
			scnt.WriteRegister = SerialWriteRegister;
			scnt.Reset = SerialReset;

			Sync();

			return true;
		}
Exemple #6
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//analyze board type
			switch (Cart.board_type)
			{
				case "MAPPER018":
				case "JALECO-JF-23":
				case "JALECO-JF-24": //TODO: there will be many boards to list here
				case "JALECO-JF-25":
				case "JALECO-JF-27":
				case "JALECO-JF-29":
				case "JALECO-JF-37":
				case "JALECO-JF-40":
					break;
				default:
					return false;
			}

			chr_bank_mask_1k = Cart.chr_size / 1 - 1;
			prg_bank_mask_8k = Cart.prg_size / 8 - 1;
			prg_banks_8k[3] = 0xFF;

			// i have no idea what power-on defaults are supposed to be used
			ppuclock = 0;
			irqclock = 0xffff;
			irqreload = 0xffff;
			irqcountwidth = 16;
			irqcountpaused = true;

			SetMirrorType(EMirrorType.Horizontal);
			return true;
		}
Exemple #7
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER090":
				case "UNIF_UNL-TEK90":
					mapper_090 = true;
					nt_advanced_control = false;
					break;
				case "MAPPER209":
					mapper_209 = true;	
					break;
				case "MAPPER211":
					nt_advanced_control = true;
					mapper_211 = true;
					break;
				default:
					return false;
			}

			prg_bank_mask_8k = Cart.prg_size / 8 - 1;
			chr_bank_mask_1k = Cart.chr_size - 1;

			InitValues();

			return true;
		}
Exemple #8
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER080":
					break;
				case "MAPPER207":
					tlsrewire = true;
					break;
				case "TAITO-X1-005":
					if (Cart.pcb == "アシユラー")
						tlsrewire = true;
					break;
				default:
					return false;
			}

			SetMirrorType(EMirrorType.Vertical);
			chr_bank_mask = Cart.chr_size / 1 - 1;
			prg_bank_mask = Cart.prg_size / 8 - 1;
			
			// the chip has 128 bytes of WRAM built into it, which we have to instantiate ourselves
			Cart.wram_size = 0;

			prg_regs_8k[3] = 0xFF;
			return true;
		}
Exemple #9
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER071":
					break;
				case "CAMERICA-ALGN": //Linus Spacehead's Cosmic Crusade (U)
					AssertPrg(128,256); AssertChr(0); AssertWram(0); 
					AssertVram(8,16); //zero 22-mar-2012 - added 16 here as a hack to make micro machines (aladdin) load. should remove this after it is fixed in the DB
					break;
				case "CAMERICA-BF9093": //Big Nose Freaks Out (U)
					AssertPrg(64,128,256); AssertChr(0); AssertWram(0); AssertVram(8);
					break;
				case "CAMERICA-BF9097": //Fire Hawk
					AssertPrg(128); AssertChr(0); AssertWram(0); AssertVram(8);
					mirror_control_enabled = true;
					break;
				case "CODEMASTERS-NR8N": // untested
					AssertPrg(256); AssertChr(0); AssertWram(0); AssertVram(8);
					break;
				default:
					return false;
			}

			prg_bank_mask_16k = Cart.prg_size / 16 - 1;

			prg_banks_16k[0] = 0x00;
			prg_banks_16k[1] = 0xFF & prg_bank_mask_16k;

			SetMirrorType(Cart.pad_h, Cart.pad_v);

			return true;
		}
Exemple #10
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "AVE-NINA-07": // wally bear and the gang
					// it's not the NINA_001 but something entirely different; actually a colordreams with VRAM
					// this actually works
					AssertPrg(128); AssertChr(0); AssertWram(0); AssertVram(8);
					break;

				case "IREM-BNROM": //Mashou (J).nes
				case "NES-BNROM": //Deadly Towers (U)
					AssertPrg(128); AssertChr(0); AssertWram(0); AssertVram(8);
					break;

				default:
					return false;
			}

			prg_bank_mask_32k = Cart.prg_size / 32 - 1;

			SetMirrorType(Cart.pad_h, Cart.pad_v);

			return true;
		}
Exemple #11
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "NAMCOT-175":
					//wagyan land 2
					//splatter house
					SetMirrorType(Cart.pad_h, Cart.pad_v);
					break;
				case "NAMCOT-340":
					//family circuit '91
					//dream master
					//famista '92
					enablemirror = true;
					break;
				case "MAPPER210":
					// not sure what to do here because the popular public collection
					// has nothing in mapper 210 except some mortal kombat pirate cart
					enablemirror = true;
					SetMirrorType(Cart.pad_h, Cart.pad_v);
					break;
				default:
					return false;
			}
			AssertPrg(64, 128, 256, 512);
			AssertChr(64, 128, 256);
			AssertVram(0);

			prg_bank_mask_8k = Cart.prg_size / 8 - 1;
			chr_bank_mask_1k = Cart.chr_size / 1 - 1;
			prg[3] = prg_bank_mask_8k;
			return true;
		}
Exemple #12
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER176":
					break;
				default:
					return false;
			}
			prg_bank_mask_8k = (Cart.prg_size / 8) - 1;
			chr_bank_mask_8k = (Cart.chr_size / 8) - 1;

			mirror = 0;
			SyncMirror();

			sbw = 0;
			prg_banks_8k[0] = 0;
			prg_banks_8k[1] = 1;
			prg_banks_8k[2] = 62;
			prg_banks_8k[3] = 63;
			ApplyMemoryMapMask(prg_bank_mask_8k,prg_banks_8k);

			chr_banks_8k[0] = 0;
			ApplyMemoryMapMask(chr_bank_mask_8k, chr_banks_8k);

			return true;
		}
Exemple #13
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER066":
					break;
				case "NES-GNROM": //thunder & lightning
				case "BANDAI-GNROM":
				case "HVC-GNROM":
				case "NES-MHROM": //Super Mario Bros. / Duck Hunt
					AssertPrg(Cart.board_type == "NES-MHROM" ? 64 : 128); AssertChr(8, 16, 32); AssertVram(0); AssertWram(0);
					break;

				default:
					return false;
			}

			prg_mask = (Cart.prg_size / 32) - 1;
			chr_mask = (Cart.chr_size / 8) - 1;
			SetMirrorType(Cart.pad_h, Cart.pad_v);

			if(origin == NES.EDetectionOrigin.INES)
				Console.WriteLine("Caution! This board (inferred from iNES) might have wrong mirr.type");


			return true;
		}
Exemple #14
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER013":
					AssertPrg(32);
					AssertChr(0);
					Cart.vram_size = 16;
					Cart.wram_size = 0;
					break;

				case "NES-CPROM": //videomation
					AssertPrg(32); AssertChr(0); AssertVram(16); AssertWram(0);
					break;
				
				default:
					return false;
			}

			//TODO - assert that mirror type is vertical?
			//set it in the cart?

			SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical);

			return true;
		}
Exemple #15
0
        public static void Apply(NES.INESBoard board)
        {
            var fields = board.GetType().GetFields();
            foreach (var field in fields)
            {
                var attribs = field.GetCustomAttributes(false);
                foreach (var attrib in attribs)
                {
                    if (attrib is MapperPropAttribute)
                    {
                        string Name = ((MapperPropAttribute)attrib).Name ?? field.Name;

                        string Value;
                        if (board.InitialRegisterValues.TryGetValue(Name, out Value))
                        {
                            try
                            {
                                field.SetValue(board, Convert.ChangeType(Value, field.FieldType));
                            }
                            catch (Exception e)
                            {
                                if (e is InvalidCastException || e is FormatException || e is OverflowException)
                                    throw new InvalidDataException("Auto Mapper Properties were in a bad format!", e);
                                else
                                    throw e;
                            }
                        }
                        break;
                    }
                }
            }
        }
Exemple #16
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER011":
					break;

				case "Discrete_74x377-FLEX":
					break;
				case "COLORDREAMS-74*377":
					AssertPrg(32, 64, 128); AssertChr(16, 32, 64, 128); AssertVram(0); AssertWram(0);
					break;

				case "AGCI-47516":
					SetMirrorType(Cart.pad_h, Cart.pad_v);
					break;

				case "AGCI-50282": // death race
				case "MAPPER144":
					bus_conflict_50282 = true;
					bus_conflict = false;
					SetMirrorType(Cart.pad_h, Cart.pad_v);
					break;

				default:
					return false;
			}
			AssertPrg(32, 64, 128);
			AssertChr(8, 16, 32, 64, 128);

			prg_bank_mask_32k = Cart.prg_size / 32 - 1;
			chr_bank_mask_8k = Cart.chr_size / 8 - 1;

			return true;
		}
Exemple #17
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER032":
					break;
				case "IREM-G101":
					if (Cart.pcb == "UNK-IF-13")
					{
						//special case for major league
						oneScreenHack = true;
					}
					AssertPrg(128, 256); AssertChr(128); AssertWram(0, 8); AssertVram(0);
					break;
				default:
					return false;
			}

			prg_bank_mask = Cart.prg_size / 8 - 1;
			chr_bank_mask = Cart.chr_size - 1;

			prg_regs_8k[0] = 0x00;
			prg_regs_8k[1] = 0x01;
			prg_regs_8k[2] = 0xFE; //constant
			prg_regs_8k[3] = 0xFF; //constant
			prg_regs_8k[4] = 0xFE; //constant //** NOTE ** according to disch's doc this would be fixed to 0. but it needs to be this to work. someone should let him know.
			prg_regs_8k[5] = 0x01;
			prg_regs_8k[6] = 0x00;
			prg_regs_8k[7] = 0xFF; //constant

			SyncMirror();

			return true;
		}
Exemple #18
0
		bool simple; // when true, we're in some sort of "simplified" mode

		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				// quite a few crappy games on these boards, shouldn't be hard to find examples?
				case "MAPPER141":
				case "UNIF_UNL-Sachen-8259A":
				case "SACHEN-8259A":
					shiftout = 1; // 256KiB chr max
					break;
				case "MAPPER138":
				case "UNIF_UNL-Sachen-8259B":
				case "SACHEN-8259B":
					shiftout = 0; // 128KiB chr max
					break;
				case "MAPPER139":
				case "UNIF_UNL-Sachen-8259C":
				case "SACHEN-8259C":
					shiftout = 2; // 512KiB chr max
					break;
				default:
					return false;
			}
			Cart.wram_size = 0; // cart responds to regs in 6000:7fff
			Cart.vram_size = 0;

			shiftmask = (1 << shiftout) - 1;
			prg_bank_mask_32k = Cart.prg_size / 32 - 1;
			chr_bank_mask_2k = Cart.chr_size / 2 - 1;

			SetMirrorType(EMirrorType.Vertical);

			return true;
		}
Exemple #19
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			//configure
			switch (Cart.board_type)
			{
				case "MAPPER068":
					break;
				case "TENGEN-800042":
					AssertPrg(128); AssertChr(256); AssertVram(0); AssertWram(0);
					break;
				case "SUNSOFT-4":
					AssertPrg(128); AssertChr(128,256); AssertVram(0); AssertWram(0,8); 
					break;
				case "UNIF_NES-NTBROM":
					AssertPrg(128 + 16); AssertChr(128); Cart.wram_size = 8; Cart.vram_size = 0;
					/* The actual cart had 128k prg, with a small slot on the top that can load an optional daughterboard.
					 * The UNIF dump has this as an extra 16k prg lump.  I don't know how this lump is actually used,
					 * though.
					 */
					break;
				default:
					return false;
			}

			SetMirrorType(EMirrorType.Vertical);
			prg_regs_16k[1] = 0xFF;
			prg_bank_mask = Cart.prg_size / 16 - 1;
			if (Cart.prg_size == 128 + 16)
				prg_bank_mask = 7; // ignore extra prg lump
			chr_bank_mask = Cart.chr_size / 2 - 1;
			nt_bank_mask = Cart.chr_size - 1;
			return true;
		}
Exemple #20
0
        public override void AtVsyncNMI()
        {
            if (Patch_Vectors)
            {
                NES.cpu.NMI = true;
            }

            //strobe pad
            NES.WriteMemory(0x4016, 1);
            NES.WriteMemory(0x4016, 0);

            //read pad and create rising edge button signals so we dont trigger events as quickly as we hold the button down
            int currButtons = 0;

            for (int i = 0; i < 8; i++)
            {
                currButtons <<= 1;
                currButtons  |= (NES.ReadMemory(0x4016) & 1);
            }
            int justDown = (~ButtonState) & currButtons;
            Bit a        = (justDown >> 7) & 1;
            Bit b        = (justDown >> 6) & 1;
            Bit sel      = (justDown >> 5) & 1;
            Bit start    = (justDown >> 4) & 1;
            Bit up       = (justDown >> 3) & 1;
            Bit down     = (justDown >> 2) & 1;
            Bit left     = (justDown >> 1) & 1;
            Bit right    = (justDown >> 0) & 1;

            ButtonState = currButtons;

            //RIGHT: next song
            //LEFT: prev song
            //A: restart song

            bool reset = false;

            if (right)
            {
                CurrentSong++;
                reset = true;
            }
            if (left)
            {
                CurrentSong--;
                reset = true;
            }

            if (a)
            {
                reset = true;
            }

            if (reset)
            {
                ReplayInit();
            }
        }
Exemple #21
0
 public NESWatch(NES nes, EDomain domain, int address)
 {
     Address = address;
     Domain  = domain;
     if (domain == EDomain.Sysbus)
     {
         watches = nes.sysbus_watch;
     }
 }
Exemple #22
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			if (Cart.board_type != "SUNSOFT-1" || Cart.pcb != "SUNSOFT-4")
				return false;

			AssertChr(0); AssertVram(8); AssertWram(0); AssertPrg(128);
			SetMirrorType(Cart.pad_h, Cart.pad_v);
			return true;
		}
Exemple #23
0
		private void NesPPU_Load(object sender, EventArgs e)
		{
			LoadConfigSettings();
			_nes = Global.Emulator as NES;
			ClearDetails();
			RefreshRate.Value = Global.Config.NESPPURefreshRate;
			Generate(true);
			CHRROMViewReload();
		}
Exemple #24
0
			public NESWatch(NES nes, EDomain domain, int address)
			{
				Address = address;
				Domain = domain;
				if (domain == EDomain.Sysbus)
				{
					watches = nes.sysbus_watch;
				}
			}
		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);
		}
Exemple #26
0
		public void Restart()
		{
			if (Global.Emulator is NES)
			{
				_nes = Global.Emulator as NES;
			}
			else
			{
				Close();
			}
		}
Exemple #27
0
			public MagicSoundProvider(NES nes, uint infreq)
			{
				this.nes = nes;

				blip = new BlipBuffer(blipbuffsize);
				blip.SetRates(infreq, 44100);

				//var actualMetaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V);
				//1.789773mhz NTSC
				//resampler = new Sound.Utilities.SpeexResampler(2, infreq, 44100 * APU.DECIMATIONFACTOR, infreq, 44100, actualMetaspu.buffer.enqueue_samples);
				//output = new Sound.Utilities.DCFilter(actualMetaspu);
			}
Exemple #28
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER120":
					break;
				default:
					return false;
			}
			SetMirrorType(EMirrorType.Vertical);
			return true;
		}
Exemple #29
0
            public MagicSoundProvider(NES nes, uint infreq)
            {
                this.nes = nes;

                blip = new BlipBuffer(blipbuffsize);
                blip.SetRates(infreq, 44100);

                //var actualMetaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V);
                //1.789773mhz NTSC
                //resampler = new Sound.Utilities.SpeexResampler(2, infreq, 44100 * APU.DECIMATIONFACTOR, infreq, 44100, actualMetaspu.buffer.enqueue_samples);
                //output = new Sound.Utilities.DCFilter(actualMetaspu);
            }
Exemple #30
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER204":
					break;
				default:
					return false;
			}

			return true;
		}
Exemple #31
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "UNIF_DREAMTECH01":
					break;
				default:
					return false;
			}

			return true;
		}
Exemple #32
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER051":
					break;
				default:
					return false;
			}

			SetMirrorType(Cart.pad_h, Cart.pad_v);
			return true;
		}
Exemple #33
0
		public override bool Configure(NES.EDetectionOrigin origin)
		{
			switch (Cart.board_type)
			{
				case "MAPPER226":
					break;
				default:
					return false;
			}
			prg_page = 0;
			prg_mode = false;
			return true;
		}
Exemple #34
0
		public APU(NES nes, APU old, bool pal)
		{
			this.nes = nes;
			dmc = new DMCUnit(this, pal);
			sequencer_lut = pal ? sequencer_lut_pal : sequencer_lut_ntsc;
			
			noise = new NoiseUnit(this, pal);
			triangle = new TriangleUnit(this);
			pulse[0] = new PulseUnit(this, 1);
			pulse[1] = new PulseUnit(this, 0);
			if (old != null)
			{
				m_vol = old.m_vol;
			}
		}
Exemple #35
0
 public APU(NES nes, APU old, bool pal)
 {
     this.nes = nes;
     dmc      = new DMCUnit(this, pal);
     noise    = new NoiseUnit(this, pal);
     triangle = new TriangleUnit(this);
     pulse[0] = new PulseUnit(this, 0);
     pulse[1] = new PulseUnit(this, 1);
     if (old != null)
     {
         Square1V  = old.Square1V;
         Square2V  = old.Square2V;
         TriangleV = old.TriangleV;
         NoiseV    = old.NoiseV;
         DMCV      = old.DMCV;
     }
 }
Exemple #36
0
        public PPU(NES nes)
        {
            this.nes = nes;

            OAM    = new byte[0x100];
            PALRAM = new byte[0x20];

            //power-up palette verified by blargg's power_up_palette test.
            //he speculates that these may differ depending on the system tested..
            //and I don't see why the ppu would waste any effort setting these..
            //but for the sake of uniformity, we'll do it.
            Array.Copy(new byte[] {
                0x09, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x0D, 0x08, 0x10, 0x08, 0x24, 0x00, 0x00, 0x04, 0x2C,
                0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, 0x08, 0x3A, 0x00, 0x02, 0x00, 0x20, 0x2C, 0x08
            }, PALRAM, 0x20);

            Reset();
        }
Exemple #37
0
        /// <summary>
        /// finds a board class which can handle the provided cart
        /// </summary>
        static Type FindBoard(CartInfo cart, EDetectionOrigin origin, Dictionary <string, string> properties)
        {
            NES nes = new NES();

            nes.cart = cart;
            Type ret = null;

            lock (INESBoardImplementors)
                foreach (var type in INESBoardImplementors)
                {
                    using (NESBoardBase board = (NESBoardBase)Activator.CreateInstance(type))
                    {
                        //unif demands that the boards set themselves up with expected legal values based on the board size
                        //except, i guess, for the rom/chr sizes. go figure.
                        //so, disable the asserts here
                        if (origin == EDetectionOrigin.UNIF)
                        {
                            board.DisableConfigAsserts = true;
                        }

                        board.Create(nes);
                        board.InitialRegisterValues = properties;
                        if (board.Configure(origin))
                        {
#if DEBUG
                            if (ret != null)
                            {
                                throw new Exception($"Boards {ret} and {type} both responded to {nameof(NESBoardBase.Configure)}!");
                            }
                            else
                            {
                                ret = type;
                            }
#else
                            return(type);
#endif
                        }
                    }
                }
            return(ret);
        }
Exemple #38
0
        public override void AtVsyncNmi()
        {
            if (Patch_Vectors)
            {
                NES.cpu.NMI = true;
            }

            //strobe pad
            NES.WriteMemory(0x4016, 1);
            NES.WriteMemory(0x4016, 0);

            //read pad and create rising edge button signals so we don't trigger events as quickly as we hold the button down
            int currButtons = 0;

            for (int i = 0; i < 8; i++)
            {
                currButtons <<= 1;
                currButtons  |= (NES.ReadMemory(0x4016) & 1);
            }
            int justDown = (~ButtonState) & currButtons;
            Bit a        = (justDown >> 7) & 1;
            Bit b        = (justDown >> 6) & 1;
            Bit sel      = (justDown >> 5) & 1;
            Bit start    = (justDown >> 4) & 1;
            Bit up       = (justDown >> 3) & 1;
            Bit down     = (justDown >> 2) & 1;
            Bit left     = (justDown >> 1) & 1;
            Bit right    = (justDown >> 0) & 1;

            ButtonState = currButtons;

            //RIGHT: next song
            //LEFT: prev song
            //A: restart song

            //RTC_Hijack :: control NSF from System Bus 0x00CE
            ushort songChangeAdress = 0x00CE;                           //RTC_Hijack
            byte   songValue        = NES.ReadMemory(songChangeAdress); //RTC_Hijack
            bool   reset            = false;

            if (right || (songValue == 0xFB))             //RTC_Hijack
            {
                NES.WriteMemory(songChangeAdress, 0xFF);  //RTC_Hijack
                if (CurrentSong < nsf.TotalSongs - 1)
                {
                    CurrentSong++;
                    reset = true;
                }
            }
            if (left || (songValue == 0xFA))             //RTC_Hijack
            {
                NES.WriteMemory(songChangeAdress, 0xFF); //RTC_Hijack
                if (CurrentSong > 0)
                {
                    CurrentSong--;
                    reset = true;
                }
            }

            if (a)
            {
                reset = true;
            }

            if (reset)
            {
                ReplayInit();
            }
        }
Exemple #39
0
 public BisqAPU(NES nes)
 {
     this.nes = nes;
 }
Exemple #40
0
 public MyVideoProvider(NES emu)
 {
     this.emu = emu;
 }
Exemple #41
0
 public CpuLink(NES nes)
 {
     _nes = nes;
 }
Exemple #42
0
        public override byte ReadReg2xxx(int addr)
        {
            if (addr < 0x3800)
            {
                return(base.ReadReg2xxx(addr));
            }
            else if (addr >= 0x3FF0)
            {
                switch (addr)
                {
                case 0x3FF0:
                {
                    byte ret = 0;
                    if (InitPending)
                    {
                        ret = 1;
                    }
                    InitPending = false;
                    return(ret);
                }

                case 0x3FF1:
                {
                    //kevtris's reset process seems not to work. dunno what all is going on in there

                    //our own innovation, should work OK..
                    NES.apu.NESSoftReset();

                    //mostly fceux's guidance
                    NES.WriteMemory(0x4015, 0);
                    for (int i = 0; i < 14; i++)
                    {
                        NES.WriteMemory((ushort)(0x4000 + i), 0);
                    }
                    NES.WriteMemory(0x4015, 0x0F);

                    //clearing APU misc stuff, maybe not needed with soft reset above
                    //NES.WriteMemory(0x4017, 0xC0);
                    //NES.WriteMemory(0x4017, 0xC0);
                    //NES.WriteMemory(0x4017, 0x40);

                    //important to NSF standard for ram to be cleared, otherwise replayers are confused on account of not initializing memory themselves
                    var ram       = NES.ram;
                    var wram      = this.WRAM;
                    int wram_size = wram.Length;
                    for (int i = 0; i < 0x800; i++)
                    {
                        ram[i] = 0;
                    }
                    for (int i = 0; i < wram_size; i++)
                    {
                        wram[i] = 0;
                    }

                    //store specified initial bank state
                    if (BankSwitched)
                    {
                        for (int i = 0; i < 8; i++)
                        {
                            WriteEXP(0x5FF8 + i - 0x4000, InitBankSwitches[i]);
                        }
                    }

                    return((byte)(CurrentSong - 1));
                }

                case 0x3FF2:
                    return(0);                            //always return NTSC for now

                case 0x3FF3:
                    Patch_Vectors = false;
                    return(0);

                case 0x3FF4:
                    Patch_Vectors = true;
                    return(0);

                default:
                    return(base.ReadReg2xxx(addr));
                }
            }
            else if (addr - 0x3800 < NSFROM.Length)
            {
                return(NSFROM[addr - 0x3800]);
            }
            else
            {
                return(base.ReadReg2xxx(addr));
            }
        }
 public override void WritePrg(int addr, byte value)
 {
     NES.LogLine("{0:x4}<={1:x2}", addr + 0x8000, value);
 }
Exemple #44
0
 public virtual void Create(NES nes)
 {
     this.NES = nes;
 }
Exemple #45
0
 public virtual void Create(NES nes)
 {
     NES = nes;
 }