Ejemplo n.º 1
0
        public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings)
        {
            CoreComm          = comm;
            this.SyncSettings = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings();
            bool skipbios = this.SyncSettings.SkipBiosIntro;

            Cpu               = new Z80A();
            Cpu.ReadMemory    = ReadMemory;
            Cpu.WriteMemory   = WriteMemory;
            Cpu.ReadHardware  = ReadPort;
            Cpu.WriteHardware = WritePort;

            VDP = new TMS9918A(Cpu);
            PSG = new SN76489();

            // TODO: hack to allow bios-less operation would be nice, no idea if its feasible
            string biosPath = CoreComm.CoreFileProvider.GetFirmwarePath("Coleco", "Bios", true, "Coleco BIOS file is required.");

            BiosRom = File.ReadAllBytes(biosPath);

            // gamedb can overwrite the syncsettings; this is ok
            if (game["NoSkip"])
            {
                skipbios = false;
            }
            LoadRom(rom, skipbios);
            this.game = game;
            SetupMemoryDomains();
        }
Ejemplo n.º 2
0
        public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings)
        {
            ServiceProvider = new BasicServiceProvider(this);
            MemoryCallbacks = new MemoryCallbackSystem();
            CoreComm        = comm;
            _syncSettings   = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings();
            bool skipbios = this._syncSettings.SkipBiosIntro;

            Cpu                 = new Z80A();
            Cpu.ReadMemory      = ReadMemory;
            Cpu.WriteMemory     = WriteMemory;
            Cpu.ReadHardware    = ReadPort;
            Cpu.WriteHardware   = WritePort;
            Cpu.MemoryCallbacks = MemoryCallbacks;

            VDP = new TMS9918A(Cpu);
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(VDP);
            PSG = new SN76489();

            // TODO: hack to allow bios-less operation would be nice, no idea if its feasible
            BiosRom = CoreComm.CoreFileProvider.GetFirmware("Coleco", "Bios", true, "Coleco BIOS file is required.");

            // gamedb can overwrite the syncsettings; this is ok
            if (game["NoSkip"])
            {
                skipbios = false;
            }
            LoadRom(rom, skipbios);
            this.game = game;
            SetupMemoryDomains();
            (ServiceProvider as BasicServiceProvider).Register <IDisassemblable>(new Disassembler());
        }
Ejemplo n.º 3
0
 void Awake()
 {
     m_SampleRate = AudioSettings.outputSampleRate;
     m_PSGChip    = new SN76489(m_SampleRate, (int)clockFrequency);
     Debug.Log(AudioSettings.outputSampleRate);
     ResetChip();
 }
Ejemplo n.º 4
0
 void Awake()
 {
     m_SampleRate = AudioSettings.outputSampleRate;
     m_PSGChip    = new SN76489(m_SampleRate, (int)SN76489.Clock.PAL);
     Debug.Log(AudioSettings.outputSampleRate);
     ResetChip();
 }
Ejemplo n.º 5
0
        public SoundMagicCard()
        {
            uint sample_rate = TVCManagers.Default.AudioManager.SampleRate;

            m_SN76489 = new SN76489();
            m_SN76489.Initialize(sample_rate, SN_CLOCK);

            m_SAA1099 = new SAA1099();
            m_SAA1099.Initialize(sample_rate);
        }
Ejemplo n.º 6
0
        public GameCard(ExpansionMain in_expansion_main)
        {
            m_sound_chip_enable   = false;
            m_audio_channel_index = -1;
            m_expansion_main      = in_expansion_main;

            m_sound_chip = new SN76489();
            m_sound_chip.Initialize(TVCManagers.Default.AudioManager.SampleRate, SN_CLOCK);

            m_joystick3 = new TVCJoystick();
            m_joystick4 = new TVCJoystick();
        }
