public void ClientNotification_Serialization()
        {

            //Arrange

            var controller = new NullController();
            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg1 = new NotificationMessage("hello", "world");
            var msg2 = new NotificationMessage("world", NotificationType.Error);
            var msg3 = new NotificationMessage("good", NotificationType.Warning);
            var msg4 = new NotificationMessage("bye", NotificationType.Success);

            //Act

            notifications.Add(msg1);
            notifications.Add(msg2);
            notifications.Add(msg3);
            notifications.Add(msg4);

            //Assert

            var serializeed = notifications.ToJsonString();
            Assert.AreEqual(@"[{""id"":""" + msg1.Id.ToString("N") + @""",""message"":""hello"",""title"":""world"",""type"":""info""},{""id"":""" + msg2.Id.ToString("N") + @""",""message"":""world"",""title"":"""",""type"":""error""},{""id"":""" + msg3.Id.ToString("N") + @""",""message"":""good"",""title"":"""",""type"":""warning""},{""id"":""" + msg4.Id.ToString("N") + @""",""message"":""bye"",""title"":"""",""type"":""success""}]", serializeed);
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await Task.Yield();

            var controller = new NullController();
            var random     = new Random();

            while (!stoppingToken.IsCancellationRequested)
            {
                var currentDemo = CurrentDemo;
                var demo        = new ServiceReadyDemo();
                demo.Begin(controller, random);

                while (demo.Step(controller, random) == DemoState.InProgress)
                {
                    if (stoppingToken.IsCancellationRequested)
                    {
                        break;
                    }

                    //if (currentDemo != CurrentDemo)
                    // TODO !
                }
            }
        }
Example #3
0
        public SpriteShip(Sprite sprite) : base(sprite, false)
        {
            _boundary = new Rectangle
            {
                X      = 10,
                Y      = 50,
                Height = (int)World.Instance.WorldSize.Y - 80,
                Width  = (int)World.Instance.WorldSize.X - 10
            };
            Scale.X     = Scale.Y = 0.15f;
            PlayerStats = new PlayerStatistics();

            Controller = new NullController();

            // Create collider for ship
            CircleCollider cldr = new CircleCollider()
            {
                Radius   = (int)230 * Scale.X,
                Position = Position
            };

            cldr.Center.X = (Width / 2) - 9;
            cldr.Center.Y = (Height / 2) - 9;

            Collider = cldr;
            _weapon  = new SingleBlaster(Width);

            Sprite.Frames.Add(new Rectangle {
                X = 0, Y = 0, Width = 405, Height = 488
            });
            Sprite.CenterPoint = new Vector2D {
                X = 405f / 2f, Y = 488f / 2f
            };
        }
Example #4
0
    public static IInputController[] CreateControllers(int playersCount)
    {
        var controllerNames = Input.GetJoystickNames();
        int controllerCount = controllerNames.Length;

        IInputController[] controllers = new IInputController[playersCount];

        for (int i = 0; i < playersCount; i++)
        {
            //if i exceeds controllerCount then a controller will become a nullcontroller
            if (i >= controllerCount)
            {
                controllers[i] = new NullController();
                continue;
            }

            // Create gamepad controller
            bool isPSController = controllerNames[i] == dualShockName;

            JoystickMap       map     = isPSController ? dualShockMap : xBoneMap;
            GamepadController gamepad = CreateGamepad(isPSController, i + 1);

            // This is fine
            gamepad.AxisInversion = isPSController ? -1f : 1f;

            // Now set controller to interface array
            controllers [i] = gamepad;
        }
        return(controllers);
    }
Example #5
0
    private void Spawn()
    {
        IInputController controller;

        switch (controllerType)
        {
        case ControllerType.XBox:       controller = InputControllerManager.CreateGamepad(false, controllerIndex);      break;

        case ControllerType.PS4:        controller = InputControllerManager.CreateGamepad(true, controllerIndex);       break;

        default: controller = new NullController(); break;
        }

        var cameraRig = Instantiate(cameraRigPrefab);

        cameraRig.SetInputController(controller);

        var player = Instantiate(playerPrefab);

        // Hud won't show without canvas
        var hud = Instantiate(hudPrefab, hudCanvas.transform);

        hud.viewportRect = new Rect(0, 0, 1, 1);
        hud.Rebuild();

        player.Initialize(new PlayerHandle(0), cameraRig, controller, Color.clear, hud);
        player.Spawn(transform.position, transform.forward);

        displayObject.SetActive(false);
    }
