Example #1
0
    IEnumerator CrashingOccuring()
    {
        yield return(new WaitForSeconds(.5f)); // a slight delay

        //Grab all the information needed for the game to feign crashing and play those animations
        GlobalVars.isCrashing = true;
        player.GetComponent <BoxCollider2D>().enabled = false;
        GameObject panel = GameObject.FindGameObjectWithTag("ConvoPanel");

        panel.GetComponent <Animator>().Play("crashingText");
        player.transform.Find("Up").GetComponent <Animator>().Play("crashingUp");
        player.transform.Find("Left").GetComponent <Animator>().Play("crashingLeft");
        player.transform.Find("Right").GetComponent <Animator>().Play("crashingRight");
        player.transform.Find("Down").GetComponent <Animator>().Play("crashingDown");

        SoundMixer mixer = Camera.main.GetComponent <SoundMixer>(); //start scrambling the sound as well

        if (mixer != null)
        {
            mixer.changeChance = 1;
            mixer.ActivateScramble();
        }


        yield return(new WaitForSeconds(7.0f)); //wait for the animations to play out

        //Set up the rest of the vars so that the game is now Scrambled
        GlobalVars.isTutorial = false;
        GlobalVars.isCrashing = false;
        GoalTimes.ChangeScene();
        SceneManager.LoadScene(0);
    }
        void ToggleMute(object sender, EventArgs e)
        {
            var check = (CheckBox)sender;

            if (check == mutes[16])
            {
                bool b = check.CheckState != CheckState.Unchecked;
                for (int i = 0; i < SongPlayer.NumTracks; i++)
                {
                    mutes[i].Checked = b;
                }
            }
            else
            {
                int on = 0;
                for (int i = 0; i < SongPlayer.NumTracks; i++)
                {
                    if (mutes[i] == check)
                    {
                        SoundMixer.SetMute(i, !check.Checked);
                    }
                    if (mutes[i].Checked)
                    {
                        on++;
                    }
                }
                mutes[16].CheckStateChanged -= ToggleMute;
                mutes[16].CheckState         = on == SongPlayer.NumTracks ? CheckState.Checked : (on == 0 ? CheckState.Unchecked : CheckState.Indeterminate);
                mutes[16].CheckStateChanged += ToggleMute;
            }
        }
Example #3
0
    public void GetHelloSoundsBlueRabbit()
    {
        List <SoundMixer.SoundFX> list = SoundMixer.GetWelcomeSounds(BLUE_RABBIT);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.BLUE_RABBIT, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Example #4
0
    public void Start()
    {
        story = GetComponent <StorySelector>();
        audio = GameObject.FindGameObjectWithTag("Audio").GetComponent <SoundMixer>();


        console = GameObject.FindGameObjectWithTag("DisplayText");
        myLog   = console.GetComponent <PlayerLog> ();
    }
Example #5
0
 /// <summary>
 /// Change the shape of wave
 /// </summary>
 /// <param name="waveForm">Method to generate a wave</param>
 public void ChangeWaveForm(WaveFormEquation waveForm)
 {
     WaveForm = waveForm;
     ResetOutput();
     if (Beat != null)
     {
         SoundMixer.AddInputStream(Beat.Channel);
     }
 }
Example #6
0
    public void GetHelloSoundsRedMouse()
    {
        List <SoundMixer.SoundFX> list = SoundMixer.GetWelcomeSounds(RED_MOUSE);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.RED_MOUSE, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Example #7
0
 /// <summary>
 /// Stop playing beat
 /// </summary>
 public void StopPlayingBeat()
 {
     if (Beat != null)
     {
         SoundMixer.RemoveInputStream(Beat.Channel);
         Beat.Dispose();
     }
     Beat        = null;
     BeatPlaying = false;
 }
Example #8
0
    public void GetMoveSoundFXMouseBorder()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.CLOSED,
            Status   = MoveDetails.MoveStatus.ABORTED
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(1, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.BORDER, list[0]);
    }
Example #9
0
    public void GetMoveSoundFXRabbitMouseHole()
    {
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            WallType = Wall.Type.MOUSE_HOLE,
            Status   = MoveDetails.MoveStatus.FAILURE
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.MOUSE_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_NOT_PASS, list[1]);
    }