Ejemplo n.º 7
0
        public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings)
        {
            ServiceProvider = new BasicServiceProvider(this);
            MemoryCallbacks = new MemoryCallbackSystem();
            CoreComm        = comm;
            _syncSettings   = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings();
            bool skipbios = _syncSettings.SkipBiosIntro;

            Cpu = new Z80A
            {
                ReadMemory      = ReadMemory,
                WriteMemory     = WriteMemory,
                ReadHardware    = ReadPort,
                WriteHardware   = WritePort,
                MemoryCallbacks = MemoryCallbacks
            };

            PSG            = new SN76489();
            _fakeSyncSound = new FakeSyncSound(PSG, 735);
            (ServiceProvider as BasicServiceProvider).Register <ISoundProvider>(_fakeSyncSound);

            ControllerDeck = new ColecoVisionControllerDeck(_syncSettings.Port1, _syncSettings.Port2);

            VDP = new TMS9918A(Cpu);
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(VDP);

            // TODO: hack to allow bios-less operation would be nice, no idea if its feasible
            BiosRom = CoreComm.CoreFileProvider.GetFirmware("Coleco", "Bios", true, "Coleco BIOS file is required.");

            // gamedb can overwrite the syncsettings; this is ok
            if (game["NoSkip"])
            {
                skipbios = false;
            }

            LoadRom(rom, skipbios);
            _game = game;
            SetupMemoryDomains();

            Tracer.Header = Cpu.TraceHeader;
            var serviceProvider = ServiceProvider as BasicServiceProvider;

            serviceProvider.Register <IDisassemblable>(new Disassembler());
            serviceProvider.Register <ITraceable>(Tracer);
        }
Ejemplo n.º 8
0
        public SMS(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings)
        {
            ServiceProvider = new BasicServiceProvider(this);
            Settings        = (SMSSettings)settings ?? new SMSSettings();
            SyncSettings    = (SMSSyncSettings)syncSettings ?? new SMSSyncSettings();
            CoreComm        = comm;
            MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" });

            IsGameGear   = game.System == "GG";
            IsGameGear_C = game.System == "GG";
            IsSG1000     = game.System == "SG";
            RomData      = rom;

            if (RomData.Length % BankSize != 0)
            {
                Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
            }

            RomBanks = (byte)(RomData.Length / BankSize);

            Region = DetermineDisplayType(SyncSettings.DisplayType, game.Region);
            if (game["PAL"] && Region != DisplayType.PAL)
            {
                Region = DisplayType.PAL;
                CoreComm.Notify("Display was forced to PAL mode for game compatibility.");
            }

            if (IsGameGear)
            {
                Region = DisplayType.NTSC;                 // all game gears run at 60hz/NTSC mode
            }

            RegionStr = SyncSettings.ConsoleRegion;
            if (RegionStr == "Auto")
            {
                RegionStr = DetermineRegion(game.Region);
            }

            if (game["Japan"] && RegionStr != "Japan")
            {
                RegionStr = "Japan";
                CoreComm.Notify("Region was forced to Japan for game compatibility.");
            }

            if (game["Korea"] && RegionStr != "Korea")
            {
                RegionStr = "Korea";
                CoreComm.Notify("Region was forced to Korea for game compatibility.");
            }

            if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear)
            {
                HasYM2413 = true;
            }

            Cpu = new Z80A()
            {
                ReadHardware    = ReadPort,
                WriteHardware   = WritePort,
                FetchMemory     = FetchMemory,
                ReadMemory      = ReadMemory,
                WriteMemory     = WriteMemory,
                MemoryCallbacks = MemoryCallbacks,
                OnExecFetch     = OnExecMemory
            };


            if (game["GG_in_SMS"])
            {
                // skip setting the BIOS because this is a game gear game that puts the system
                // in SMS compatibility mode (it will fail the check sum if played on an actual SMS though.)
                IsGameGear   = false;
                IsGameGear_C = true;
                game.System  = "GG";
                Console.WriteLine("Using SMS Compatibility mode for Game Gear System");
            }

            Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, Region);
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(Vdp);
            PSG        = new SN76489();
            YM2413     = new YM2413();
            SoundMixer = new SoundMixer(YM2413, PSG);
            if (HasYM2413 && game["WhenFMDisablePSG"])
            {
                SoundMixer.DisableSource(PSG);
            }

            ActiveSoundProvider = HasYM2413 ? (IAsyncSoundProvider)SoundMixer : PSG;
            _fakeSyncSound      = new FakeSyncSound(ActiveSoundProvider, 735);
            (ServiceProvider as BasicServiceProvider).Register <ISoundProvider>(_fakeSyncSound);

            SystemRam = new byte[0x2000];

            if (game["CMMapper"])
            {
                InitCodeMastersMapper();
            }
            else if (game["CMMapperWithRam"])
            {
                InitCodeMastersMapperRam();
            }
            else if (game["ExtRam"])
            {
                InitExt2kMapper(int.Parse(game.OptionValue("ExtRam")));
            }
            else if (game["KoreaMapper"])
            {
                InitKoreaMapper();
            }
            else if (game["MSXMapper"])
            {
                InitMSXMapper();
            }
            else if (game["NemesisMapper"])
            {
                InitNemesisMapper();
            }
            else if (game["TerebiOekaki"])
            {
                InitTerebiOekaki();
            }
            else if (game["EEPROM"])
            {
                InitEEPROMMapper();
            }
            else
            {
                InitSegaMapper();
            }

            if (Settings.ForceStereoSeparation && !IsGameGear)
            {
                if (game["StereoByte"])
                {
                    ForceStereoByte = byte.Parse(game.OptionValue("StereoByte"));
                }

                PSG.StereoPanning = ForceStereoByte;
            }

            if (SyncSettings.AllowOverlock && game["OverclockSafe"])
            {
                Vdp.IPeriod = 512;
            }

            if (Settings.SpriteLimit)
            {
                Vdp.SpriteLimit = true;
            }

            if (game["3D"])
            {
                IsGame3D = true;
            }

            if (game["BIOS"])
            {
                Port3E = 0xF7;                 // Disable cartridge, enable BIOS rom
                InitBiosMapper();
            }
            else if ((game.System == "SMS") && !game["GG_in_SMS"])
            {
                BiosRom = comm.CoreFileProvider.GetFirmware("SMS", RegionStr, false);

                if (BiosRom == null)
                {
                    throw new MissingFirmwareException("No BIOS found");
                }
                else if (!game["RequireBios"] && !SyncSettings.UseBIOS)
                {
                    // we are skipping the BIOS
                    // but only if it won't break the game
                }
                else
                {
                    Port3E = 0xF7;
                }
            }

            if (game["SRAM"])
            {
                SaveRAM = new byte[int.Parse(game.OptionValue("SRAM"))];
                Console.WriteLine(SaveRAM.Length);
            }
            else if (game.NotInDatabase)
            {
                SaveRAM = new byte[0x8000];
            }

            SetupMemoryDomains();

            //this manages the linkage between the cpu and mapper callbacks so it needs running before bootup is complete
            ((ICodeDataLogger)this).SetCDL(null);

            InputCallbacks = new InputCallbackSystem();

            Tracer = new TraceBuffer {
                Header = Cpu.TraceHeader
            };

            var serviceProvider = ServiceProvider as BasicServiceProvider;

            serviceProvider.Register <ITraceable>(Tracer);
            serviceProvider.Register <IDisassemblable>(Cpu);
            Vdp.ProcessOverscan();

            Cpu.ReadMemory  = ReadMemory;
            Cpu.WriteMemory = WriteMemory;
        }