Example #6
0
        public void ClientNotification_Serialization()
        {
            //Arrange

            var controller = new NullController();

            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg1 = new NotificationMessage("hello", "world");
            var msg2 = new NotificationMessage("world", NotificationType.Error);
            var msg3 = new NotificationMessage("good", NotificationType.Warning);
            var msg4 = new NotificationMessage("bye", NotificationType.Success);

            //Act

            notifications.Add(msg1);
            notifications.Add(msg2);
            notifications.Add(msg3);
            notifications.Add(msg4);

            //Assert

            var serializeed = notifications.ToJsonString();

            Assert.AreEqual(@"[{""id"":""" + msg1.Id.ToString("N") + @""",""message"":""hello"",""title"":""world"",""type"":""info""},{""id"":""" + msg2.Id.ToString("N") + @""",""message"":""world"",""title"":"""",""type"":""error""},{""id"":""" + msg3.Id.ToString("N") + @""",""message"":""good"",""title"":"""",""type"":""warning""},{""id"":""" + msg4.Id.ToString("N") + @""",""message"":""bye"",""title"":"""",""type"":""success""}]", serializeed);
        }
Example #7
0
        public void ClientNotification_Unique_Messages_Only()
        {
            //Arrange
            var controller = new NullController();

            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg = new NotificationMessage("hello");

            //Act

            notifications.Add(msg);
            notifications.Add(msg);
        }
Example #8
0
        private static HtmlHelper CreateHtmlHelper(HttpContext httpContext)
        {
            var controller     = new NullController();
            var requestContext = new RequestContext(
                new HttpContextWrapper(httpContext),
                new RouteData());
            var controllerContext = new ControllerContext(requestContext, controller);

            controller.ControllerContext = controllerContext;
            var viewContext = new ViewContext(
                controllerContext,
                new NullView(),
                new ViewDataDictionary(),
                new TempDataDictionary(),
                TextWriter.Null);

            return(new HtmlHelper(viewContext, new ViewPage()));
        }
Example #9
0
        public void ClientNotification_Message_Added()
        {
            //Arrange
            var controller = new NullController();

            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg = new NotificationMessage("hello");

            //Act

            notifications.Add(msg);

            //Assert

            Assert.AreEqual(1, notifications.Count());
        }
        public void ClientNotification_Message_Added()
        {

            //Arrange
            var controller = new NullController();
            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg = new NotificationMessage("hello");
            
            //Act

            notifications.Add(msg);
            
            //Assert

            Assert.AreEqual(1, notifications.Count());
        }
Example #11
0
 public override void visit(NullController nullController)
 {
 }
Example #12
0
 public void visit(NullController nullController)
 {
 }
 public override void visit(NullController nullController)
 {
     throw new System.NotImplementedException();
 }
        public void ClientNotification_Unique_Messages_Only()
        {

            //Arrange
            var controller = new NullController();
            controller.InjectDependencies(new FakeBackOfficeRequestContext(new FakeRebelApplicationContext(false)));
            var notifications = new ClientNotifications(controller.ControllerContext);

            var msg = new NotificationMessage("hello");

            //Act

            notifications.Add(msg);
            notifications.Add(msg);

          
        }
Example #15
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 #16
0
        void Init(GameInfo game, byte[] rom)
        {
            Controller = NullController.GetNullController();
            Cpu        = new HuC6280(MemoryCallbacks);
            VCE        = new VCE();
            VDC1       = new VDC(this, Cpu, VCE);
            PSG        = new HuC6280PSG();
            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(PSG, CDAudio, ADPCM);
                SoundSynchronizer = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
                soundProvider     = SoundSynchronizer;
                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  = string.Format("{0:X1}:{1}", SF2MapperLatch, 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);
            SetupMemoryDomains();
        }
 public abstract void visit(NullController nullController);