Example #10
0
    public void GetMoveSoundFXMouseMouseHole()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.MOUSE_HOLE,
            Status   = MoveDetails.MoveStatus.SUCCESS_KNOWN
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.MOUSE_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Example #11
0
    public void GetMoveSoundFXMouseOpen()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.OPEN,
            Status   = MoveDetails.MoveStatus.SUCCESS_NEW
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.OPEN_WALL, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Example #12
0
    public void GetMoveSoundFXRabbitRabbitHole()
    {
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            WallType = Wall.Type.RABBIT_HOLE,
            Status   = MoveDetails.MoveStatus.SUCCESS_KNOWN
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.RABBIT_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Example #13
0
    public void GetMoveSoundFXMouseClosed()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.CLOSED,
            Status   = MoveDetails.MoveStatus.FAILURE
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.CLOSED_WALL, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_NOT_PASS, list[1]);
    }
Example #14
0
    public void GetHelloSoundsGreenRabbit()
    {
        Player player = new Player(
            Player.Animal.RABBIT,
            Player.Color.GREEN,
            new Position(0, 0)
            );

        List <SoundMixer.SoundFX> list = SoundMixer.GetWelcomeSounds(player);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.GREEN_RABBIT, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Example #15
0
    public void GetHelloSoundsYellowMouse()
    {
        Player player = new Player(
            Player.Animal.MOUSE,
            Player.Color.YELLOW,
            new Position(0, 0)
            );

        List <SoundMixer.SoundFX> list = SoundMixer.GetWelcomeSounds(player);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.YELLOW_MOUSE, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Example #16
0
    public void GetNextPlayerSoundsGameOver()
    {
        List <Player> players = new List <Player>()
        {
            BLUE_RABBIT, RED_MOUSE
        };
        Game game = new Game(players, new Board(), 1);

        game.NextPlayer();
        game.NextPlayer();

        List <SoundMixer.SoundFX> list = SoundMixer.GetNextPlayerSounds(null, game);

        Assert.AreEqual(1, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.DEFEAT, list[0]);
    }
Example #17
0
    public void GetNextPlayerSounds()
    {
        List <Player> players = new List <Player>()
        {
            BLUE_RABBIT, RED_MOUSE
        };
        Game        game        = new Game(players, new Board(), 1);
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE);

        List <SoundMixer.SoundFX> list = SoundMixer.GetNextPlayerSounds(moveDetails, game);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.BLUE_RABBIT, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Example #18
0
        /// <summary>
        /// Stop playing given pitch
        /// </summary>
        /// <param name="pitch">Pitch</param>
        public void StopPlayingPitch(Pitch pitch)
        {
            // alert recorder that a change has been made
            UpdateRecorder();

            // do nothing if no tone was released
            if (pitch == Pitch.Empty)
            {
                return;
            }

            WavePlayer inputStream = PitchSelector.GetWavePlayer(pitch, WaveForm);

            SoundMixer.RemoveInputStream(inputStream.Channel);
            CurrentlyPlayingPitches[(int)pitch] = false;
        }
Example #19
0
        /// <summary>
        /// Starts playing beat with the specified bpm.
        /// </summary>
        /// <param name="bpm">Beats per minute</param>
        public void StartPlayingBeat(int bpm)
        {
            // generate beat wave
            byte[] beatWave = Wave.ConvertShortWaveToBytes(Wave.GenerateBeatWave(bpm));

            // write the wave into a file
            using (FileStream fs = File.Create(defaultBeatFilePath))
                Wave.WriteToStream(fs, beatWave, beatWave.Length / sizeof(short),
                                   Config.SAMPLE_RATE, Config.BITS_PER_SAMPLE, Config.CHANNELS);

            // play the file
            Beat = new WavePlayer(defaultBeatFilePath);
            SoundMixer.AddInputStream(Beat.Channel);
            BeatPlaying = true;
            CurrentBpm  = bpm;
        }
Example #20
0
    public void GetNextPlayerSoundsPlayAgain()
    {
        List <Player> players = new List <Player>()
        {
            BLUE_RABBIT, RED_MOUSE
        };
        Game        game        = new Game(players, new Board(), 1);
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            PlayAgain = true
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetNextPlayerSounds(moveDetails, game);

        Assert.AreEqual(1, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.PLAY_AGAIN, list[0]);
    }
Example #21
0
        /// <summary>
        /// Starts playing the specified pitch
        /// </summary>
        /// <param name="pitch">Pitch</param>
        public void StartPlayingPitch(Pitch pitch)
        {
            // do nothing if no tone is added
            if (pitch == Pitch.Empty)
            {
                return;
            }

            if (!CurrentlyPlayingPitches[(int)pitch])
            {
                UpdateRecorder();

                WavePlayer inputStream = PitchSelector.GetWavePlayer(pitch, WaveForm);
                SoundMixer.AddInputStream(inputStream.Channel);
                CurrentlyPlayingPitches[(int)pitch] = true;
            }
        }
Example #22
0
        static void HandleChannelMessageReceived(object sender, ChannelMessageEventArgs e)
        {
            Console.WriteLine("{0}\t\t{1}\t{2}\t{3}", e.Message.Command, e.Message.MidiChannel, e.Message.Data1, e.Message.Data2);

            var  note             = (sbyte)e.Message.Data1;
            byte volumeOrVelocity = (byte)((e.Message.Data2 / 127f) * Engine.GetMaxVolume());

            if (e.Message.Command == ChannelCommand.Controller && e.Message.Data1 == 7) // Volume
            {
                track.Volume = volumeOrVelocity;
            }
            else if ((e.Message.Command == ChannelCommand.NoteOn && e.Message.Data2 == 0) || e.Message.Command == ChannelCommand.NoteOff) // Note off
            {
                SoundMixer.ReleaseChannels(16, note);
            }
            else if (e.Message.Command == ChannelCommand.NoteOn) // Note on
            {
                // Has some input lag
                SongPlayer.PlayNote(track, note, Config.MIDIKeyboardFixedVelocity ? Engine.GetMaxVolume() : volumeOrVelocity, -1);
            }
        }
        private void Init(GameInfo game, byte[] rom)
        {
            Cpu  = new HuC6280(MemoryCallbacks);
            VCE  = new VCE();
            VDC1 = new VDC(this, Cpu, VCE);
            PSG  = new HuC6280PSG(735);
            SCSI = new ScsiCDBus(this, disc);

            Cpu.Logger = s => Tracer.Put(s);

            if (TurboGrafx)
            {
                Ram = new byte[0x2000];
                Cpu.ReadMemory21  = ReadMemory;
                Cpu.WriteMemory21 = WriteMemory;
                Cpu.WriteVDC      = VDC1.WriteVDC;
                _soundProvider    = PSG;
                CDAudio           = new CDAudio(null, 0);
            }

            else if (SuperGrafx)
            {
                VDC2              = new VDC(this, Cpu, VCE);
                VPC               = new VPC(this, VDC1, VDC2, VCE, Cpu);
                Ram               = new byte[0x8000];
                Cpu.ReadMemory21  = ReadMemorySGX;
                Cpu.WriteMemory21 = WriteMemorySGX;
                Cpu.WriteVDC      = VDC1.WriteVDC;
                _soundProvider    = PSG;
                CDAudio           = new CDAudio(null, 0);
            }

            else if (TurboCD)
            {
                Ram               = new byte[0x2000];
                CDRam             = new byte[0x10000];
                ADPCM             = new ADPCM(this, SCSI);
                Cpu.ReadMemory21  = ReadMemoryCD;
                Cpu.WriteMemory21 = WriteMemoryCD;
                Cpu.WriteVDC      = VDC1.WriteVDC;
                CDAudio           = new CDAudio(disc);
                SetCDAudioCallback();
                PSG.MaxVolume   = short.MaxValue * 3 / 4;
                SoundMixer      = new SoundMixer(735, PSG, CDAudio, ADPCM);
                _soundProvider  = SoundMixer;
                Cpu.ThinkAction = cycles => { SCSI.Think(); ADPCM.Think(cycles); };
            }

            if (rom.Length == 0x60000)
            {
                // 384k roms require special loading code. Why ;_;
                // In memory, 384k roms look like [1st 256k][Then full 384k]
                RomData = new byte[0xA0000];
                var origRom = rom;
                for (int i = 0; i < 0x40000; i++)
                {
                    RomData[i] = origRom[i];
                }
                for (int i = 0; i < 0x60000; i++)
                {
                    RomData[i + 0x40000] = origRom[i];
                }
                RomLength = RomData.Length;
            }
            else if (rom.Length > 1024 * 1024)
            {
                // If the rom is bigger than 1 megabyte, switch to Street Fighter 2 mapper
                Cpu.ReadMemory21  = ReadMemorySF2;
                Cpu.WriteMemory21 = WriteMemorySF2;
                RomData           = rom;
                RomLength         = RomData.Length;

                // user request: current value of the SF2MapperLatch on the tracelogger
                Cpu.Logger = s => Tracer.Put(new TraceInfo
                {
                    Disassembly  = $"{SF2MapperLatch:X1}:{s}",
                    RegisterInfo = ""
                });
            }
            else
            {
                // normal rom.
                RomData   = rom;
                RomLength = RomData.Length;
            }

            if (game["BRAM"] || Type == NecSystemType.TurboCD)
            {
                BramEnabled = true;
                BRAM        = new byte[2048];

                // pre-format BRAM. damn are we helpful.
                BRAM[0] = 0x48; BRAM[1] = 0x55; BRAM[2] = 0x42; BRAM[3] = 0x4D;
                BRAM[4] = 0x00; BRAM[5] = 0x88; BRAM[6] = 0x10; BRAM[7] = 0x80;
            }

            if (game["SuperSysCard"])
            {
                SuperRam = new byte[0x30000];
            }

            if (game["ArcadeCard"])
            {
                ArcadeRam            = new byte[0x200000];
                ArcadeCard           = true;
                ArcadeCardRewindHack = Settings.ArcadeCardRewindHack;
                for (int i = 0; i < 4; i++)
                {
                    ArcadePage[i] = new ArcadeCardPage();
                }
            }

            if (game["PopulousSRAM"])
            {
                PopulousRAM       = new byte[0x8000];
                Cpu.ReadMemory21  = ReadMemoryPopulous;
                Cpu.WriteMemory21 = WriteMemoryPopulous;
            }

            // the gamedb can force sprite limit on, ignoring settings
            if (game["ForceSpriteLimit"] || game.NotInDatabase)
            {
                ForceSpriteLimit = true;
            }

            if (game["CdVol"])
            {
                CDAudio.MaxVolume = int.Parse(game.OptionValue("CdVol"));
            }

            if (game["PsgVol"])
            {
                PSG.MaxVolume = int.Parse(game.OptionValue("PsgVol"));
            }

            if (game["AdpcmVol"])
            {
                ADPCM.MaxVolume = int.Parse(game.OptionValue("AdpcmVol"));
            }

            // the gamedb can also force equalizevolumes on
            if (TurboCD && (Settings.EqualizeVolume || game["EqualizeVolumes"] || game.NotInDatabase))
            {
                SoundMixer.EqualizeVolumes();
            }

            // Ok, yes, HBlankPeriod's only purpose is game-specific hax.
            // 1) At least they're not coded directly into the emulator, but instead data-driven.
            // 2) The games which have custom HBlankPeriods work without it, the override only
            //    serves to clean up minor gfx anomalies.
            // 3) There's no point in haxing the timing with incorrect values in an attempt to avoid this.
            //    The proper fix is cycle-accurate/bus-accurate timing. That isn't coming to the C#
            //    version of this core. Let's just acknolwedge that the timing is imperfect and fix
            //    it in the least intrusive and most honest way we can.
            if (game["HBlankPeriod"])
            {
                VDC1.HBlankCycles = game.GetIntValue("HBlankPeriod");
            }

            // This is also a hack. Proper multi-res/TV emulation will be a native-code core feature.
            if (game["MultiResHack"])
            {
                VDC1.MultiResHack = game.GetIntValue("MultiResHack");
            }

            Cpu.ResetPC();

            Tracer = new TraceBuffer {
                Header = Cpu.TraceHeader
            };
            var ser = new BasicServiceProvider(this);

            ServiceProvider = ser;
            ser.Register <ITraceable>(Tracer);
            ser.Register <IDisassemblable>(Cpu);
            ser.Register <IVideoProvider>((IVideoProvider)VPC ?? VDC1);
            ser.Register <ISoundProvider>(_soundProvider);
            ser.Register <IStatable>(new StateSerializer(SyncState));
            SetupMemoryDomains();
        }
Example #24
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;
        }
Example #25
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());
        }
Example #26
0
 static Settings()
 {
     displayHandler = new DisplayHandler();
     soundMixer     = new SoundMixer();
 }
Example #27
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);
        }