Ejemplo n.º 9
0
        public SMS(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings)
        {
            ServiceProvider = new BasicServiceProvider(this);
            Settings        = (SMSSettings)settings ?? new SMSSettings();
            SyncSettings    = (SMSSyncSettings)syncSettings ?? new SMSSyncSettings();
            CoreComm        = comm;
            MemoryCallbacks = new MemoryCallbackSystem();

            IsGameGear = game.System == "GG";
            IsSG1000   = game.System == "SG";
            RomData    = rom;
            Tracer     = new TraceBuffer();
            (ServiceProvider as BasicServiceProvider).Register <ITraceable>(Tracer);
            if (RomData.Length % BankSize != 0)
            {
                Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
            }
            RomBanks = (byte)(RomData.Length / BankSize);

            Region = DetermineDisplayType(SyncSettings.DisplayType, game.Region);
            if (game["PAL"] && Region != DisplayType.PAL)
            {
                Region = DisplayType.PAL;
                CoreComm.Notify("Display was forced to PAL mode for game compatibility.");
            }
            if (IsGameGear)
            {
                Region = DisplayType.NTSC;                 // all game gears run at 60hz/NTSC mode
            }
            CoreComm.VsyncNum = Region == DisplayType.NTSC ? 60 : 50;
            CoreComm.VsyncDen = 1;

            RegionStr = SyncSettings.ConsoleRegion;
            if (RegionStr == "Auto")
            {
                RegionStr = DetermineRegion(game.Region);
            }

            if (game["Japan"] && RegionStr != "Japan")
            {
                RegionStr = "Japan";
                CoreComm.Notify("Region was forced to Japan for game compatibility.");
            }

            if ((game.NotInDatabase || game["FM"]) && SyncSettings.EnableFM && !IsGameGear)
            {
                HasYM2413 = true;
            }

            if (Controller == null)
            {
                Controller = NullController.GetNullController();
            }

            Cpu                 = new Z80A();
            Cpu.RegisterSP      = 0xDFF0;
            Cpu.ReadHardware    = ReadPort;
            Cpu.WriteHardware   = WritePort;
            Cpu.MemoryCallbacks = MemoryCallbacks;

            Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, Region);
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(Vdp);
            PSG        = new SN76489();
            YM2413     = new YM2413();
            SoundMixer = new SoundMixer(YM2413, PSG);
            if (HasYM2413 && game["WhenFMDisablePSG"])
            {
                SoundMixer.DisableSource(PSG);
            }
            ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG;

            SystemRam = new byte[0x2000];

            if (game["CMMapper"])
            {
                InitCodeMastersMapper();
            }
            else if (game["CMMapperWithRam"])
            {
                InitCodeMastersMapperRam();
            }
            else if (game["ExtRam"])
            {
                InitExt2kMapper(int.Parse(game.OptionValue("ExtRam")));
            }
            else if (game["KoreaMapper"])
            {
                InitKoreaMapper();
            }
            else if (game["MSXMapper"])
            {
                InitMSXMapper();
            }
            else if (game["NemesisMapper"])
            {
                InitNemesisMapper();
            }
            else if (game["TerebiOekaki"])
            {
                InitTerebiOekaki();
            }
            else
            {
                InitSegaMapper();
            }

            if (Settings.ForceStereoSeparation && !IsGameGear)
            {
                if (game["StereoByte"])
                {
                    ForceStereoByte = byte.Parse(game.OptionValue("StereoByte"));
                }
                PSG.StereoPanning = ForceStereoByte;
            }

            if (SyncSettings.AllowOverlock && game["OverclockSafe"])
            {
                Vdp.IPeriod = 512;
            }

            if (Settings.SpriteLimit)
            {
                Vdp.SpriteLimit = true;
            }

            if (game["3D"])
            {
                IsGame3D = true;
            }

            if (game["BIOS"])
            {
                Port3E = 0xF7;                 // Disable cartridge, enable BIOS rom
                InitBiosMapper();
            }
            else if (game.System == "SMS")
            {
                BiosRom = comm.CoreFileProvider.GetFirmware("SMS", RegionStr, false);
                if (BiosRom != null && (game["RequireBios"] || SyncSettings.UseBIOS))
                {
                    Port3E = 0xF7;
                }

                if (BiosRom == null && game["RequireBios"])
                {
                    throw new MissingFirmwareException("BIOS image not available. This game requires BIOS to function.");
                }
                if (SyncSettings.UseBIOS && BiosRom == null)
                {
                    CoreComm.Notify("BIOS was selected, but rom image not available. BIOS not enabled.");
                }
            }

            if (game["SRAM"])
            {
                SaveRAM = new byte[int.Parse(game.OptionValue("SRAM"))];
            }
            else if (game.NotInDatabase)
            {
                SaveRAM = new byte[0x8000];
            }

            SetupMemoryDomains();

            //this manages the linkage between the cpu and mapper callbacks so it needs running before bootup is complete
            ((ICodeDataLogger)this).SetCDL(null);

            (ServiceProvider as BasicServiceProvider).Register <IDisassemblable>(new Disassembler());
        }
Ejemplo n.º 10
0
        public Genesis(CoreComm comm, GameInfo game, byte[] rom)
        {
            ServiceProvider = new BasicServiceProvider(this);
            CoreComm        = comm;
            MainCPU         = new MC68000();
            SoundCPU        = new Z80A();
            YM2612          = new YM2612()
            {
                MaxVolume = 23405
            };
            PSG = new SN76489()
            {
                MaxVolume = 4681
            };
            VDP = new GenVDP();
            VDP.DmaReadFrom68000 = ReadWord;
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(VDP);
            SoundMixer = new SoundMixer(YM2612, PSG);

            MainCPU.ReadByte    = ReadByte;
            MainCPU.ReadWord    = ReadWord;
            MainCPU.ReadLong    = ReadLong;
            MainCPU.WriteByte   = WriteByte;
            MainCPU.WriteWord   = WriteWord;
            MainCPU.WriteLong   = WriteLong;
            MainCPU.IrqCallback = InterruptCallback;

            // ---------------------- musashi -----------------------
#if MUSASHI
            _vdp    = vdpcallback;
            read8   = Read8;
            read16  = Read16;
            read32  = Read32;
            write8  = Write8;
            write16 = Write16;
            write32 = Write32;

            Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp));
            Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8));
            Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16));
            Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32));
            Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8));
            Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16));
            Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32));
#endif
            // ---------------------- musashi -----------------------

            SoundCPU.ReadMemory    = ReadMemoryZ80;
            SoundCPU.WriteMemory   = WriteMemoryZ80;
            SoundCPU.WriteHardware = (a, v) => { Console.WriteLine("Z80: Attempt I/O Write {0:X2}:{1:X2}", a, v); };
            SoundCPU.ReadHardware  = x => 0xFF;
            SoundCPU.IRQCallback   = () => SoundCPU.Interrupt = false;
            Z80Reset = true;
            RomData  = new byte[0x400000];
            for (int i = 0; i < rom.Length; i++)
            {
                RomData[i] = rom[i];
            }

            SetupMemoryDomains();
#if MUSASHI
            Musashi.Init();
            Musashi.Reset();
            VDP.GetPC = () => Musashi.PC;
#else
            MainCPU.Reset();
            VDP.GetPC = () => MainCPU.PC;
#endif
            InitializeCartHardware(game);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructor for SoundPlayer.
 /// </summary>
 /// <param name="state"></param>
 public SoundPlayer(GameState state)
 {
     psg                  = new SN76489();
     this.state           = state;
     this.soundNumPlaying = -1;
 }
Ejemplo n.º 12
0
		public Genesis(CoreComm comm, GameInfo game, byte[] rom)
		{
			ServiceProvider = new BasicServiceProvider(this);
			CoreComm = comm;
			MainCPU = new MC68000();
			SoundCPU = new Z80A();
			YM2612 = new YM2612() { MaxVolume = 23405 };
			PSG = new SN76489() { MaxVolume = 4681 };
			VDP = new GenVDP();
			VDP.DmaReadFrom68000 = ReadWord;
			(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(VDP);
			SoundMixer = new SoundMixer(YM2612, PSG);

			MainCPU.ReadByte = ReadByte;
			MainCPU.ReadWord = ReadWord;
			MainCPU.ReadLong = ReadLong;
			MainCPU.WriteByte = WriteByte;
			MainCPU.WriteWord = WriteWord;
			MainCPU.WriteLong = WriteLong;
			MainCPU.IrqCallback = InterruptCallback;

			// ---------------------- musashi -----------------------
#if MUSASHI
			_vdp = vdpcallback;
			read8 = Read8;
			read16 = Read16;
			read32 = Read32;
			write8 = Write8;
			write16 = Write16;
			write32 = Write32;

			Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp));
			Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8));
			Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16));
			Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32));
			Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8));
			Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16));
			Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32));
#endif
			// ---------------------- musashi -----------------------

			SoundCPU.ReadMemory = ReadMemoryZ80;
			SoundCPU.WriteMemory = WriteMemoryZ80;
			SoundCPU.WriteHardware = (a, v) => { Console.WriteLine("Z80: Attempt I/O Write {0:X2}:{1:X2}", a, v); };
			SoundCPU.ReadHardware = x => 0xFF;
			SoundCPU.IRQCallback = () => SoundCPU.Interrupt = false;
			Z80Reset = true;
			RomData = new byte[0x400000];
			for (int i = 0; i < rom.Length; i++)
				RomData[i] = rom[i];

			SetupMemoryDomains();
#if MUSASHI
			Musashi.Init();
			Musashi.Reset();
			VDP.GetPC = () => Musashi.PC;
#else
			MainCPU.Reset();
			VDP.GetPC = () => MainCPU.PC;
#endif
			InitializeCartHardware(game);
		}